1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.systemui.plugins;
import android.app.PendingIntent;
import android.app.smartspace.SmartspaceAction;
import android.app.smartspace.SmartspaceTarget;
import android.app.smartspace.SmartspaceTargetEvent;
import android.app.smartspace.uitemplatedata.TapAction;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Parcelable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import com.android.systemui.plugins.annotations.ProvidesInterface;
import java.util.List;
/**
* Interface to provide SmartspaceTargets to BcSmartspace.
*/
@ProvidesInterface(action = BcSmartspaceDataPlugin.ACTION, version = BcSmartspaceDataPlugin.VERSION)
public interface BcSmartspaceDataPlugin extends Plugin {
String UI_SURFACE_LOCK_SCREEN_AOD = "lockscreen";
String UI_SURFACE_HOME_SCREEN = "home";
String UI_SURFACE_MEDIA = "media_data_manager";
String UI_SURFACE_DREAM = "dream";
String ACTION = "com.android.systemui.action.PLUGIN_BC_SMARTSPACE_DATA";
int VERSION = 1;
String TAG = "BcSmartspaceDataPlugin";
/** Register a listener to get Smartspace data. */
default void registerListener(SmartspaceTargetListener listener) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/** Unregister a listener. */
default void unregisterListener(SmartspaceTargetListener listener) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/** Register a SmartspaceEventNotifier. */
default void registerSmartspaceEventNotifier(SmartspaceEventNotifier notifier) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/** Push a SmartspaceTargetEvent to the SmartspaceEventNotifier. */
default void notifySmartspaceEvent(SmartspaceTargetEvent event) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/** Allows for notifying the SmartspaceSession of SmartspaceTargetEvents. */
interface SmartspaceEventNotifier {
/** Pushes a given SmartspaceTargetEvent to the SmartspaceSession. */
void notifySmartspaceEvent(SmartspaceTargetEvent event);
}
/**
* Create a view to be shown within the parent. Do not add the view, as the parent
* will be responsible for correctly setting the LayoutParams
*/
default SmartspaceView getView(ViewGroup parent) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/**
* As the smartspace view becomes available, allow listeners to receive an event.
*/
default void addOnAttachStateChangeListener(View.OnAttachStateChangeListener listener) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/** Updates Smartspace data and propagates it to any listeners. */
default void onTargetsAvailable(List<SmartspaceTarget> targets) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/** Provides Smartspace data to registered listeners. */
interface SmartspaceTargetListener {
/** Each Parcelable is a SmartspaceTarget that represents a card. */
void onSmartspaceTargetsUpdated(List<? extends Parcelable> targets);
}
/** View to which this plugin can be registered, in order to get updates. */
interface SmartspaceView {
void registerDataProvider(BcSmartspaceDataPlugin plugin);
/**
* Sets {@link BcSmartspaceConfigPlugin}.
*/
default void registerConfigProvider(BcSmartspaceConfigPlugin configProvider) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/**
* Primary color for unprotected text
*/
void setPrimaryTextColor(int color);
/**
* Set the UI surface for the cards. Should be called immediately after the view is created.
*/
void setUiSurface(String uiSurface);
/**
* Range [0.0 - 1.0] when transitioning from Lockscreen to/from AOD
*/
void setDozeAmount(float amount);
/**
* Set the current keyguard bypass enabled status.
*/
default void setKeyguardBypassEnabled(boolean enabled) {}
/**
* Overrides how Intents/PendingIntents gets launched. Mostly to support auth from
* the lockscreen.
*/
void setIntentStarter(IntentStarter intentStarter);
/**
* When on the lockscreen, use the FalsingManager to help detect errant touches
*/
void setFalsingManager(com.android.systemui.plugins.FalsingManager falsingManager);
/**
* Set or clear Do Not Disturb information.
*/
default void setDnd(@Nullable Drawable image, @Nullable String description) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/**
* Set or clear next alarm information
*/
default void setNextAlarm(@Nullable Drawable image, @Nullable String description) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/**
* Set or clear device media playing
*/
default void setMediaTarget(@Nullable SmartspaceTarget target) {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/**
* Get the index of the currently selected page.
*/
default int getSelectedPage() {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
/**
* Return the top padding value from the currently visible card, or 0 if there is no current
* card.
*/
default int getCurrentCardTopPadding() {
throw new UnsupportedOperationException("Not implemented by " + getClass());
}
}
/** Interface for launching Intents, which can differ on the lockscreen */
interface IntentStarter {
default void startFromAction(SmartspaceAction action, View v, boolean showOnLockscreen) {
try {
if (action.getIntent() != null) {
startIntent(v, action.getIntent(), showOnLockscreen);
} else if (action.getPendingIntent() != null) {
startPendingIntent(action.getPendingIntent(), showOnLockscreen);
}
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Could not launch intent for action: " + action, e);
}
}
default void startFromAction(TapAction action, View v, boolean showOnLockscreen) {
try {
if (action.getIntent() != null) {
startIntent(v, action.getIntent(), showOnLockscreen);
} else if (action.getPendingIntent() != null) {
startPendingIntent(action.getPendingIntent(), showOnLockscreen);
}
} catch (ActivityNotFoundException e) {
Log.w(TAG, "Could not launch intent for action: " + action, e);
}
}
/** Start the intent */
void startIntent(View v, Intent i, boolean showOnLockscreen);
/** Start the PendingIntent */
void startPendingIntent(PendingIntent pi, boolean showOnLockscreen);
}
}
|