blob: ca1143065dede691b4f6e6b6f9a5c62a0b1e894b [file] [log] [blame]
Joe Onorato0cbda992010-05-02 16:28:15 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Joe Onorato79de0c52010-05-26 17:03:26 -040017package com.android.systemui.statusbar;
Joe Onorato0cbda992010-05-02 16:28:15 -070018
Charles Chenf3d295c2018-11-30 18:15:21 +080019import static android.app.StatusBarManager.DISABLE2_NONE;
20import static android.app.StatusBarManager.DISABLE_NONE;
lumark7570cac2019-03-07 22:14:38 +080021import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT;
22import static android.inputmethodservice.InputMethodService.IME_INVISIBLE;
Charles Chenf3d295c2018-11-30 18:15:21 +080023import static android.view.Display.DEFAULT_DISPLAY;
lumark7570cac2019-03-07 22:14:38 +080024import static android.view.Display.INVALID_DISPLAY;
Charles Chenf3d295c2018-11-30 18:15:21 +080025
Jason Monk297c04e2018-08-23 17:16:59 -040026import static com.android.systemui.statusbar.phone.StatusBar.ONLY_CORE_APPS;
27
28import android.app.StatusBarManager;
Charles Chenf3d295c2018-11-30 18:15:21 +080029import android.app.StatusBarManager.Disable2Flags;
30import android.app.StatusBarManager.DisableFlags;
31import android.app.StatusBarManager.WindowType;
32import android.app.StatusBarManager.WindowVisibleState;
Jason Monk7e53f202016-01-28 10:40:20 -050033import android.content.ComponentName;
Charles Chenf3d295c2018-11-30 18:15:21 +080034import android.content.Context;
Kevin Chyn23289ef2018-11-28 16:32:36 -080035import android.hardware.biometrics.IBiometricServiceReceiverInternal;
Charles Chenf3d295c2018-11-30 18:15:21 +080036import android.hardware.display.DisplayManager;
37import android.inputmethodservice.InputMethodService.BackDispositionMode;
Jorim Jaggi165ce062015-07-06 16:18:11 -070038import android.os.Bundle;
Joe Onorato0cbda992010-05-02 16:28:15 -070039import android.os.Handler;
Joe Onoratoa0c56fe2010-05-20 10:21:52 -070040import android.os.IBinder;
Jason Monkb5b092012017-01-05 11:35:34 -050041import android.os.Looper;
Joe Onorato0cbda992010-05-02 16:28:15 -070042import android.os.Message;
Kevin Chyn1b9f8df2018-11-12 19:04:55 -080043import android.util.Pair;
Charles Chenf3d295c2018-11-30 18:15:21 +080044import android.util.SparseArray;
Jorim Jaggi956ca412019-01-07 14:49:14 +010045import android.view.InsetsState.InternalInsetType;
Jorim Jaggi956ca412019-01-07 14:49:14 +010046import android.view.WindowInsetsController.Appearance;
Jason Monk297c04e2018-08-23 17:16:59 -040047
Jorim Jaggi86905582016-02-09 21:36:09 -080048import com.android.internal.os.SomeArgs;
Joe Onorato0cbda992010-05-02 16:28:15 -070049import com.android.internal.statusbar.IStatusBar;
50import com.android.internal.statusbar.StatusBarIcon;
Jorim Jaggi956ca412019-01-07 14:49:14 +010051import com.android.internal.view.AppearanceRegion;
Jason Monkd7c98552018-12-04 11:14:50 -050052import com.android.systemui.statusbar.CommandQueue.Callbacks;
53import com.android.systemui.statusbar.policy.CallbackController;
Joe Onorato0cbda992010-05-02 16:28:15 -070054
Jason Monk49fa0162017-01-11 09:21:56 -050055import java.util.ArrayList;
56
Joe Onoratof3f0e052010-05-14 18:49:29 -070057/**
58 * This class takes the functions from IStatusBar that come in on
59 * binder pool threads and posts messages to get them onto the main
60 * thread, and calls onto Callbacks. It also takes care of
Joe Onorato4762c2d2010-05-17 15:42:59 -070061 * coalescing these calls so they don't stack up. For the calls
62 * are coalesced, note that they are all idempotent.
Joe Onoratof3f0e052010-05-14 18:49:29 -070063 */
Charles Chenf3d295c2018-11-30 18:15:21 +080064public class CommandQueue extends IStatusBar.Stub implements CallbackController<Callbacks>,
65 DisplayManager.DisplayListener {
Daniel Sandler1d4d30a2011-04-28 12:35:29 -040066 private static final int INDEX_MASK = 0xffff;
67 private static final int MSG_SHIFT = 16;
68 private static final int MSG_MASK = 0xffff << MSG_SHIFT;
Joe Onorato0cbda992010-05-02 16:28:15 -070069
Daniel Sandler1d4d30a2011-04-28 12:35:29 -040070 private static final int OP_SET_ICON = 1;
Joe Onorato0cbda992010-05-02 16:28:15 -070071 private static final int OP_REMOVE_ICON = 2;
72
Robert Horvath5560f382019-07-10 10:46:38 +020073 private static final int MSG_ICON = 1 << MSG_SHIFT;
74 private static final int MSG_DISABLE = 2 << MSG_SHIFT;
75 private static final int MSG_EXPAND_NOTIFICATIONS = 3 << MSG_SHIFT;
76 private static final int MSG_COLLAPSE_PANELS = 4 << MSG_SHIFT;
77 private static final int MSG_EXPAND_SETTINGS = 5 << MSG_SHIFT;
78 private static final int MSG_SYSTEM_BAR_APPEARANCE_CHANGED = 6 << MSG_SHIFT;
79 private static final int MSG_DISPLAY_READY = 7 << MSG_SHIFT;
80 private static final int MSG_SHOW_IME_BUTTON = 8 << MSG_SHIFT;
81 private static final int MSG_TOGGLE_RECENT_APPS = 9 << MSG_SHIFT;
82 private static final int MSG_PRELOAD_RECENT_APPS = 10 << MSG_SHIFT;
83 private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 11 << MSG_SHIFT;
84 private static final int MSG_SET_WINDOW_STATE = 12 << MSG_SHIFT;
85 private static final int MSG_SHOW_RECENT_APPS = 13 << MSG_SHIFT;
86 private static final int MSG_HIDE_RECENT_APPS = 14 << MSG_SHIFT;
87 private static final int MSG_SHOW_SCREEN_PIN_REQUEST = 18 << MSG_SHIFT;
88 private static final int MSG_APP_TRANSITION_PENDING = 19 << MSG_SHIFT;
89 private static final int MSG_APP_TRANSITION_CANCELLED = 20 << MSG_SHIFT;
90 private static final int MSG_APP_TRANSITION_STARTING = 21 << MSG_SHIFT;
91 private static final int MSG_ASSIST_DISCLOSURE = 22 << MSG_SHIFT;
92 private static final int MSG_START_ASSIST = 23 << MSG_SHIFT;
93 private static final int MSG_CAMERA_LAUNCH_GESTURE = 24 << MSG_SHIFT;
94 private static final int MSG_TOGGLE_KEYBOARD_SHORTCUTS = 25 << MSG_SHIFT;
95 private static final int MSG_SHOW_PICTURE_IN_PICTURE_MENU = 26 << MSG_SHIFT;
96 private static final int MSG_ADD_QS_TILE = 27 << MSG_SHIFT;
97 private static final int MSG_REMOVE_QS_TILE = 28 << MSG_SHIFT;
98 private static final int MSG_CLICK_QS_TILE = 29 << MSG_SHIFT;
99 private static final int MSG_TOGGLE_APP_SPLIT_SCREEN = 30 << MSG_SHIFT;
100 private static final int MSG_APP_TRANSITION_FINISHED = 31 << MSG_SHIFT;
101 private static final int MSG_DISMISS_KEYBOARD_SHORTCUTS = 32 << MSG_SHIFT;
102 private static final int MSG_HANDLE_SYSTEM_KEY = 33 << MSG_SHIFT;
103 private static final int MSG_SHOW_GLOBAL_ACTIONS = 34 << MSG_SHIFT;
104 private static final int MSG_TOGGLE_PANEL = 35 << MSG_SHIFT;
105 private static final int MSG_SHOW_SHUTDOWN_UI = 36 << MSG_SHIFT;
106 private static final int MSG_SET_TOP_APP_HIDES_STATUS_BAR = 37 << MSG_SHIFT;
107 private static final int MSG_ROTATION_PROPOSAL = 38 << MSG_SHIFT;
108 private static final int MSG_BIOMETRIC_SHOW = 39 << MSG_SHIFT;
109 private static final int MSG_BIOMETRIC_AUTHENTICATED = 40 << MSG_SHIFT;
110 private static final int MSG_BIOMETRIC_HELP = 41 << MSG_SHIFT;
111 private static final int MSG_BIOMETRIC_ERROR = 42 << MSG_SHIFT;
112 private static final int MSG_BIOMETRIC_HIDE = 43 << MSG_SHIFT;
113 private static final int MSG_SHOW_CHARGING_ANIMATION = 44 << MSG_SHIFT;
114 private static final int MSG_SHOW_PINNING_TOAST_ENTER_EXIT = 45 << MSG_SHIFT;
115 private static final int MSG_SHOW_PINNING_TOAST_ESCAPE = 46 << MSG_SHIFT;
116 private static final int MSG_RECENTS_ANIMATION_STATE_CHANGED = 47 << MSG_SHIFT;
117 private static final int MSG_SHOW_TRANSIENT = 48 << MSG_SHIFT;
118 private static final int MSG_ABORT_TRANSIENT = 49 << MSG_SHIFT;
119 private static final int MSG_TOP_APP_WINDOW_CHANGED = 50 << MSG_SHIFT;
120 private static final int MSG_SHOW_INATTENTIVE_SLEEP_WARNING = 51 << MSG_SHIFT;
121 private static final int MSG_DISMISS_INATTENTIVE_SLEEP_WARNING = 52 << MSG_SHIFT;
Daniel Sandler328310c2011-09-23 15:56:52 -0400122
Jim Miller9a720f52012-05-30 03:19:43 -0700123 public static final int FLAG_EXCLUDE_NONE = 0;
124 public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
125 public static final int FLAG_EXCLUDE_RECENTS_PANEL = 1 << 1;
126 public static final int FLAG_EXCLUDE_NOTIFICATION_PANEL = 1 << 2;
127 public static final int FLAG_EXCLUDE_INPUT_METHODS_PANEL = 1 << 3;
128 public static final int FLAG_EXCLUDE_COMPAT_MODE_PANEL = 1 << 4;
129
Jason Monkb605fec2014-05-02 17:04:10 -0400130 private static final String SHOW_IME_SWITCHER_KEY = "showImeSwitcherKey";
131
Jason Monk07473ce2016-01-05 14:59:19 -0500132 private final Object mLock = new Object();
Jason Monk49fa0162017-01-11 09:21:56 -0500133 private ArrayList<Callbacks> mCallbacks = new ArrayList<>();
Jason Monkb5b092012017-01-05 11:35:34 -0500134 private Handler mHandler = new H(Looper.getMainLooper());
Charles Chenf3d295c2018-11-30 18:15:21 +0800135 /** A map of display id - disable flag pair */
136 private SparseArray<Pair<Integer, Integer>> mDisplayDisabled = new SparseArray<>();
lumark7570cac2019-03-07 22:14:38 +0800137 /**
138 * The last ID of the display where IME window for which we received setImeWindowStatus
139 * event.
140 */
141 private int mLastUpdatedImeDisplayId = INVALID_DISPLAY;
Joe Onorato0cbda992010-05-02 16:28:15 -0700142
143 /**
144 * These methods are called back on the main thread.
145 */
146 public interface Callbacks {
Jason Monkb5b092012017-01-05 11:35:34 -0500147 default void setIcon(String slot, StatusBarIcon icon) { }
148 default void removeIcon(String slot) { }
Charles Chenf3d295c2018-11-30 18:15:21 +0800149
150 /**
151 * Called to notify that disable flags are updated.
152 * @see IStatusBar#disable(int, int, int).
153 *
154 * @param displayId The id of the display to notify.
155 * @param state1 The combination of following DISABLE_* flags:
156 * @param state2 The combination of following DISABLE2_* flags:
157 * @param animate {@code true} to show animations.
158 */
159 default void disable(int displayId, @DisableFlags int state1, @Disable2Flags int state2,
160 boolean animate) { }
Jason Monkb5b092012017-01-05 11:35:34 -0500161 default void animateExpandNotificationsPanel() { }
Jason Monk297c04e2018-08-23 17:16:59 -0400162 default void animateCollapsePanels(int flags, boolean force) { }
Anthony Chen9ad00e02017-05-12 15:53:36 -0700163 default void togglePanel() { }
Jason Monkb5b092012017-01-05 11:35:34 -0500164 default void animateExpandSettingsPanel(String obj) { }
Charles Chenf3d295c2018-11-30 18:15:21 +0800165
166 /**
Charles Chenf3d295c2018-11-30 18:15:21 +0800167 * Called to notify IME window status changes.
168 *
169 * @param displayId The id of the display to notify.
170 * @param token IME token.
171 * @param vis IME visibility.
172 * @param backDisposition Disposition mode of back button. It should be one of below flags:
173 * @param showImeSwitcher {@code true} to show IME switch button.
174 */
175 default void setImeWindowStatus(int displayId, IBinder token, int vis,
176 @BackDispositionMode int backDisposition, boolean showImeSwitcher) { }
Winson Chungdff7a732017-12-11 12:17:06 -0800177 default void showRecentApps(boolean triggeredFromAltTab) { }
Jason Monkb5b092012017-01-05 11:35:34 -0500178 default void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { }
179 default void toggleRecentApps() { }
180 default void toggleSplitScreen() { }
181 default void preloadRecentApps() { }
182 default void dismissKeyboardShortcutsMenu() { }
183 default void toggleKeyboardShortcutsMenu(int deviceId) { }
184 default void cancelPreloadRecentApps() { }
Charles Chenf3d295c2018-11-30 18:15:21 +0800185
186 /**
187 * Called to notify window state changes.
188 * @see IStatusBar#setWindowState(int, int, int)
189 *
190 * @param displayId The id of the display to notify.
191 * @param window Window type. It should be one of {@link StatusBarManager#WINDOW_STATUS_BAR}
192 * or {@link StatusBarManager#WINDOW_NAVIGATION_BAR}
193 * @param state Window visible state.
194 */
195 default void setWindowState(int displayId, @WindowType int window,
196 @WindowVisibleState int state) { }
Jason Monkb5b092012017-01-05 11:35:34 -0500197 default void showScreenPinningRequest(int taskId) { }
Charles Chenf3d295c2018-11-30 18:15:21 +0800198
199 /**
200 * Called to notify System UI that an application transition is pending.
201 * @see IStatusBar#appTransitionPending(int).
202 *
203 * @param displayId The id of the display to notify.
204 * @param forced {@code true} to force transition pending.
205 */
206 default void appTransitionPending(int displayId, boolean forced) { }
207
208 /**
209 * Called to notify System UI that an application transition is canceled.
210 * @see IStatusBar#appTransitionCancelled(int).
211 *
212 * @param displayId The id of the display to notify.
213 */
214 default void appTransitionCancelled(int displayId) { }
215
216 /**
217 * Called to notify System UI that an application transition is starting.
218 * @see IStatusBar#appTransitionStarting(int, long, long).
219 *
220 * @param displayId The id of the display to notify.
221 * @param startTime Transition start time.
222 * @param duration Transition duration.
223 * @param forced {@code true} to force transition pending.
224 */
225 default void appTransitionStarting(
226 int displayId, long startTime, long duration, boolean forced) { }
227
228 /**
229 * Called to notify System UI that an application transition is finished.
230 * @see IStatusBar#appTransitionFinished(int)
231 *
232 * @param displayId The id of the display to notify.
233 */
234 default void appTransitionFinished(int displayId) { }
Jason Monkb5b092012017-01-05 11:35:34 -0500235 default void showAssistDisclosure() { }
236 default void startAssist(Bundle args) { }
237 default void onCameraLaunchGestureDetected(int source) { }
Winson Chungac52f282017-03-30 14:44:52 -0700238 default void showPictureInPictureMenu() { }
Selim Cinek3a49ba22017-08-10 11:17:39 -0700239 default void setTopAppHidesStatusBar(boolean topAppHidesStatusBar) { }
Jason Monk7e53f202016-01-28 10:40:20 -0500240
Jason Monkb5b092012017-01-05 11:35:34 -0500241 default void addQsTile(ComponentName tile) { }
242 default void remQsTile(ComponentName tile) { }
243 default void clickTile(ComponentName tile) { }
Jim Miller07e03842016-06-22 15:18:13 -0700244
Philip Quinnc3a503d2017-07-18 23:23:41 -0700245 default void handleSystemKey(int arg1) { }
Matthew Ng9c3bce52018-02-01 22:00:31 +0000246 default void showPinningEnterExitToast(boolean entering) { }
247 default void showPinningEscapeToast() { }
Jason Monk361915c2017-03-21 20:33:59 -0400248 default void handleShowGlobalActionsMenu() { }
Jason Monkb4302182017-08-04 13:39:17 -0400249 default void handleShowShutdownUi(boolean isReboot, String reason) { }
Mike Digman93f08342017-11-24 21:46:53 -0800250
Beverlyac32c9a2018-01-31 16:10:41 -0500251 default void showWirelessChargingAnimation(int batteryLevel) { }
Beverlyae79ab92017-12-11 09:20:02 -0500252
Mike Digmane0777312018-01-19 12:41:51 -0800253 default void onRotationProposal(int rotation, boolean isValid) { }
Kevin Chynaae4a152018-01-18 11:48:09 -0800254
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700255 default void showAuthenticationDialog(Bundle bundle,
256 IBiometricServiceReceiverInternal receiver, int biometricModality,
257 boolean requireConfirmation, int userId, String opPackageName) { }
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700258 default void onBiometricAuthenticated() { }
Kevin Chyne9275662018-07-23 16:42:06 -0700259 default void onBiometricHelp(String message) { }
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700260 default void onBiometricError(int modality, int error, int vendorCode) { }
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700261 default void hideAuthenticationDialog() { }
Charles Chen3dedec32019-01-24 22:19:37 +0800262
263 /**
Riddle Hsucf33f1c2019-02-18 21:20:51 +0800264 * @see IStatusBar#onDisplayReady(int)
265 */
Charles Chen3dedec32019-01-24 22:19:37 +0800266 default void onDisplayReady(int displayId) { }
Winson Chung67e49362019-05-17 16:40:38 -0700267
Riddle Hsucf33f1c2019-02-18 21:20:51 +0800268 /**
269 * @see DisplayManager.DisplayListener#onDisplayRemoved(int)
270 */
271 default void onDisplayRemoved(int displayId) { }
Winson Chung67e49362019-05-17 16:40:38 -0700272
273 /**
274 * @see IStatusBar#onRecentsAnimationStateChanged(boolean)
275 */
276 default void onRecentsAnimationStateChanged(boolean running) { }
Jorim Jaggi956ca412019-01-07 14:49:14 +0100277
278 /**
279 * @see IStatusBar#onSystemBarAppearanceChanged(int, int, AppearanceRegion[], boolean).
280 */
281 default void onSystemBarAppearanceChanged(int displayId, @Appearance int appearance,
282 AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme) { }
283
284 /**
285 * @see IStatusBar#showTransient(int, int[]).
286 */
287 default void showTransient(int displayId, @InternalInsetType int[] types) { }
288
289 /**
290 * @see IStatusBar#abortTransient(int, int[]).
291 */
292 default void abortTransient(int displayId, @InternalInsetType int[] types) { }
293
294 /**
295 * @see IStatusBar#topAppWindowChanged(int, boolean, boolean).
296 */
297 default void topAppWindowChanged(int displayId, boolean isFullscreen, boolean isImmersive) {
298 }
Robert Horvath5560f382019-07-10 10:46:38 +0200299
300 /**
301 * Called to notify System UI that a warning about the device going to sleep
302 * due to prolonged user inactivity should be shown.
303 */
304 default void showInattentiveSleepWarning() { }
305
306 /**
307 * Called to notify System UI that the warning about the device going to sleep
308 * due to prolonged user inactivity should be dismissed.
309 */
Robert Horvath60e51fe2019-08-20 13:10:34 +0200310 default void dismissInattentiveSleepWarning(boolean animated) { }
Joe Onorato0cbda992010-05-02 16:28:15 -0700311 }
312
Charles Chenf3d295c2018-11-30 18:15:21 +0800313 public CommandQueue(Context context) {
314 context.getSystemService(DisplayManager.class).registerDisplayListener(this, mHandler);
315 // We always have default display.
316 setDisabled(DEFAULT_DISPLAY, DISABLE_NONE, DISABLE2_NONE);
Jason Monk297c04e2018-08-23 17:16:59 -0400317 }
318
Charles Chenf3d295c2018-11-30 18:15:21 +0800319 @Override
320 public void onDisplayAdded(int displayId) { }
321
322 @Override
323 public void onDisplayRemoved(int displayId) {
324 synchronized (mLock) {
325 mDisplayDisabled.remove(displayId);
326 }
Riddle Hsucf33f1c2019-02-18 21:20:51 +0800327 // This callback is registered with {@link #mHandler} that already posts to run on main
328 // thread, so it is safe to dispatch directly.
329 for (int i = mCallbacks.size() - 1; i >= 0; i--) {
330 mCallbacks.get(i).onDisplayRemoved(displayId);
331 }
Charles Chenf3d295c2018-11-30 18:15:21 +0800332 }
333
334 @Override
335 public void onDisplayChanged(int displayId) { }
336
337 // TODO(b/118592525): add multi-display support if needed.
Jason Monk297c04e2018-08-23 17:16:59 -0400338 public boolean panelsEnabled() {
Charles Chenf3d295c2018-11-30 18:15:21 +0800339 final int disabled1 = getDisabled1(DEFAULT_DISPLAY);
340 final int disabled2 = getDisabled2(DEFAULT_DISPLAY);
341 return (disabled1 & StatusBarManager.DISABLE_EXPAND) == 0
342 && (disabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) == 0
Jason Monk297c04e2018-08-23 17:16:59 -0400343 && !ONLY_CORE_APPS;
Jason Monkb5b092012017-01-05 11:35:34 -0500344 }
345
Jason Monkd7c98552018-12-04 11:14:50 -0500346 public void addCallback(Callbacks callbacks) {
Jason Monk49fa0162017-01-11 09:21:56 -0500347 mCallbacks.add(callbacks);
Charles Chenf3d295c2018-11-30 18:15:21 +0800348 // TODO(b/117478341): find a better way to pass disable flags by display.
349 for (int i = 0; i < mDisplayDisabled.size(); i++) {
350 int displayId = mDisplayDisabled.keyAt(i);
351 int disabled1 = getDisabled1(displayId);
352 int disabled2 = getDisabled2(displayId);
353 callbacks.disable(displayId, disabled1, disabled2, false /* animate */);
354 }
Jason Monk49fa0162017-01-11 09:21:56 -0500355 }
356
Jason Monkd7c98552018-12-04 11:14:50 -0500357 public void removeCallback(Callbacks callbacks) {
Jason Monk49fa0162017-01-11 09:21:56 -0500358 mCallbacks.remove(callbacks);
Joe Onorato0cbda992010-05-02 16:28:15 -0700359 }
360
Jason Monk07473ce2016-01-05 14:59:19 -0500361 public void setIcon(String slot, StatusBarIcon icon) {
362 synchronized (mLock) {
363 // don't coalesce these
364 mHandler.obtainMessage(MSG_ICON, OP_SET_ICON, 0,
365 new Pair<String, StatusBarIcon>(slot, icon)).sendToTarget();
Joe Onorato0cbda992010-05-02 16:28:15 -0700366 }
367 }
368
Jason Monk07473ce2016-01-05 14:59:19 -0500369 public void removeIcon(String slot) {
370 synchronized (mLock) {
371 // don't coalesce these
372 mHandler.obtainMessage(MSG_ICON, OP_REMOVE_ICON, 0, slot).sendToTarget();
Joe Onorato0cbda992010-05-02 16:28:15 -0700373 }
374 }
375
Charles Chenf3d295c2018-11-30 18:15:21 +0800376 /**
377 * Called to notify that disable flags are updated.
378 * @see Callbacks#disable(int, int, int, boolean).
379 */
380 public void disable(int displayId, @DisableFlags int state1, @Disable2Flags int state2,
381 boolean animate) {
Jason Monk07473ce2016-01-05 14:59:19 -0500382 synchronized (mLock) {
Charles Chenf3d295c2018-11-30 18:15:21 +0800383 setDisabled(displayId, state1, state2);
Joe Onoratof3f0e052010-05-14 18:49:29 -0700384 mHandler.removeMessages(MSG_DISABLE);
Charles Chenf3d295c2018-11-30 18:15:21 +0800385 final SomeArgs args = SomeArgs.obtain();
386 args.argi1 = displayId;
387 args.argi2 = state1;
388 args.argi3 = state2;
389 args.argi4 = animate ? 1 : 0;
390 Message msg = mHandler.obtainMessage(MSG_DISABLE, args);
Jason Monk3d3e99c2017-04-20 11:26:36 -0400391 if (Looper.myLooper() == mHandler.getLooper()) {
392 // If its the right looper execute immediately so hides can be handled quickly.
393 mHandler.handleMessage(msg);
394 msg.recycle();
395 } else {
396 msg.sendToTarget();
397 }
Joe Onoratof3f0e052010-05-14 18:49:29 -0700398 }
399 }
400
Charles Chen24e7a9f2018-11-21 11:59:07 +0800401 @Override
Charles Chenf3d295c2018-11-30 18:15:21 +0800402 public void disable(int displayId, @DisableFlags int state1, @Disable2Flags int state2) {
403 disable(displayId, state1, state2, true);
Jason Monk1e5ba5d2017-02-14 15:48:57 -0500404 }
405
Charles Chenf3d295c2018-11-30 18:15:21 +0800406 /**
407 * Apply current disable flags by {@link CommandQueue#disable(int, int, int, boolean)}.
408 *
409 * @param displayId The id of the display to notify.
410 * @param animate {@code true} to show animations.
411 */
412 public void recomputeDisableFlags(int displayId, boolean animate) {
413 int disabled1 = getDisabled1(displayId);
414 int disabled2 = getDisabled2(displayId);
415 disable(displayId, disabled1, disabled2, animate);
416 }
417
418 private void setDisabled(int displayId, int disabled1, int disabled2) {
419 mDisplayDisabled.put(displayId, new Pair<>(disabled1, disabled2));
420 }
421
422 private int getDisabled1(int displayId) {
423 return getDisabled(displayId).first;
424 }
425
426 private int getDisabled2(int displayId) {
427 return getDisabled(displayId).second;
428 }
429
430 private Pair<Integer, Integer> getDisabled(int displayId) {
431 Pair<Integer, Integer> disablePair = mDisplayDisabled.get(displayId);
432 if (disablePair == null) {
433 disablePair = new Pair<>(DISABLE_NONE, DISABLE2_NONE);
434 mDisplayDisabled.put(displayId, disablePair);
435 }
436 return disablePair;
Jason Monk00659ba2017-03-03 10:28:45 -0500437 }
438
Daniel Sandler11cf1782012-09-27 14:03:08 -0400439 public void animateExpandNotificationsPanel() {
Jason Monk07473ce2016-01-05 14:59:19 -0500440 synchronized (mLock) {
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700441 mHandler.removeMessages(MSG_EXPAND_NOTIFICATIONS);
442 mHandler.sendEmptyMessage(MSG_EXPAND_NOTIFICATIONS);
Joe Onorato4762c2d2010-05-17 15:42:59 -0700443 }
444 }
445
Daniel Sandler11cf1782012-09-27 14:03:08 -0400446 public void animateCollapsePanels() {
Jason Monk07473ce2016-01-05 14:59:19 -0500447 synchronized (mLock) {
Daniel Sandler11cf1782012-09-27 14:03:08 -0400448 mHandler.removeMessages(MSG_COLLAPSE_PANELS);
Jason Monk9c7844c2017-01-18 15:21:53 -0500449 mHandler.obtainMessage(MSG_COLLAPSE_PANELS, 0, 0).sendToTarget();
450 }
451 }
452
Jason Monk297c04e2018-08-23 17:16:59 -0400453 public void animateCollapsePanels(int flags, boolean force) {
Jason Monk9c7844c2017-01-18 15:21:53 -0500454 synchronized (mLock) {
455 mHandler.removeMessages(MSG_COLLAPSE_PANELS);
Jason Monk297c04e2018-08-23 17:16:59 -0400456 mHandler.obtainMessage(MSG_COLLAPSE_PANELS, flags, force ? 1 : 0).sendToTarget();
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700457 }
Jim Miller9a720f52012-05-30 03:19:43 -0700458 }
459
Anthony Chen9ad00e02017-05-12 15:53:36 -0700460 public void togglePanel() {
461 synchronized (mLock) {
462 mHandler.removeMessages(MSG_TOGGLE_PANEL);
463 mHandler.obtainMessage(MSG_TOGGLE_PANEL, 0, 0).sendToTarget();
464 }
465 }
466
Jason Monka9927322015-12-13 16:22:37 -0500467 public void animateExpandSettingsPanel(String subPanel) {
Jason Monk07473ce2016-01-05 14:59:19 -0500468 synchronized (mLock) {
Daniel Sandler11cf1782012-09-27 14:03:08 -0400469 mHandler.removeMessages(MSG_EXPAND_SETTINGS);
Jason Monka9927322015-12-13 16:22:37 -0500470 mHandler.obtainMessage(MSG_EXPAND_SETTINGS, subPanel).sendToTarget();
Joe Onorato4762c2d2010-05-17 15:42:59 -0700471 }
472 }
473
Charles Chen24e7a9f2018-11-21 11:59:07 +0800474 @Override
Jorim Jaggi956ca412019-01-07 14:49:14 +0100475 public void topAppWindowChanged(int displayId, boolean isFullscreen, boolean isImmersive) {
476 synchronized (mLock) {
477 SomeArgs args = SomeArgs.obtain();
478 args.argi1 = displayId;
479 args.argi2 = isFullscreen ? 1 : 0;
480 args.argi3 = isImmersive ? 1 : 0;
481 mHandler.obtainMessage(MSG_TOP_APP_WINDOW_CHANGED, args).sendToTarget();
482 }
483
484 }
Daniel Sandlere02d8082010-10-08 15:13:22 -0400485
Charles Chen24e7a9f2018-11-21 11:59:07 +0800486 @Override
487 public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition,
Tarandeep Singh07b318b2019-07-17 11:12:04 -0700488 boolean showImeSwitcher, boolean isMultiClientImeEnabled) {
Jason Monk07473ce2016-01-05 14:59:19 -0500489 synchronized (mLock) {
satok06487a52010-10-29 11:37:18 +0900490 mHandler.removeMessages(MSG_SHOW_IME_BUTTON);
Charles Chenf3d295c2018-11-30 18:15:21 +0800491 SomeArgs args = SomeArgs.obtain();
492 args.argi1 = displayId;
493 args.argi2 = vis;
494 args.argi3 = backDisposition;
495 args.argi4 = showImeSwitcher ? 1 : 0;
Tarandeep Singh07b318b2019-07-17 11:12:04 -0700496 args.argi5 = isMultiClientImeEnabled ? 1 : 0;
Charles Chenf3d295c2018-11-30 18:15:21 +0800497 args.arg1 = token;
498 Message m = mHandler.obtainMessage(MSG_SHOW_IME_BUTTON, args);
Jason Monkb605fec2014-05-02 17:04:10 -0400499 m.sendToTarget();
satok06487a52010-10-29 11:37:18 +0900500 }
501 }
502
Winson Chungdff7a732017-12-11 12:17:06 -0800503 public void showRecentApps(boolean triggeredFromAltTab) {
Jason Monk07473ce2016-01-05 14:59:19 -0500504 synchronized (mLock) {
Winson Chung1e8d71b2014-05-16 17:05:22 -0700505 mHandler.removeMessages(MSG_SHOW_RECENT_APPS);
Winson Chungdff7a732017-12-11 12:17:06 -0800506 mHandler.obtainMessage(MSG_SHOW_RECENT_APPS, triggeredFromAltTab ? 1 : 0, 0,
507 null).sendToTarget();
Winson Chung1e8d71b2014-05-16 17:05:22 -0700508 }
509 }
510
Winson Chungcdcd4872014-08-05 18:00:13 -0700511 public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
Jason Monk07473ce2016-01-05 14:59:19 -0500512 synchronized (mLock) {
Winson Chung1e8d71b2014-05-16 17:05:22 -0700513 mHandler.removeMessages(MSG_HIDE_RECENT_APPS);
Winson Chung6cb485f2014-05-19 10:30:43 -0700514 mHandler.obtainMessage(MSG_HIDE_RECENT_APPS,
Winson Chungcdcd4872014-08-05 18:00:13 -0700515 triggeredFromAltTab ? 1 : 0, triggeredFromHomeKey ? 1 : 0,
516 null).sendToTarget();
Winson Chung1e8d71b2014-05-16 17:05:22 -0700517 }
518 }
519
Phil Weaver315c34e2016-02-19 15:12:29 -0800520 public void toggleSplitScreen() {
521 synchronized (mLock) {
522 mHandler.removeMessages(MSG_TOGGLE_APP_SPLIT_SCREEN);
523 mHandler.obtainMessage(MSG_TOGGLE_APP_SPLIT_SCREEN, 0, 0, null).sendToTarget();
524 }
525 }
526
Michael Jurka3b1fc472011-06-13 10:54:40 -0700527 public void toggleRecentApps() {
Jason Monk07473ce2016-01-05 14:59:19 -0500528 synchronized (mLock) {
Michael Jurka3b1fc472011-06-13 10:54:40 -0700529 mHandler.removeMessages(MSG_TOGGLE_RECENT_APPS);
Jorim Jaggi6b460382017-05-13 23:16:44 +0200530 Message msg = mHandler.obtainMessage(MSG_TOGGLE_RECENT_APPS, 0, 0, null);
531 msg.setAsynchronous(true);
532 msg.sendToTarget();
Michael Jurka3b1fc472011-06-13 10:54:40 -0700533 }
534 }
535
Michael Jurka7f2668c2012-03-27 07:49:52 -0700536 public void preloadRecentApps() {
Jason Monk07473ce2016-01-05 14:59:19 -0500537 synchronized (mLock) {
Michael Jurka7f2668c2012-03-27 07:49:52 -0700538 mHandler.removeMessages(MSG_PRELOAD_RECENT_APPS);
539 mHandler.obtainMessage(MSG_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget();
540 }
541 }
542
543 public void cancelPreloadRecentApps() {
Jason Monk07473ce2016-01-05 14:59:19 -0500544 synchronized (mLock) {
Michael Jurka7f2668c2012-03-27 07:49:52 -0700545 mHandler.removeMessages(MSG_CANCEL_PRELOAD_RECENT_APPS);
546 mHandler.obtainMessage(MSG_CANCEL_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget();
547 }
548 }
549
Clara Bayarrif2debb12015-07-10 14:47:17 +0100550 @Override
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +0100551 public void dismissKeyboardShortcutsMenu() {
552 synchronized (mLock) {
553 mHandler.removeMessages(MSG_DISMISS_KEYBOARD_SHORTCUTS);
554 mHandler.obtainMessage(MSG_DISMISS_KEYBOARD_SHORTCUTS).sendToTarget();
555 }
556 }
557
558 @Override
Clara Bayarri4e850ff2016-03-02 11:12:32 -0800559 public void toggleKeyboardShortcutsMenu(int deviceId) {
Jason Monk07473ce2016-01-05 14:59:19 -0500560 synchronized (mLock) {
Andrei Stingaceanuc22ab792016-01-07 12:39:38 +0000561 mHandler.removeMessages(MSG_TOGGLE_KEYBOARD_SHORTCUTS);
Clara Bayarri4e850ff2016-03-02 11:12:32 -0800562 mHandler.obtainMessage(MSG_TOGGLE_KEYBOARD_SHORTCUTS, deviceId, 0).sendToTarget();
Clara Bayarrif2debb12015-07-10 14:47:17 +0100563 }
564 }
565
Jaewan Kimc552b042016-01-18 16:08:45 +0900566 @Override
Winson Chungac52f282017-03-30 14:44:52 -0700567 public void showPictureInPictureMenu() {
Jaewan Kimc552b042016-01-18 16:08:45 +0900568 synchronized (mLock) {
Winson Chungac52f282017-03-30 14:44:52 -0700569 mHandler.removeMessages(MSG_SHOW_PICTURE_IN_PICTURE_MENU);
570 mHandler.obtainMessage(MSG_SHOW_PICTURE_IN_PICTURE_MENU).sendToTarget();
Jaewan Kimc552b042016-01-18 16:08:45 +0900571 }
572 }
573
Charles Chen24e7a9f2018-11-21 11:59:07 +0800574 @Override
575 public void setWindowState(int displayId, int window, int state) {
Jason Monk07473ce2016-01-05 14:59:19 -0500576 synchronized (mLock) {
John Spurlock5b9145b2013-08-20 15:13:47 -0400577 // don't coalesce these
Charles Chenf3d295c2018-11-30 18:15:21 +0800578 mHandler.obtainMessage(MSG_SET_WINDOW_STATE, displayId, window, state).sendToTarget();
John Spurlock97642182013-07-29 17:58:39 -0400579 }
580 }
581
Andrii Kulian0f051f52016-04-14 00:41:51 -0700582 public void showScreenPinningRequest(int taskId) {
Jason Monk07473ce2016-01-05 14:59:19 -0500583 synchronized (mLock) {
Andrii Kulian0f051f52016-04-14 00:41:51 -0700584 mHandler.obtainMessage(MSG_SHOW_SCREEN_PIN_REQUEST, taskId, 0, null)
585 .sendToTarget();
Jason Monk5565cb42014-09-12 10:59:21 -0400586 }
587 }
588
Charles Chen24e7a9f2018-11-21 11:59:07 +0800589 @Override
590 public void appTransitionPending(int displayId) {
Charles Chenf3d295c2018-11-30 18:15:21 +0800591 appTransitionPending(displayId, false /* forced */);
Jason Monkaa573e92017-01-27 17:00:29 -0500592 }
593
Charles Chenf3d295c2018-11-30 18:15:21 +0800594 /**
595 * Called to notify System UI that an application transition is pending.
596 * @see Callbacks#appTransitionPending(int, boolean)
597 */
598 public void appTransitionPending(int displayId, boolean forced) {
Jason Monk07473ce2016-01-05 14:59:19 -0500599 synchronized (mLock) {
Charles Chenf3d295c2018-11-30 18:15:21 +0800600 mHandler.obtainMessage(MSG_APP_TRANSITION_PENDING, displayId, forced ? 1 : 0)
601 .sendToTarget();
Jorim Jaggi24bec7c2015-02-04 12:40:14 +0100602 }
603 }
604
Charles Chen24e7a9f2018-11-21 11:59:07 +0800605 @Override
606 public void appTransitionCancelled(int displayId) {
Jason Monk07473ce2016-01-05 14:59:19 -0500607 synchronized (mLock) {
Charles Chen54fce2c2019-03-13 18:17:29 +0800608 mHandler.obtainMessage(MSG_APP_TRANSITION_CANCELLED, displayId, 0 /* unused */)
609 .sendToTarget();
Jorim Jaggi24bec7c2015-02-04 12:40:14 +0100610 }
611 }
612
Charles Chen24e7a9f2018-11-21 11:59:07 +0800613 @Override
614 public void appTransitionStarting(int displayId, long startTime, long duration) {
Charles Chenf3d295c2018-11-30 18:15:21 +0800615 appTransitionStarting(displayId, startTime, duration, false /* forced */);
Jason Monkaa573e92017-01-27 17:00:29 -0500616 }
617
Charles Chenf3d295c2018-11-30 18:15:21 +0800618 /**
619 * Called to notify System UI that an application transition is starting.
620 * @see Callbacks#appTransitionStarting(int, long, long, boolean).
621 */
622 public void appTransitionStarting(int displayId, long startTime, long duration,
623 boolean forced) {
Jason Monk07473ce2016-01-05 14:59:19 -0500624 synchronized (mLock) {
Charles Chenf3d295c2018-11-30 18:15:21 +0800625 final SomeArgs args = SomeArgs.obtain();
626 args.argi1 = displayId;
627 args.argi2 = forced ? 1 : 0;
628 args.arg1 = startTime;
629 args.arg2 = duration;
630 mHandler.obtainMessage(MSG_APP_TRANSITION_STARTING, args).sendToTarget();
Jorim Jaggi24bec7c2015-02-04 12:40:14 +0100631 }
632 }
633
Jorim Jaggi2adba072016-03-03 13:43:39 +0100634 @Override
Charles Chen24e7a9f2018-11-21 11:59:07 +0800635 public void appTransitionFinished(int displayId) {
Jorim Jaggi2adba072016-03-03 13:43:39 +0100636 synchronized (mLock) {
Charles Chen54fce2c2019-03-13 18:17:29 +0800637 mHandler.obtainMessage(MSG_APP_TRANSITION_FINISHED, displayId, 0 /* unused */)
638 .sendToTarget();
Jorim Jaggi2adba072016-03-03 13:43:39 +0100639 }
640 }
641
Adrian Roos4f43dc02015-06-17 16:43:38 -0700642 public void showAssistDisclosure() {
Jason Monk07473ce2016-01-05 14:59:19 -0500643 synchronized (mLock) {
Adrian Roos4f43dc02015-06-17 16:43:38 -0700644 mHandler.removeMessages(MSG_ASSIST_DISCLOSURE);
645 mHandler.obtainMessage(MSG_ASSIST_DISCLOSURE).sendToTarget();
646 }
647 }
648
Jorim Jaggi165ce062015-07-06 16:18:11 -0700649 public void startAssist(Bundle args) {
Jason Monk07473ce2016-01-05 14:59:19 -0500650 synchronized (mLock) {
Jorim Jaggi165ce062015-07-06 16:18:11 -0700651 mHandler.removeMessages(MSG_START_ASSIST);
652 mHandler.obtainMessage(MSG_START_ASSIST, args).sendToTarget();
653 }
654 }
655
Selim Cinek372d1bd2015-08-14 13:19:37 -0700656 @Override
Jorim Jaggi40aa8812015-09-23 12:59:22 -0700657 public void onCameraLaunchGestureDetected(int source) {
Jason Monk07473ce2016-01-05 14:59:19 -0500658 synchronized (mLock) {
Selim Cinek372d1bd2015-08-14 13:19:37 -0700659 mHandler.removeMessages(MSG_CAMERA_LAUNCH_GESTURE);
Jorim Jaggi40aa8812015-09-23 12:59:22 -0700660 mHandler.obtainMessage(MSG_CAMERA_LAUNCH_GESTURE, source, 0).sendToTarget();
Selim Cinek372d1bd2015-08-14 13:19:37 -0700661 }
662 }
663
Jason Monk7e53f202016-01-28 10:40:20 -0500664 @Override
665 public void addQsTile(ComponentName tile) {
666 synchronized (mLock) {
667 mHandler.obtainMessage(MSG_ADD_QS_TILE, tile).sendToTarget();
668 }
669 }
670
671 @Override
672 public void remQsTile(ComponentName tile) {
673 synchronized (mLock) {
674 mHandler.obtainMessage(MSG_REMOVE_QS_TILE, tile).sendToTarget();
675 }
676 }
677
678 @Override
679 public void clickQsTile(ComponentName tile) {
680 synchronized (mLock) {
681 mHandler.obtainMessage(MSG_CLICK_QS_TILE, tile).sendToTarget();
682 }
683 }
684
Jim Miller07e03842016-06-22 15:18:13 -0700685 @Override
Philip Quinnc3a503d2017-07-18 23:23:41 -0700686 public void handleSystemKey(int key) {
Jim Miller07e03842016-06-22 15:18:13 -0700687 synchronized (mLock) {
Philip Quinnc3a503d2017-07-18 23:23:41 -0700688 mHandler.obtainMessage(MSG_HANDLE_SYSTEM_KEY, key, 0).sendToTarget();
Jim Miller07e03842016-06-22 15:18:13 -0700689 }
690 }
691
Jason Monk361915c2017-03-21 20:33:59 -0400692 @Override
Matthew Ng9c3bce52018-02-01 22:00:31 +0000693 public void showPinningEnterExitToast(boolean entering) {
694 synchronized (mLock) {
695 mHandler.obtainMessage(MSG_SHOW_PINNING_TOAST_ENTER_EXIT, entering).sendToTarget();
696 }
697 }
698
699 @Override
700 public void showPinningEscapeToast() {
701 synchronized (mLock) {
702 mHandler.obtainMessage(MSG_SHOW_PINNING_TOAST_ESCAPE).sendToTarget();
703 }
704 }
705
706
707 @Override
Jason Monk361915c2017-03-21 20:33:59 -0400708 public void showGlobalActionsMenu() {
709 synchronized (mLock) {
710 mHandler.removeMessages(MSG_SHOW_GLOBAL_ACTIONS);
711 mHandler.obtainMessage(MSG_SHOW_GLOBAL_ACTIONS).sendToTarget();
712 }
713 }
714
Jason Monkb4302182017-08-04 13:39:17 -0400715 @Override
Selim Cinek3a49ba22017-08-10 11:17:39 -0700716 public void setTopAppHidesStatusBar(boolean hidesStatusBar) {
717 mHandler.removeMessages(MSG_SET_TOP_APP_HIDES_STATUS_BAR);
718 mHandler.obtainMessage(MSG_SET_TOP_APP_HIDES_STATUS_BAR, hidesStatusBar ? 1 : 0, 0)
719 .sendToTarget();
720 }
721
722 @Override
Jason Monkb4302182017-08-04 13:39:17 -0400723 public void showShutdownUi(boolean isReboot, String reason) {
724 synchronized (mLock) {
725 mHandler.removeMessages(MSG_SHOW_SHUTDOWN_UI);
726 mHandler.obtainMessage(MSG_SHOW_SHUTDOWN_UI, isReboot ? 1 : 0, 0, reason)
727 .sendToTarget();
728 }
729 }
730
Mike Digman93f08342017-11-24 21:46:53 -0800731 @Override
Beverlyac32c9a2018-01-31 16:10:41 -0500732 public void showWirelessChargingAnimation(int batteryLevel) {
Beverlyae79ab92017-12-11 09:20:02 -0500733 mHandler.removeMessages(MSG_SHOW_CHARGING_ANIMATION);
734 mHandler.obtainMessage(MSG_SHOW_CHARGING_ANIMATION, batteryLevel, 0)
735 .sendToTarget();
736 }
737
738 @Override
Mike Digmane0777312018-01-19 12:41:51 -0800739 public void onProposedRotationChanged(int rotation, boolean isValid) {
Mike Digman93f08342017-11-24 21:46:53 -0800740 synchronized (mLock) {
741 mHandler.removeMessages(MSG_ROTATION_PROPOSAL);
Mike Digmane0777312018-01-19 12:41:51 -0800742 mHandler.obtainMessage(MSG_ROTATION_PROPOSAL, rotation, isValid ? 1 : 0,
Mike Digman93f08342017-11-24 21:46:53 -0800743 null).sendToTarget();
744 }
745 }
746
Kevin Chynaae4a152018-01-18 11:48:09 -0800747 @Override
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700748 public void showAuthenticationDialog(Bundle bundle, IBiometricServiceReceiverInternal receiver,
749 int biometricModality, boolean requireConfirmation, int userId, String opPackageName) {
Kevin Chynaae4a152018-01-18 11:48:09 -0800750 synchronized (mLock) {
751 SomeArgs args = SomeArgs.obtain();
752 args.arg1 = bundle;
753 args.arg2 = receiver;
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700754 args.argi1 = biometricModality;
Kevin Chyn6cf54e82018-09-18 19:13:27 -0700755 args.arg3 = requireConfirmation;
Kevin Chyn1b9f8df2018-11-12 19:04:55 -0800756 args.argi2 = userId;
Kevin Chyn050315f2019-08-08 14:22:54 -0700757 args.arg4 = opPackageName;
Kevin Chyne9275662018-07-23 16:42:06 -0700758 mHandler.obtainMessage(MSG_BIOMETRIC_SHOW, args)
Kevin Chynaae4a152018-01-18 11:48:09 -0800759 .sendToTarget();
760 }
761 }
762
763 @Override
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700764 public void onBiometricAuthenticated() {
Kevin Chynaae4a152018-01-18 11:48:09 -0800765 synchronized (mLock) {
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700766 mHandler.obtainMessage(MSG_BIOMETRIC_AUTHENTICATED).sendToTarget();
Kevin Chynaae4a152018-01-18 11:48:09 -0800767 }
768 }
769
770 @Override
Kevin Chyne9275662018-07-23 16:42:06 -0700771 public void onBiometricHelp(String message) {
Kevin Chynaae4a152018-01-18 11:48:09 -0800772 synchronized (mLock) {
Kevin Chyne9275662018-07-23 16:42:06 -0700773 mHandler.obtainMessage(MSG_BIOMETRIC_HELP, message).sendToTarget();
Kevin Chynaae4a152018-01-18 11:48:09 -0800774 }
775 }
776
777 @Override
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700778 public void onBiometricError(int modality, int error, int vendorCode) {
Kevin Chynaae4a152018-01-18 11:48:09 -0800779 synchronized (mLock) {
Ilya Matyukhin0f9da352019-10-03 14:10:01 -0700780 SomeArgs args = SomeArgs.obtain();
781 args.argi1 = modality;
782 args.argi2 = error;
783 args.argi3 = vendorCode;
784 mHandler.obtainMessage(MSG_BIOMETRIC_ERROR, args).sendToTarget();
Kevin Chynaae4a152018-01-18 11:48:09 -0800785 }
786 }
787
788 @Override
Kevin Chyn86f1b8e2019-09-24 19:00:49 -0700789 public void hideAuthenticationDialog() {
Kevin Chynaae4a152018-01-18 11:48:09 -0800790 synchronized (mLock) {
Kevin Chyne9275662018-07-23 16:42:06 -0700791 mHandler.obtainMessage(MSG_BIOMETRIC_HIDE).sendToTarget();
Kevin Chynaae4a152018-01-18 11:48:09 -0800792 }
793 }
794
Charles Chen3dedec32019-01-24 22:19:37 +0800795 @Override
796 public void onDisplayReady(int displayId) {
797 synchronized (mLock) {
798 mHandler.obtainMessage(MSG_DISPLAY_READY, displayId, 0).sendToTarget();
799 }
800 }
801
Winson Chung67e49362019-05-17 16:40:38 -0700802 @Override
803 public void onRecentsAnimationStateChanged(boolean running) {
804 synchronized (mLock) {
805 mHandler.obtainMessage(MSG_RECENTS_ANIMATION_STATE_CHANGED, running ? 1 : 0, 0)
806 .sendToTarget();
807 }
808 }
809
Robert Horvath5560f382019-07-10 10:46:38 +0200810 @Override
811 public void showInattentiveSleepWarning() {
812 synchronized (mLock) {
813 mHandler.obtainMessage(MSG_SHOW_INATTENTIVE_SLEEP_WARNING)
814 .sendToTarget();
815 }
816 }
817
818 @Override
Robert Horvath60e51fe2019-08-20 13:10:34 +0200819 public void dismissInattentiveSleepWarning(boolean animated) {
Robert Horvath5560f382019-07-10 10:46:38 +0200820 synchronized (mLock) {
Robert Horvath60e51fe2019-08-20 13:10:34 +0200821 mHandler.obtainMessage(MSG_DISMISS_INATTENTIVE_SLEEP_WARNING, animated)
Robert Horvath5560f382019-07-10 10:46:38 +0200822 .sendToTarget();
823 }
824 }
825
lumark7570cac2019-03-07 22:14:38 +0800826 private void handleShowImeButton(int displayId, IBinder token, int vis, int backDisposition,
Tarandeep Singh07b318b2019-07-17 11:12:04 -0700827 boolean showImeSwitcher, boolean isMultiClientImeEnabled) {
lumark7570cac2019-03-07 22:14:38 +0800828 if (displayId == INVALID_DISPLAY) return;
829
Tarandeep Singh07b318b2019-07-17 11:12:04 -0700830 if (!isMultiClientImeEnabled && mLastUpdatedImeDisplayId != displayId
lumark7570cac2019-03-07 22:14:38 +0800831 && mLastUpdatedImeDisplayId != INVALID_DISPLAY) {
832 // Set previous NavBar's IME window status as invisible when IME
833 // window switched to another display for single-session IME case.
834 sendImeInvisibleStatusForPrevNavBar();
835 }
836 for (int i = 0; i < mCallbacks.size(); i++) {
837 mCallbacks.get(i).setImeWindowStatus(displayId, token, vis, backDisposition,
838 showImeSwitcher);
839 }
840 mLastUpdatedImeDisplayId = displayId;
841 }
842
843 private void sendImeInvisibleStatusForPrevNavBar() {
844 for (int i = 0; i < mCallbacks.size(); i++) {
845 mCallbacks.get(i).setImeWindowStatus(mLastUpdatedImeDisplayId,
846 null /* token */, IME_INVISIBLE, BACK_DISPOSITION_DEFAULT,
847 false /* showImeSwitcher */);
848 }
849 }
850
Jorim Jaggi956ca412019-01-07 14:49:14 +0100851 @Override
852 public void onSystemBarAppearanceChanged(int displayId, @Appearance int appearance,
853 AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme) {
854 synchronized (mLock) {
855 SomeArgs args = SomeArgs.obtain();
856 args.argi1 = displayId;
857 args.argi2 = appearance;
858 args.argi3 = navbarColorManagedByIme ? 1 : 0;
859 args.arg1 = appearanceRegions;
860 mHandler.obtainMessage(MSG_SYSTEM_BAR_APPEARANCE_CHANGED, args).sendToTarget();
861 }
862 }
863
864 @Override
865 public void showTransient(int displayId, int[] types) {
866 synchronized (mLock) {
867 mHandler.obtainMessage(MSG_SHOW_TRANSIENT, displayId, 0, types).sendToTarget();
868 }
869 }
870
871 @Override
872 public void abortTransient(int displayId, int[] types) {
873 synchronized (mLock) {
874 mHandler.obtainMessage(MSG_ABORT_TRANSIENT, displayId, 0, types).sendToTarget();
875 }
876 }
877
Joe Onorato0cbda992010-05-02 16:28:15 -0700878 private final class H extends Handler {
Jason Monkb5b092012017-01-05 11:35:34 -0500879 private H(Looper l) {
880 super(l);
881 }
882
Joe Onorato0cbda992010-05-02 16:28:15 -0700883 public void handleMessage(Message msg) {
Joe Onoratof3f0e052010-05-14 18:49:29 -0700884 final int what = msg.what & MSG_MASK;
Joe Onorato66d7d012010-05-14 10:05:10 -0700885 switch (what) {
Joe Onorato0cbda992010-05-02 16:28:15 -0700886 case MSG_ICON: {
Joe Onorato0cbda992010-05-02 16:28:15 -0700887 switch (msg.arg1) {
888 case OP_SET_ICON: {
Jason Monk07473ce2016-01-05 14:59:19 -0500889 Pair<String, StatusBarIcon> p = (Pair<String, StatusBarIcon>) msg.obj;
Jason Monk49fa0162017-01-11 09:21:56 -0500890 for (int i = 0; i < mCallbacks.size(); i++) {
891 mCallbacks.get(i).setIcon(p.first, p.second);
Jason Monkb5b092012017-01-05 11:35:34 -0500892 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700893 break;
894 }
895 case OP_REMOVE_ICON:
Jason Monk49fa0162017-01-11 09:21:56 -0500896 for (int i = 0; i < mCallbacks.size(); i++) {
897 mCallbacks.get(i).removeIcon((String) msg.obj);
Jason Monkb5b092012017-01-05 11:35:34 -0500898 }
Joe Onorato0cbda992010-05-02 16:28:15 -0700899 break;
900 }
901 break;
Joe Onoratof3f0e052010-05-14 18:49:29 -0700902 }
903 case MSG_DISABLE:
Charles Chenf3d295c2018-11-30 18:15:21 +0800904 SomeArgs args = (SomeArgs) msg.obj;
Jason Monk49fa0162017-01-11 09:21:56 -0500905 for (int i = 0; i < mCallbacks.size(); i++) {
Charles Chenf3d295c2018-11-30 18:15:21 +0800906 mCallbacks.get(i).disable(args.argi1, args.argi2, args.argi3,
907 args.argi4 != 0 /* animate */);
Jason Monkb5b092012017-01-05 11:35:34 -0500908 }
Joe Onoratof3f0e052010-05-14 18:49:29 -0700909 break;
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700910 case MSG_EXPAND_NOTIFICATIONS:
Jason Monk49fa0162017-01-11 09:21:56 -0500911 for (int i = 0; i < mCallbacks.size(); i++) {
912 mCallbacks.get(i).animateExpandNotificationsPanel();
Jason Monkb5b092012017-01-05 11:35:34 -0500913 }
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700914 break;
Daniel Sandler11cf1782012-09-27 14:03:08 -0400915 case MSG_COLLAPSE_PANELS:
Jason Monk49fa0162017-01-11 09:21:56 -0500916 for (int i = 0; i < mCallbacks.size(); i++) {
Jason Monk297c04e2018-08-23 17:16:59 -0400917 mCallbacks.get(i).animateCollapsePanels(msg.arg1, msg.arg2 != 0);
Jason Monkb5b092012017-01-05 11:35:34 -0500918 }
Svetoslav Ganove20a1772012-09-25 16:07:46 -0700919 break;
Anthony Chen9ad00e02017-05-12 15:53:36 -0700920 case MSG_TOGGLE_PANEL:
921 for (int i = 0; i < mCallbacks.size(); i++) {
922 mCallbacks.get(i).togglePanel();
923 }
924 break;
Daniel Sandler11cf1782012-09-27 14:03:08 -0400925 case MSG_EXPAND_SETTINGS:
Jason Monk49fa0162017-01-11 09:21:56 -0500926 for (int i = 0; i < mCallbacks.size(); i++) {
927 mCallbacks.get(i).animateExpandSettingsPanel((String) msg.obj);
Jason Monkb5b092012017-01-05 11:35:34 -0500928 }
Joe Onorato93056472010-09-10 10:30:46 -0400929 break;
satok06487a52010-10-29 11:37:18 +0900930 case MSG_SHOW_IME_BUTTON:
Charles Chenf3d295c2018-11-30 18:15:21 +0800931 args = (SomeArgs) msg.obj;
lumark7570cac2019-03-07 22:14:38 +0800932 handleShowImeButton(args.argi1 /* displayId */, (IBinder) args.arg1 /* token */,
933 args.argi2 /* vis */, args.argi3 /* backDisposition */,
Tarandeep Singh07b318b2019-07-17 11:12:04 -0700934 args.argi4 != 0 /* showImeSwitcher */,
935 args.argi5 != 0 /* isMultiClientImeEnabled */);
satok06487a52010-10-29 11:37:18 +0900936 break;
Winson Chung1e8d71b2014-05-16 17:05:22 -0700937 case MSG_SHOW_RECENT_APPS:
Jason Monk49fa0162017-01-11 09:21:56 -0500938 for (int i = 0; i < mCallbacks.size(); i++) {
Winson Chungdff7a732017-12-11 12:17:06 -0800939 mCallbacks.get(i).showRecentApps(msg.arg1 != 0);
Jason Monkb5b092012017-01-05 11:35:34 -0500940 }
Winson Chung1e8d71b2014-05-16 17:05:22 -0700941 break;
942 case MSG_HIDE_RECENT_APPS:
Jason Monk49fa0162017-01-11 09:21:56 -0500943 for (int i = 0; i < mCallbacks.size(); i++) {
944 mCallbacks.get(i).hideRecentApps(msg.arg1 != 0, msg.arg2 != 0);
Jason Monkb5b092012017-01-05 11:35:34 -0500945 }
Winson Chung1e8d71b2014-05-16 17:05:22 -0700946 break;
Michael Jurka3b1fc472011-06-13 10:54:40 -0700947 case MSG_TOGGLE_RECENT_APPS:
Jason Monk49fa0162017-01-11 09:21:56 -0500948 for (int i = 0; i < mCallbacks.size(); i++) {
949 mCallbacks.get(i).toggleRecentApps();
Jason Monkb5b092012017-01-05 11:35:34 -0500950 }
Michael Jurka3b1fc472011-06-13 10:54:40 -0700951 break;
Michael Jurka7f2668c2012-03-27 07:49:52 -0700952 case MSG_PRELOAD_RECENT_APPS:
Jason Monk49fa0162017-01-11 09:21:56 -0500953 for (int i = 0; i < mCallbacks.size(); i++) {
954 mCallbacks.get(i).preloadRecentApps();
Jason Monkb5b092012017-01-05 11:35:34 -0500955 }
Michael Jurka7f2668c2012-03-27 07:49:52 -0700956 break;
957 case MSG_CANCEL_PRELOAD_RECENT_APPS:
Jason Monk49fa0162017-01-11 09:21:56 -0500958 for (int i = 0; i < mCallbacks.size(); i++) {
959 mCallbacks.get(i).cancelPreloadRecentApps();
Jason Monkb5b092012017-01-05 11:35:34 -0500960 }
Michael Jurka7f2668c2012-03-27 07:49:52 -0700961 break;
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +0100962 case MSG_DISMISS_KEYBOARD_SHORTCUTS:
Jason Monk49fa0162017-01-11 09:21:56 -0500963 for (int i = 0; i < mCallbacks.size(); i++) {
964 mCallbacks.get(i).dismissKeyboardShortcutsMenu();
Jason Monkb5b092012017-01-05 11:35:34 -0500965 }
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +0100966 break;
Andrei Stingaceanuc22ab792016-01-07 12:39:38 +0000967 case MSG_TOGGLE_KEYBOARD_SHORTCUTS:
Jason Monk49fa0162017-01-11 09:21:56 -0500968 for (int i = 0; i < mCallbacks.size(); i++) {
969 mCallbacks.get(i).toggleKeyboardShortcutsMenu(msg.arg1);
Jason Monkb5b092012017-01-05 11:35:34 -0500970 }
Clara Bayarrif2debb12015-07-10 14:47:17 +0100971 break;
John Spurlock97642182013-07-29 17:58:39 -0400972 case MSG_SET_WINDOW_STATE:
Jason Monk49fa0162017-01-11 09:21:56 -0500973 for (int i = 0; i < mCallbacks.size(); i++) {
Charles Chenf3d295c2018-11-30 18:15:21 +0800974 mCallbacks.get(i).setWindowState(msg.arg1, msg.arg2, (int) msg.obj);
Jason Monkb5b092012017-01-05 11:35:34 -0500975 }
John Spurlock97642182013-07-29 17:58:39 -0400976 break;
Jason Monk5565cb42014-09-12 10:59:21 -0400977 case MSG_SHOW_SCREEN_PIN_REQUEST:
Jason Monk49fa0162017-01-11 09:21:56 -0500978 for (int i = 0; i < mCallbacks.size(); i++) {
979 mCallbacks.get(i).showScreenPinningRequest(msg.arg1);
Jason Monkb5b092012017-01-05 11:35:34 -0500980 }
Jason Monk5565cb42014-09-12 10:59:21 -0400981 break;
Jorim Jaggi24bec7c2015-02-04 12:40:14 +0100982 case MSG_APP_TRANSITION_PENDING:
Jason Monk49fa0162017-01-11 09:21:56 -0500983 for (int i = 0; i < mCallbacks.size(); i++) {
Charles Chenf3d295c2018-11-30 18:15:21 +0800984 mCallbacks.get(i).appTransitionPending(msg.arg1, msg.arg2 != 0);
Jason Monkb5b092012017-01-05 11:35:34 -0500985 }
Jorim Jaggi24bec7c2015-02-04 12:40:14 +0100986 break;
987 case MSG_APP_TRANSITION_CANCELLED:
Jason Monk49fa0162017-01-11 09:21:56 -0500988 for (int i = 0; i < mCallbacks.size(); i++) {
Charles Chenf3d295c2018-11-30 18:15:21 +0800989 mCallbacks.get(i).appTransitionCancelled(msg.arg1);
Jason Monkb5b092012017-01-05 11:35:34 -0500990 }
Jorim Jaggi24bec7c2015-02-04 12:40:14 +0100991 break;
992 case MSG_APP_TRANSITION_STARTING:
Charles Chenf3d295c2018-11-30 18:15:21 +0800993 args = (SomeArgs) msg.obj;
Jason Monk49fa0162017-01-11 09:21:56 -0500994 for (int i = 0; i < mCallbacks.size(); i++) {
Charles Chenf3d295c2018-11-30 18:15:21 +0800995 mCallbacks.get(i).appTransitionStarting(args.argi1, (long) args.arg1,
996 (long) args.arg2, args.argi2 != 0 /* forced */);
Jason Monkb5b092012017-01-05 11:35:34 -0500997 }
Jorim Jaggi24bec7c2015-02-04 12:40:14 +0100998 break;
Jorim Jaggi2adba072016-03-03 13:43:39 +0100999 case MSG_APP_TRANSITION_FINISHED:
Jason Monk49fa0162017-01-11 09:21:56 -05001000 for (int i = 0; i < mCallbacks.size(); i++) {
Charles Chenf3d295c2018-11-30 18:15:21 +08001001 mCallbacks.get(i).appTransitionFinished(msg.arg1);
Jason Monkb5b092012017-01-05 11:35:34 -05001002 }
Jorim Jaggi2adba072016-03-03 13:43:39 +01001003 break;
Adrian Roos4f43dc02015-06-17 16:43:38 -07001004 case MSG_ASSIST_DISCLOSURE:
Jason Monk49fa0162017-01-11 09:21:56 -05001005 for (int i = 0; i < mCallbacks.size(); i++) {
1006 mCallbacks.get(i).showAssistDisclosure();
Jason Monkb5b092012017-01-05 11:35:34 -05001007 }
Adrian Roos4f43dc02015-06-17 16:43:38 -07001008 break;
Jorim Jaggi165ce062015-07-06 16:18:11 -07001009 case MSG_START_ASSIST:
Jason Monk49fa0162017-01-11 09:21:56 -05001010 for (int i = 0; i < mCallbacks.size(); i++) {
1011 mCallbacks.get(i).startAssist((Bundle) msg.obj);
Jason Monkb5b092012017-01-05 11:35:34 -05001012 }
Jorim Jaggi165ce062015-07-06 16:18:11 -07001013 break;
Selim Cinek372d1bd2015-08-14 13:19:37 -07001014 case MSG_CAMERA_LAUNCH_GESTURE:
Jason Monk49fa0162017-01-11 09:21:56 -05001015 for (int i = 0; i < mCallbacks.size(); i++) {
1016 mCallbacks.get(i).onCameraLaunchGestureDetected(msg.arg1);
Jason Monkb5b092012017-01-05 11:35:34 -05001017 }
Selim Cinek372d1bd2015-08-14 13:19:37 -07001018 break;
Winson Chungac52f282017-03-30 14:44:52 -07001019 case MSG_SHOW_PICTURE_IN_PICTURE_MENU:
Jason Monk49fa0162017-01-11 09:21:56 -05001020 for (int i = 0; i < mCallbacks.size(); i++) {
Winson Chungac52f282017-03-30 14:44:52 -07001021 mCallbacks.get(i).showPictureInPictureMenu();
Jason Monkb5b092012017-01-05 11:35:34 -05001022 }
Jaewan Kimc552b042016-01-18 16:08:45 +09001023 break;
Jason Monk7e53f202016-01-28 10:40:20 -05001024 case MSG_ADD_QS_TILE:
Jason Monk49fa0162017-01-11 09:21:56 -05001025 for (int i = 0; i < mCallbacks.size(); i++) {
1026 mCallbacks.get(i).addQsTile((ComponentName) msg.obj);
Jason Monkb5b092012017-01-05 11:35:34 -05001027 }
Jason Monk7e53f202016-01-28 10:40:20 -05001028 break;
1029 case MSG_REMOVE_QS_TILE:
Jason Monk49fa0162017-01-11 09:21:56 -05001030 for (int i = 0; i < mCallbacks.size(); i++) {
1031 mCallbacks.get(i).remQsTile((ComponentName) msg.obj);
Jason Monkb5b092012017-01-05 11:35:34 -05001032 }
Jason Monk7e53f202016-01-28 10:40:20 -05001033 break;
1034 case MSG_CLICK_QS_TILE:
Jason Monk49fa0162017-01-11 09:21:56 -05001035 for (int i = 0; i < mCallbacks.size(); i++) {
1036 mCallbacks.get(i).clickTile((ComponentName) msg.obj);
Jason Monkb5b092012017-01-05 11:35:34 -05001037 }
Jason Monk7e53f202016-01-28 10:40:20 -05001038 break;
Phil Weaver315c34e2016-02-19 15:12:29 -08001039 case MSG_TOGGLE_APP_SPLIT_SCREEN:
Jason Monk49fa0162017-01-11 09:21:56 -05001040 for (int i = 0; i < mCallbacks.size(); i++) {
1041 mCallbacks.get(i).toggleSplitScreen();
Jason Monkb5b092012017-01-05 11:35:34 -05001042 }
Phil Weaver315c34e2016-02-19 15:12:29 -08001043 break;
Philip Quinnc3a503d2017-07-18 23:23:41 -07001044 case MSG_HANDLE_SYSTEM_KEY:
Jason Monk49fa0162017-01-11 09:21:56 -05001045 for (int i = 0; i < mCallbacks.size(); i++) {
Philip Quinnc3a503d2017-07-18 23:23:41 -07001046 mCallbacks.get(i).handleSystemKey(msg.arg1);
Jason Monkb5b092012017-01-05 11:35:34 -05001047 }
Jim Miller07e03842016-06-22 15:18:13 -07001048 break;
Jason Monk361915c2017-03-21 20:33:59 -04001049 case MSG_SHOW_GLOBAL_ACTIONS:
1050 for (int i = 0; i < mCallbacks.size(); i++) {
1051 mCallbacks.get(i).handleShowGlobalActionsMenu();
1052 }
1053 break;
Jason Monkb4302182017-08-04 13:39:17 -04001054 case MSG_SHOW_SHUTDOWN_UI:
1055 for (int i = 0; i < mCallbacks.size(); i++) {
1056 mCallbacks.get(i).handleShowShutdownUi(msg.arg1 != 0, (String) msg.obj);
1057 }
1058 break;
Selim Cinek3a49ba22017-08-10 11:17:39 -07001059 case MSG_SET_TOP_APP_HIDES_STATUS_BAR:
1060 for (int i = 0; i < mCallbacks.size(); i++) {
1061 mCallbacks.get(i).setTopAppHidesStatusBar(msg.arg1 != 0);
1062 }
1063 break;
Mike Digman93f08342017-11-24 21:46:53 -08001064 case MSG_ROTATION_PROPOSAL:
1065 for (int i = 0; i < mCallbacks.size(); i++) {
Mike Digmane0777312018-01-19 12:41:51 -08001066 mCallbacks.get(i).onRotationProposal(msg.arg1, msg.arg2 != 0);
Mike Digman93f08342017-11-24 21:46:53 -08001067 }
1068 break;
Kevin Chyne674e852019-04-24 12:39:40 -07001069 case MSG_BIOMETRIC_SHOW: {
Kevin Chyne9275662018-07-23 16:42:06 -07001070 mHandler.removeMessages(MSG_BIOMETRIC_ERROR);
1071 mHandler.removeMessages(MSG_BIOMETRIC_HELP);
1072 mHandler.removeMessages(MSG_BIOMETRIC_AUTHENTICATED);
Kevin Chyn5a2ff5d2018-08-29 19:07:30 -07001073 SomeArgs someArgs = (SomeArgs) msg.obj;
Kevin Chynaae4a152018-01-18 11:48:09 -08001074 for (int i = 0; i < mCallbacks.size(); i++) {
Kevin Chyn86f1b8e2019-09-24 19:00:49 -07001075 mCallbacks.get(i).showAuthenticationDialog(
Kevin Chyn5a2ff5d2018-08-29 19:07:30 -07001076 (Bundle) someArgs.arg1,
Kevin Chyn23289ef2018-11-28 16:32:36 -08001077 (IBiometricServiceReceiverInternal) someArgs.arg2,
Kevin Chyn86f1b8e2019-09-24 19:00:49 -07001078 someArgs.argi1 /* biometricModality */,
Kevin Chyn1b9f8df2018-11-12 19:04:55 -08001079 (boolean) someArgs.arg3 /* requireConfirmation */,
Kevin Chyn050315f2019-08-08 14:22:54 -07001080 someArgs.argi2 /* userId */,
1081 (String) someArgs.arg4 /* opPackageName */);
Kevin Chynaae4a152018-01-18 11:48:09 -08001082 }
Kevin Chyn5a2ff5d2018-08-29 19:07:30 -07001083 someArgs.recycle();
Kevin Chynaae4a152018-01-18 11:48:09 -08001084 break;
Kevin Chyne674e852019-04-24 12:39:40 -07001085 }
1086 case MSG_BIOMETRIC_AUTHENTICATED: {
Kevin Chynaae4a152018-01-18 11:48:09 -08001087 for (int i = 0; i < mCallbacks.size(); i++) {
Ilya Matyukhin0f9da352019-10-03 14:10:01 -07001088 mCallbacks.get(i).onBiometricAuthenticated();
Kevin Chynaae4a152018-01-18 11:48:09 -08001089 }
1090 break;
Kevin Chyne674e852019-04-24 12:39:40 -07001091 }
Kevin Chyne9275662018-07-23 16:42:06 -07001092 case MSG_BIOMETRIC_HELP:
Kevin Chynaae4a152018-01-18 11:48:09 -08001093 for (int i = 0; i < mCallbacks.size(); i++) {
Kevin Chyne9275662018-07-23 16:42:06 -07001094 mCallbacks.get(i).onBiometricHelp((String) msg.obj);
Kevin Chynaae4a152018-01-18 11:48:09 -08001095 }
1096 break;
Kevin Chyne9275662018-07-23 16:42:06 -07001097 case MSG_BIOMETRIC_ERROR:
Ilya Matyukhin0f9da352019-10-03 14:10:01 -07001098 SomeArgs someArgs = (SomeArgs) msg.obj;
Kevin Chynaae4a152018-01-18 11:48:09 -08001099 for (int i = 0; i < mCallbacks.size(); i++) {
Ilya Matyukhin0f9da352019-10-03 14:10:01 -07001100 mCallbacks.get(i).onBiometricError(
1101 someArgs.argi1 /* modality */,
1102 someArgs.argi2 /* error */,
1103 someArgs.argi3 /* vendorCode */
1104 );
Kevin Chynaae4a152018-01-18 11:48:09 -08001105 }
Ilya Matyukhin0f9da352019-10-03 14:10:01 -07001106 someArgs.recycle();
Kevin Chynaae4a152018-01-18 11:48:09 -08001107 break;
Kevin Chyne9275662018-07-23 16:42:06 -07001108 case MSG_BIOMETRIC_HIDE:
Kevin Chynaae4a152018-01-18 11:48:09 -08001109 for (int i = 0; i < mCallbacks.size(); i++) {
Kevin Chyn86f1b8e2019-09-24 19:00:49 -07001110 mCallbacks.get(i).hideAuthenticationDialog();
Kevin Chynaae4a152018-01-18 11:48:09 -08001111 }
Beverlyae79ab92017-12-11 09:20:02 -05001112 break;
1113 case MSG_SHOW_CHARGING_ANIMATION:
1114 for (int i = 0; i < mCallbacks.size(); i++) {
Beverlyac32c9a2018-01-31 16:10:41 -05001115 mCallbacks.get(i).showWirelessChargingAnimation(msg.arg1);
Beverlyae79ab92017-12-11 09:20:02 -05001116 }
1117 break;
Matthew Ng9c3bce52018-02-01 22:00:31 +00001118 case MSG_SHOW_PINNING_TOAST_ENTER_EXIT:
1119 for (int i = 0; i < mCallbacks.size(); i++) {
1120 mCallbacks.get(i).showPinningEnterExitToast((Boolean) msg.obj);
1121 }
1122 break;
1123 case MSG_SHOW_PINNING_TOAST_ESCAPE:
1124 for (int i = 0; i < mCallbacks.size(); i++) {
1125 mCallbacks.get(i).showPinningEscapeToast();
1126 }
1127 break;
Charles Chen3dedec32019-01-24 22:19:37 +08001128 case MSG_DISPLAY_READY:
1129 for (int i = 0; i < mCallbacks.size(); i++) {
1130 mCallbacks.get(i).onDisplayReady(msg.arg1);
1131 }
1132 break;
Winson Chung67e49362019-05-17 16:40:38 -07001133 case MSG_RECENTS_ANIMATION_STATE_CHANGED:
1134 for (int i = 0; i < mCallbacks.size(); i++) {
1135 mCallbacks.get(i).onRecentsAnimationStateChanged(msg.arg1 > 0);
1136 }
1137 break;
Jorim Jaggi956ca412019-01-07 14:49:14 +01001138 case MSG_SYSTEM_BAR_APPEARANCE_CHANGED:
1139 args = (SomeArgs) msg.obj;
1140 for (int i = 0; i < mCallbacks.size(); i++) {
1141 mCallbacks.get(i).onSystemBarAppearanceChanged(args.argi1, args.argi2,
1142 (AppearanceRegion[]) args.arg1, args.argi3 == 1);
1143 }
1144 args.recycle();
1145 break;
1146 case MSG_SHOW_TRANSIENT: {
1147 final int displayId = msg.arg1;
1148 final int[] types = (int[]) msg.obj;
1149 for (int i = 0; i < mCallbacks.size(); i++) {
1150 mCallbacks.get(i).showTransient(displayId, types);
1151 }
1152 break;
1153 }
1154 case MSG_ABORT_TRANSIENT: {
1155 final int displayId = msg.arg1;
1156 final int[] types = (int[]) msg.obj;
1157 for (int i = 0; i < mCallbacks.size(); i++) {
1158 mCallbacks.get(i).abortTransient(displayId, types);
1159 }
1160 break;
1161 }
1162 case MSG_TOP_APP_WINDOW_CHANGED: {
1163 args = (SomeArgs) msg.obj;
1164 for (int i = 0; i < mCallbacks.size(); i++) {
1165 mCallbacks.get(i).topAppWindowChanged(
1166 args.argi1, args.argi2 != 0, args.argi3 != 0);
1167 }
1168 args.recycle();
1169 break;
1170 }
Robert Horvath5560f382019-07-10 10:46:38 +02001171 case MSG_SHOW_INATTENTIVE_SLEEP_WARNING:
1172 for (int i = 0; i < mCallbacks.size(); i++) {
1173 mCallbacks.get(i).showInattentiveSleepWarning();
1174 }
1175 break;
1176 case MSG_DISMISS_INATTENTIVE_SLEEP_WARNING:
1177 for (int i = 0; i < mCallbacks.size(); i++) {
Robert Horvath60e51fe2019-08-20 13:10:34 +02001178 mCallbacks.get(i).dismissInattentiveSleepWarning((Boolean) msg.obj);
Robert Horvath5560f382019-07-10 10:46:38 +02001179 }
1180 break;
Joe Onorato0cbda992010-05-02 16:28:15 -07001181 }
1182 }
1183 }
1184}