1 /* 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 17 package com.android.systemui.statusbar; 18 19 import static android.app.StatusBarManager.DISABLE2_NONE; 20 import static android.app.StatusBarManager.DISABLE_NONE; 21 import static android.inputmethodservice.InputMethodService.BACK_DISPOSITION_DEFAULT; 22 import static android.inputmethodservice.InputMethodService.IME_INVISIBLE; 23 import static android.view.Display.INVALID_DISPLAY; 24 25 import android.annotation.Nullable; 26 import android.app.ITransientNotificationCallback; 27 import android.app.StatusBarManager; 28 import android.app.StatusBarManager.Disable2Flags; 29 import android.app.StatusBarManager.DisableFlags; 30 import android.app.StatusBarManager.WindowType; 31 import android.app.StatusBarManager.WindowVisibleState; 32 import android.content.ComponentName; 33 import android.content.Context; 34 import android.graphics.drawable.Icon; 35 import android.hardware.biometrics.BiometricAuthenticator.Modality; 36 import android.hardware.biometrics.IBiometricContextListener; 37 import android.hardware.biometrics.IBiometricSysuiReceiver; 38 import android.hardware.biometrics.PromptInfo; 39 import android.hardware.fingerprint.IUdfpsRefreshRateRequestCallback; 40 import android.inputmethodservice.InputMethodService.BackDispositionMode; 41 import android.media.INearbyMediaDevicesProvider; 42 import android.media.MediaRoute2Info; 43 import android.os.Binder; 44 import android.os.Bundle; 45 import android.os.Handler; 46 import android.os.HandlerExecutor; 47 import android.os.IBinder; 48 import android.os.Looper; 49 import android.os.Message; 50 import android.os.ParcelFileDescriptor; 51 import android.os.Process; 52 import android.os.RemoteException; 53 import android.os.UserHandle; 54 import android.util.Pair; 55 import android.util.SparseArray; 56 import android.view.KeyEvent; 57 import android.view.WindowInsets.Type.InsetsType; 58 import android.view.WindowInsetsController.Appearance; 59 import android.view.WindowInsetsController.Behavior; 60 import android.view.accessibility.Flags; 61 62 import androidx.annotation.NonNull; 63 import androidx.annotation.VisibleForTesting; 64 65 import com.android.internal.os.SomeArgs; 66 import com.android.internal.statusbar.IAddTileResultCallback; 67 import com.android.internal.statusbar.IStatusBar; 68 import com.android.internal.statusbar.IUndoMediaTransferCallback; 69 import com.android.internal.statusbar.LetterboxDetails; 70 import com.android.internal.statusbar.StatusBarIcon; 71 import com.android.internal.util.GcUtils; 72 import com.android.internal.view.AppearanceRegion; 73 import com.android.systemui.dump.DumpHandler; 74 import com.android.systemui.power.domain.interactor.PowerInteractor; 75 import com.android.systemui.settings.DisplayTracker; 76 import com.android.systemui.statusbar.CommandQueue.Callbacks; 77 import com.android.systemui.statusbar.commandline.CommandRegistry; 78 import com.android.systemui.statusbar.policy.CallbackController; 79 80 import dagger.Lazy; 81 82 import java.io.FileDescriptor; 83 import java.io.FileOutputStream; 84 import java.io.OutputStream; 85 import java.io.PrintWriter; 86 import java.util.ArrayList; 87 88 /** 89 * This class takes the functions from IStatusBar that come in on 90 * binder pool threads and posts messages to get them onto the main 91 * thread, and calls onto Callbacks. It also takes care of 92 * coalescing these calls so they don't stack up. For the calls 93 * are coalesced, note that they are all idempotent. 94 */ 95 public class CommandQueue extends IStatusBar.Stub implements 96 CallbackController<Callbacks> { 97 private static final String TAG = CommandQueue.class.getSimpleName(); 98 99 private static final int INDEX_MASK = 0xffff; 100 private static final int MSG_SHIFT = 16; 101 private static final int MSG_MASK = 0xffff << MSG_SHIFT; 102 103 private static final int OP_SET_ICON = 1; 104 private static final int OP_REMOVE_ICON = 2; 105 106 private static final int MSG_ICON = 1 << MSG_SHIFT; 107 private static final int MSG_DISABLE = 2 << MSG_SHIFT; 108 private static final int MSG_EXPAND_NOTIFICATIONS = 3 << MSG_SHIFT; 109 private static final int MSG_COLLAPSE_PANELS = 4 << MSG_SHIFT; 110 private static final int MSG_EXPAND_SETTINGS = 5 << MSG_SHIFT; 111 private static final int MSG_SYSTEM_BAR_CHANGED = 6 << MSG_SHIFT; 112 private static final int MSG_DISPLAY_READY = 7 << MSG_SHIFT; 113 private static final int MSG_SHOW_IME_BUTTON = 8 << MSG_SHIFT; 114 private static final int MSG_TOGGLE_RECENT_APPS = 9 << MSG_SHIFT; 115 private static final int MSG_PRELOAD_RECENT_APPS = 10 << MSG_SHIFT; 116 private static final int MSG_CANCEL_PRELOAD_RECENT_APPS = 11 << MSG_SHIFT; 117 private static final int MSG_SET_WINDOW_STATE = 12 << MSG_SHIFT; 118 private static final int MSG_SHOW_RECENT_APPS = 13 << MSG_SHIFT; 119 private static final int MSG_HIDE_RECENT_APPS = 14 << MSG_SHIFT; 120 private static final int MSG_SHOW_SCREEN_PIN_REQUEST = 18 << MSG_SHIFT; 121 private static final int MSG_APP_TRANSITION_PENDING = 19 << MSG_SHIFT; 122 private static final int MSG_APP_TRANSITION_CANCELLED = 20 << MSG_SHIFT; 123 private static final int MSG_APP_TRANSITION_STARTING = 21 << MSG_SHIFT; 124 private static final int MSG_ASSIST_DISCLOSURE = 22 << MSG_SHIFT; 125 private static final int MSG_START_ASSIST = 23 << MSG_SHIFT; 126 private static final int MSG_CAMERA_LAUNCH_GESTURE = 24 << MSG_SHIFT; 127 private static final int MSG_TOGGLE_KEYBOARD_SHORTCUTS = 25 << MSG_SHIFT; 128 private static final int MSG_SHOW_PICTURE_IN_PICTURE_MENU = 26 << MSG_SHIFT; 129 private static final int MSG_ADD_QS_TILE = 27 << MSG_SHIFT; 130 private static final int MSG_REMOVE_QS_TILE = 28 << MSG_SHIFT; 131 private static final int MSG_CLICK_QS_TILE = 29 << MSG_SHIFT; 132 private static final int MSG_TOGGLE_APP_SPLIT_SCREEN = 30 << MSG_SHIFT; 133 private static final int MSG_APP_TRANSITION_FINISHED = 31 << MSG_SHIFT; 134 private static final int MSG_DISMISS_KEYBOARD_SHORTCUTS = 32 << MSG_SHIFT; 135 private static final int MSG_HANDLE_SYSTEM_KEY = 33 << MSG_SHIFT; 136 private static final int MSG_SHOW_GLOBAL_ACTIONS = 34 << MSG_SHIFT; 137 private static final int MSG_TOGGLE_NOTIFICATION_PANEL = 35 << MSG_SHIFT; 138 private static final int MSG_SHOW_SHUTDOWN_UI = 36 << MSG_SHIFT; 139 private static final int MSG_SET_TOP_APP_HIDES_STATUS_BAR = 37 << MSG_SHIFT; 140 private static final int MSG_ROTATION_PROPOSAL = 38 << MSG_SHIFT; 141 private static final int MSG_BIOMETRIC_SHOW = 39 << MSG_SHIFT; 142 private static final int MSG_BIOMETRIC_AUTHENTICATED = 40 << MSG_SHIFT; 143 private static final int MSG_BIOMETRIC_HELP = 41 << MSG_SHIFT; 144 private static final int MSG_BIOMETRIC_ERROR = 42 << MSG_SHIFT; 145 private static final int MSG_BIOMETRIC_HIDE = 43 << MSG_SHIFT; 146 private static final int MSG_SHOW_CHARGING_ANIMATION = 44 << MSG_SHIFT; 147 private static final int MSG_SHOW_PINNING_TOAST_ENTER_EXIT = 45 << MSG_SHIFT; 148 private static final int MSG_SHOW_PINNING_TOAST_ESCAPE = 46 << MSG_SHIFT; 149 private static final int MSG_RECENTS_ANIMATION_STATE_CHANGED = 47 << MSG_SHIFT; 150 private static final int MSG_SHOW_TRANSIENT = 48 << MSG_SHIFT; 151 private static final int MSG_ABORT_TRANSIENT = 49 << MSG_SHIFT; 152 private static final int MSG_SHOW_INATTENTIVE_SLEEP_WARNING = 50 << MSG_SHIFT; 153 private static final int MSG_DISMISS_INATTENTIVE_SLEEP_WARNING = 51 << MSG_SHIFT; 154 private static final int MSG_SHOW_TOAST = 52 << MSG_SHIFT; 155 private static final int MSG_HIDE_TOAST = 53 << MSG_SHIFT; 156 private static final int MSG_TRACING_STATE_CHANGED = 54 << MSG_SHIFT; 157 private static final int MSG_SUPPRESS_AMBIENT_DISPLAY = 55 << MSG_SHIFT; 158 private static final int MSG_REQUEST_MAGNIFICATION_CONNECTION = 56 << MSG_SHIFT; 159 //TODO(b/169175022) Update name and when feature name is locked. 160 private static final int MSG_EMERGENCY_ACTION_LAUNCH_GESTURE = 58 << MSG_SHIFT; 161 private static final int MSG_SET_NAVIGATION_BAR_LUMA_SAMPLING_ENABLED = 59 << MSG_SHIFT; 162 private static final int MSG_SET_UDFPS_REFRESH_RATE_CALLBACK = 60 << MSG_SHIFT; 163 private static final int MSG_TILE_SERVICE_REQUEST_ADD = 61 << MSG_SHIFT; 164 private static final int MSG_TILE_SERVICE_REQUEST_CANCEL = 62 << MSG_SHIFT; 165 private static final int MSG_SET_BIOMETRICS_LISTENER = 63 << MSG_SHIFT; 166 private static final int MSG_MEDIA_TRANSFER_SENDER_STATE = 64 << MSG_SHIFT; 167 private static final int MSG_MEDIA_TRANSFER_RECEIVER_STATE = 65 << MSG_SHIFT; 168 private static final int MSG_REGISTER_NEARBY_MEDIA_DEVICE_PROVIDER = 66 << MSG_SHIFT; 169 private static final int MSG_UNREGISTER_NEARBY_MEDIA_DEVICE_PROVIDER = 67 << MSG_SHIFT; 170 private static final int MSG_TILE_SERVICE_REQUEST_LISTENING_STATE = 68 << MSG_SHIFT; 171 private static final int MSG_SHOW_REAR_DISPLAY_DIALOG = 69 << MSG_SHIFT; 172 private static final int MSG_MOVE_FOCUSED_TASK_TO_FULLSCREEN = 70 << MSG_SHIFT; 173 private static final int MSG_MOVE_FOCUSED_TASK_TO_STAGE_SPLIT = 71 << MSG_SHIFT; 174 private static final int MSG_SHOW_MEDIA_OUTPUT_SWITCHER = 72 << MSG_SHIFT; 175 private static final int MSG_TOGGLE_TASKBAR = 73 << MSG_SHIFT; 176 private static final int MSG_SETTING_CHANGED = 74 << MSG_SHIFT; 177 private static final int MSG_LOCK_TASK_MODE_CHANGED = 75 << MSG_SHIFT; 178 private static final int MSG_CONFIRM_IMMERSIVE_PROMPT = 77 << MSG_SHIFT; 179 private static final int MSG_IMMERSIVE_CHANGED = 78 << MSG_SHIFT; 180 private static final int MSG_SET_QS_TILES = 79 << MSG_SHIFT; 181 private static final int MSG_ENTER_DESKTOP = 80 << MSG_SHIFT; 182 private static final int MSG_SET_SPLITSCREEN_FOCUS = 81 << MSG_SHIFT; 183 private static final int MSG_TOGGLE_QUICK_SETTINGS_PANEL = 82 << MSG_SHIFT; 184 public static final int FLAG_EXCLUDE_NONE = 0; 185 public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0; 186 public static final int FLAG_EXCLUDE_RECENTS_PANEL = 1 << 1; 187 public static final int FLAG_EXCLUDE_NOTIFICATION_PANEL = 1 << 2; 188 public static final int FLAG_EXCLUDE_INPUT_METHODS_PANEL = 1 << 3; 189 public static final int FLAG_EXCLUDE_COMPAT_MODE_PANEL = 1 << 4; 190 191 private static final String SHOW_IME_SWITCHER_KEY = "showImeSwitcherKey"; 192 193 private final Object mLock = new Object(); 194 private ArrayList<Callbacks> mCallbacks = new ArrayList<>(); 195 private Handler mHandler = new H(Looper.getMainLooper()); 196 /** A map of display id - disable flag pair */ 197 private SparseArray<Pair<Integer, Integer>> mDisplayDisabled = new SparseArray<>(); 198 /** 199 * The last ID of the display where IME window for which we received setImeWindowStatus 200 * event. 201 */ 202 private int mLastUpdatedImeDisplayId = INVALID_DISPLAY; 203 private final DisplayTracker mDisplayTracker; 204 private final @Nullable CommandRegistry mRegistry; 205 private final @Nullable DumpHandler mDumpHandler; 206 private final @Nullable Lazy<PowerInteractor> mPowerInteractor; 207 208 /** 209 * These methods are called back on the main thread. 210 */ 211 public interface Callbacks { setIcon(String slot, StatusBarIcon icon)212 default void setIcon(String slot, StatusBarIcon icon) { } removeIcon(String slot)213 default void removeIcon(String slot) { } 214 215 /** 216 * Called to notify that disable flags are updated. 217 * @see IStatusBar#disable(int, int, int). 218 * 219 * @param displayId The id of the display to notify. 220 * @param state1 The combination of following DISABLE_* flags: 221 * @param state2 The combination of following DISABLE2_* flags: 222 * @param animate {@code true} to show animations. 223 */ disable(int displayId, @DisableFlags int state1, @Disable2Flags int state2, boolean animate)224 default void disable(int displayId, @DisableFlags int state1, @Disable2Flags int state2, 225 boolean animate) { } 226 227 /** 228 * Called to expand Notifications panel with animation. 229 */ animateExpandNotificationsPanel()230 default void animateExpandNotificationsPanel() { } 231 /** 232 * Called to collapse Notifications panel with animation. 233 * @param flags Exclusion flags. See {@link FLAG_EXCLUDE_NONE}. 234 * @param force True to force the operation. 235 */ animateCollapsePanels(int flags, boolean force)236 default void animateCollapsePanels(int flags, boolean force) { } 237 238 /** 239 * Called to toggle Notifications panel. 240 */ toggleNotificationsPanel()241 default void toggleNotificationsPanel() { } 242 243 /** 244 * Called to expand Quick Settings panel with animation. 245 * @param subPanel subPanel one wish to expand. 246 */ animateExpandSettingsPanel(String subPanel)247 default void animateExpandSettingsPanel(String subPanel) { } 248 249 /** 250 * Called to toggle Quick Settings panel. 251 */ toggleQuickSettingsPanel()252 default void toggleQuickSettingsPanel() { } 253 254 /** 255 * Called to notify IME window status changes. 256 * 257 * @param displayId The id of the display to notify. 258 * @param token IME token. 259 * @param vis IME visibility. 260 * @param backDisposition Disposition mode of back button. It should be one of below flags: 261 * @param showImeSwitcher {@code true} to show IME switch button. 262 */ setImeWindowStatus(int displayId, IBinder token, int vis, @BackDispositionMode int backDisposition, boolean showImeSwitcher)263 default void setImeWindowStatus(int displayId, IBinder token, int vis, 264 @BackDispositionMode int backDisposition, boolean showImeSwitcher) { } showRecentApps(boolean triggeredFromAltTab)265 default void showRecentApps(boolean triggeredFromAltTab) { } hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey)266 default void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { } toggleTaskbar()267 default void toggleTaskbar() { } toggleRecentApps()268 default void toggleRecentApps() { } toggleSplitScreen()269 default void toggleSplitScreen() { } preloadRecentApps()270 default void preloadRecentApps() { } dismissKeyboardShortcutsMenu()271 default void dismissKeyboardShortcutsMenu() { } toggleKeyboardShortcutsMenu(int deviceId)272 default void toggleKeyboardShortcutsMenu(int deviceId) { } cancelPreloadRecentApps()273 default void cancelPreloadRecentApps() { } 274 275 /** 276 * Called to notify window state changes. 277 * @see IStatusBar#setWindowState(int, int, int) 278 * 279 * @param displayId The id of the display to notify. 280 * @param window Window type. It should be one of {@link StatusBarManager#WINDOW_STATUS_BAR} 281 * or {@link StatusBarManager#WINDOW_NAVIGATION_BAR} 282 * @param state Window visible state. 283 */ setWindowState(int displayId, @WindowType int window, @WindowVisibleState int state)284 default void setWindowState(int displayId, @WindowType int window, 285 @WindowVisibleState int state) { } showScreenPinningRequest(int taskId)286 default void showScreenPinningRequest(int taskId) { } 287 288 /** 289 * Called to notify System UI that an application transition is pending. 290 * @see IStatusBar#appTransitionPending(int). 291 * 292 * @param displayId The id of the display to notify. 293 * @param forced {@code true} to force transition pending. 294 */ appTransitionPending(int displayId, boolean forced)295 default void appTransitionPending(int displayId, boolean forced) { } 296 297 /** 298 * Called to notify System UI that an application transition is canceled. 299 * @see IStatusBar#appTransitionCancelled(int). 300 * 301 * @param displayId The id of the display to notify. 302 */ appTransitionCancelled(int displayId)303 default void appTransitionCancelled(int displayId) { } 304 305 /** 306 * Called to notify System UI that an application transition is starting. 307 * @see IStatusBar#appTransitionStarting(int, long, long). 308 * 309 * @param displayId The id of the display to notify. 310 * @param startTime Transition start time. 311 * @param duration Transition duration. 312 * @param forced {@code true} to force transition pending. 313 */ appTransitionStarting( int displayId, long startTime, long duration, boolean forced)314 default void appTransitionStarting( 315 int displayId, long startTime, long duration, boolean forced) { } 316 317 /** 318 * Called to notify System UI that an application transition is finished. 319 * @see IStatusBar#appTransitionFinished(int) 320 * 321 * @param displayId The id of the display to notify. 322 */ appTransitionFinished(int displayId)323 default void appTransitionFinished(int displayId) { } showAssistDisclosure()324 default void showAssistDisclosure() { } startAssist(Bundle args)325 default void startAssist(Bundle args) { } onCameraLaunchGestureDetected(int source)326 default void onCameraLaunchGestureDetected(int source) { } 327 328 /** 329 * Notifies SysUI that the emergency action gesture was detected. 330 */ onEmergencyActionLaunchGestureDetected()331 default void onEmergencyActionLaunchGestureDetected() { } showPictureInPictureMenu()332 default void showPictureInPictureMenu() { } setTopAppHidesStatusBar(boolean topAppHidesStatusBar)333 default void setTopAppHidesStatusBar(boolean topAppHidesStatusBar) { } 334 addQsTile(ComponentName tile)335 default void addQsTile(ComponentName tile) { } 336 337 /** 338 * Add a tile to the Quick Settings Panel 339 * @param tile the ComponentName of the {@link android.service.quicksettings.TileService} 340 * @param end if true, the tile will be added at the end. If false, at the beginning. 341 */ addQsTileToFrontOrEnd(ComponentName tile, boolean end)342 default void addQsTileToFrontOrEnd(ComponentName tile, boolean end) { } remQsTile(ComponentName tile)343 default void remQsTile(ComponentName tile) { } 344 setQsTiles(String[] tiles)345 default void setQsTiles(String[] tiles) {} clickTile(ComponentName tile)346 default void clickTile(ComponentName tile) { } 347 handleSystemKey(KeyEvent arg1)348 default void handleSystemKey(KeyEvent arg1) { } showPinningEnterExitToast(boolean entering)349 default void showPinningEnterExitToast(boolean entering) { } showPinningEscapeToast()350 default void showPinningEscapeToast() { } handleShowGlobalActionsMenu()351 default void handleShowGlobalActionsMenu() { } handleShowShutdownUi(boolean isReboot, String reason)352 default void handleShowShutdownUi(boolean isReboot, String reason) { } 353 showWirelessChargingAnimation(int batteryLevel)354 default void showWirelessChargingAnimation(int batteryLevel) { } 355 onRotationProposal(int rotation, boolean isValid)356 default void onRotationProposal(int rotation, boolean isValid) { } 357 showAuthenticationDialog(PromptInfo promptInfo, IBiometricSysuiReceiver receiver, int[] sensorIds, boolean credentialAllowed, boolean requireConfirmation, int userId, long operationId, String opPackageName, long requestId)358 default void showAuthenticationDialog(PromptInfo promptInfo, 359 IBiometricSysuiReceiver receiver, 360 int[] sensorIds, boolean credentialAllowed, 361 boolean requireConfirmation, int userId, long operationId, String opPackageName, 362 long requestId) { 363 } 364 365 /** @see IStatusBar#onBiometricAuthenticated(int) */ onBiometricAuthenticated(@odality int modality)366 default void onBiometricAuthenticated(@Modality int modality) { 367 } 368 369 /** @see IStatusBar#onBiometricHelp(int, String) */ onBiometricHelp(@odality int modality, String message)370 default void onBiometricHelp(@Modality int modality, String message) { 371 } 372 373 /** @see IStatusBar#onBiometricError(int, int, int) */ onBiometricError(@odality int modality, int error, int vendorCode)374 default void onBiometricError(@Modality int modality, int error, int vendorCode) { 375 } 376 hideAuthenticationDialog(long requestId)377 default void hideAuthenticationDialog(long requestId) { 378 } 379 380 /** 381 * @see IStatusBar#setBiometicContextListener(IBiometricContextListener) 382 */ setBiometricContextListener(IBiometricContextListener listener)383 default void setBiometricContextListener(IBiometricContextListener listener) { 384 } 385 386 /** 387 * @see IStatusBar#setUdfpsRefreshRateCallback(IUdfpsRefreshRateRequestCallback) 388 */ setUdfpsRefreshRateCallback(IUdfpsRefreshRateRequestCallback callback)389 default void setUdfpsRefreshRateCallback(IUdfpsRefreshRateRequestCallback callback) { 390 } 391 392 /** 393 * @see IStatusBar#onDisplayReady(int) 394 */ onDisplayReady(int displayId)395 default void onDisplayReady(int displayId) { 396 } 397 398 /** 399 * @see DisplayTracker.Callback#onDisplayRemoved(int) 400 */ onDisplayRemoved(int displayId)401 default void onDisplayRemoved(int displayId) { 402 } 403 404 /** 405 * @see IStatusBar#onRecentsAnimationStateChanged(boolean) 406 */ onRecentsAnimationStateChanged(boolean running)407 default void onRecentsAnimationStateChanged(boolean running) { } 408 409 /** 410 * @see IStatusBar#onSystemBarAttributesChanged 411 */ onSystemBarAttributesChanged(int displayId, @Appearance int appearance, AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme, @Behavior int behavior, @InsetsType int requestedVisibleTypes, String packageName, LetterboxDetails[] letterboxDetails)412 default void onSystemBarAttributesChanged(int displayId, @Appearance int appearance, 413 AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme, 414 @Behavior int behavior, @InsetsType int requestedVisibleTypes, 415 String packageName, LetterboxDetails[] letterboxDetails) { } 416 417 /** 418 * @see IStatusBar#showTransient(int, int, boolean). 419 */ showTransient(int displayId, @InsetsType int types, boolean isGestureOnSystemBar)420 default void showTransient(int displayId, @InsetsType int types, 421 boolean isGestureOnSystemBar) {} 422 423 /** 424 * @see IStatusBar#abortTransient(int, int). 425 */ abortTransient(int displayId, @InsetsType int types)426 default void abortTransient(int displayId, @InsetsType int types) { } 427 428 /** 429 * Called to notify System UI that a warning about the device going to sleep 430 * due to prolonged user inactivity should be shown. 431 */ showInattentiveSleepWarning()432 default void showInattentiveSleepWarning() { } 433 434 /** 435 * Called to notify System UI that the warning about the device going to sleep 436 * due to prolonged user inactivity should be dismissed. 437 */ dismissInattentiveSleepWarning(boolean animated)438 default void dismissInattentiveSleepWarning(boolean animated) { } 439 440 /** Called to suppress ambient display. */ suppressAmbientDisplay(boolean suppress)441 default void suppressAmbientDisplay(boolean suppress) { } 442 443 /** 444 * @see IStatusBar#showToast(int, String, IBinder, CharSequence, IBinder, int, 445 * ITransientNotificationCallback, int) 446 */ showToast(int uid, String packageName, IBinder token, CharSequence text, IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback, int displayId)447 default void showToast(int uid, String packageName, IBinder token, CharSequence text, 448 IBinder windowToken, int duration, 449 @Nullable ITransientNotificationCallback callback, int displayId) { } 450 451 /** 452 * @see IStatusBar#hideToast(String, IBinder) (String, IBinder) 453 */ hideToast(String packageName, IBinder token)454 default void hideToast(String packageName, IBinder token) { } 455 456 /** 457 * @param enabled 458 */ onTracingStateChanged(boolean enabled)459 default void onTracingStateChanged(boolean enabled) { } 460 461 /** 462 * Requests {@link com.android.systemui.accessibility.Magnification} to invoke 463 * {@code android.view.accessibility.AccessibilityManager# 464 * setMagnificationConnection(IMagnificationConnection)} 465 * 466 * @param connect {@code true} if needs connection, otherwise set the connection to null. 467 */ requestMagnificationConnection(boolean connect)468 default void requestMagnificationConnection(boolean connect) { } 469 470 /** 471 * @see IStatusBar#setNavigationBarLumaSamplingEnabled(int, boolean) 472 */ setNavigationBarLumaSamplingEnabled(int displayId, boolean enable)473 default void setNavigationBarLumaSamplingEnabled(int displayId, boolean enable) {} 474 475 /** 476 * @see IStatusBar#requestTileServiceListeningState 477 */ requestTileServiceListeningState(@onNull ComponentName componentName)478 default void requestTileServiceListeningState(@NonNull ComponentName componentName) {} 479 480 /** 481 * @see IStatusBar#requestAddTile 482 */ requestAddTile( int callingUid, @NonNull ComponentName componentName, @NonNull CharSequence appName, @NonNull CharSequence label, @NonNull Icon icon, @NonNull IAddTileResultCallback callback)483 default void requestAddTile( 484 int callingUid, 485 @NonNull ComponentName componentName, 486 @NonNull CharSequence appName, 487 @NonNull CharSequence label, 488 @NonNull Icon icon, 489 @NonNull IAddTileResultCallback callback) {} 490 491 /** 492 * @see IStatusBar#cancelRequestAddTile 493 */ cancelRequestAddTile(@onNull String packageName)494 default void cancelRequestAddTile(@NonNull String packageName) {} 495 496 /** @see IStatusBar#updateMediaTapToTransferSenderDisplay */ updateMediaTapToTransferSenderDisplay( @tatusBarManager.MediaTransferSenderState int displayState, @NonNull MediaRoute2Info routeInfo, @Nullable IUndoMediaTransferCallback undoCallback)497 default void updateMediaTapToTransferSenderDisplay( 498 @StatusBarManager.MediaTransferSenderState int displayState, 499 @NonNull MediaRoute2Info routeInfo, 500 @Nullable IUndoMediaTransferCallback undoCallback) {} 501 502 /** @see IStatusBar#updateMediaTapToTransferReceiverDisplay */ updateMediaTapToTransferReceiverDisplay( @tatusBarManager.MediaTransferReceiverState int displayState, @NonNull MediaRoute2Info routeInfo, @Nullable Icon appIcon, @Nullable CharSequence appName)503 default void updateMediaTapToTransferReceiverDisplay( 504 @StatusBarManager.MediaTransferReceiverState int displayState, 505 @NonNull MediaRoute2Info routeInfo, 506 @Nullable Icon appIcon, 507 @Nullable CharSequence appName) {} 508 509 /** 510 * @see IStatusBar#registerNearbyMediaDevicesProvider 511 */ registerNearbyMediaDevicesProvider( @onNull INearbyMediaDevicesProvider provider)512 default void registerNearbyMediaDevicesProvider( 513 @NonNull INearbyMediaDevicesProvider provider) {} 514 515 /** 516 * @see IStatusBar#unregisterNearbyMediaDevicesProvider 517 */ unregisterNearbyMediaDevicesProvider( @onNull INearbyMediaDevicesProvider provider)518 default void unregisterNearbyMediaDevicesProvider( 519 @NonNull INearbyMediaDevicesProvider provider) {} 520 521 /** 522 * @see IStatusBar#showRearDisplayDialog 523 */ showRearDisplayDialog(int currentBaseState)524 default void showRearDisplayDialog(int currentBaseState) {} 525 526 /** 527 * @see IStatusBar#moveFocusedTaskToFullscreen 528 */ moveFocusedTaskToFullscreen(int displayId)529 default void moveFocusedTaskToFullscreen(int displayId) {} 530 531 /** 532 * @see IStatusBar#moveFocusedTaskToStageSplit 533 */ moveFocusedTaskToStageSplit(int displayId, boolean leftOrTop)534 default void moveFocusedTaskToStageSplit(int displayId, boolean leftOrTop) {} 535 536 /** 537 * @see IStatusBar#setSplitscreenFocus 538 */ setSplitscreenFocus(boolean leftOrTop)539 default void setSplitscreenFocus(boolean leftOrTop) {} 540 541 /** 542 * @see IStatusBar#showMediaOutputSwitcher 543 */ showMediaOutputSwitcher(String packageName, UserHandle userHandle)544 default void showMediaOutputSwitcher(String packageName, UserHandle userHandle) {} 545 546 /** 547 * @see IStatusBar#confirmImmersivePrompt 548 */ confirmImmersivePrompt()549 default void confirmImmersivePrompt() {} 550 551 /** 552 * @see IStatusBar#immersiveModeChanged 553 */ immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode)554 default void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode) {} 555 556 /** 557 * @see IStatusBar#moveFocusedTaskToDesktop(int) 558 */ moveFocusedTaskToDesktop(int displayId)559 default void moveFocusedTaskToDesktop(int displayId) {} 560 } 561 562 @VisibleForTesting CommandQueue(Context context, DisplayTracker displayTracker)563 public CommandQueue(Context context, DisplayTracker displayTracker) { 564 this(context, displayTracker, null, null, null); 565 } 566 CommandQueue( Context context, DisplayTracker displayTracker, CommandRegistry registry, DumpHandler dumpHandler, Lazy<PowerInteractor> powerInteractor )567 public CommandQueue( 568 Context context, 569 DisplayTracker displayTracker, 570 CommandRegistry registry, 571 DumpHandler dumpHandler, 572 Lazy<PowerInteractor> powerInteractor 573 ) { 574 mDisplayTracker = displayTracker; 575 mRegistry = registry; 576 mDumpHandler = dumpHandler; 577 mDisplayTracker.addDisplayChangeCallback(new DisplayTracker.Callback() { 578 @Override 579 public void onDisplayRemoved(int displayId) { 580 synchronized (mLock) { 581 mDisplayDisabled.remove(displayId); 582 } 583 // This callback is registered with {@link #mHandler} that already posts to run on 584 // main thread, so it is safe to dispatch directly. 585 for (int i = mCallbacks.size() - 1; i >= 0; i--) { 586 mCallbacks.get(i).onDisplayRemoved(displayId); 587 } 588 } 589 }, new HandlerExecutor(mHandler)); 590 // We always have default display. 591 setDisabled(mDisplayTracker.getDefaultDisplayId(), DISABLE_NONE, DISABLE2_NONE); 592 mPowerInteractor = powerInteractor; 593 } 594 595 // TODO(b/118592525): add multi-display support if needed. panelsEnabled()596 public boolean panelsEnabled() { 597 final int disabled1 = getDisabled1(mDisplayTracker.getDefaultDisplayId()); 598 final int disabled2 = getDisabled2(mDisplayTracker.getDefaultDisplayId()); 599 return (disabled1 & StatusBarManager.DISABLE_EXPAND) == 0 600 && (disabled2 & StatusBarManager.DISABLE2_NOTIFICATION_SHADE) == 0; 601 } 602 603 @Override addCallback(@onNull Callbacks callbacks)604 public void addCallback(@NonNull Callbacks callbacks) { 605 mCallbacks.add(callbacks); 606 // TODO(b/117478341): find a better way to pass disable flags by display. 607 for (int i = 0; i < mDisplayDisabled.size(); i++) { 608 int displayId = mDisplayDisabled.keyAt(i); 609 int disabled1 = getDisabled1(displayId); 610 int disabled2 = getDisabled2(displayId); 611 callbacks.disable(displayId, disabled1, disabled2, false /* animate */); 612 } 613 } 614 615 @Override removeCallback(@onNull Callbacks callbacks)616 public void removeCallback(@NonNull Callbacks callbacks) { 617 mCallbacks.remove(callbacks); 618 } 619 setIcon(String slot, StatusBarIcon icon)620 public void setIcon(String slot, StatusBarIcon icon) { 621 synchronized (mLock) { 622 // don't coalesce these 623 mHandler.obtainMessage(MSG_ICON, OP_SET_ICON, 0, 624 new Pair<String, StatusBarIcon>(slot, icon)).sendToTarget(); 625 } 626 } 627 removeIcon(String slot)628 public void removeIcon(String slot) { 629 synchronized (mLock) { 630 // don't coalesce these 631 mHandler.obtainMessage(MSG_ICON, OP_REMOVE_ICON, 0, slot).sendToTarget(); 632 } 633 } 634 635 /** 636 * Called to notify that disable flags are updated. 637 * @see Callbacks#disable(int, int, int, boolean). 638 */ disable(int displayId, @DisableFlags int state1, @Disable2Flags int state2, boolean animate)639 public void disable(int displayId, @DisableFlags int state1, @Disable2Flags int state2, 640 boolean animate) { 641 synchronized (mLock) { 642 setDisabled(displayId, state1, state2); 643 mHandler.removeMessages(MSG_DISABLE); 644 final SomeArgs args = SomeArgs.obtain(); 645 args.argi1 = displayId; 646 args.argi2 = state1; 647 args.argi3 = state2; 648 args.argi4 = animate ? 1 : 0; 649 Message msg = mHandler.obtainMessage(MSG_DISABLE, args); 650 if (Looper.myLooper() == mHandler.getLooper()) { 651 // If its the right looper execute immediately so hides can be handled quickly. 652 mHandler.handleMessage(msg); 653 msg.recycle(); 654 } else { 655 msg.sendToTarget(); 656 } 657 } 658 } 659 660 @Override disable(int displayId, @DisableFlags int state1, @Disable2Flags int state2)661 public void disable(int displayId, @DisableFlags int state1, @Disable2Flags int state2) { 662 disable(displayId, state1, state2, true); 663 } 664 665 /** 666 * Apply current disable flags by {@link CommandQueue#disable(int, int, int, boolean)}. 667 * 668 * @param displayId The id of the display to notify. 669 * @param animate {@code true} to show animations. 670 */ recomputeDisableFlags(int displayId, boolean animate)671 public void recomputeDisableFlags(int displayId, boolean animate) { 672 // This must update holding the lock otherwise it can clobber the disabled flags set on the 673 // binder thread from the disable() call 674 synchronized (mLock) { 675 int disabled1 = getDisabled1(displayId); 676 int disabled2 = getDisabled2(displayId); 677 disable(displayId, disabled1, disabled2, animate); 678 } 679 } 680 setDisabled(int displayId, int disabled1, int disabled2)681 private void setDisabled(int displayId, int disabled1, int disabled2) { 682 mDisplayDisabled.put(displayId, new Pair<>(disabled1, disabled2)); 683 } 684 getDisabled1(int displayId)685 private int getDisabled1(int displayId) { 686 return getDisabled(displayId).first; 687 } 688 getDisabled2(int displayId)689 private int getDisabled2(int displayId) { 690 return getDisabled(displayId).second; 691 } 692 getDisabled(int displayId)693 private Pair<Integer, Integer> getDisabled(int displayId) { 694 Pair<Integer, Integer> disablePair = mDisplayDisabled.get(displayId); 695 if (disablePair == null) { 696 disablePair = new Pair<>(DISABLE_NONE, DISABLE2_NONE); 697 mDisplayDisabled.put(displayId, disablePair); 698 } 699 return disablePair; 700 } 701 animateExpandNotificationsPanel()702 public void animateExpandNotificationsPanel() { 703 synchronized (mLock) { 704 mHandler.removeMessages(MSG_EXPAND_NOTIFICATIONS); 705 mHandler.sendEmptyMessage(MSG_EXPAND_NOTIFICATIONS); 706 } 707 } 708 animateCollapsePanels()709 public void animateCollapsePanels() { 710 synchronized (mLock) { 711 mHandler.removeMessages(MSG_COLLAPSE_PANELS); 712 mHandler.obtainMessage(MSG_COLLAPSE_PANELS, 0, 0).sendToTarget(); 713 } 714 } 715 animateCollapsePanels(int flags, boolean force)716 public void animateCollapsePanels(int flags, boolean force) { 717 synchronized (mLock) { 718 mHandler.removeMessages(MSG_COLLAPSE_PANELS); 719 mHandler.obtainMessage(MSG_COLLAPSE_PANELS, flags, force ? 1 : 0).sendToTarget(); 720 } 721 } 722 toggleNotificationsPanel()723 public void toggleNotificationsPanel() { 724 synchronized (mLock) { 725 mHandler.removeMessages(MSG_TOGGLE_NOTIFICATION_PANEL); 726 mHandler.obtainMessage(MSG_TOGGLE_NOTIFICATION_PANEL, 0, 0).sendToTarget(); 727 } 728 } 729 animateExpandSettingsPanel(String subPanel)730 public void animateExpandSettingsPanel(String subPanel) { 731 synchronized (mLock) { 732 mHandler.removeMessages(MSG_EXPAND_SETTINGS); 733 mHandler.obtainMessage(MSG_EXPAND_SETTINGS, subPanel).sendToTarget(); 734 } 735 } 736 toggleQuickSettingsPanel()737 public void toggleQuickSettingsPanel() { 738 synchronized (mLock) { 739 mHandler.removeMessages(MSG_TOGGLE_QUICK_SETTINGS_PANEL); 740 mHandler.obtainMessage(MSG_TOGGLE_QUICK_SETTINGS_PANEL, 0, 0).sendToTarget(); 741 } 742 } 743 744 @Override setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition, boolean showImeSwitcher)745 public void setImeWindowStatus(int displayId, IBinder token, int vis, int backDisposition, 746 boolean showImeSwitcher) { 747 synchronized (mLock) { 748 mHandler.removeMessages(MSG_SHOW_IME_BUTTON); 749 SomeArgs args = SomeArgs.obtain(); 750 args.argi1 = displayId; 751 args.argi2 = vis; 752 args.argi3 = backDisposition; 753 args.argi4 = showImeSwitcher ? 1 : 0; 754 args.arg1 = token; 755 Message m = mHandler.obtainMessage(MSG_SHOW_IME_BUTTON, args); 756 m.sendToTarget(); 757 } 758 } 759 showRecentApps(boolean triggeredFromAltTab)760 public void showRecentApps(boolean triggeredFromAltTab) { 761 synchronized (mLock) { 762 mHandler.removeMessages(MSG_SHOW_RECENT_APPS); 763 mHandler.obtainMessage(MSG_SHOW_RECENT_APPS, triggeredFromAltTab ? 1 : 0, 0, 764 null).sendToTarget(); 765 } 766 } 767 hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey)768 public void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) { 769 synchronized (mLock) { 770 mHandler.removeMessages(MSG_HIDE_RECENT_APPS); 771 mHandler.obtainMessage(MSG_HIDE_RECENT_APPS, 772 triggeredFromAltTab ? 1 : 0, triggeredFromHomeKey ? 1 : 0, 773 null).sendToTarget(); 774 } 775 } 776 toggleSplitScreen()777 public void toggleSplitScreen() { 778 synchronized (mLock) { 779 mHandler.removeMessages(MSG_TOGGLE_APP_SPLIT_SCREEN); 780 mHandler.obtainMessage(MSG_TOGGLE_APP_SPLIT_SCREEN, 0, 0, null).sendToTarget(); 781 } 782 } 783 toggleTaskbar()784 public void toggleTaskbar() { 785 synchronized (mLock) { 786 mHandler.removeMessages(MSG_TOGGLE_TASKBAR); 787 mHandler.obtainMessage(MSG_TOGGLE_TASKBAR, 0, 0, null).sendToTarget(); 788 } 789 } 790 toggleRecentApps()791 public void toggleRecentApps() { 792 synchronized (mLock) { 793 mHandler.removeMessages(MSG_TOGGLE_RECENT_APPS); 794 Message msg = mHandler.obtainMessage(MSG_TOGGLE_RECENT_APPS, 0, 0, null); 795 msg.setAsynchronous(true); 796 msg.sendToTarget(); 797 } 798 } 799 preloadRecentApps()800 public void preloadRecentApps() { 801 synchronized (mLock) { 802 mHandler.removeMessages(MSG_PRELOAD_RECENT_APPS); 803 mHandler.obtainMessage(MSG_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget(); 804 } 805 } 806 cancelPreloadRecentApps()807 public void cancelPreloadRecentApps() { 808 synchronized (mLock) { 809 mHandler.removeMessages(MSG_CANCEL_PRELOAD_RECENT_APPS); 810 mHandler.obtainMessage(MSG_CANCEL_PRELOAD_RECENT_APPS, 0, 0, null).sendToTarget(); 811 } 812 } 813 814 @Override dismissKeyboardShortcutsMenu()815 public void dismissKeyboardShortcutsMenu() { 816 synchronized (mLock) { 817 mHandler.removeMessages(MSG_DISMISS_KEYBOARD_SHORTCUTS); 818 mHandler.obtainMessage(MSG_DISMISS_KEYBOARD_SHORTCUTS).sendToTarget(); 819 } 820 } 821 822 @Override toggleKeyboardShortcutsMenu(int deviceId)823 public void toggleKeyboardShortcutsMenu(int deviceId) { 824 synchronized (mLock) { 825 mHandler.removeMessages(MSG_TOGGLE_KEYBOARD_SHORTCUTS); 826 mHandler.obtainMessage(MSG_TOGGLE_KEYBOARD_SHORTCUTS, deviceId, 0).sendToTarget(); 827 } 828 } 829 830 @Override showPictureInPictureMenu()831 public void showPictureInPictureMenu() { 832 synchronized (mLock) { 833 mHandler.removeMessages(MSG_SHOW_PICTURE_IN_PICTURE_MENU); 834 mHandler.obtainMessage(MSG_SHOW_PICTURE_IN_PICTURE_MENU).sendToTarget(); 835 } 836 } 837 838 @Override setWindowState(int displayId, int window, int state)839 public void setWindowState(int displayId, int window, int state) { 840 synchronized (mLock) { 841 // don't coalesce these 842 mHandler.obtainMessage(MSG_SET_WINDOW_STATE, displayId, window, state).sendToTarget(); 843 } 844 } 845 showScreenPinningRequest(int taskId)846 public void showScreenPinningRequest(int taskId) { 847 synchronized (mLock) { 848 mHandler.obtainMessage(MSG_SHOW_SCREEN_PIN_REQUEST, taskId, 0, null) 849 .sendToTarget(); 850 } 851 } 852 853 @Override confirmImmersivePrompt()854 public void confirmImmersivePrompt() { 855 synchronized (mLock) { 856 mHandler.obtainMessage(MSG_CONFIRM_IMMERSIVE_PROMPT).sendToTarget(); 857 } 858 } 859 860 @Override immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode)861 public void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode) { 862 synchronized (mLock) { 863 final SomeArgs args = SomeArgs.obtain(); 864 args.argi1 = rootDisplayAreaId; 865 args.argi2 = isImmersiveMode ? 1 : 0; 866 mHandler.obtainMessage(MSG_IMMERSIVE_CHANGED, args).sendToTarget(); 867 } 868 } 869 870 @Override appTransitionPending(int displayId)871 public void appTransitionPending(int displayId) { 872 appTransitionPending(displayId, false /* forced */); 873 } 874 875 /** 876 * Called to notify System UI that an application transition is pending. 877 * @see Callbacks#appTransitionPending(int, boolean) 878 */ appTransitionPending(int displayId, boolean forced)879 public void appTransitionPending(int displayId, boolean forced) { 880 synchronized (mLock) { 881 mHandler.obtainMessage(MSG_APP_TRANSITION_PENDING, displayId, forced ? 1 : 0) 882 .sendToTarget(); 883 } 884 } 885 886 @Override appTransitionCancelled(int displayId)887 public void appTransitionCancelled(int displayId) { 888 synchronized (mLock) { 889 mHandler.obtainMessage(MSG_APP_TRANSITION_CANCELLED, displayId, 0 /* unused */) 890 .sendToTarget(); 891 } 892 } 893 894 @Override appTransitionStarting(int displayId, long startTime, long duration)895 public void appTransitionStarting(int displayId, long startTime, long duration) { 896 appTransitionStarting(displayId, startTime, duration, false /* forced */); 897 } 898 899 /** 900 * Called to notify System UI that an application transition is starting. 901 * @see Callbacks#appTransitionStarting(int, long, long, boolean). 902 */ appTransitionStarting(int displayId, long startTime, long duration, boolean forced)903 public void appTransitionStarting(int displayId, long startTime, long duration, 904 boolean forced) { 905 synchronized (mLock) { 906 final SomeArgs args = SomeArgs.obtain(); 907 args.argi1 = displayId; 908 args.argi2 = forced ? 1 : 0; 909 args.arg1 = startTime; 910 args.arg2 = duration; 911 mHandler.obtainMessage(MSG_APP_TRANSITION_STARTING, args).sendToTarget(); 912 } 913 } 914 915 @Override appTransitionFinished(int displayId)916 public void appTransitionFinished(int displayId) { 917 synchronized (mLock) { 918 mHandler.obtainMessage(MSG_APP_TRANSITION_FINISHED, displayId, 0 /* unused */) 919 .sendToTarget(); 920 } 921 } 922 showAssistDisclosure()923 public void showAssistDisclosure() { 924 synchronized (mLock) { 925 mHandler.removeMessages(MSG_ASSIST_DISCLOSURE); 926 mHandler.obtainMessage(MSG_ASSIST_DISCLOSURE).sendToTarget(); 927 } 928 } 929 startAssist(Bundle args)930 public void startAssist(Bundle args) { 931 synchronized (mLock) { 932 mHandler.removeMessages(MSG_START_ASSIST); 933 mHandler.obtainMessage(MSG_START_ASSIST, args).sendToTarget(); 934 } 935 } 936 937 @Override onCameraLaunchGestureDetected(int source)938 public void onCameraLaunchGestureDetected(int source) { 939 synchronized (mLock) { 940 if (mPowerInteractor != null) { 941 mPowerInteractor.get().onCameraLaunchGestureDetected(); 942 } 943 944 mHandler.removeMessages(MSG_CAMERA_LAUNCH_GESTURE); 945 mHandler.obtainMessage(MSG_CAMERA_LAUNCH_GESTURE, source, 0).sendToTarget(); 946 } 947 } 948 949 @Override onEmergencyActionLaunchGestureDetected()950 public void onEmergencyActionLaunchGestureDetected() { 951 synchronized (mLock) { 952 mHandler.removeMessages(MSG_EMERGENCY_ACTION_LAUNCH_GESTURE); 953 mHandler.obtainMessage(MSG_EMERGENCY_ACTION_LAUNCH_GESTURE).sendToTarget(); 954 } 955 } 956 957 @Override addQsTile(ComponentName tile)958 public void addQsTile(ComponentName tile) { 959 if (Flags.a11yQsShortcut()) { 960 addQsTileToFrontOrEnd(tile, false); 961 } else { 962 synchronized (mLock) { 963 mHandler.obtainMessage(MSG_ADD_QS_TILE, tile).sendToTarget(); 964 } 965 } 966 } 967 968 /** 969 * Add a tile to the Quick Settings Panel 970 * @param tile the ComponentName of the {@link android.service.quicksettings.TileService} 971 * @param end if true, the tile will be added at the end. If false, at the beginning. 972 */ 973 @Override addQsTileToFrontOrEnd(ComponentName tile, boolean end)974 public void addQsTileToFrontOrEnd(ComponentName tile, boolean end) { 975 if (Flags.a11yQsShortcut()) { 976 synchronized (mLock) { 977 SomeArgs args = SomeArgs.obtain(); 978 args.arg1 = tile; 979 args.arg2 = end; 980 mHandler.obtainMessage(MSG_ADD_QS_TILE, args).sendToTarget(); 981 } 982 } 983 } 984 985 @Override remQsTile(ComponentName tile)986 public void remQsTile(ComponentName tile) { 987 synchronized (mLock) { 988 mHandler.obtainMessage(MSG_REMOVE_QS_TILE, tile).sendToTarget(); 989 } 990 } 991 992 @Override setQsTiles(String[] tiles)993 public void setQsTiles(String[] tiles) { 994 synchronized (mLock) { 995 mHandler.obtainMessage(MSG_SET_QS_TILES, tiles).sendToTarget(); 996 } 997 } 998 999 @Override clickQsTile(ComponentName tile)1000 public void clickQsTile(ComponentName tile) { 1001 synchronized (mLock) { 1002 mHandler.obtainMessage(MSG_CLICK_QS_TILE, tile).sendToTarget(); 1003 } 1004 } 1005 1006 @Override handleSystemKey(KeyEvent key)1007 public void handleSystemKey(KeyEvent key) { 1008 synchronized (mLock) { 1009 mHandler.obtainMessage(MSG_HANDLE_SYSTEM_KEY, key).sendToTarget(); 1010 } 1011 } 1012 1013 @Override showPinningEnterExitToast(boolean entering)1014 public void showPinningEnterExitToast(boolean entering) { 1015 synchronized (mLock) { 1016 mHandler.obtainMessage(MSG_SHOW_PINNING_TOAST_ENTER_EXIT, entering).sendToTarget(); 1017 } 1018 } 1019 1020 @Override showPinningEscapeToast()1021 public void showPinningEscapeToast() { 1022 synchronized (mLock) { 1023 mHandler.obtainMessage(MSG_SHOW_PINNING_TOAST_ESCAPE).sendToTarget(); 1024 } 1025 } 1026 1027 1028 @Override showGlobalActionsMenu()1029 public void showGlobalActionsMenu() { 1030 synchronized (mLock) { 1031 mHandler.removeMessages(MSG_SHOW_GLOBAL_ACTIONS); 1032 mHandler.obtainMessage(MSG_SHOW_GLOBAL_ACTIONS).sendToTarget(); 1033 } 1034 } 1035 1036 @Override setTopAppHidesStatusBar(boolean hidesStatusBar)1037 public void setTopAppHidesStatusBar(boolean hidesStatusBar) { 1038 mHandler.removeMessages(MSG_SET_TOP_APP_HIDES_STATUS_BAR); 1039 mHandler.obtainMessage(MSG_SET_TOP_APP_HIDES_STATUS_BAR, hidesStatusBar ? 1 : 0, 0) 1040 .sendToTarget(); 1041 } 1042 1043 @Override showShutdownUi(boolean isReboot, String reason)1044 public void showShutdownUi(boolean isReboot, String reason) { 1045 synchronized (mLock) { 1046 mHandler.removeMessages(MSG_SHOW_SHUTDOWN_UI); 1047 mHandler.obtainMessage(MSG_SHOW_SHUTDOWN_UI, isReboot ? 1 : 0, 0, reason) 1048 .sendToTarget(); 1049 } 1050 } 1051 1052 @Override showWirelessChargingAnimation(int batteryLevel)1053 public void showWirelessChargingAnimation(int batteryLevel) { 1054 mHandler.removeMessages(MSG_SHOW_CHARGING_ANIMATION); 1055 mHandler.obtainMessage(MSG_SHOW_CHARGING_ANIMATION, batteryLevel, 0) 1056 .sendToTarget(); 1057 } 1058 1059 @Override onProposedRotationChanged(int rotation, boolean isValid)1060 public void onProposedRotationChanged(int rotation, boolean isValid) { 1061 synchronized (mLock) { 1062 mHandler.removeMessages(MSG_ROTATION_PROPOSAL); 1063 mHandler.obtainMessage(MSG_ROTATION_PROPOSAL, rotation, isValid ? 1 : 0, 1064 null).sendToTarget(); 1065 } 1066 } 1067 1068 @Override showAuthenticationDialog(PromptInfo promptInfo, IBiometricSysuiReceiver receiver, int[] sensorIds, boolean credentialAllowed, boolean requireConfirmation, int userId, long operationId, String opPackageName, long requestId)1069 public void showAuthenticationDialog(PromptInfo promptInfo, IBiometricSysuiReceiver receiver, 1070 int[] sensorIds, boolean credentialAllowed, boolean requireConfirmation, 1071 int userId, long operationId, String opPackageName, long requestId) { 1072 synchronized (mLock) { 1073 SomeArgs args = SomeArgs.obtain(); 1074 args.arg1 = promptInfo; 1075 args.arg2 = receiver; 1076 args.arg3 = sensorIds; 1077 args.arg4 = credentialAllowed; 1078 args.arg5 = requireConfirmation; 1079 args.argi1 = userId; 1080 args.arg6 = opPackageName; 1081 args.argl1 = operationId; 1082 args.argl2 = requestId; 1083 mHandler.obtainMessage(MSG_BIOMETRIC_SHOW, args) 1084 .sendToTarget(); 1085 } 1086 } 1087 1088 @Override showToast(int uid, String packageName, IBinder token, CharSequence text, IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback, int displayId)1089 public void showToast(int uid, String packageName, IBinder token, CharSequence text, 1090 IBinder windowToken, int duration, @Nullable ITransientNotificationCallback callback, 1091 int displayId) { 1092 synchronized (mLock) { 1093 SomeArgs args = SomeArgs.obtain(); 1094 args.arg1 = packageName; 1095 args.arg2 = token; 1096 args.arg3 = text; 1097 args.arg4 = windowToken; 1098 args.arg5 = callback; 1099 args.argi1 = uid; 1100 args.argi2 = duration; 1101 args.argi3 = displayId; 1102 mHandler.obtainMessage(MSG_SHOW_TOAST, args).sendToTarget(); 1103 } 1104 } 1105 1106 @Override hideToast(String packageName, IBinder token)1107 public void hideToast(String packageName, IBinder token) { 1108 synchronized (mLock) { 1109 SomeArgs args = SomeArgs.obtain(); 1110 args.arg1 = packageName; 1111 args.arg2 = token; 1112 mHandler.obtainMessage(MSG_HIDE_TOAST, args).sendToTarget(); 1113 } 1114 } 1115 1116 @Override onBiometricAuthenticated(@odality int modality)1117 public void onBiometricAuthenticated(@Modality int modality) { 1118 synchronized (mLock) { 1119 SomeArgs args = SomeArgs.obtain(); 1120 args.argi1 = modality; 1121 mHandler.obtainMessage(MSG_BIOMETRIC_AUTHENTICATED, args).sendToTarget(); 1122 } 1123 } 1124 1125 @Override onBiometricHelp(@odality int modality, String message)1126 public void onBiometricHelp(@Modality int modality, String message) { 1127 synchronized (mLock) { 1128 SomeArgs args = SomeArgs.obtain(); 1129 args.argi1 = modality; 1130 args.arg1 = message; 1131 mHandler.obtainMessage(MSG_BIOMETRIC_HELP, args).sendToTarget(); 1132 } 1133 } 1134 1135 @Override onBiometricError(int modality, int error, int vendorCode)1136 public void onBiometricError(int modality, int error, int vendorCode) { 1137 synchronized (mLock) { 1138 SomeArgs args = SomeArgs.obtain(); 1139 args.argi1 = modality; 1140 args.argi2 = error; 1141 args.argi3 = vendorCode; 1142 mHandler.obtainMessage(MSG_BIOMETRIC_ERROR, args).sendToTarget(); 1143 } 1144 } 1145 1146 @Override hideAuthenticationDialog(long requestId)1147 public void hideAuthenticationDialog(long requestId) { 1148 synchronized (mLock) { 1149 final SomeArgs args = SomeArgs.obtain(); 1150 args.argl1 = requestId; 1151 mHandler.obtainMessage(MSG_BIOMETRIC_HIDE, args).sendToTarget(); 1152 } 1153 } 1154 1155 @Override setBiometicContextListener(IBiometricContextListener listener)1156 public void setBiometicContextListener(IBiometricContextListener listener) { 1157 synchronized (mLock) { 1158 mHandler.obtainMessage(MSG_SET_BIOMETRICS_LISTENER, listener).sendToTarget(); 1159 } 1160 } 1161 1162 @Override setUdfpsRefreshRateCallback(IUdfpsRefreshRateRequestCallback callback)1163 public void setUdfpsRefreshRateCallback(IUdfpsRefreshRateRequestCallback callback) { 1164 synchronized (mLock) { 1165 mHandler.obtainMessage(MSG_SET_UDFPS_REFRESH_RATE_CALLBACK, callback).sendToTarget(); 1166 } 1167 } 1168 1169 @Override onDisplayReady(int displayId)1170 public void onDisplayReady(int displayId) { 1171 synchronized (mLock) { 1172 mHandler.obtainMessage(MSG_DISPLAY_READY, displayId, 0).sendToTarget(); 1173 } 1174 } 1175 1176 @Override onRecentsAnimationStateChanged(boolean running)1177 public void onRecentsAnimationStateChanged(boolean running) { 1178 synchronized (mLock) { 1179 mHandler.obtainMessage(MSG_RECENTS_ANIMATION_STATE_CHANGED, running ? 1 : 0, 0) 1180 .sendToTarget(); 1181 } 1182 } 1183 1184 @Override showInattentiveSleepWarning()1185 public void showInattentiveSleepWarning() { 1186 synchronized (mLock) { 1187 mHandler.obtainMessage(MSG_SHOW_INATTENTIVE_SLEEP_WARNING) 1188 .sendToTarget(); 1189 } 1190 } 1191 1192 @Override dismissInattentiveSleepWarning(boolean animated)1193 public void dismissInattentiveSleepWarning(boolean animated) { 1194 synchronized (mLock) { 1195 mHandler.obtainMessage(MSG_DISMISS_INATTENTIVE_SLEEP_WARNING, animated) 1196 .sendToTarget(); 1197 } 1198 } 1199 1200 @Override requestMagnificationConnection(boolean connect)1201 public void requestMagnificationConnection(boolean connect) { 1202 synchronized (mLock) { 1203 mHandler.obtainMessage(MSG_REQUEST_MAGNIFICATION_CONNECTION, connect) 1204 .sendToTarget(); 1205 } 1206 } 1207 handleShowImeButton(int displayId, IBinder token, int vis, int backDisposition, boolean showImeSwitcher)1208 private void handleShowImeButton(int displayId, IBinder token, int vis, int backDisposition, 1209 boolean showImeSwitcher) { 1210 if (displayId == INVALID_DISPLAY) return; 1211 1212 if (mLastUpdatedImeDisplayId != displayId 1213 && mLastUpdatedImeDisplayId != INVALID_DISPLAY) { 1214 // Set previous NavBar's IME window status as invisible when IME 1215 // window switched to another display for single-session IME case. 1216 sendImeInvisibleStatusForPrevNavBar(); 1217 } 1218 for (int i = 0; i < mCallbacks.size(); i++) { 1219 mCallbacks.get(i).setImeWindowStatus(displayId, token, vis, backDisposition, 1220 showImeSwitcher); 1221 } 1222 mLastUpdatedImeDisplayId = displayId; 1223 } 1224 sendImeInvisibleStatusForPrevNavBar()1225 private void sendImeInvisibleStatusForPrevNavBar() { 1226 for (int i = 0; i < mCallbacks.size(); i++) { 1227 mCallbacks.get(i).setImeWindowStatus(mLastUpdatedImeDisplayId, 1228 null /* token */, IME_INVISIBLE, BACK_DISPOSITION_DEFAULT, 1229 false /* showImeSwitcher */); 1230 } 1231 } 1232 1233 @Override onSystemBarAttributesChanged(int displayId, @Appearance int appearance, AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme, @Behavior int behavior, @InsetsType int requestedVisibleTypes, String packageName, LetterboxDetails[] letterboxDetails)1234 public void onSystemBarAttributesChanged(int displayId, @Appearance int appearance, 1235 AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme, 1236 @Behavior int behavior, @InsetsType int requestedVisibleTypes, String packageName, 1237 LetterboxDetails[] letterboxDetails) { 1238 synchronized (mLock) { 1239 SomeArgs args = SomeArgs.obtain(); 1240 args.argi1 = displayId; 1241 args.argi2 = appearance; 1242 args.argi3 = navbarColorManagedByIme ? 1 : 0; 1243 args.arg1 = appearanceRegions; 1244 args.argi4 = behavior; 1245 args.argi5 = requestedVisibleTypes; 1246 args.arg3 = packageName; 1247 args.arg4 = letterboxDetails; 1248 mHandler.obtainMessage(MSG_SYSTEM_BAR_CHANGED, args).sendToTarget(); 1249 } 1250 } 1251 1252 @Override showTransient(int displayId, int types, boolean isGestureOnSystemBar)1253 public void showTransient(int displayId, int types, boolean isGestureOnSystemBar) { 1254 synchronized (mLock) { 1255 SomeArgs args = SomeArgs.obtain(); 1256 args.argi1 = displayId; 1257 args.argi2 = types; 1258 args.argi3 = isGestureOnSystemBar ? 1 : 0; 1259 mHandler.obtainMessage(MSG_SHOW_TRANSIENT, args).sendToTarget(); 1260 } 1261 } 1262 1263 @Override abortTransient(int displayId, int types)1264 public void abortTransient(int displayId, int types) { 1265 synchronized (mLock) { 1266 SomeArgs args = SomeArgs.obtain(); 1267 args.argi1 = displayId; 1268 args.argi2 = types; 1269 mHandler.obtainMessage(MSG_ABORT_TRANSIENT, args).sendToTarget(); 1270 } 1271 } 1272 1273 @Override startTracing()1274 public void startTracing() { 1275 synchronized (mLock) { 1276 mHandler.obtainMessage(MSG_TRACING_STATE_CHANGED, true).sendToTarget(); 1277 } 1278 } 1279 1280 @Override stopTracing()1281 public void stopTracing() { 1282 synchronized (mLock) { 1283 mHandler.obtainMessage(MSG_TRACING_STATE_CHANGED, false).sendToTarget(); 1284 } 1285 } 1286 1287 @Override suppressAmbientDisplay(boolean suppress)1288 public void suppressAmbientDisplay(boolean suppress) { 1289 synchronized (mLock) { 1290 mHandler.obtainMessage(MSG_SUPPRESS_AMBIENT_DISPLAY, suppress).sendToTarget(); 1291 } 1292 } 1293 1294 @Override setNavigationBarLumaSamplingEnabled(int displayId, boolean enable)1295 public void setNavigationBarLumaSamplingEnabled(int displayId, boolean enable) { 1296 synchronized (mLock) { 1297 mHandler.obtainMessage(MSG_SET_NAVIGATION_BAR_LUMA_SAMPLING_ENABLED, displayId, 1298 enable ? 1 : 0).sendToTarget(); 1299 } 1300 } 1301 1302 @Override passThroughShellCommand(String[] args, ParcelFileDescriptor pfd)1303 public void passThroughShellCommand(String[] args, ParcelFileDescriptor pfd) { 1304 final FileOutputStream fos = new FileOutputStream(pfd.getFileDescriptor()); 1305 final PrintWriter pw = new PrintWriter(fos); 1306 // This is mimicking Binder#dumpAsync, but on this side of the binder. Might be possible 1307 // to just throw this work onto the handler just like the other messages 1308 Thread thr = new Thread("Sysui.passThroughShellCommand") { 1309 public void run() { 1310 try { 1311 if (mRegistry == null) { 1312 return; 1313 } 1314 1315 // Registry blocks this thread until finished 1316 mRegistry.onShellCommand(pw, args); 1317 } finally { 1318 pw.flush(); 1319 try { 1320 // Close the file descriptor so the TransferPipe finishes its thread 1321 pfd.close(); 1322 } catch (Exception e) { 1323 } 1324 } 1325 } 1326 }; 1327 thr.start(); 1328 } 1329 1330 @Override dumpProto(String[] args, ParcelFileDescriptor pfd)1331 public void dumpProto(String[] args, ParcelFileDescriptor pfd) { 1332 final FileDescriptor fd = pfd.getFileDescriptor(); 1333 // This is mimicking Binder#dumpAsync, but on this side of the binder. Might be possible 1334 // to just throw this work onto the handler just like the other messages 1335 Thread thr = new Thread("Sysui.dumpProto") { 1336 public void run() { 1337 try { 1338 if (mDumpHandler == null) { 1339 return; 1340 } 1341 // We won't be using the PrintWriter. 1342 OutputStream o = new OutputStream() { 1343 @Override 1344 public void write(int b) {} 1345 }; 1346 mDumpHandler.dump(fd, new PrintWriter(o), args); 1347 } finally { 1348 try { 1349 // Close the file descriptor so the TransferPipe finishes its thread 1350 pfd.close(); 1351 } catch (Exception e) { 1352 } 1353 } 1354 } 1355 }; 1356 thr.start(); 1357 } 1358 1359 @Override runGcForTest()1360 public void runGcForTest() { 1361 // Gc sysui 1362 GcUtils.runGcAndFinalizersSync(); 1363 } 1364 1365 @Override requestTileServiceListeningState(@onNull ComponentName componentName)1366 public void requestTileServiceListeningState(@NonNull ComponentName componentName) { 1367 mHandler.obtainMessage(MSG_TILE_SERVICE_REQUEST_LISTENING_STATE, componentName) 1368 .sendToTarget(); 1369 } 1370 1371 @Override showRearDisplayDialog(int currentBaseState)1372 public void showRearDisplayDialog(int currentBaseState) { 1373 synchronized (mLock) { 1374 mHandler.obtainMessage(MSG_SHOW_REAR_DISPLAY_DIALOG, currentBaseState).sendToTarget(); 1375 } 1376 } 1377 1378 @Override moveFocusedTaskToStageSplit(int displayId, boolean leftOrTop)1379 public void moveFocusedTaskToStageSplit(int displayId, boolean leftOrTop) { 1380 synchronized (mLock) { 1381 SomeArgs args = SomeArgs.obtain(); 1382 args.argi1 = displayId; 1383 args.argi2 = leftOrTop ? 1 : 0; 1384 mHandler.obtainMessage(MSG_MOVE_FOCUSED_TASK_TO_STAGE_SPLIT, 1385 args).sendToTarget(); 1386 } 1387 } 1388 1389 @Override setSplitscreenFocus(boolean leftOrTop)1390 public void setSplitscreenFocus(boolean leftOrTop) { 1391 synchronized (mLock) { 1392 mHandler.obtainMessage(MSG_SET_SPLITSCREEN_FOCUS, leftOrTop).sendToTarget(); 1393 } 1394 } 1395 @Override showMediaOutputSwitcher(String packageName, UserHandle userHandle)1396 public void showMediaOutputSwitcher(String packageName, UserHandle userHandle) { 1397 int callingUid = Binder.getCallingUid(); 1398 if (callingUid != 0 && callingUid != Process.SYSTEM_UID) { 1399 throw new SecurityException("Call only allowed from system server."); 1400 } 1401 synchronized (mLock) { 1402 SomeArgs args = SomeArgs.obtain(); 1403 args.arg1 = packageName; 1404 args.arg2 = userHandle; 1405 mHandler.obtainMessage(MSG_SHOW_MEDIA_OUTPUT_SWITCHER, args).sendToTarget(); 1406 } 1407 } 1408 1409 @Override requestAddTile( int callingUid, @NonNull ComponentName componentName, @NonNull CharSequence appName, @NonNull CharSequence label, @NonNull Icon icon, @NonNull IAddTileResultCallback callback )1410 public void requestAddTile( 1411 int callingUid, 1412 @NonNull ComponentName componentName, 1413 @NonNull CharSequence appName, 1414 @NonNull CharSequence label, 1415 @NonNull Icon icon, 1416 @NonNull IAddTileResultCallback callback 1417 ) { 1418 SomeArgs args = SomeArgs.obtain(); 1419 args.arg1 = componentName; 1420 args.arg2 = appName; 1421 args.arg3 = label; 1422 args.arg4 = icon; 1423 args.arg5 = callback; 1424 args.arg6 = callingUid; 1425 mHandler.obtainMessage(MSG_TILE_SERVICE_REQUEST_ADD, args).sendToTarget(); 1426 } 1427 1428 @Override cancelRequestAddTile(@onNull String s)1429 public void cancelRequestAddTile(@NonNull String s) throws RemoteException { 1430 mHandler.obtainMessage(MSG_TILE_SERVICE_REQUEST_CANCEL, s).sendToTarget(); 1431 } 1432 1433 @Override updateMediaTapToTransferSenderDisplay( @tatusBarManager.MediaTransferSenderState int displayState, MediaRoute2Info routeInfo, IUndoMediaTransferCallback undoCallback )1434 public void updateMediaTapToTransferSenderDisplay( 1435 @StatusBarManager.MediaTransferSenderState int displayState, 1436 MediaRoute2Info routeInfo, 1437 IUndoMediaTransferCallback undoCallback 1438 ) throws RemoteException { 1439 SomeArgs args = SomeArgs.obtain(); 1440 args.arg1 = displayState; 1441 args.arg2 = routeInfo; 1442 args.arg3 = undoCallback; 1443 mHandler.obtainMessage(MSG_MEDIA_TRANSFER_SENDER_STATE, args).sendToTarget(); 1444 } 1445 1446 @Override updateMediaTapToTransferReceiverDisplay( int displayState, @NonNull MediaRoute2Info routeInfo, @Nullable Icon appIcon, @Nullable CharSequence appName)1447 public void updateMediaTapToTransferReceiverDisplay( 1448 int displayState, 1449 @NonNull MediaRoute2Info routeInfo, 1450 @Nullable Icon appIcon, 1451 @Nullable CharSequence appName) { 1452 SomeArgs args = SomeArgs.obtain(); 1453 args.arg1 = displayState; 1454 args.arg2 = routeInfo; 1455 args.arg3 = appIcon; 1456 args.arg4 = appName; 1457 mHandler.obtainMessage(MSG_MEDIA_TRANSFER_RECEIVER_STATE, args).sendToTarget(); 1458 } 1459 1460 @Override registerNearbyMediaDevicesProvider(@onNull INearbyMediaDevicesProvider provider)1461 public void registerNearbyMediaDevicesProvider(@NonNull INearbyMediaDevicesProvider provider) { 1462 mHandler.obtainMessage(MSG_REGISTER_NEARBY_MEDIA_DEVICE_PROVIDER, provider).sendToTarget(); 1463 } 1464 1465 @Override unregisterNearbyMediaDevicesProvider( @onNull INearbyMediaDevicesProvider provider)1466 public void unregisterNearbyMediaDevicesProvider( 1467 @NonNull INearbyMediaDevicesProvider provider) { 1468 mHandler.obtainMessage(MSG_UNREGISTER_NEARBY_MEDIA_DEVICE_PROVIDER, provider) 1469 .sendToTarget(); 1470 } 1471 1472 @Override moveFocusedTaskToFullscreen(int displayId)1473 public void moveFocusedTaskToFullscreen(int displayId) { 1474 SomeArgs args = SomeArgs.obtain(); 1475 args.arg1 = displayId; 1476 mHandler.obtainMessage(MSG_MOVE_FOCUSED_TASK_TO_FULLSCREEN, args).sendToTarget(); 1477 } 1478 1479 @Override moveFocusedTaskToDesktop(int displayId)1480 public void moveFocusedTaskToDesktop(int displayId) { 1481 SomeArgs args = SomeArgs.obtain(); 1482 args.arg1 = displayId; 1483 mHandler.obtainMessage(MSG_ENTER_DESKTOP, args).sendToTarget(); 1484 } 1485 1486 private final class H extends Handler { H(Looper l)1487 private H(Looper l) { 1488 super(l); 1489 } 1490 handleMessage(Message msg)1491 public void handleMessage(Message msg) { 1492 final int what = msg.what & MSG_MASK; 1493 switch (what) { 1494 case MSG_ICON: { 1495 switch (msg.arg1) { 1496 case OP_SET_ICON: { 1497 Pair<String, StatusBarIcon> p = (Pair<String, StatusBarIcon>) msg.obj; 1498 for (int i = 0; i < mCallbacks.size(); i++) { 1499 mCallbacks.get(i).setIcon(p.first, p.second); 1500 } 1501 break; 1502 } 1503 case OP_REMOVE_ICON: 1504 for (int i = 0; i < mCallbacks.size(); i++) { 1505 mCallbacks.get(i).removeIcon((String) msg.obj); 1506 } 1507 break; 1508 } 1509 break; 1510 } 1511 case MSG_DISABLE: 1512 SomeArgs args = (SomeArgs) msg.obj; 1513 for (int i = 0; i < mCallbacks.size(); i++) { 1514 mCallbacks.get(i).disable(args.argi1, args.argi2, args.argi3, 1515 args.argi4 != 0 /* animate */); 1516 } 1517 break; 1518 case MSG_EXPAND_NOTIFICATIONS: 1519 for (int i = 0; i < mCallbacks.size(); i++) { 1520 mCallbacks.get(i).animateExpandNotificationsPanel(); 1521 } 1522 break; 1523 case MSG_COLLAPSE_PANELS: 1524 for (int i = 0; i < mCallbacks.size(); i++) { 1525 mCallbacks.get(i).animateCollapsePanels(msg.arg1, msg.arg2 != 0); 1526 } 1527 break; 1528 case MSG_TOGGLE_NOTIFICATION_PANEL: 1529 for (int i = 0; i < mCallbacks.size(); i++) { 1530 mCallbacks.get(i).toggleNotificationsPanel(); 1531 } 1532 break; 1533 case MSG_EXPAND_SETTINGS: 1534 for (int i = 0; i < mCallbacks.size(); i++) { 1535 mCallbacks.get(i).animateExpandSettingsPanel((String) msg.obj); 1536 } 1537 break; 1538 case MSG_TOGGLE_QUICK_SETTINGS_PANEL: 1539 for (int i = 0; i < mCallbacks.size(); i++) { 1540 mCallbacks.get(i).toggleQuickSettingsPanel(); 1541 } 1542 break; 1543 case MSG_SHOW_IME_BUTTON: 1544 args = (SomeArgs) msg.obj; 1545 handleShowImeButton(args.argi1 /* displayId */, (IBinder) args.arg1 /* token */, 1546 args.argi2 /* vis */, args.argi3 /* backDisposition */, 1547 args.argi4 != 0 /* showImeSwitcher */); 1548 break; 1549 case MSG_SHOW_RECENT_APPS: 1550 for (int i = 0; i < mCallbacks.size(); i++) { 1551 mCallbacks.get(i).showRecentApps(msg.arg1 != 0); 1552 } 1553 break; 1554 case MSG_HIDE_RECENT_APPS: 1555 for (int i = 0; i < mCallbacks.size(); i++) { 1556 mCallbacks.get(i).hideRecentApps(msg.arg1 != 0, msg.arg2 != 0); 1557 } 1558 break; 1559 case MSG_TOGGLE_TASKBAR: 1560 for (int i = 0; i < mCallbacks.size(); i++) { 1561 mCallbacks.get(i).toggleTaskbar(); 1562 } 1563 break; 1564 case MSG_TOGGLE_RECENT_APPS: 1565 for (int i = 0; i < mCallbacks.size(); i++) { 1566 mCallbacks.get(i).toggleRecentApps(); 1567 } 1568 break; 1569 case MSG_PRELOAD_RECENT_APPS: 1570 for (int i = 0; i < mCallbacks.size(); i++) { 1571 mCallbacks.get(i).preloadRecentApps(); 1572 } 1573 break; 1574 case MSG_CANCEL_PRELOAD_RECENT_APPS: 1575 for (int i = 0; i < mCallbacks.size(); i++) { 1576 mCallbacks.get(i).cancelPreloadRecentApps(); 1577 } 1578 break; 1579 case MSG_DISMISS_KEYBOARD_SHORTCUTS: 1580 for (int i = 0; i < mCallbacks.size(); i++) { 1581 mCallbacks.get(i).dismissKeyboardShortcutsMenu(); 1582 } 1583 break; 1584 case MSG_TOGGLE_KEYBOARD_SHORTCUTS: 1585 for (int i = 0; i < mCallbacks.size(); i++) { 1586 mCallbacks.get(i).toggleKeyboardShortcutsMenu(msg.arg1); 1587 } 1588 break; 1589 case MSG_SET_WINDOW_STATE: 1590 for (int i = 0; i < mCallbacks.size(); i++) { 1591 mCallbacks.get(i).setWindowState(msg.arg1, msg.arg2, (int) msg.obj); 1592 } 1593 break; 1594 case MSG_SHOW_SCREEN_PIN_REQUEST: 1595 for (int i = 0; i < mCallbacks.size(); i++) { 1596 mCallbacks.get(i).showScreenPinningRequest(msg.arg1); 1597 } 1598 break; 1599 case MSG_APP_TRANSITION_PENDING: 1600 for (int i = 0; i < mCallbacks.size(); i++) { 1601 mCallbacks.get(i).appTransitionPending(msg.arg1, msg.arg2 != 0); 1602 } 1603 break; 1604 case MSG_APP_TRANSITION_CANCELLED: 1605 for (int i = 0; i < mCallbacks.size(); i++) { 1606 mCallbacks.get(i).appTransitionCancelled(msg.arg1); 1607 } 1608 break; 1609 case MSG_APP_TRANSITION_STARTING: 1610 args = (SomeArgs) msg.obj; 1611 for (int i = 0; i < mCallbacks.size(); i++) { 1612 mCallbacks.get(i).appTransitionStarting(args.argi1, (long) args.arg1, 1613 (long) args.arg2, args.argi2 != 0 /* forced */); 1614 } 1615 break; 1616 case MSG_APP_TRANSITION_FINISHED: 1617 for (int i = 0; i < mCallbacks.size(); i++) { 1618 mCallbacks.get(i).appTransitionFinished(msg.arg1); 1619 } 1620 break; 1621 case MSG_ASSIST_DISCLOSURE: 1622 for (int i = 0; i < mCallbacks.size(); i++) { 1623 mCallbacks.get(i).showAssistDisclosure(); 1624 } 1625 break; 1626 case MSG_START_ASSIST: 1627 for (int i = 0; i < mCallbacks.size(); i++) { 1628 mCallbacks.get(i).startAssist((Bundle) msg.obj); 1629 } 1630 break; 1631 case MSG_CAMERA_LAUNCH_GESTURE: 1632 for (int i = 0; i < mCallbacks.size(); i++) { 1633 mCallbacks.get(i).onCameraLaunchGestureDetected(msg.arg1); 1634 } 1635 break; 1636 case MSG_EMERGENCY_ACTION_LAUNCH_GESTURE: 1637 for (int i = 0; i < mCallbacks.size(); i++) { 1638 mCallbacks.get(i).onEmergencyActionLaunchGestureDetected(); 1639 } 1640 break; 1641 case MSG_SHOW_PICTURE_IN_PICTURE_MENU: 1642 for (int i = 0; i < mCallbacks.size(); i++) { 1643 mCallbacks.get(i).showPictureInPictureMenu(); 1644 } 1645 break; 1646 case MSG_ADD_QS_TILE: { 1647 if (Flags.a11yQsShortcut()) { 1648 SomeArgs someArgs = (SomeArgs) msg.obj; 1649 for (int i = 0; i < mCallbacks.size(); i++) { 1650 mCallbacks.get(i).addQsTileToFrontOrEnd( 1651 (ComponentName) someArgs.arg1, (boolean) someArgs.arg2); 1652 } 1653 someArgs.recycle(); 1654 } else { 1655 for (int i = 0; i < mCallbacks.size(); i++) { 1656 mCallbacks.get(i).addQsTile((ComponentName) msg.obj); 1657 } 1658 } 1659 break; 1660 } 1661 case MSG_REMOVE_QS_TILE: 1662 for (int i = 0; i < mCallbacks.size(); i++) { 1663 mCallbacks.get(i).remQsTile((ComponentName) msg.obj); 1664 } 1665 break; 1666 case MSG_SET_QS_TILES: 1667 for (int i = 0; i < mCallbacks.size(); i++) { 1668 mCallbacks.get(i).setQsTiles((String[]) msg.obj); 1669 } 1670 break; 1671 case MSG_CLICK_QS_TILE: 1672 for (int i = 0; i < mCallbacks.size(); i++) { 1673 mCallbacks.get(i).clickTile((ComponentName) msg.obj); 1674 } 1675 break; 1676 case MSG_TOGGLE_APP_SPLIT_SCREEN: 1677 for (int i = 0; i < mCallbacks.size(); i++) { 1678 mCallbacks.get(i).toggleSplitScreen(); 1679 } 1680 break; 1681 case MSG_HANDLE_SYSTEM_KEY: 1682 for (int i = 0; i < mCallbacks.size(); i++) { 1683 mCallbacks.get(i).handleSystemKey((KeyEvent) msg.obj); 1684 } 1685 break; 1686 case MSG_SHOW_GLOBAL_ACTIONS: 1687 for (int i = 0; i < mCallbacks.size(); i++) { 1688 mCallbacks.get(i).handleShowGlobalActionsMenu(); 1689 } 1690 break; 1691 case MSG_SHOW_SHUTDOWN_UI: 1692 for (int i = 0; i < mCallbacks.size(); i++) { 1693 mCallbacks.get(i).handleShowShutdownUi(msg.arg1 != 0, (String) msg.obj); 1694 } 1695 break; 1696 case MSG_SET_TOP_APP_HIDES_STATUS_BAR: 1697 for (int i = 0; i < mCallbacks.size(); i++) { 1698 mCallbacks.get(i).setTopAppHidesStatusBar(msg.arg1 != 0); 1699 } 1700 break; 1701 case MSG_ROTATION_PROPOSAL: 1702 for (int i = 0; i < mCallbacks.size(); i++) { 1703 mCallbacks.get(i).onRotationProposal(msg.arg1, msg.arg2 != 0); 1704 } 1705 break; 1706 case MSG_BIOMETRIC_SHOW: { 1707 mHandler.removeMessages(MSG_BIOMETRIC_ERROR); 1708 mHandler.removeMessages(MSG_BIOMETRIC_HELP); 1709 mHandler.removeMessages(MSG_BIOMETRIC_AUTHENTICATED); 1710 SomeArgs someArgs = (SomeArgs) msg.obj; 1711 for (int i = 0; i < mCallbacks.size(); i++) { 1712 mCallbacks.get(i).showAuthenticationDialog( 1713 (PromptInfo) someArgs.arg1, 1714 (IBiometricSysuiReceiver) someArgs.arg2, 1715 (int[]) someArgs.arg3 /* sensorIds */, 1716 (boolean) someArgs.arg4 /* credentialAllowed */, 1717 (boolean) someArgs.arg5 /* requireConfirmation */, 1718 someArgs.argi1 /* userId */, 1719 someArgs.argl1 /* operationId */, 1720 (String) someArgs.arg6 /* opPackageName */, 1721 someArgs.argl2 /* requestId */); 1722 } 1723 someArgs.recycle(); 1724 break; 1725 } 1726 case MSG_BIOMETRIC_AUTHENTICATED: { 1727 SomeArgs someArgs = (SomeArgs) msg.obj; 1728 for (int i = 0; i < mCallbacks.size(); i++) { 1729 mCallbacks.get(i).onBiometricAuthenticated(someArgs.argi1 /* modality */); 1730 } 1731 someArgs.recycle(); 1732 break; 1733 } 1734 case MSG_BIOMETRIC_HELP: { 1735 SomeArgs someArgs = (SomeArgs) msg.obj; 1736 for (int i = 0; i < mCallbacks.size(); i++) { 1737 mCallbacks.get(i).onBiometricHelp( 1738 someArgs.argi1 /* modality */, 1739 (String) someArgs.arg1 /* message */); 1740 } 1741 someArgs.recycle(); 1742 break; 1743 } 1744 case MSG_BIOMETRIC_ERROR: { 1745 SomeArgs someArgs = (SomeArgs) msg.obj; 1746 for (int i = 0; i < mCallbacks.size(); i++) { 1747 mCallbacks.get(i).onBiometricError( 1748 someArgs.argi1 /* modality */, 1749 someArgs.argi2 /* error */, 1750 someArgs.argi3 /* vendorCode */ 1751 ); 1752 } 1753 someArgs.recycle(); 1754 break; 1755 } 1756 case MSG_BIOMETRIC_HIDE: { 1757 final SomeArgs someArgs = (SomeArgs) msg.obj; 1758 for (int i = 0; i < mCallbacks.size(); i++) { 1759 mCallbacks.get(i).hideAuthenticationDialog(someArgs.argl1 /* requestId */); 1760 } 1761 someArgs.recycle(); 1762 break; 1763 } 1764 case MSG_SET_BIOMETRICS_LISTENER: 1765 for (int i = 0; i < mCallbacks.size(); i++) { 1766 mCallbacks.get(i).setBiometricContextListener( 1767 (IBiometricContextListener) msg.obj); 1768 } 1769 break; 1770 case MSG_SET_UDFPS_REFRESH_RATE_CALLBACK: 1771 for (int i = 0; i < mCallbacks.size(); i++) { 1772 mCallbacks.get(i).setUdfpsRefreshRateCallback( 1773 (IUdfpsRefreshRateRequestCallback) msg.obj); 1774 } 1775 break; 1776 case MSG_SHOW_CHARGING_ANIMATION: 1777 for (int i = 0; i < mCallbacks.size(); i++) { 1778 mCallbacks.get(i).showWirelessChargingAnimation(msg.arg1); 1779 } 1780 break; 1781 case MSG_SHOW_PINNING_TOAST_ENTER_EXIT: 1782 for (int i = 0; i < mCallbacks.size(); i++) { 1783 mCallbacks.get(i).showPinningEnterExitToast((Boolean) msg.obj); 1784 } 1785 break; 1786 case MSG_SHOW_PINNING_TOAST_ESCAPE: 1787 for (int i = 0; i < mCallbacks.size(); i++) { 1788 mCallbacks.get(i).showPinningEscapeToast(); 1789 } 1790 break; 1791 case MSG_DISPLAY_READY: 1792 for (int i = 0; i < mCallbacks.size(); i++) { 1793 mCallbacks.get(i).onDisplayReady(msg.arg1); 1794 } 1795 break; 1796 case MSG_RECENTS_ANIMATION_STATE_CHANGED: 1797 for (int i = 0; i < mCallbacks.size(); i++) { 1798 mCallbacks.get(i).onRecentsAnimationStateChanged(msg.arg1 > 0); 1799 } 1800 break; 1801 case MSG_SYSTEM_BAR_CHANGED: 1802 args = (SomeArgs) msg.obj; 1803 for (int i = 0; i < mCallbacks.size(); i++) { 1804 mCallbacks.get(i).onSystemBarAttributesChanged(args.argi1, args.argi2, 1805 (AppearanceRegion[]) args.arg1, args.argi3 == 1, args.argi4, 1806 args.argi5, (String) args.arg3, (LetterboxDetails[]) args.arg4); 1807 } 1808 args.recycle(); 1809 break; 1810 case MSG_SHOW_TRANSIENT: { 1811 args = (SomeArgs) msg.obj; 1812 final int displayId = args.argi1; 1813 final int types = args.argi2; 1814 final boolean isGestureOnSystemBar = args.argi3 != 0; 1815 args.recycle(); 1816 for (int i = 0; i < mCallbacks.size(); i++) { 1817 mCallbacks.get(i).showTransient(displayId, types, isGestureOnSystemBar); 1818 } 1819 break; 1820 } 1821 case MSG_ABORT_TRANSIENT: { 1822 args = (SomeArgs) msg.obj; 1823 final int displayId = args.argi1; 1824 final int types = args.argi2; 1825 args.recycle(); 1826 for (int i = 0; i < mCallbacks.size(); i++) { 1827 mCallbacks.get(i).abortTransient(displayId, types); 1828 } 1829 break; 1830 } 1831 case MSG_SHOW_INATTENTIVE_SLEEP_WARNING: 1832 for (int i = 0; i < mCallbacks.size(); i++) { 1833 mCallbacks.get(i).showInattentiveSleepWarning(); 1834 } 1835 break; 1836 case MSG_DISMISS_INATTENTIVE_SLEEP_WARNING: 1837 for (int i = 0; i < mCallbacks.size(); i++) { 1838 mCallbacks.get(i).dismissInattentiveSleepWarning((Boolean) msg.obj); 1839 } 1840 break; 1841 case MSG_SHOW_TOAST: { 1842 args = (SomeArgs) msg.obj; 1843 String packageName = (String) args.arg1; 1844 IBinder token = (IBinder) args.arg2; 1845 CharSequence text = (CharSequence) args.arg3; 1846 IBinder windowToken = (IBinder) args.arg4; 1847 ITransientNotificationCallback callback = 1848 (ITransientNotificationCallback) args.arg5; 1849 int uid = args.argi1; 1850 int duration = args.argi2; 1851 int displayId = args.argi3; 1852 for (Callbacks callbacks : mCallbacks) { 1853 callbacks.showToast(uid, packageName, token, text, windowToken, duration, 1854 callback, displayId); 1855 } 1856 break; 1857 } 1858 case MSG_HIDE_TOAST: { 1859 args = (SomeArgs) msg.obj; 1860 String packageName = (String) args.arg1; 1861 IBinder token = (IBinder) args.arg2; 1862 for (Callbacks callbacks : mCallbacks) { 1863 callbacks.hideToast(packageName, token); 1864 } 1865 break; 1866 } 1867 case MSG_TRACING_STATE_CHANGED: 1868 for (int i = 0; i < mCallbacks.size(); i++) { 1869 mCallbacks.get(i).onTracingStateChanged((Boolean) msg.obj); 1870 } 1871 break; 1872 case MSG_SUPPRESS_AMBIENT_DISPLAY: 1873 for (Callbacks callbacks: mCallbacks) { 1874 callbacks.suppressAmbientDisplay((boolean) msg.obj); 1875 } 1876 break; 1877 case MSG_REQUEST_MAGNIFICATION_CONNECTION: 1878 for (int i = 0; i < mCallbacks.size(); i++) { 1879 mCallbacks.get(i).requestMagnificationConnection((Boolean) msg.obj); 1880 } 1881 break; 1882 case MSG_SET_NAVIGATION_BAR_LUMA_SAMPLING_ENABLED: 1883 for (int i = 0; i < mCallbacks.size(); i++) { 1884 mCallbacks.get(i).setNavigationBarLumaSamplingEnabled(msg.arg1, 1885 msg.arg2 != 0); 1886 } 1887 break; 1888 case MSG_TILE_SERVICE_REQUEST_ADD: 1889 args = (SomeArgs) msg.obj; 1890 ComponentName componentName = (ComponentName) args.arg1; 1891 CharSequence appName = (CharSequence) args.arg2; 1892 CharSequence label = (CharSequence) args.arg3; 1893 Icon icon = (Icon) args.arg4; 1894 IAddTileResultCallback callback = (IAddTileResultCallback) args.arg5; 1895 int callingUid = (int) args.arg6; 1896 for (int i = 0; i < mCallbacks.size(); i++) { 1897 mCallbacks.get(i).requestAddTile(callingUid, 1898 componentName, appName, label, icon, callback); 1899 } 1900 args.recycle(); 1901 break; 1902 case MSG_TILE_SERVICE_REQUEST_CANCEL: 1903 String packageName = (String) msg.obj; 1904 for (int i = 0; i < mCallbacks.size(); i++) { 1905 mCallbacks.get(i).cancelRequestAddTile(packageName); 1906 } 1907 break; 1908 case MSG_MEDIA_TRANSFER_SENDER_STATE: 1909 args = (SomeArgs) msg.obj; 1910 int displayState = (int) args.arg1; 1911 MediaRoute2Info routeInfo = (MediaRoute2Info) args.arg2; 1912 IUndoMediaTransferCallback undoCallback = 1913 (IUndoMediaTransferCallback) args.arg3; 1914 for (int i = 0; i < mCallbacks.size(); i++) { 1915 mCallbacks.get(i).updateMediaTapToTransferSenderDisplay( 1916 displayState, routeInfo, undoCallback); 1917 } 1918 args.recycle(); 1919 break; 1920 case MSG_MEDIA_TRANSFER_RECEIVER_STATE: 1921 args = (SomeArgs) msg.obj; 1922 int receiverDisplayState = (int) args.arg1; 1923 MediaRoute2Info receiverRouteInfo = (MediaRoute2Info) args.arg2; 1924 Icon appIcon = (Icon) args.arg3; 1925 appName = (CharSequence) args.arg4; 1926 for (int i = 0; i < mCallbacks.size(); i++) { 1927 mCallbacks.get(i).updateMediaTapToTransferReceiverDisplay( 1928 receiverDisplayState, receiverRouteInfo, appIcon, appName); 1929 } 1930 args.recycle(); 1931 break; 1932 case MSG_REGISTER_NEARBY_MEDIA_DEVICE_PROVIDER: 1933 INearbyMediaDevicesProvider provider = (INearbyMediaDevicesProvider) msg.obj; 1934 for (int i = 0; i < mCallbacks.size(); i++) { 1935 mCallbacks.get(i).registerNearbyMediaDevicesProvider(provider); 1936 } 1937 break; 1938 case MSG_UNREGISTER_NEARBY_MEDIA_DEVICE_PROVIDER: 1939 provider = (INearbyMediaDevicesProvider) msg.obj; 1940 for (int i = 0; i < mCallbacks.size(); i++) { 1941 mCallbacks.get(i).unregisterNearbyMediaDevicesProvider(provider); 1942 } 1943 break; 1944 case MSG_TILE_SERVICE_REQUEST_LISTENING_STATE: 1945 ComponentName component = (ComponentName) msg.obj; 1946 for (int i = 0; i < mCallbacks.size(); i++) { 1947 mCallbacks.get(i).requestTileServiceListeningState(component); 1948 } 1949 break; 1950 case MSG_SHOW_REAR_DISPLAY_DIALOG: 1951 for (int i = 0; i < mCallbacks.size(); i++) { 1952 mCallbacks.get(i).showRearDisplayDialog((Integer) msg.obj); 1953 } 1954 break; 1955 case MSG_MOVE_FOCUSED_TASK_TO_FULLSCREEN: { 1956 args = (SomeArgs) msg.obj; 1957 int displayId = args.argi1; 1958 for (int i = 0; i < mCallbacks.size(); i++) { 1959 mCallbacks.get(i).moveFocusedTaskToFullscreen(displayId); 1960 } 1961 break; 1962 } 1963 case MSG_MOVE_FOCUSED_TASK_TO_STAGE_SPLIT: { 1964 args = (SomeArgs) msg.obj; 1965 int displayId = args.argi1; 1966 boolean leftOrTop = args.argi2 != 0; 1967 for (int i = 0; i < mCallbacks.size(); i++) { 1968 mCallbacks.get(i).moveFocusedTaskToStageSplit(displayId, leftOrTop); 1969 } 1970 break; 1971 } 1972 case MSG_SET_SPLITSCREEN_FOCUS: 1973 for (int i = 0; i < mCallbacks.size(); i++) { 1974 mCallbacks.get(i).setSplitscreenFocus((Boolean) msg.obj); 1975 } 1976 break; 1977 case MSG_SHOW_MEDIA_OUTPUT_SWITCHER: 1978 args = (SomeArgs) msg.obj; 1979 String clientPackageName = (String) args.arg1; 1980 UserHandle clientUserHandle = (UserHandle) args.arg2; 1981 for (int i = 0; i < mCallbacks.size(); i++) { 1982 mCallbacks.get(i).showMediaOutputSwitcher(clientPackageName, 1983 clientUserHandle); 1984 } 1985 break; 1986 case MSG_CONFIRM_IMMERSIVE_PROMPT: 1987 for (int i = 0; i < mCallbacks.size(); i++) { 1988 mCallbacks.get(i).confirmImmersivePrompt(); 1989 } 1990 break; 1991 case MSG_IMMERSIVE_CHANGED: 1992 args = (SomeArgs) msg.obj; 1993 int rootDisplayAreaId = args.argi1; 1994 boolean isImmersiveMode = args.argi2 != 0; 1995 for (int i = 0; i < mCallbacks.size(); i++) { 1996 mCallbacks.get(i).immersiveModeChanged(rootDisplayAreaId, isImmersiveMode); 1997 } 1998 break; 1999 case MSG_ENTER_DESKTOP: { 2000 args = (SomeArgs) msg.obj; 2001 int displayId = args.argi1; 2002 for (int i = 0; i < mCallbacks.size(); i++) { 2003 mCallbacks.get(i).moveFocusedTaskToDesktop(displayId); 2004 } 2005 break; 2006 } 2007 } 2008 } 2009 } 2010 } 2011