1 /* 2 * Copyright (C) 2017 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.server.wm; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.content.ClipData; 22 import android.content.Context; 23 import android.graphics.Rect; 24 import android.graphics.Region; 25 import android.hardware.display.DisplayManagerInternal; 26 import android.os.Bundle; 27 import android.os.IBinder; 28 import android.view.Display; 29 import android.view.IInputFilter; 30 import android.view.IRemoteAnimationFinishedCallback; 31 import android.view.IWindow; 32 import android.view.InputChannel; 33 import android.view.MagnificationSpec; 34 import android.view.RemoteAnimationTarget; 35 import android.view.WindowInfo; 36 import android.view.WindowManager.DisplayImePolicy; 37 38 import com.android.internal.policy.KeyInterceptionInfo; 39 import com.android.server.input.InputManagerService; 40 import com.android.server.policy.WindowManagerPolicy; 41 42 import java.util.List; 43 import java.util.Set; 44 45 /** 46 * Window manager local system service interface. 47 * 48 * @hide Only for use within the system server. 49 */ 50 public abstract class WindowManagerInternal { 51 52 /** 53 * Interface for accessibility features implemented by AccessibilityController inside 54 * WindowManager. 55 */ 56 public interface AccessibilityControllerInternal { 57 /** 58 * Start tracing for the given logging types. 59 * @param loggingTypeFlags flags of the logging types enabled. 60 */ startTrace(long loggingTypeFlags)61 void startTrace(long loggingTypeFlags); 62 63 /** 64 * Disable accessibility tracing for all logging types. 65 */ stopTrace()66 void stopTrace(); 67 68 /** 69 * Is tracing enabled for any logging type. 70 */ isAccessibilityTracingEnabled()71 boolean isAccessibilityTracingEnabled(); 72 73 /** 74 * Add an accessibility trace entry. 75 * 76 * @param where A string to identify this log entry, which can be used to filter/search 77 * through the tracing file. 78 * @param loggingTypeFlags The flags for the logging types this log entry belongs to. 79 * @param callingParams The parameters for the method to be logged. 80 * @param a11yDump The proto byte array for a11y state when the entry is generated. 81 * @param callingUid The calling uid. 82 * @param stackTrace The stack trace, null if not needed. 83 * @param ignoreStackEntries The stack entries can be removed 84 */ logTrace( String where, long loggingTypeFlags, String callingParams, byte[] a11yDump, int callingUid, StackTraceElement[] stackTrace, Set<String> ignoreStackEntries)85 void logTrace( 86 String where, long loggingTypeFlags, String callingParams, byte[] a11yDump, 87 int callingUid, StackTraceElement[] stackTrace, Set<String> ignoreStackEntries); 88 89 /** 90 * Add an accessibility trace entry. 91 * 92 * @param where A string to identify this log entry, which can be used to filter/search 93 * through the tracing file. 94 * @param loggingTypeFlags The flags for the logging types this log entry belongs to. 95 * @param callingParams The parameters for the method to be logged. 96 * @param a11yDump The proto byte array for a11y state when the entry is generated. 97 * @param callingUid The calling uid. 98 * @param callStack The call stack of the method to be logged. 99 * @param timeStamp The time when the method to be logged is called. 100 * @param processId The calling process Id. 101 * @param threadId The calling thread Id. 102 * @param ignoreStackEntries The stack entries can be removed 103 */ logTrace(String where, long loggingTypeFlags, String callingParams, byte[] a11yDump, int callingUid, StackTraceElement[] callStack, long timeStamp, int processId, long threadId, Set<String> ignoreStackEntries)104 void logTrace(String where, long loggingTypeFlags, String callingParams, 105 byte[] a11yDump, int callingUid, StackTraceElement[] callStack, long timeStamp, 106 int processId, long threadId, Set<String> ignoreStackEntries); 107 } 108 109 /** 110 * Interface to receive a callback when the windows reported for 111 * accessibility changed. 112 */ 113 public interface WindowsForAccessibilityCallback { 114 115 /** 116 * Called when the windows for accessibility changed. 117 * 118 * @param forceSend Send the windows for accessibility even if they haven't changed. 119 * @param topFocusedDisplayId The display Id which has the top focused window. 120 * @param topFocusedWindowToken The window token of top focused window. 121 * @param windows The windows for accessibility. 122 */ onWindowsForAccessibilityChanged(boolean forceSend, int topFocusedDisplayId, IBinder topFocusedWindowToken, @NonNull List<WindowInfo> windows)123 void onWindowsForAccessibilityChanged(boolean forceSend, int topFocusedDisplayId, 124 IBinder topFocusedWindowToken, @NonNull List<WindowInfo> windows); 125 126 /** 127 * Called when the display is reparented and becomes an embedded 128 * display. The {@link WindowsForAccessibilityCallback} with the given embedded 129 * display will be replaced by the {@link WindowsForAccessibilityCallback} 130 * associated with its parent display at the same time. 131 * 132 * @param embeddedDisplayId The embedded display Id. 133 */ onDisplayReparented(int embeddedDisplayId)134 void onDisplayReparented(int embeddedDisplayId); 135 } 136 137 /** 138 * Callbacks for contextual changes that affect the screen magnification 139 * feature. 140 */ 141 public interface MagnificationCallbacks { 142 143 /** 144 * Called when the region where magnification operates changes. Note that this isn't the 145 * entire screen. For example, IMEs are not magnified. 146 * 147 * @param magnificationRegion the current magnification region 148 */ onMagnificationRegionChanged(Region magnificationRegion)149 void onMagnificationRegionChanged(Region magnificationRegion); 150 151 /** 152 * Called when an application requests a rectangle on the screen to allow 153 * the client to apply the appropriate pan and scale. 154 * 155 * @param left The rectangle left. 156 * @param top The rectangle top. 157 * @param right The rectangle right. 158 * @param bottom The rectangle bottom. 159 */ onRectangleOnScreenRequested(int left, int top, int right, int bottom)160 void onRectangleOnScreenRequested(int left, int top, int right, int bottom); 161 162 /** 163 * Notifies that the display size is changed when rotation or the 164 * logical display is changed. 165 * 166 */ onDisplaySizeChanged()167 void onDisplaySizeChanged(); 168 169 /** 170 * Notifies that the context of the user changed. For example, an application 171 * was started. 172 */ onUserContextChanged()173 void onUserContextChanged(); 174 175 /** 176 * Notifies that the IME window visibility changed. 177 * @param shown {@code true} means the IME window shows on the screen. Otherwise it's 178 * hidden. 179 */ onImeWindowVisibilityChanged(boolean shown)180 void onImeWindowVisibilityChanged(boolean shown); 181 } 182 183 /** 184 * Abstract class to be notified about {@link com.android.server.wm.AppTransition} events. Held 185 * as an abstract class so a listener only needs to implement the methods of its interest. 186 */ 187 public static abstract class AppTransitionListener { 188 189 /** 190 * Called when an app transition is being setup and about to be executed. 191 */ onAppTransitionPendingLocked()192 public void onAppTransitionPendingLocked() {} 193 194 /** 195 * Called when a pending app transition gets cancelled. 196 * 197 * @param keyguardGoingAway true if keyguard going away transition got cancelled. 198 */ onAppTransitionCancelledLocked(boolean keyguardGoingAway)199 public void onAppTransitionCancelledLocked(boolean keyguardGoingAway) {} 200 201 /** 202 * Called when an app transition is timed out. 203 */ onAppTransitionTimeoutLocked()204 public void onAppTransitionTimeoutLocked() {} 205 206 /** 207 * Called when an app transition gets started 208 * 209 * @param keyguardGoingAway true if keyguard going away transition is started. 210 * @param keyguardOccluding true if keyguard (un)occlude transition is started. 211 * @param duration the total duration of the transition 212 * @param statusBarAnimationStartTime the desired start time for all visual animations in 213 * the status bar caused by this app transition in uptime millis 214 * @param statusBarAnimationDuration the duration for all visual animations in the status 215 * bar caused by this app transition in millis 216 * 217 * @return Return any bit set of {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_LAYOUT}, 218 * {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_CONFIG}, 219 * {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_WALLPAPER}, 220 * or {@link WindowManagerPolicy#FINISH_LAYOUT_REDO_ANIM}. 221 */ onAppTransitionStartingLocked(boolean keyguardGoingAway, boolean keyguardOccluding, long duration, long statusBarAnimationStartTime, long statusBarAnimationDuration)222 public int onAppTransitionStartingLocked(boolean keyguardGoingAway, 223 boolean keyguardOccluding, long duration, long statusBarAnimationStartTime, 224 long statusBarAnimationDuration) { 225 return 0; 226 } 227 228 /** 229 * Called when an app transition is finished running. 230 * 231 * @param token the token for app whose transition has finished 232 */ onAppTransitionFinishedLocked(IBinder token)233 public void onAppTransitionFinishedLocked(IBinder token) {} 234 } 235 236 /** 237 * An interface to be notified when keyguard exit animation should start. 238 */ 239 public interface KeyguardExitAnimationStartListener { 240 /** 241 * Called when keyguard exit animation should start. 242 * @param apps The list of apps to animate. 243 * @param wallpapers The list of wallpapers to animate. 244 * @param finishedCallback The callback to invoke when the animation is finished. 245 */ onAnimationStart(RemoteAnimationTarget[] apps, RemoteAnimationTarget[] wallpapers, IRemoteAnimationFinishedCallback finishedCallback)246 void onAnimationStart(RemoteAnimationTarget[] apps, 247 RemoteAnimationTarget[] wallpapers, 248 IRemoteAnimationFinishedCallback finishedCallback); 249 } 250 251 /** 252 * An interface to be notified about hardware keyboard status. 253 */ 254 public interface OnHardKeyboardStatusChangeListener { onHardKeyboardStatusChange(boolean available)255 public void onHardKeyboardStatusChange(boolean available); 256 } 257 258 /** 259 * An interface to customize drag and drop behaviors. 260 */ 261 public interface IDragDropCallback { registerInputChannel( DragState state, Display display, InputManagerService service, InputChannel source)262 default boolean registerInputChannel( 263 DragState state, Display display, InputManagerService service, 264 InputChannel source) { 265 state.register(display); 266 return service.transferTouchFocus(source, state.getInputChannel(), 267 true /* isDragDrop */); 268 } 269 270 /** 271 * Called when drag operation is starting. 272 */ prePerformDrag(IWindow window, IBinder dragToken, int touchSource, float touchX, float touchY, float thumbCenterX, float thumbCenterY, ClipData data)273 default boolean prePerformDrag(IWindow window, IBinder dragToken, 274 int touchSource, float touchX, float touchY, float thumbCenterX, float thumbCenterY, 275 ClipData data) { 276 return true; 277 } 278 279 /** 280 * Called when drag operation is started. 281 */ postPerformDrag()282 default void postPerformDrag() {} 283 284 /** 285 * Called when drop result is being reported. 286 */ preReportDropResult(IWindow window, boolean consumed)287 default void preReportDropResult(IWindow window, boolean consumed) {} 288 289 /** 290 * Called when drop result was reported. 291 */ postReportDropResult()292 default void postReportDropResult() {} 293 294 /** 295 * Called when drag operation is being cancelled. 296 */ preCancelDragAndDrop(IBinder dragToken)297 default void preCancelDragAndDrop(IBinder dragToken) {} 298 299 /** 300 * Called when drag operation was cancelled. 301 */ postCancelDragAndDrop()302 default void postCancelDragAndDrop() {} 303 } 304 305 /** 306 * Request the interface to access features implemented by AccessibilityController. 307 */ getAccessibilityController()308 public abstract AccessibilityControllerInternal getAccessibilityController(); 309 310 /** 311 * Request that the window manager call 312 * {@link DisplayManagerInternal#performTraversalInTransactionFromWindowManager} 313 * within a surface transaction at a later time. 314 */ requestTraversalFromDisplayManager()315 public abstract void requestTraversalFromDisplayManager(); 316 317 /** 318 * Set by the accessibility layer to observe changes in the magnified region, 319 * rotation, and other window transformations related to display magnification 320 * as the window manager is responsible for doing the actual magnification 321 * and has access to the raw window data while the accessibility layer serves 322 * as a controller. 323 * 324 * @param displayId The logical display id. 325 * @param callbacks The callbacks to invoke. 326 * @return {@code false} if display id is not valid or an embedded display. 327 */ setMagnificationCallbacks(int displayId, @Nullable MagnificationCallbacks callbacks)328 public abstract boolean setMagnificationCallbacks(int displayId, 329 @Nullable MagnificationCallbacks callbacks); 330 331 /** 332 * Set by the accessibility layer to specify the magnification and panning to 333 * be applied to all windows that should be magnified. 334 * 335 * @param displayId The logical display id. 336 * @param spec The MagnficationSpec to set. 337 * 338 * @see #setMagnificationCallbacks(int, MagnificationCallbacks) 339 */ setMagnificationSpec(int displayId, MagnificationSpec spec)340 public abstract void setMagnificationSpec(int displayId, MagnificationSpec spec); 341 342 /** 343 * Set by the accessibility framework to indicate whether the magnifiable regions of the display 344 * should be shown. 345 * 346 * @param displayId The logical display id. 347 * @param show {@code true} to show magnifiable region bounds, {@code false} to hide 348 */ setForceShowMagnifiableBounds(int displayId, boolean show)349 public abstract void setForceShowMagnifiableBounds(int displayId, boolean show); 350 351 /** 352 * Obtains the magnification regions. 353 * 354 * @param displayId The logical display id. 355 * @param magnificationRegion the current magnification region 356 */ getMagnificationRegion(int displayId, @NonNull Region magnificationRegion)357 public abstract void getMagnificationRegion(int displayId, @NonNull Region magnificationRegion); 358 359 /** 360 * Gets the magnification and translation applied to a window given its token. 361 * Not all windows are magnified and the window manager policy determines which 362 * windows are magnified. The returned result also takes into account the compat 363 * scale if necessary. 364 * 365 * @param windowToken The window's token. 366 * 367 * @return The magnification spec for the window. 368 * 369 * @see #setMagnificationCallbacks(int, MagnificationCallbacks) 370 */ getCompatibleMagnificationSpecForWindow( IBinder windowToken)371 public abstract MagnificationSpec getCompatibleMagnificationSpecForWindow( 372 IBinder windowToken); 373 374 /** 375 * Sets a callback for observing which windows are touchable for the purposes 376 * of accessibility on specified display. 377 * 378 * @param displayId The logical display id. 379 * @param callback The callback. 380 * @return {@code false} if display id is not valid. 381 */ setWindowsForAccessibilityCallback(int displayId, WindowsForAccessibilityCallback callback)382 public abstract boolean setWindowsForAccessibilityCallback(int displayId, 383 WindowsForAccessibilityCallback callback); 384 385 /** 386 * Sets a filter for manipulating the input event stream. 387 * 388 * @param filter The filter implementation. 389 */ setInputFilter(IInputFilter filter)390 public abstract void setInputFilter(IInputFilter filter); 391 392 /** 393 * Gets the token of the window that has input focus. 394 * 395 * @return The token. 396 */ getFocusedWindowToken()397 public abstract IBinder getFocusedWindowToken(); 398 399 /** 400 * @return Whether the keyguard is engaged. 401 */ isKeyguardLocked()402 public abstract boolean isKeyguardLocked(); 403 404 /** 405 * @return Whether the keyguard is showing and not occluded. 406 */ isKeyguardShowingAndNotOccluded()407 public abstract boolean isKeyguardShowingAndNotOccluded(); 408 409 /** 410 * Gets the frame of a window given its token. 411 * 412 * @param token The token. 413 * @param outBounds The frame to populate. 414 */ getWindowFrame(IBinder token, Rect outBounds)415 public abstract void getWindowFrame(IBinder token, Rect outBounds); 416 417 /** 418 * Opens the global actions dialog. 419 */ showGlobalActions()420 public abstract void showGlobalActions(); 421 422 /** 423 * Invalidate all visible windows on a given display, and report back on the callback when all 424 * windows have redrawn. 425 * 426 * @param callback reporting callback to be called when all windows have redrawn. 427 * @param timeout calls the callback anyway after the timeout. 428 * @param displayId waits for the windows on the given display, INVALID_DISPLAY to wait for all 429 * windows on all displays. 430 */ waitForAllWindowsDrawn(Runnable callback, long timeout, int displayId)431 public abstract void waitForAllWindowsDrawn(Runnable callback, long timeout, int displayId); 432 433 /** 434 * Overrides the display size. 435 * 436 * @param displayId The display to override the display size. 437 * @param width The width to override. 438 * @param height The height to override. 439 */ setForcedDisplaySize(int displayId, int width, int height)440 public abstract void setForcedDisplaySize(int displayId, int width, int height); 441 442 /** 443 * Recover the display size to real display size. 444 * 445 * @param displayId The display to recover the display size. 446 */ clearForcedDisplaySize(int displayId)447 public abstract void clearForcedDisplaySize(int displayId); 448 449 /** 450 * Adds a window token for a given window type. 451 * 452 * @param token The token to add. 453 * @param type The window type. 454 * @param displayId The display to add the token to. 455 * @param options A bundle used to pass window-related options. 456 */ addWindowToken(@onNull android.os.IBinder token, int type, int displayId, @Nullable Bundle options)457 public abstract void addWindowToken(@NonNull android.os.IBinder token, int type, int displayId, 458 @Nullable Bundle options); 459 460 /** 461 * Removes a window token. 462 * 463 * @param token The toke to remove. 464 * @param removeWindows Whether to also remove the windows associated with the token. 465 * @param displayId The display to remove the token from. 466 */ removeWindowToken(android.os.IBinder token, boolean removeWindows, int displayId)467 public final void removeWindowToken(android.os.IBinder token, boolean removeWindows, 468 int displayId) { 469 removeWindowToken(token, removeWindows, true /* animateExit */, displayId); 470 } 471 472 /** 473 * Removes a window token. 474 * 475 * @param token The toke to remove. 476 * @param removeWindows Whether to also remove the windows associated with the token. 477 * @param animateExit Whether to play the windows exit animation after the token removal. 478 * @param displayId The display to remove the token from. 479 */ removeWindowToken(android.os.IBinder token, boolean removeWindows, boolean animateExit, int displayId)480 public abstract void removeWindowToken(android.os.IBinder token, boolean removeWindows, 481 boolean animateExit, int displayId); 482 483 /** 484 * Registers a listener to be notified about app transition events. 485 * 486 * @param listener The listener to register. 487 */ registerAppTransitionListener(AppTransitionListener listener)488 public abstract void registerAppTransitionListener(AppTransitionListener listener); 489 490 /** 491 * Registers a listener to be notified to start the keyguard exit animation. 492 * 493 * @param listener The listener to register. 494 */ registerKeyguardExitAnimationStartListener( KeyguardExitAnimationStartListener listener)495 public abstract void registerKeyguardExitAnimationStartListener( 496 KeyguardExitAnimationStartListener listener); 497 498 /** 499 * Reports that the password for the given user has changed. 500 */ reportPasswordChanged(int userId)501 public abstract void reportPasswordChanged(int userId); 502 503 /** 504 * Retrieves a height of input method window for given display. 505 */ getInputMethodWindowVisibleHeight(int displayId)506 public abstract int getInputMethodWindowVisibleHeight(int displayId); 507 508 /** 509 * Notifies WindowManagerService that the expected back-button behavior might have changed. 510 * 511 * <p>Only {@link com.android.server.inputmethod.InputMethodManagerService} is the expected and 512 * tested caller of this method.</p> 513 * 514 * @param dismissImeOnBackKeyPressed {@code true} if the software keyboard is shown and the back 515 * key is expected to dismiss the software keyboard. 516 */ setDismissImeOnBackKeyPressed(boolean dismissImeOnBackKeyPressed)517 public abstract void setDismissImeOnBackKeyPressed(boolean dismissImeOnBackKeyPressed); 518 519 /** 520 * Notifies WindowManagerService that the current IME window status is being changed. 521 * 522 * <p>Only {@link com.android.server.inputmethod.InputMethodManagerService} is the expected and 523 * tested caller of this method.</p> 524 * 525 * @param imeToken token to track the active input method. Corresponding IME windows can be 526 * identified by checking {@link android.view.WindowManager.LayoutParams#token}. 527 * Note that there is no guarantee that the corresponding window is already 528 * created 529 * @param imeTargetWindowToken token to identify the target window that the IME is associated 530 * with 531 */ updateInputMethodTargetWindow(@onNull IBinder imeToken, @NonNull IBinder imeTargetWindowToken)532 public abstract void updateInputMethodTargetWindow(@NonNull IBinder imeToken, 533 @NonNull IBinder imeTargetWindowToken); 534 535 /** 536 * Returns true when the hardware keyboard is available. 537 */ isHardKeyboardAvailable()538 public abstract boolean isHardKeyboardAvailable(); 539 540 /** 541 * Sets the callback listener for hardware keyboard status changes. 542 * 543 * @param listener The listener to set. 544 */ setOnHardKeyboardStatusChangeListener( OnHardKeyboardStatusChangeListener listener)545 public abstract void setOnHardKeyboardStatusChangeListener( 546 OnHardKeyboardStatusChangeListener listener); 547 548 /** 549 * Requests the window manager to resend the windows for accessibility on specified display. 550 * 551 * @param displayId Display ID to be computed its windows for accessibility 552 */ computeWindowsForAccessibility(int displayId)553 public abstract void computeWindowsForAccessibility(int displayId); 554 555 /** 556 * Called after virtual display Id is updated by 557 * {@link com.android.server.vr.Vr2dDisplay} with a specific 558 * {@param vr2dDisplayId}. 559 */ setVr2dDisplayId(int vr2dDisplayId)560 public abstract void setVr2dDisplayId(int vr2dDisplayId); 561 562 /** 563 * Sets callback to DragDropController. 564 */ registerDragDropControllerCallback(IDragDropCallback callback)565 public abstract void registerDragDropControllerCallback(IDragDropCallback callback); 566 567 /** 568 * @see android.view.IWindowManager#lockNow 569 */ lockNow()570 public abstract void lockNow(); 571 572 /** 573 * Return the user that owns the given window, {@link android.os.UserHandle#USER_NULL} if 574 * the window token is not found. 575 */ getWindowOwnerUserId(IBinder windowToken)576 public abstract int getWindowOwnerUserId(IBinder windowToken); 577 578 /** 579 * Returns {@code true} if a Window owned by {@code uid} has focus. 580 */ isUidFocused(int uid)581 public abstract boolean isUidFocused(int uid); 582 583 /** 584 * Checks whether the specified IME client has IME focus or not. 585 * 586 * @param uid UID of the process to be queried 587 * @param pid PID of the process to be queried 588 * @param displayId Display ID reported from the client. Note that this method also verifies 589 * whether the specified process is allowed to access to this display or not 590 * @return {@code true} if the IME client specified with {@code uid}, {@code pid}, and 591 * {@code displayId} has IME focus 592 */ isInputMethodClientFocus(int uid, int pid, int displayId)593 public abstract boolean isInputMethodClientFocus(int uid, int pid, int displayId); 594 595 /** 596 * Checks whether the given {@code uid} is allowed to use the given {@code displayId} or not. 597 * 598 * @param displayId Display ID to be checked 599 * @param uid UID to be checked. 600 * @return {@code true} if the given {@code uid} is allowed to use the given {@code displayId} 601 */ isUidAllowedOnDisplay(int displayId, int uid)602 public abstract boolean isUidAllowedOnDisplay(int displayId, int uid); 603 604 /** 605 * Return the display Id for given window. 606 */ getDisplayIdForWindow(IBinder windowToken)607 public abstract int getDisplayIdForWindow(IBinder windowToken); 608 609 /** 610 * @return The top focused display ID. 611 */ getTopFocusedDisplayId()612 public abstract int getTopFocusedDisplayId(); 613 614 /** 615 * @return The UI context of top focused display. 616 */ getTopFocusedDisplayUiContext()617 public abstract Context getTopFocusedDisplayUiContext(); 618 619 /** 620 * Checks if this display is configured and allowed to show system decorations. 621 */ shouldShowSystemDecorOnDisplay(int displayId)622 public abstract boolean shouldShowSystemDecorOnDisplay(int displayId); 623 624 /** 625 * Indicates the policy for how the display should show IME. 626 * 627 * @param displayId The id of the display. 628 * @return The policy for how the display should show IME. 629 */ getDisplayImePolicy(int displayId)630 public abstract @DisplayImePolicy int getDisplayImePolicy(int displayId); 631 632 /** 633 * Show IME on imeTargetWindow once IME has finished layout. 634 * 635 * @param imeTargetWindowToken token of the (IME target) window on which IME should be shown. 636 */ showImePostLayout(IBinder imeTargetWindowToken)637 public abstract void showImePostLayout(IBinder imeTargetWindowToken); 638 639 /** 640 * Hide IME using imeTargetWindow when requested. 641 * 642 * @param imeTargetWindowToken token of the (IME target) window on which IME should be hidden. 643 * @param displayId the id of the display the IME is on. 644 */ hideIme(IBinder imeTargetWindowToken, int displayId)645 public abstract void hideIme(IBinder imeTargetWindowToken, int displayId); 646 647 /** 648 * Tell window manager about a package that should not be running with high refresh rate 649 * setting until removeNonHighRefreshRatePackage is called for the same package. 650 * 651 * This must not be called again for the same package. 652 */ addNonHighRefreshRatePackage(@onNull String packageName)653 public abstract void addNonHighRefreshRatePackage(@NonNull String packageName); 654 655 /** 656 * Tell window manager to stop constraining refresh rate for the given package. 657 */ removeNonHighRefreshRatePackage(@onNull String packageName)658 public abstract void removeNonHighRefreshRatePackage(@NonNull String packageName); 659 660 /** 661 * Checks if the device supports touch or faketouch. 662 */ isTouchOrFaketouchDevice()663 public abstract boolean isTouchOrFaketouchDevice(); 664 665 /** 666 * Returns the info associated with the input token used to determine if a key should be 667 * intercepted. This info can be accessed without holding the global wm lock. 668 */ 669 public abstract @Nullable KeyInterceptionInfo getKeyInterceptionInfoFromToken(IBinder inputToken)670 getKeyInterceptionInfoFromToken(IBinder inputToken); 671 672 /** 673 * Clears the snapshot cache of running activities so they show the splash-screen 674 * the next time the activities are opened. 675 */ clearSnapshotCache()676 public abstract void clearSnapshotCache(); 677 678 /** 679 * Assigns accessibility ID a window surface as a layer metadata. 680 */ setAccessibilityIdToSurfaceMetadata( IBinder windowToken, int accessibilityWindowId)681 public abstract void setAccessibilityIdToSurfaceMetadata( 682 IBinder windowToken, int accessibilityWindowId); 683 684 /** 685 * 686 * Returns the window name associated to the given binder. 687 * 688 * @param binder The {@link IBinder} object 689 * @return The corresponding {@link WindowState#getName()} 690 */ getWindowName(@onNull IBinder binder)691 public abstract String getWindowName(@NonNull IBinder binder); 692 693 /** 694 * The callback after the request of show/hide input method is sent. 695 * 696 * @param show Whether to show or hide input method. 697 * @param focusedToken The token of focused window. 698 * @param requestToken The token of window who requests the change. 699 * @param displayId The ID of the display which input method is currently focused. 700 * @return The information of the input method target. 701 */ onToggleImeRequested(boolean show, @NonNull IBinder focusedToken, @NonNull IBinder requestToken, int displayId)702 public abstract ImeTargetInfo onToggleImeRequested(boolean show, 703 @NonNull IBinder focusedToken, @NonNull IBinder requestToken, int displayId); 704 705 /** The information of input method target when IME is requested to show or hide. */ 706 public static class ImeTargetInfo { 707 public final String focusedWindowName; 708 public final String requestWindowName; 709 710 /** The window name of IME Insets control target. */ 711 public final String imeControlTargetName; 712 713 /** 714 * The current window name of the input method is on top of. 715 * <p> 716 * Note that the concept of this window is only used to reparent the target window behind 717 * the input method window, it may be different from the window reported by 718 * {@link com.android.server.inputmethod.InputMethodManagerService#reportStartInput} which 719 * has input connection. 720 */ 721 public final String imeLayerTargetName; 722 ImeTargetInfo(String focusedWindowName, String requestWindowName, String imeControlTargetName, String imeLayerTargetName)723 public ImeTargetInfo(String focusedWindowName, String requestWindowName, 724 String imeControlTargetName, String imeLayerTargetName) { 725 this.focusedWindowName = focusedWindowName; 726 this.requestWindowName = requestWindowName; 727 this.imeControlTargetName = imeControlTargetName; 728 this.imeLayerTargetName = imeLayerTargetName; 729 } 730 } 731 732 /** 733 * Moves the {@link WindowToken} {@code binder} to the display specified by {@code displayId}. 734 */ moveWindowTokenToDisplay(IBinder binder, int displayId)735 public abstract void moveWindowTokenToDisplay(IBinder binder, int displayId); 736 737 /** 738 * Checks whether the given window should restore the last IME visibility. 739 * 740 * @param imeTargetWindowToken The token of the (IME target) window 741 * @return {@code true} when the system allows to restore the IME visibility, 742 * {@code false} otherwise. 743 */ shouldRestoreImeVisibility(IBinder imeTargetWindowToken)744 public abstract boolean shouldRestoreImeVisibility(IBinder imeTargetWindowToken); 745 } 746