1 /* 2 ** Copyright 2006, 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 android.view; 18 19 import com.android.internal.os.IResultReceiver; 20 import com.android.internal.policy.IKeyguardDismissCallback; 21 import com.android.internal.policy.IKeyguardLockedStateListener; 22 import com.android.internal.policy.IShortcutService; 23 24 import android.app.IAssistDataReceiver; 25 import android.content.ComponentName; 26 import android.content.res.CompatibilityInfo; 27 import android.content.res.Configuration; 28 import android.graphics.Bitmap; 29 import android.graphics.GraphicBuffer; 30 import android.graphics.Point; 31 import android.graphics.Rect; 32 import android.graphics.Region; 33 import android.os.Bundle; 34 import android.os.IRemoteCallback; 35 import android.os.ParcelFileDescriptor; 36 import android.view.DisplayCutout; 37 import android.view.DisplayInfo; 38 import android.view.IAppTransitionAnimationSpecsFuture; 39 import android.view.ICrossWindowBlurEnabledListener; 40 import android.view.IDisplayWindowInsetsController; 41 import android.view.IDisplayWindowListener; 42 import android.view.IDisplayFoldListener; 43 import android.view.IDisplayChangeWindowController; 44 import android.view.IOnKeyguardExitResult; 45 import android.view.IPinnedTaskListener; 46 import android.view.IScrollCaptureResponseListener; 47 import android.view.RemoteAnimationAdapter; 48 import android.view.IRotationWatcher; 49 import android.view.ISystemGestureExclusionListener; 50 import android.view.IWallpaperVisibilityListener; 51 import android.view.IWindow; 52 import android.view.IWindowSession; 53 import android.view.IWindowSessionCallback; 54 import android.view.KeyEvent; 55 import android.view.InputEvent; 56 import android.view.InsetsState; 57 import android.view.MagnificationSpec; 58 import android.view.MotionEvent; 59 import android.view.InputChannel; 60 import android.view.InputDevice; 61 import android.view.IInputFilter; 62 import android.view.AppTransitionAnimationSpec; 63 import android.view.TaskTransitionSpec; 64 import android.view.WindowContentFrameStats; 65 import android.view.WindowManager; 66 import android.view.SurfaceControl; 67 import android.view.displayhash.DisplayHash; 68 import android.view.displayhash.VerifiedDisplayHash; 69 import android.window.AddToSurfaceSyncGroupResult; 70 import android.window.ISurfaceSyncGroupCompletedListener; 71 import android.window.ITaskFpsCallback; 72 import android.window.ScreenCapture; 73 74 /** 75 * System private interface to the window manager. 76 * 77 * {@hide} 78 */ 79 interface IWindowManager 80 { 81 /** 82 * No overridden behavior is provided in terms of fixing rotation to user rotation. Use 83 * other flags to derive the default behavior, such as {@link WindowManagerService#mIsPc} 84 * and {@link WindowManagerService#mForceDesktopModeOnExternalDisplays}. 85 */ 86 const int FIXED_TO_USER_ROTATION_DEFAULT = 0; 87 /** 88 * Don't fix display rotation to {@link DisplayRotation#mUserRotation} only. Always allow 89 * other factors to play a role in deciding display rotation. 90 */ 91 const int FIXED_TO_USER_ROTATION_DISABLED = 1; 92 /** 93 * Only use {@link DisplayRotation#mUserRotation} as the display rotation. 94 */ 95 const int FIXED_TO_USER_ROTATION_ENABLED = 2; 96 97 /** 98 * ===== NOTICE ===== 99 * The first three methods must remain the first three methods. Scripts 100 * and tools rely on their transaction number to work properly. 101 */ 102 // This is used for debugging startViewServer(int port)103 boolean startViewServer(int port); // Transaction #1 stopViewServer()104 boolean stopViewServer(); // Transaction #2 isViewServerRunning()105 boolean isViewServerRunning(); // Transaction #3 106 openSession(in IWindowSessionCallback callback)107 IWindowSession openSession(in IWindowSessionCallback callback); 108 useBLAST()109 boolean useBLAST(); 110 111 @UnsupportedAppUsage getInitialDisplaySize(int displayId, out Point size)112 void getInitialDisplaySize(int displayId, out Point size); 113 @UnsupportedAppUsage getBaseDisplaySize(int displayId, out Point size)114 void getBaseDisplaySize(int displayId, out Point size); setForcedDisplaySize(int displayId, int width, int height)115 void setForcedDisplaySize(int displayId, int width, int height); clearForcedDisplaySize(int displayId)116 void clearForcedDisplaySize(int displayId); 117 @UnsupportedAppUsage getInitialDisplayDensity(int displayId)118 int getInitialDisplayDensity(int displayId); getBaseDisplayDensity(int displayId)119 int getBaseDisplayDensity(int displayId); getDisplayIdByUniqueId(String uniqueId)120 int getDisplayIdByUniqueId(String uniqueId); setForcedDisplayDensityForUser(int displayId, int density, int userId)121 void setForcedDisplayDensityForUser(int displayId, int density, int userId); clearForcedDisplayDensityForUser(int displayId, int userId)122 void clearForcedDisplayDensityForUser(int displayId, int userId); setForcedDisplayScalingMode(int displayId, int mode)123 void setForcedDisplayScalingMode(int displayId, int mode); // 0 = auto, 1 = disable 124 125 // These can only be called when holding the MANAGE_APP_TOKENS permission. setEventDispatching(boolean enabled)126 void setEventDispatching(boolean enabled); 127 128 /** Returns {@code true} if this binder is a registered window token. */ isWindowToken(in IBinder binder)129 boolean isWindowToken(in IBinder binder); 130 /** 131 * Adds window token for a given type. 132 * 133 * @param token Token to be registered. 134 * @param type Window type to be used with this token. 135 * @param displayId The ID of the display where this token should be added. 136 * @param options A bundle used to pass window-related options. 137 */ addWindowToken(IBinder token, int type, int displayId, in Bundle options)138 void addWindowToken(IBinder token, int type, int displayId, in Bundle options); 139 /** 140 * Remove window token on a specific display. 141 * 142 * @param token Token to be removed 143 * @displayId The ID of the display where this token should be removed. 144 */ removeWindowToken(IBinder token, int displayId)145 void removeWindowToken(IBinder token, int displayId); 146 147 /** 148 * Sets a singular remote controller of display rotations. There can only be one. The 149 * controller is called after the display has "frozen" for a rotation and display rotation will 150 * only continue once the controller has finished calculating associated configurations. 151 */ setDisplayChangeWindowController(IDisplayChangeWindowController controller)152 void setDisplayChangeWindowController(IDisplayChangeWindowController controller); 153 154 /** 155 * Adds a root container that a client shell can populate with its own windows (usually via 156 * WindowlessWindowManager). 157 * 158 * @param client an IWindow used for window-level communication (ime, finish draw, etc.). 159 * @param shellRootLayer The container's layer. See WindowManager#ShellRootLayer. 160 * @return a SurfaceControl to add things to. 161 */ addShellRoot(int displayId, IWindow client, int shellRootLayer)162 SurfaceControl addShellRoot(int displayId, IWindow client, int shellRootLayer); 163 164 /** 165 * Sets the window token sent to accessibility for a particular shell root. The 166 * displayId and windowType identify which shell-root to update. 167 * 168 * @param target The IWindow that accessibility service interfaces with. 169 */ setShellRootAccessibilityWindow(int displayId, int shellRootLayer, IWindow target)170 void setShellRootAccessibilityWindow(int displayId, int shellRootLayer, IWindow target); 171 172 /** 173 * Like overridePendingAppTransitionMultiThumb, but uses a future to supply the specs. This is 174 * used for recents, where generating the thumbnails of the specs takes a non-trivial amount of 175 * time, so we want to move that off the critical path for starting the new activity. 176 */ 177 @UnsupportedAppUsage overridePendingAppTransitionMultiThumbFuture( IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback startedCallback, boolean scaleUp, int displayId)178 void overridePendingAppTransitionMultiThumbFuture( 179 IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback startedCallback, 180 boolean scaleUp, int displayId); 181 @UnsupportedAppUsage overridePendingAppTransitionRemote(in RemoteAnimationAdapter remoteAnimationAdapter, int displayId)182 void overridePendingAppTransitionRemote(in RemoteAnimationAdapter remoteAnimationAdapter, 183 int displayId); 184 185 /** 186 * Used by system ui to report that recents has shown itself. 187 * @deprecated to be removed once prebuilts are updated 188 */ 189 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) endProlongedAnimations()190 void endProlongedAnimations(); 191 startFreezingScreen(int exitAnim, int enterAnim)192 void startFreezingScreen(int exitAnim, int enterAnim); stopFreezingScreen()193 void stopFreezingScreen(); 194 195 // these require DISABLE_KEYGUARD permission 196 /** @deprecated use Activity.setShowWhenLocked instead. */ disableKeyguard(IBinder token, String tag, int userId)197 void disableKeyguard(IBinder token, String tag, int userId); 198 /** @deprecated use Activity.setShowWhenLocked instead. */ reenableKeyguard(IBinder token, int userId)199 void reenableKeyguard(IBinder token, int userId); exitKeyguardSecurely(IOnKeyguardExitResult callback)200 void exitKeyguardSecurely(IOnKeyguardExitResult callback); 201 @UnsupportedAppUsage isKeyguardLocked()202 boolean isKeyguardLocked(); 203 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) isKeyguardSecure(int userId)204 boolean isKeyguardSecure(int userId); dismissKeyguard(IKeyguardDismissCallback callback, CharSequence message)205 void dismissKeyguard(IKeyguardDismissCallback callback, CharSequence message); 206 207 @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" 208 + ".permission.SUBSCRIBE_TO_KEYGUARD_LOCKED_STATE)") addKeyguardLockedStateListener(in IKeyguardLockedStateListener listener)209 void addKeyguardLockedStateListener(in IKeyguardLockedStateListener listener); 210 211 @JavaPassthrough(annotation = "@android.annotation.RequiresPermission(android.Manifest" 212 + ".permission.SUBSCRIBE_TO_KEYGUARD_LOCKED_STATE)") removeKeyguardLockedStateListener(in IKeyguardLockedStateListener listener)213 void removeKeyguardLockedStateListener(in IKeyguardLockedStateListener listener); 214 215 // Requires INTERACT_ACROSS_USERS_FULL permission setSwitchingUser(boolean switching)216 void setSwitchingUser(boolean switching); 217 closeSystemDialogs(String reason)218 void closeSystemDialogs(String reason); 219 220 // These can only be called with the SET_ANIMATON_SCALE permission. 221 @UnsupportedAppUsage getAnimationScale(int which)222 float getAnimationScale(int which); 223 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) getAnimationScales()224 float[] getAnimationScales(); 225 @UnsupportedAppUsage setAnimationScale(int which, float scale)226 void setAnimationScale(int which, float scale); 227 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) setAnimationScales(in float[] scales)228 void setAnimationScales(in float[] scales); 229 getCurrentAnimatorScale()230 float getCurrentAnimatorScale(); 231 232 // Request to change the touch mode on the display represented by the displayId parameter. 233 // 234 // If com.android.internal.R.bool.config_perDisplayFocusEnabled is false, then it will request 235 // to change the touch mode on all displays (disregarding displayId parameter). setInTouchMode(boolean inTouch, int displayId)236 void setInTouchMode(boolean inTouch, int displayId); 237 238 // Request to change the touch mode on all displays (disregarding the value 239 // com.android.internal.R.bool.config_perDisplayFocusEnabled). setInTouchModeOnAllDisplays(boolean inTouch)240 void setInTouchModeOnAllDisplays(boolean inTouch); 241 242 // Returns the touch mode state for the display represented by the displayId parameter. isInTouchMode(int displayId)243 boolean isInTouchMode(int displayId); 244 245 // For StrictMode flashing a red border on violations from the UI 246 // thread. The uid/pid is implicit from the Binder call, and the Window 247 // Manager uses that to determine whether or not the red border should 248 // actually be shown. (it will be ignored that pid doesn't have windows 249 // on screen) 250 @UnsupportedAppUsage(maxTargetSdk = 28) showStrictModeViolation(boolean on)251 void showStrictModeViolation(boolean on); 252 253 // Proxy to set the system property for whether the flashing 254 // should be enabled. The 'enabled' value is null or blank for 255 // the system default (differs per build variant) or any valid 256 // boolean string as parsed by SystemProperties.getBoolean(). 257 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) setStrictModeVisualIndicatorPreference(String enabled)258 void setStrictModeVisualIndicatorPreference(String enabled); 259 260 /** 261 * Set whether screen capture is disabled for all windows of a specific user from 262 * the device policy cache. 263 */ refreshScreenCaptureDisabled()264 void refreshScreenCaptureDisabled(); 265 266 /** 267 * Retrieve the current orientation of the primary screen. 268 * @return Constant as per {@link android.view.Surface.Rotation}. 269 * 270 * @see android.view.Display#DEFAULT_DISPLAY 271 */ getDefaultDisplayRotation()272 int getDefaultDisplayRotation(); 273 274 /** 275 * Watch the rotation of the specified screen. Returns the current rotation, 276 * calls back when it changes. 277 */ watchRotation(IRotationWatcher watcher, int displayId)278 int watchRotation(IRotationWatcher watcher, int displayId); 279 280 /** 281 * Remove a rotation watcher set using watchRotation. 282 * @hide 283 */ 284 @UnsupportedAppUsage removeRotationWatcher(IRotationWatcher watcher)285 void removeRotationWatcher(IRotationWatcher watcher); 286 287 /** Registers the listener to the context token and returns the current proposed rotation. */ registerProposedRotationListener(IBinder contextToken, IRotationWatcher listener)288 int registerProposedRotationListener(IBinder contextToken, IRotationWatcher listener); 289 290 /** 291 * Determine the preferred edge of the screen to pin the compact options menu against. 292 * 293 * @param displayId Id of the display where the menu window currently resides. 294 * @return a Gravity value for the options menu panel. 295 * @hide 296 */ getPreferredOptionsPanelGravity(int displayId)297 int getPreferredOptionsPanelGravity(int displayId); 298 299 /** 300 * Equivalent to calling {@link #freezeDisplayRotation(int, int)} with {@link 301 * android.view.Display#DEFAULT_DISPLAY} and given rotation. 302 */ 303 @UnsupportedAppUsage freezeRotation(int rotation)304 void freezeRotation(int rotation); 305 306 /** 307 * Equivalent to calling {@link #thawDisplayRotation(int)} with {@link 308 * android.view.Display#DEFAULT_DISPLAY}. 309 */ 310 @UnsupportedAppUsage thawRotation()311 void thawRotation(); 312 313 /** 314 * Equivelant to call {@link #isDisplayRotationFrozen(int)} with {@link 315 * android.view.Display#DEFAULT_DISPLAY}. 316 */ isRotationFrozen()317 boolean isRotationFrozen(); 318 319 /** 320 * Lock the display orientation to the specified rotation, or to the current 321 * rotation if -1. Sensor input will be ignored until thawRotation() is called. 322 * 323 * @param displayId the ID of display which rotation should be frozen. 324 * @param rotation one of {@link android.view.Surface#ROTATION_0}, 325 * {@link android.view.Surface#ROTATION_90}, {@link android.view.Surface#ROTATION_180}, 326 * {@link android.view.Surface#ROTATION_270} or -1 to freeze it to current rotation. 327 * @hide 328 */ freezeDisplayRotation(int displayId, int rotation)329 void freezeDisplayRotation(int displayId, int rotation); 330 331 /** 332 * Release the orientation lock imposed by freezeRotation() on the display. 333 * 334 * @param displayId the ID of display which rotation should be thawed. 335 * @hide 336 */ thawDisplayRotation(int displayId)337 void thawDisplayRotation(int displayId); 338 339 /** 340 * Gets whether the rotation is frozen on the display. 341 * 342 * @param displayId the ID of display which frozen is needed. 343 * @return Whether the rotation is frozen. 344 */ isDisplayRotationFrozen(int displayId)345 boolean isDisplayRotationFrozen(int displayId); 346 347 /** 348 * Sets if display rotation is fixed to user specified value for given displayId. 349 */ setFixedToUserRotation(int displayId, int fixedToUserRotation)350 void setFixedToUserRotation(int displayId, int fixedToUserRotation); 351 352 /** 353 * Sets if all requested fixed orientation should be ignored for given displayId. 354 */ setIgnoreOrientationRequest(int displayId, boolean ignoreOrientationRequest)355 void setIgnoreOrientationRequest(int displayId, boolean ignoreOrientationRequest); 356 357 /** 358 * Screenshot the current wallpaper layer, including the whole screen. 359 */ screenshotWallpaper()360 Bitmap screenshotWallpaper(); 361 362 /** 363 * Mirrors the wallpaper for the given display. 364 * 365 * @param displayId ID of the display for the wallpaper. 366 * @return A SurfaceControl for the parent of the mirrored wallpaper. 367 */ mirrorWallpaperSurface(int displayId)368 SurfaceControl mirrorWallpaperSurface(int displayId); 369 370 /** 371 * Registers a wallpaper visibility listener. 372 * @return Current visibility. 373 */ registerWallpaperVisibilityListener(IWallpaperVisibilityListener listener, int displayId)374 boolean registerWallpaperVisibilityListener(IWallpaperVisibilityListener listener, 375 int displayId); 376 377 /** 378 * Remove a visibility watcher that was added using registerWallpaperVisibilityListener. 379 */ unregisterWallpaperVisibilityListener(IWallpaperVisibilityListener listener, int displayId)380 void unregisterWallpaperVisibilityListener(IWallpaperVisibilityListener listener, 381 int displayId); 382 383 /** 384 * Registers a system gesture exclusion listener for a given display. 385 */ registerSystemGestureExclusionListener(ISystemGestureExclusionListener listener, int displayId)386 void registerSystemGestureExclusionListener(ISystemGestureExclusionListener listener, 387 int displayId); 388 389 /** 390 * Unregisters a system gesture exclusion listener for a given display. 391 */ unregisterSystemGestureExclusionListener(ISystemGestureExclusionListener listener, int displayId)392 void unregisterSystemGestureExclusionListener(ISystemGestureExclusionListener listener, 393 int displayId); 394 395 /** 396 * Used only for assist -- request a screenshot of the current application. 397 */ requestAssistScreenshot(IAssistDataReceiver receiver)398 boolean requestAssistScreenshot(IAssistDataReceiver receiver); 399 400 /** 401 * Called by System UI to notify Window Manager to hide transient bars. 402 */ hideTransientBars(int displayId)403 oneway void hideTransientBars(int displayId); 404 405 /** 406 * Called by System UI to notify of changes to the visibility of Recents. 407 */ setRecentsVisibility(boolean visible)408 oneway void setRecentsVisibility(boolean visible); 409 410 /** 411 * Called by System UI to indicate the maximum bounds of the system Privacy Indicator, for the 412 * current orientation, whether the indicator is showing or not. Should be an array of length 413 * 4, with the bounds for ROTATION_0, 90, 180, and 270, in that order. 414 */ updateStaticPrivacyIndicatorBounds(int displayId, in Rect[] staticBounds)415 oneway void updateStaticPrivacyIndicatorBounds(int displayId, in Rect[] staticBounds); 416 417 /** 418 * Called by System UI to enable or disable haptic feedback on the navigation bar buttons. 419 */ 420 @UnsupportedAppUsage setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled)421 void setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled); 422 423 /** 424 * Device has a software navigation bar (separate from the status bar) on specific display. 425 * 426 * @param displayId the id of display to check if there is a software navigation bar. 427 */ 428 @UnsupportedAppUsage hasNavigationBar(int displayId)429 boolean hasNavigationBar(int displayId); 430 431 /** 432 * Lock the device immediately with the specified options (can be null). 433 */ 434 @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) lockNow(in Bundle options)435 void lockNow(in Bundle options); 436 437 /** 438 * Device is in safe mode. 439 */ 440 @UnsupportedAppUsage isSafeModeEnabled()441 boolean isSafeModeEnabled(); 442 443 /** 444 * Clears the frame statistics for a given window. 445 * 446 * @param token The window token. 447 * @return Whether the frame statistics were cleared. 448 */ clearWindowContentFrameStats(IBinder token)449 boolean clearWindowContentFrameStats(IBinder token); 450 451 /** 452 * Gets the content frame statistics for a given window. 453 * 454 * @param token The window token. 455 * @return The frame statistics or null if the window does not exist. 456 */ getWindowContentFrameStats(IBinder token)457 WindowContentFrameStats getWindowContentFrameStats(IBinder token); 458 459 /** 460 * This is a no-op. 461 */ 462 @UnsupportedAppUsage getDockedStackSide()463 int getDockedStackSide(); 464 465 /** 466 * Registers a listener that will be called when the pinned task state changes. 467 */ registerPinnedTaskListener(int displayId, IPinnedTaskListener listener)468 void registerPinnedTaskListener(int displayId, IPinnedTaskListener listener); 469 470 /** 471 * Requests Keyboard Shortcuts from the displayed window. 472 * 473 * @param receiver The receiver to deliver the results to. 474 * @param deviceId The deviceId of KeyEvent by which this request is triggered, or -1 if it's 475 * not triggered by a KeyEvent. 476 * @see #requestImeKeyboardShortcuts(IResultReceiver, int) 477 */ requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId)478 void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId); 479 480 /** 481 * Requests Keyboard Shortcuts from currently selected IME. 482 * 483 * @param receiver The receiver to deliver the results to. 484 * @param deviceId The deviceId of KeyEvent by which this request is triggered, or -1 if it's 485 * not triggered by a KeyEvent. 486 * @see #requestAppKeyboardShortcuts(IResultReceiver, int) 487 */ requestImeKeyboardShortcuts(IResultReceiver receiver, int deviceId)488 void requestImeKeyboardShortcuts(IResultReceiver receiver, int deviceId); 489 490 /** 491 * Retrieves the current stable insets from the primary display. 492 */ 493 @UnsupportedAppUsage getStableInsets(int displayId, out Rect outInsets)494 void getStableInsets(int displayId, out Rect outInsets); 495 496 /** 497 * Register shortcut key. Shortcut code is packed as: 498 * (MetaState << Integer.SIZE) | KeyCode 499 * @hide 500 */ registerShortcutKey(in long shortcutCode, IShortcutService keySubscriber)501 void registerShortcutKey(in long shortcutCode, IShortcutService keySubscriber); 502 503 /** 504 * Create an input consumer by name and display id. 505 */ 506 @UnsupportedAppUsage createInputConsumer(IBinder token, String name, int displayId, out InputChannel inputChannel)507 void createInputConsumer(IBinder token, String name, int displayId, 508 out InputChannel inputChannel); 509 510 /** 511 * Destroy an input consumer by name and display id. 512 * This method will also dispose the input channels associated with that InputConsumer. 513 */ 514 @UnsupportedAppUsage destroyInputConsumer(String name, int displayId)515 boolean destroyInputConsumer(String name, int displayId); 516 517 /** 518 * Return the touch region for the current IME window, or an empty region if there is none. 519 */ getCurrentImeTouchRegion()520 Region getCurrentImeTouchRegion(); 521 522 /** 523 * Registers an IDisplayFoldListener. 524 */ registerDisplayFoldListener(IDisplayFoldListener listener)525 void registerDisplayFoldListener(IDisplayFoldListener listener); 526 527 /** 528 * Unregisters an IDisplayFoldListener. 529 */ unregisterDisplayFoldListener(IDisplayFoldListener listener)530 void unregisterDisplayFoldListener(IDisplayFoldListener listener); 531 532 /** 533 * Registers an IDisplayContainerListener, and returns the set of existing display ids. The 534 * listener's onDisplayAdded() will not be called for the displays returned. 535 */ registerDisplayWindowListener(IDisplayWindowListener listener)536 int[] registerDisplayWindowListener(IDisplayWindowListener listener); 537 538 /** 539 * Unregisters an IDisplayContainerListener. 540 */ unregisterDisplayWindowListener(IDisplayWindowListener listener)541 void unregisterDisplayWindowListener(IDisplayWindowListener listener); 542 543 /** 544 * Starts a window trace. 545 */ startWindowTrace()546 void startWindowTrace(); 547 548 /** 549 * Stops a window trace. 550 */ stopWindowTrace()551 void stopWindowTrace(); 552 553 /** 554 * If window tracing is active, saves the window trace to file, otherwise does nothing 555 */ saveWindowTraceToFile()556 void saveWindowTraceToFile(); 557 558 /** 559 * Returns true if window trace is enabled. 560 */ isWindowTraceEnabled()561 boolean isWindowTraceEnabled(); 562 563 /** 564 * Starts a transition trace. 565 */ startTransitionTrace()566 void startTransitionTrace(); 567 568 /** 569 * Stops a transition trace. 570 */ stopTransitionTrace()571 void stopTransitionTrace(); 572 573 /** 574 * Returns true if transition trace is enabled. 575 */ isTransitionTraceEnabled()576 boolean isTransitionTraceEnabled(); 577 578 /** 579 * Gets the windowing mode of the display. 580 * 581 * @param displayId The id of the display. 582 * @return {@link WindowConfiguration.WindowingMode} 583 */ getWindowingMode(int displayId)584 int getWindowingMode(int displayId); 585 586 /** 587 * Sets the windowing mode of the display. 588 * 589 * @param displayId The id of the display. 590 * @param mode {@link WindowConfiguration.WindowingMode} 591 */ setWindowingMode(int displayId, int mode)592 void setWindowingMode(int displayId, int mode); 593 594 /** 595 * Gets current remove content mode of the display. 596 * <p> 597 * What actions should be performed with the display's content when it is removed. Default 598 * behavior for public displays in this case is to move all activities to the primary display 599 * and make it focused. For private display is to destroy all activities. 600 * </p> 601 * 602 * @param displayId The id of the display. 603 * @return The remove content mode of the display. 604 * @see WindowManager#REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY 605 * @see WindowManager#REMOVE_CONTENT_MODE_DESTROY 606 */ getRemoveContentMode(int displayId)607 int getRemoveContentMode(int displayId); 608 609 /** 610 * Sets the remove content mode of the display. 611 * <p> 612 * This mode indicates what actions should be performed with the display's content when it is 613 * removed. 614 * </p> 615 * 616 * @param displayId The id of the display. 617 * @param mode Remove content mode. 618 * @see WindowManager#REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY 619 * @see WindowManager#REMOVE_CONTENT_MODE_DESTROY 620 */ setRemoveContentMode(int displayId, int mode)621 void setRemoveContentMode(int displayId, int mode); 622 623 /** 624 * Indicates that the display should show its content when non-secure keyguard is shown. 625 * <p> 626 * This flag identifies secondary displays that will continue showing content if keyguard can be 627 * dismissed without entering credentials. 628 * </p><p> 629 * An example of usage is a virtual display which content is displayed on external hardware 630 * display that is not visible to the system directly. 631 * </p> 632 * 633 * @param displayId The id of the display. 634 * @return {@code true} if the display should show its content when non-secure keyguard is 635 * shown. 636 * @see KeyguardManager#isDeviceSecure() 637 * @see KeyguardManager#isDeviceLocked() 638 */ shouldShowWithInsecureKeyguard(int displayId)639 boolean shouldShowWithInsecureKeyguard(int displayId); 640 641 /** 642 * Sets that the display should show its content when non-secure keyguard is shown. 643 * 644 * @param displayId The id of the display. 645 * @param shouldShow Indicates that the display should show its content when non-secure keyguard 646 * is shown. 647 * @see KeyguardManager#isDeviceSecure() 648 * @see KeyguardManager#isDeviceLocked() 649 */ setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow)650 void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow); 651 652 /** 653 * Indicates the display should show system decors. 654 * <p> 655 * System decors include status bar, navigation bar, launcher. 656 * </p> 657 * 658 * @param displayId The id of the display. 659 * @return {@code true} if the display should show system decors. 660 */ shouldShowSystemDecors(int displayId)661 boolean shouldShowSystemDecors(int displayId); 662 663 /** 664 * Sets that the display should show system decors. 665 * <p> 666 * System decors include status bar, navigation bar, launcher. 667 * </p> 668 * 669 * @param displayId The id of the display. 670 * @param shouldShow Indicates that the display should show system decors. 671 */ setShouldShowSystemDecors(int displayId, boolean shouldShow)672 void setShouldShowSystemDecors(int displayId, boolean shouldShow); 673 674 /** 675 * Indicates the policy for how the display should show IME. 676 * 677 * @param displayId The id of the display. 678 * @return The policy for how the display should show IME. 679 * @see KeyguardManager#isDeviceSecure() 680 * @see KeyguardManager#isDeviceLocked() 681 */ getDisplayImePolicy(int displayId)682 int getDisplayImePolicy(int displayId); 683 684 /** 685 * Sets the policy for how the display should show IME. 686 * 687 * @param displayId The id of the display. 688 * @param imePolicy Indicates the policy for how the display should show IME. 689 * @see KeyguardManager#isDeviceSecure() 690 * @see KeyguardManager#isDeviceLocked() 691 */ setDisplayImePolicy(int displayId, int imePolicy)692 void setDisplayImePolicy(int displayId, int imePolicy); 693 694 /** 695 * Waits until input information has been sent from WindowManager to native InputManager, 696 * optionally waiting for animations to complete. 697 * 698 * This is needed for testing since we need to ensure input information has been propagated to 699 * native InputManager before proceeding with tests. 700 */ syncInputTransactions(boolean waitForAnimations)701 void syncInputTransactions(boolean waitForAnimations); 702 703 /** 704 * Returns whether SurfaceFlinger layer tracing is enabled. 705 */ isLayerTracing()706 boolean isLayerTracing(); 707 708 /** 709 * Enables/disables SurfaceFlinger layer tracing. 710 */ setLayerTracing(boolean enabled)711 void setLayerTracing(boolean enabled); 712 713 /** 714 * Mirrors a specified display. The root of the mirrored hierarchy will be stored in 715 * outSurfaceControl. 716 * Requires the ACCESS_SURFACE_FLINGER permission. 717 * 718 * @param displayId The id of the display to mirror 719 * @param outSurfaceControl The SurfaceControl for the root of the mirrored hierarchy. 720 * 721 * @return true if the display was successfully mirrored. 722 */ mirrorDisplay(int displayId, out SurfaceControl outSurfaceControl)723 boolean mirrorDisplay(int displayId, out SurfaceControl outSurfaceControl); 724 725 /** 726 * When in multi-window mode, the provided displayWindowInsetsController will control insets 727 * animations. 728 */ setDisplayWindowInsetsController( int displayId, in IDisplayWindowInsetsController displayWindowInsetsController)729 void setDisplayWindowInsetsController( 730 int displayId, in IDisplayWindowInsetsController displayWindowInsetsController); 731 732 /** 733 * Called when a remote process updates the requested visibilities of insets on a display window 734 * container. 735 */ updateDisplayWindowRequestedVisibleTypes(int displayId, int requestedVisibleTypes)736 void updateDisplayWindowRequestedVisibleTypes(int displayId, int requestedVisibleTypes); 737 738 /** 739 * Called to get the expected window insets. 740 * 741 * @return {@code true} if system bars are always consumed. 742 */ getWindowInsets(int displayId, in IBinder token, out InsetsState outInsetsState)743 boolean getWindowInsets(int displayId, in IBinder token, out InsetsState outInsetsState); 744 745 /** 746 * Returns a list of {@link android.view.DisplayInfo} for the logical display. This is not 747 * guaranteed to include all possible device states. The list items are unique. 748 * 749 * If invoked through a package other than a launcher app, returns an empty list. 750 * 751 * @param displayId the id of the logical display 752 */ getPossibleDisplayInfo(int displayId)753 List<DisplayInfo> getPossibleDisplayInfo(int displayId); 754 755 /** 756 * Called to show global actions. 757 */ showGlobalActions()758 void showGlobalActions(); 759 760 /** 761 * Sets layer tracing flags for SurfaceFlingerTrace. 762 * 763 * @param flags see definition in SurfaceTracing.cpp 764 */ setLayerTracingFlags(int flags)765 void setLayerTracingFlags(int flags); 766 767 /** 768 * Toggle active SurfaceFlinger transaction tracing. 769 */ setActiveTransactionTracing(boolean active)770 void setActiveTransactionTracing(boolean active); 771 772 /** 773 * Forwards a scroll capture request to the appropriate window, if available. 774 * 775 * @param displayId the id of the display to target 776 * @param behindClient token for a window, used to filter the search to windows behind it, or 777 * {@code null} to accept a window at any zOrder 778 * @param taskId specifies the id of a task the result must belong to, or -1 to ignore task ids 779 * @param listener the object to receive the response 780 */ requestScrollCapture(int displayId, IBinder behindClient, int taskId, IScrollCaptureResponseListener listener)781 void requestScrollCapture(int displayId, IBinder behindClient, int taskId, 782 IScrollCaptureResponseListener listener); 783 784 /** 785 * Holds the WM lock for the specified amount of milliseconds. 786 * Intended for use by the tests that need to imitate lock contention. 787 * The token should be obtained by 788 * {@link android.content.pm.PackageManager#getHoldLockToken()}. 789 */ holdLock(in IBinder token, in int durationMs)790 void holdLock(in IBinder token, in int durationMs); 791 792 /** 793 * Gets an array of support hash algorithms that can be used to generate a DisplayHash. The 794 * String value of one algorithm should be used when requesting to generate 795 * the DisplayHash. 796 * 797 * @return a String array of supported hash algorithms. 798 */ getSupportedDisplayHashAlgorithms()799 String[] getSupportedDisplayHashAlgorithms(); 800 801 /** 802 * Validate the DisplayHash was generated by the system. The DisplayHash passed in should be 803 * the object generated when calling {@link IWindowSession#generateDisplayHash} 804 * 805 * @param DisplayHash The hash to verify that it was generated by the system. 806 * @return a {@link VerifiedDisplayHash} if the hash was generated by the system or null 807 * if the token cannot be verified. 808 */ verifyDisplayHash(in DisplayHash displayHash)809 VerifiedDisplayHash verifyDisplayHash(in DisplayHash displayHash); 810 811 /** 812 * Call to enable or disable the throttling when generating a display hash. This should only be 813 * used for testing. Throttling is enabled by default. 814 * 815 * Must be called from a process that has {@link android.Manifest.permission#READ_FRAME_BUFFER} 816 * permission. 817 */ setDisplayHashThrottlingEnabled(boolean enable)818 void setDisplayHashThrottlingEnabled(boolean enable); 819 820 /** 821 * Attaches a {@link android.window.WindowContext} to the DisplayArea specified by {@code type}, 822 * {@code displayId} and {@code options}. 823 * <p> 824 * Note that this API should be invoked after calling 825 * {@link android.window.WindowTokenClient#attachContext(Context)} 826 * </p><p> 827 * Generally, this API is used for initializing a {@link android.window.WindowContext} 828 * before obtaining a valid {@link com.android.server.wm.WindowToken}. A WindowToken is usually 829 * generated when calling {@link android.view.WindowManager#addView(View, LayoutParams)}, or 830 * obtained from {@link android.view.WindowManager.LayoutParams#token}. 831 * </p><p> 832 * In some cases, the WindowToken is passed from the server side because it is managed by the 833 * system server. {@link #attachWindowContextToWindowToken(IBinder, IBinder)} could be used in 834 * this case to attach the WindowContext to the WindowToken.</p> 835 * 836 * @param clientToken {@link android.window.WindowContext#getWindowContextToken() 837 * the WindowContext's token} 838 * @param type Window type of the window context 839 * @param displayId The display associated with the window context 840 * @param options A bundle used to pass window-related options and choose the right DisplayArea 841 * 842 * @return the DisplayArea's {@link android.app.res.Configuration} if the WindowContext is 843 * attached to the DisplayArea successfully. {@code null}, otherwise. 844 */ attachWindowContextToDisplayArea(IBinder clientToken, int type, int displayId, in Bundle options)845 Configuration attachWindowContextToDisplayArea(IBinder clientToken, int type, int displayId, 846 in Bundle options); 847 848 /** 849 * Attaches a {@link android.window.WindowContext} to a {@code WindowToken}. 850 * <p> 851 * This API is used when we hold a valid WindowToken and want to associate with the token and 852 * receive its configuration updates. 853 * </p><p> 854 * Note that this API should be invoked after calling 855 * {@link android.window.WindowTokenClient#attachContext(Context)} 856 * </p> 857 * 858 * @param clientToken {@link android.window.WindowContext#getWindowContextToken() 859 * the WindowContext's token} 860 * @param token the WindowToken to attach 861 * 862 * @throws IllegalArgumentException if the {@code clientToken} have not been attached to 863 * the server or the WindowContext's type doesn't match WindowToken {@code token}'s type. 864 * 865 * @see #attachWindowContextToDisplayArea(IBinder, int, int, Bundle) 866 */ attachWindowContextToWindowToken(IBinder clientToken, IBinder token)867 void attachWindowContextToWindowToken(IBinder clientToken, IBinder token); 868 869 /** 870 * Attaches a {@code clientToken} to associate with DisplayContent. 871 * <p> 872 * Note that this API should be invoked after calling 873 * {@link android.window.WindowTokenClient#attachContext(Context)} 874 * </p> 875 * 876 * @param clientToken {@link android.window.WindowContext#getWindowContextToken() 877 * the WindowContext's token} 878 * @param displayId The display associated with the window context 879 * 880 * @return the DisplayContent's {@link android.app.res.Configuration} if the Context is 881 * attached to the DisplayContent successfully. {@code null}, otherwise. 882 * @throws android.view.WindowManager.InvalidDisplayException if the display ID is invalid 883 */ attachToDisplayContent(IBinder clientToken, int displayId)884 Configuration attachToDisplayContent(IBinder clientToken, int displayId); 885 886 /** 887 * Detaches {@link android.window.WindowContext} from the window manager node it's currently 888 * attached to. It is no-op if the WindowContext is not attached to a window manager node. 889 * 890 * @param clientToken the window context's token 891 */ detachWindowContextFromWindowContainer(IBinder clientToken)892 void detachWindowContextFromWindowContainer(IBinder clientToken); 893 894 /** 895 * Registers a listener, which is to be called whenever cross-window blur is enabled/disabled. 896 * 897 * @param listener the listener to be registered 898 * @return true if cross-window blur is currently enabled; false otherwise 899 */ registerCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener)900 boolean registerCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener); 901 902 /** 903 * Unregisters a listener which was registered with 904 * {@link #registerCrossWindowBlurEnabledListener()}. 905 * 906 * @param listener the listener to be unregistered 907 */ unregisterCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener)908 void unregisterCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener); 909 isTaskSnapshotSupported()910 boolean isTaskSnapshotSupported(); 911 912 /** 913 * Returns the preferred display ID to show software keyboard. 914 * 915 * @see android.window.WindowProviderService#getLaunchedDisplayId 916 */ getImeDisplayId()917 int getImeDisplayId(); 918 919 /** 920 * Control if we should enable task snapshot features on this device. 921 * @hide 922 */ setTaskSnapshotEnabled(boolean enabled)923 void setTaskSnapshotEnabled(boolean enabled); 924 925 /** 926 * Customized the task transition animation with a task transition spec. 927 * 928 * @param spec the spec that will be used to customize the task animations 929 */ setTaskTransitionSpec(in TaskTransitionSpec spec)930 void setTaskTransitionSpec(in TaskTransitionSpec spec); 931 932 /** 933 * Clears any task transition spec that has been previously set and 934 * reverts to using the default task transition with no spec changes. 935 */ clearTaskTransitionSpec()936 void clearTaskTransitionSpec(); 937 938 /** 939 * Registers the frame rate per second count callback for one given task ID. 940 * Each callback can only register for receiving FPS callback for one task id until unregister 941 * is called. If there's no task associated with the given task id, 942 * {@link IllegalArgumentException} will be thrown. If a task id destroyed after a callback is 943 * registered, the registered callback will not be unregistered until 944 * {@link unregisterTaskFpsCallback()} is called 945 * @param taskId task id of the task. 946 * @param callback callback to be registered. 947 * 948 * @hide 949 */ registerTaskFpsCallback(in int taskId, in ITaskFpsCallback callback)950 void registerTaskFpsCallback(in int taskId, in ITaskFpsCallback callback); 951 952 /** 953 * Unregisters the frame rate per second count callback which was registered with 954 * {@link #registerTaskFpsCallback(int,TaskFpsCallback)}. 955 * 956 * @param callback callback to be unregistered. 957 * 958 * @hide 959 */ unregisterTaskFpsCallback(in ITaskFpsCallback listener)960 void unregisterTaskFpsCallback(in ITaskFpsCallback listener); 961 962 /** 963 * Take a snapshot using the same path that's used for Recents. This is used for Testing only. 964 * 965 * @param taskId to take the snapshot of 966 * 967 * Returns a bitmap of the screenshot or {@code null} if it was unable to screenshot. 968 * @hide 969 */ snapshotTaskForRecents(int taskId)970 Bitmap snapshotTaskForRecents(int taskId); 971 972 /** 973 * Informs the system whether the recents app is currently behind the system bars. If so, 974 * means the recents app can control the SystemUI flags, and vice-versa. 975 */ setRecentsAppBehindSystemBars(boolean behindSystemBars)976 void setRecentsAppBehindSystemBars(boolean behindSystemBars); 977 978 /** 979 * Gets the background color of the letterbox. Considered invalid if the background has 980 * multiple colors {@link #isLetterboxBackgroundMultiColored}. Should be called by SystemUI when 981 * computing the letterbox appearance for status bar treatment. 982 */ getLetterboxBackgroundColorInArgb()983 int getLetterboxBackgroundColorInArgb(); 984 985 /** 986 * Whether the outer area of the letterbox has multiple colors (e.g. blurred background). 987 * Should be called by SystemUI when computing the letterbox appearance for status bar 988 * treatment. 989 */ isLetterboxBackgroundMultiColored()990 boolean isLetterboxBackgroundMultiColored(); 991 992 /** 993 * Captures the entire display specified by the displayId using the args provided. If the args 994 * are null or if the sourceCrop is invalid or null, the entire display bounds will be captured. 995 */ captureDisplay(int displayId, in @nullable ScreenCapture.CaptureArgs captureArgs, in ScreenCapture.ScreenCaptureListener listener)996 oneway void captureDisplay(int displayId, in @nullable ScreenCapture.CaptureArgs captureArgs, 997 in ScreenCapture.ScreenCaptureListener listener); 998 999 /** 1000 * Returns {@code true} if the key will be handled globally and not forwarded to all apps. 1001 * 1002 * @param keyCode the key code to check 1003 * @return {@code true} if the key will be handled globally. 1004 */ isGlobalKey(int keyCode)1005 boolean isGlobalKey(int keyCode); 1006 1007 /** 1008 * Create or add to a SurfaceSyncGroup in WindowManager. WindowManager maintains some 1009 * SurfaceSyncGroups to ensure multiple processes can sync with each other without sharing 1010 * SurfaceControls 1011 */ addToSurfaceSyncGroup(in IBinder syncGroupToken, boolean parentSyncGroupMerge, in @nullable ISurfaceSyncGroupCompletedListener completedListener, out AddToSurfaceSyncGroupResult addToSurfaceSyncGroupResult)1012 boolean addToSurfaceSyncGroup(in IBinder syncGroupToken, boolean parentSyncGroupMerge, 1013 in @nullable ISurfaceSyncGroupCompletedListener completedListener, 1014 out AddToSurfaceSyncGroupResult addToSurfaceSyncGroupResult); 1015 1016 /** 1017 * Mark a SurfaceSyncGroup stored in WindowManager as ready. 1018 */ markSurfaceSyncGroupReady(in IBinder syncGroupToken)1019 oneway void markSurfaceSyncGroupReady(in IBinder syncGroupToken); 1020 1021 /** 1022 * Invoked when a screenshot is taken of the default display to notify registered listeners. 1023 * 1024 * Should be invoked only by SysUI. 1025 * 1026 * @param displayId id of the display screenshot. 1027 * @return List of ComponentNames corresponding to the activities that were notified. 1028 */ notifyScreenshotListeners(int displayId)1029 List<ComponentName> notifyScreenshotListeners(int displayId); 1030 } 1031