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.IShortcutService;
22 
23 import android.app.IAssistDataReceiver;
24 import android.content.res.CompatibilityInfo;
25 import android.content.res.Configuration;
26 import android.graphics.Bitmap;
27 import android.graphics.GraphicBuffer;
28 import android.graphics.Insets;
29 import android.graphics.Point;
30 import android.graphics.Rect;
31 import android.graphics.Region;
32 import android.os.Bundle;
33 import android.os.IRemoteCallback;
34 import android.os.ParcelFileDescriptor;
35 import android.view.DisplayCutout;
36 import android.view.IApplicationToken;
37 import android.view.IAppTransitionAnimationSpecsFuture;
38 import android.view.ICrossWindowBlurEnabledListener;
39 import android.view.IDisplayWindowInsetsController;
40 import android.view.IDisplayWindowListener;
41 import android.view.IDisplayFoldListener;
42 import android.view.IDisplayWindowRotationController;
43 import android.view.IOnKeyguardExitResult;
44 import android.view.IPinnedTaskListener;
45 import android.view.IScrollCaptureResponseListener;
46 import android.view.RemoteAnimationAdapter;
47 import android.view.IRotationWatcher;
48 import android.view.ISystemGestureExclusionListener;
49 import android.view.IWallpaperVisibilityListener;
50 import android.view.IWindow;
51 import android.view.IWindowSession;
52 import android.view.IWindowSessionCallback;
53 import android.view.KeyEvent;
54 import android.view.InputEvent;
55 import android.view.InsetsState;
56 import android.view.InsetsVisibilities;
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 
70 /**
71  * System private interface to the window manager.
72  *
73  * {@hide}
74  */
75 interface IWindowManager
76 {
77     /**
78      * No overridden behavior is provided in terms of fixing rotation to user rotation. Use
79      * other flags to derive the default behavior, such as {@link WindowManagerService#mIsPc}
80      * and {@link WindowManagerService#mForceDesktopModeOnExternalDisplays}.
81      */
82     const int FIXED_TO_USER_ROTATION_DEFAULT = 0;
83     /**
84      * Don't fix display rotation to {@link DisplayRotation#mUserRotation} only. Always allow
85      * other factors to play a role in deciding display rotation.
86      */
87     const int FIXED_TO_USER_ROTATION_DISABLED = 1;
88     /**
89      * Only use {@link DisplayRotation#mUserRotation} as the display rotation.
90      */
91     const int FIXED_TO_USER_ROTATION_ENABLED = 2;
92 
93     /**
94      * ===== NOTICE =====
95      * The first three methods must remain the first three methods. Scripts
96      * and tools rely on their transaction number to work properly.
97      */
98     // This is used for debugging
startViewServer(int port)99     boolean startViewServer(int port);   // Transaction #1
stopViewServer()100     boolean stopViewServer();            // Transaction #2
isViewServerRunning()101     boolean isViewServerRunning();       // Transaction #3
102 
openSession(in IWindowSessionCallback callback)103     IWindowSession openSession(in IWindowSessionCallback callback);
104 
useBLAST()105     boolean useBLAST();
106 
107     @UnsupportedAppUsage
getInitialDisplaySize(int displayId, out Point size)108     void getInitialDisplaySize(int displayId, out Point size);
109     @UnsupportedAppUsage
getBaseDisplaySize(int displayId, out Point size)110     void getBaseDisplaySize(int displayId, out Point size);
setForcedDisplaySize(int displayId, int width, int height)111     void setForcedDisplaySize(int displayId, int width, int height);
clearForcedDisplaySize(int displayId)112     void clearForcedDisplaySize(int displayId);
113     @UnsupportedAppUsage
getInitialDisplayDensity(int displayId)114     int getInitialDisplayDensity(int displayId);
getBaseDisplayDensity(int displayId)115     int getBaseDisplayDensity(int displayId);
setForcedDisplayDensityForUser(int displayId, int density, int userId)116     void setForcedDisplayDensityForUser(int displayId, int density, int userId);
clearForcedDisplayDensityForUser(int displayId, int userId)117     void clearForcedDisplayDensityForUser(int displayId, int userId);
setForcedDisplayScalingMode(int displayId, int mode)118     void setForcedDisplayScalingMode(int displayId, int mode); // 0 = auto, 1 = disable
119 
120     // These can only be called when holding the MANAGE_APP_TOKENS permission.
setEventDispatching(boolean enabled)121     void setEventDispatching(boolean enabled);
122 
123     /** Returns {@code true} if this binder is a registered window token. */
isWindowToken(in IBinder binder)124     boolean isWindowToken(in IBinder binder);
125     /**
126      * Adds window token for a given type.
127      *
128      * @param token Token to be registered.
129      * @param type Window type to be used with this token.
130      * @param displayId The ID of the display where this token should be added.
131      * @param options A bundle used to pass window-related options.
132      */
addWindowToken(IBinder token, int type, int displayId, in Bundle options)133     void addWindowToken(IBinder token, int type, int displayId, in Bundle options);
134     /**
135      * Remove window token on a specific display.
136      *
137      * @param token Token to be removed
138      * @displayId The ID of the display where this token should be removed.
139      */
removeWindowToken(IBinder token, int displayId)140     void removeWindowToken(IBinder token, int displayId);
141 
142     /**
143      * Sets a singular remote controller of display rotations. There can only be one. The
144      * controller is called after the display has "frozen" for a rotation and display rotation will
145      * only continue once the controller has finished calculating associated configurations.
146      */
setDisplayWindowRotationController(IDisplayWindowRotationController controller)147     void setDisplayWindowRotationController(IDisplayWindowRotationController controller);
148 
149     /**
150      * Adds a root container that a client shell can populate with its own windows (usually via
151      * WindowlessWindowManager).
152      *
153      * @param client an IWindow used for window-level communication (ime, finish draw, etc.).
154      * @param shellRootLayer The container's layer. See WindowManager#ShellRootLayer.
155      * @return a SurfaceControl to add things to.
156      */
addShellRoot(int displayId, IWindow client, int shellRootLayer)157     SurfaceControl addShellRoot(int displayId, IWindow client, int shellRootLayer);
158 
159     /**
160      * Sets the window token sent to accessibility for a particular shell root. The
161      * displayId and windowType identify which shell-root to update.
162      *
163      * @param target The IWindow that accessibility service interfaces with.
164      */
setShellRootAccessibilityWindow(int displayId, int shellRootLayer, IWindow target)165     void setShellRootAccessibilityWindow(int displayId, int shellRootLayer, IWindow target);
166 
167     /**
168      * Like overridePendingAppTransitionMultiThumb, but uses a future to supply the specs. This is
169      * used for recents, where generating the thumbnails of the specs takes a non-trivial amount of
170      * time, so we want to move that off the critical path for starting the new activity.
171      */
172     @UnsupportedAppUsage
overridePendingAppTransitionMultiThumbFuture( IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback startedCallback, boolean scaleUp, int displayId)173     void overridePendingAppTransitionMultiThumbFuture(
174             IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback startedCallback,
175             boolean scaleUp, int displayId);
176     @UnsupportedAppUsage
overridePendingAppTransitionRemote(in RemoteAnimationAdapter remoteAnimationAdapter, int displayId)177     void overridePendingAppTransitionRemote(in RemoteAnimationAdapter remoteAnimationAdapter,
178             int displayId);
179 
180     /**
181       * Used by system ui to report that recents has shown itself.
182       * @deprecated to be removed once prebuilts are updated
183       */
184     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
endProlongedAnimations()185     void endProlongedAnimations();
186 
startFreezingScreen(int exitAnim, int enterAnim)187     void startFreezingScreen(int exitAnim, int enterAnim);
stopFreezingScreen()188     void stopFreezingScreen();
189 
190     // these require DISABLE_KEYGUARD permission
191     /** @deprecated use Activity.setShowWhenLocked instead. */
disableKeyguard(IBinder token, String tag, int userId)192     void disableKeyguard(IBinder token, String tag, int userId);
193     /** @deprecated use Activity.setShowWhenLocked instead. */
reenableKeyguard(IBinder token, int userId)194     void reenableKeyguard(IBinder token, int userId);
exitKeyguardSecurely(IOnKeyguardExitResult callback)195     void exitKeyguardSecurely(IOnKeyguardExitResult callback);
196     @UnsupportedAppUsage
isKeyguardLocked()197     boolean isKeyguardLocked();
198     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
isKeyguardSecure(int userId)199     boolean isKeyguardSecure(int userId);
dismissKeyguard(IKeyguardDismissCallback callback, CharSequence message)200     void dismissKeyguard(IKeyguardDismissCallback callback, CharSequence message);
201 
202     // Requires INTERACT_ACROSS_USERS_FULL permission
setSwitchingUser(boolean switching)203     void setSwitchingUser(boolean switching);
204 
closeSystemDialogs(String reason)205     void closeSystemDialogs(String reason);
206 
207     // These can only be called with the SET_ANIMATON_SCALE permission.
208     @UnsupportedAppUsage
getAnimationScale(int which)209     float getAnimationScale(int which);
210     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
getAnimationScales()211     float[] getAnimationScales();
212     @UnsupportedAppUsage
setAnimationScale(int which, float scale)213     void setAnimationScale(int which, float scale);
214     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setAnimationScales(in float[] scales)215     void setAnimationScales(in float[] scales);
216 
getCurrentAnimatorScale()217     float getCurrentAnimatorScale();
218 
219     // For testing
220     @UnsupportedAppUsage(maxTargetSdk = 28)
setInTouchMode(boolean showFocus)221     void setInTouchMode(boolean showFocus);
222 
223     // For StrictMode flashing a red border on violations from the UI
224     // thread.  The uid/pid is implicit from the Binder call, and the Window
225     // Manager uses that to determine whether or not the red border should
226     // actually be shown.  (it will be ignored that pid doesn't have windows
227     // on screen)
228     @UnsupportedAppUsage(maxTargetSdk = 28)
showStrictModeViolation(boolean on)229     void showStrictModeViolation(boolean on);
230 
231     // Proxy to set the system property for whether the flashing
232     // should be enabled.  The 'enabled' value is null or blank for
233     // the system default (differs per build variant) or any valid
234     // boolean string as parsed by SystemProperties.getBoolean().
235     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
setStrictModeVisualIndicatorPreference(String enabled)236     void setStrictModeVisualIndicatorPreference(String enabled);
237 
238     /**
239      * Set whether screen capture is disabled for all windows of a specific user from
240      * the device policy cache.
241      */
refreshScreenCaptureDisabled(int userId)242     void refreshScreenCaptureDisabled(int userId);
243 
244     // These can only be called with the SET_ORIENTATION permission.
245     /**
246      * Update the current screen rotation based on the current state of
247      * the world.
248      * @param alwaysSendConfiguration Flag to force a new configuration to
249      * be evaluated.  This can be used when there are other parameters in
250      * configuration that are changing.
251      * @param forceRelayout If true, the window manager will always do a relayout
252      * of its windows even if the rotation hasn't changed.
253      */
updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout)254     void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout);
255 
256     /**
257      * Retrieve the current orientation of the primary screen.
258      * @return Constant as per {@link android.view.Surface.Rotation}.
259      *
260      * @see android.view.Display#DEFAULT_DISPLAY
261      */
getDefaultDisplayRotation()262     int getDefaultDisplayRotation();
263 
264     /**
265      * Watch the rotation of the specified screen.  Returns the current rotation,
266      * calls back when it changes.
267      */
watchRotation(IRotationWatcher watcher, int displayId)268     int watchRotation(IRotationWatcher watcher, int displayId);
269 
270     /**
271      * Remove a rotation watcher set using watchRotation.
272      * @hide
273      */
274     @UnsupportedAppUsage
removeRotationWatcher(IRotationWatcher watcher)275     void removeRotationWatcher(IRotationWatcher watcher);
276 
277     /**
278      * Determine the preferred edge of the screen to pin the compact options menu against.
279      *
280      * @param displayId Id of the display where the menu window currently resides.
281      * @return a Gravity value for the options menu panel.
282      * @hide
283      */
getPreferredOptionsPanelGravity(int displayId)284     int getPreferredOptionsPanelGravity(int displayId);
285 
286     /**
287      * Equivalent to calling {@link #freezeDisplayRotation(int, int)} with {@link
288      * android.view.Display#DEFAULT_DISPLAY} and given rotation.
289      */
290     @UnsupportedAppUsage
freezeRotation(int rotation)291     void freezeRotation(int rotation);
292 
293     /**
294      * Equivalent to calling {@link #thawDisplayRotation(int)} with {@link
295      * android.view.Display#DEFAULT_DISPLAY}.
296      */
297     @UnsupportedAppUsage
thawRotation()298     void thawRotation();
299 
300     /**
301      * Equivelant to call {@link #isDisplayRotationFrozen(int)} with {@link
302      * android.view.Display#DEFAULT_DISPLAY}.
303      */
isRotationFrozen()304     boolean isRotationFrozen();
305 
306     /**
307      * Lock the display orientation to the specified rotation, or to the current
308      * rotation if -1. Sensor input will be ignored until thawRotation() is called.
309      *
310      * @param displayId the ID of display which rotation should be frozen.
311      * @param rotation one of {@link android.view.Surface#ROTATION_0},
312      *        {@link android.view.Surface#ROTATION_90}, {@link android.view.Surface#ROTATION_180},
313      *        {@link android.view.Surface#ROTATION_270} or -1 to freeze it to current rotation.
314      * @hide
315      */
freezeDisplayRotation(int displayId, int rotation)316     void freezeDisplayRotation(int displayId, int rotation);
317 
318     /**
319      * Release the orientation lock imposed by freezeRotation() on the display.
320      *
321      * @param displayId the ID of display which rotation should be thawed.
322      * @hide
323      */
thawDisplayRotation(int displayId)324     void thawDisplayRotation(int displayId);
325 
326     /**
327      * Gets whether the rotation is frozen on the display.
328      *
329      * @param displayId the ID of display which frozen is needed.
330      * @return Whether the rotation is frozen.
331      */
isDisplayRotationFrozen(int displayId)332     boolean isDisplayRotationFrozen(int displayId);
333 
334    /**
335     *  Sets if display rotation is fixed to user specified value for given displayId.
336     */
setFixedToUserRotation(int displayId, int fixedToUserRotation)337     void setFixedToUserRotation(int displayId, int fixedToUserRotation);
338 
339    /**
340     *  Sets if all requested fixed orientation should be ignored for given displayId.
341     */
setIgnoreOrientationRequest(int displayId, boolean ignoreOrientationRequest)342     void setIgnoreOrientationRequest(int displayId, boolean ignoreOrientationRequest);
343 
344     /**
345      * Screenshot the current wallpaper layer, including the whole screen.
346      */
screenshotWallpaper()347     Bitmap screenshotWallpaper();
348 
349     /**
350      * Mirrors the wallpaper for the given display.
351      *
352      * @param displayId ID of the display for the wallpaper.
353      * @return A SurfaceControl for the parent of the mirrored wallpaper.
354      */
mirrorWallpaperSurface(int displayId)355     SurfaceControl mirrorWallpaperSurface(int displayId);
356 
357     /**
358      * Registers a wallpaper visibility listener.
359      * @return Current visibility.
360      */
registerWallpaperVisibilityListener(IWallpaperVisibilityListener listener, int displayId)361     boolean registerWallpaperVisibilityListener(IWallpaperVisibilityListener listener,
362         int displayId);
363 
364     /**
365      * Remove a visibility watcher that was added using registerWallpaperVisibilityListener.
366      */
unregisterWallpaperVisibilityListener(IWallpaperVisibilityListener listener, int displayId)367     void unregisterWallpaperVisibilityListener(IWallpaperVisibilityListener listener,
368         int displayId);
369 
370     /**
371      * Registers a system gesture exclusion listener for a given display.
372      */
registerSystemGestureExclusionListener(ISystemGestureExclusionListener listener, int displayId)373     void registerSystemGestureExclusionListener(ISystemGestureExclusionListener listener,
374         int displayId);
375 
376     /**
377      * Unregisters a system gesture exclusion listener for a given display.
378      */
unregisterSystemGestureExclusionListener(ISystemGestureExclusionListener listener, int displayId)379     void unregisterSystemGestureExclusionListener(ISystemGestureExclusionListener listener,
380         int displayId);
381 
382     /**
383      * Used only for assist -- request a screenshot of the current application.
384      */
requestAssistScreenshot(IAssistDataReceiver receiver)385     boolean requestAssistScreenshot(IAssistDataReceiver receiver);
386 
387     /**
388      * Called by System UI to notify Window Manager to hide transient bars.
389      */
hideTransientBars(int displayId)390     oneway void hideTransientBars(int displayId);
391 
392     /**
393      * Called by System UI to notify of changes to the visibility of Recents.
394      */
setRecentsVisibility(boolean visible)395     oneway void setRecentsVisibility(boolean visible);
396 
397     /**
398     * Called by System UI to indicate the maximum bounds of the system Privacy Indicator, for the
399     * current orientation, whether the indicator is showing or not. Should be an array of length
400     * 4, with the bounds for ROTATION_0, 90, 180, and 270, in that order.
401     */
updateStaticPrivacyIndicatorBounds(int displayId, in Rect[] staticBounds)402      oneway void updateStaticPrivacyIndicatorBounds(int displayId, in Rect[] staticBounds);
403 
404     /**
405      * Called by System UI to enable or disable haptic feedback on the navigation bar buttons.
406      */
407     @UnsupportedAppUsage
setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled)408     void setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled);
409 
410     /**
411      * Device has a software navigation bar (separate from the status bar) on specific display.
412      *
413      * @param displayId the id of display to check if there is a software navigation bar.
414      */
415     @UnsupportedAppUsage
hasNavigationBar(int displayId)416     boolean hasNavigationBar(int displayId);
417 
418     /**
419      * Get the position of the nav bar
420      */
getNavBarPosition(int displayId)421     int getNavBarPosition(int displayId);
422 
423     /**
424      * Lock the device immediately with the specified options (can be null).
425      */
426     @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
lockNow(in Bundle options)427     void lockNow(in Bundle options);
428 
429     /**
430      * Device is in safe mode.
431      */
432     @UnsupportedAppUsage
isSafeModeEnabled()433     boolean isSafeModeEnabled();
434 
435     /**
436      * Enables the screen if all conditions are met.
437      */
enableScreenIfNeeded()438     void enableScreenIfNeeded();
439 
440     /**
441      * Clears the frame statistics for a given window.
442      *
443      * @param token The window token.
444      * @return Whether the frame statistics were cleared.
445      */
clearWindowContentFrameStats(IBinder token)446     boolean clearWindowContentFrameStats(IBinder token);
447 
448     /**
449      * Gets the content frame statistics for a given window.
450      *
451      * @param token The window token.
452      * @return The frame statistics or null if the window does not exist.
453      */
getWindowContentFrameStats(IBinder token)454     WindowContentFrameStats getWindowContentFrameStats(IBinder token);
455 
456     /**
457      * This is a no-op.
458      */
459     @UnsupportedAppUsage
getDockedStackSide()460     int getDockedStackSide();
461 
462     /**
463      * Sets the region the user can touch the divider. This region will be excluded from the region
464      * which is used to cause a focus switch when dispatching touch.
465      */
setDockedTaskDividerTouchRegion(in Rect touchableRegion)466     void setDockedTaskDividerTouchRegion(in Rect touchableRegion);
467 
468     /**
469      * Registers a listener that will be called when the pinned task state changes.
470      */
registerPinnedTaskListener(int displayId, IPinnedTaskListener listener)471     void registerPinnedTaskListener(int displayId, IPinnedTaskListener listener);
472 
473     /**
474      * Requests Keyboard Shortcuts from the displayed window.
475      *
476      * @param receiver The receiver to deliver the results to.
477      */
requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId)478     void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId);
479 
480     /**
481      * Retrieves the current stable insets from the primary display.
482      */
483     @UnsupportedAppUsage
getStableInsets(int displayId, out Rect outInsets)484     void getStableInsets(int displayId, out Rect outInsets);
485 
486     /**
487      * Set the forwarded insets on the display.
488      * <p>
489      * This is only used in case a virtual display is displayed on another display that has insets,
490      * and the bounds of the virtual display is overlapping with the insets from the host display.
491      * In that case, the contents on the virtual display won't be placed over the forwarded insets.
492      * Only the owner of the display is permitted to set the forwarded insets on it.
493      */
setForwardedInsets(int displayId, in Insets insets)494     void setForwardedInsets(int displayId, in Insets insets);
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      * Returns true if window trace is enabled.
555      */
isWindowTraceEnabled()556     boolean isWindowTraceEnabled();
557 
558     /**
559      * Notify WindowManager that it should not override the info in DisplayManager for the specified
560      * display. This can disable letter- or pillar-boxing applied in DisplayManager when the metrics
561      * of the logical display reported from WindowManager do not correspond to the metrics of the
562      * physical display it is based on.
563      *
564      * @param displayId The id of the display.
565      */
dontOverrideDisplayInfo(int displayId)566     void dontOverrideDisplayInfo(int displayId);
567 
568     /**
569      * Gets the windowing mode of the display.
570      *
571      * @param displayId The id of the display.
572      * @return {@link WindowConfiguration.WindowingMode}
573      */
getWindowingMode(int displayId)574     int getWindowingMode(int displayId);
575 
576     /**
577      * Sets the windowing mode of the display.
578      *
579      * @param displayId The id of the display.
580      * @param mode {@link WindowConfiguration.WindowingMode}
581      */
setWindowingMode(int displayId, int mode)582     void setWindowingMode(int displayId, int mode);
583 
584     /**
585      * Gets current remove content mode of the display.
586      * <p>
587      * What actions should be performed with the display's content when it is removed. Default
588      * behavior for public displays in this case is to move all activities to the primary display
589      * and make it focused. For private display is to destroy all activities.
590      * </p>
591      *
592      * @param displayId The id of the display.
593      * @return The remove content mode of the display.
594      * @see WindowManager#REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY
595      * @see WindowManager#REMOVE_CONTENT_MODE_DESTROY
596      */
getRemoveContentMode(int displayId)597     int getRemoveContentMode(int displayId);
598 
599     /**
600      * Sets the remove content mode of the display.
601      * <p>
602      * This mode indicates what actions should be performed with the display's content when it is
603      * removed.
604      * </p>
605      *
606      * @param displayId The id of the display.
607      * @param mode Remove content mode.
608      * @see WindowManager#REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY
609      * @see WindowManager#REMOVE_CONTENT_MODE_DESTROY
610      */
setRemoveContentMode(int displayId, int mode)611     void setRemoveContentMode(int displayId, int mode);
612 
613     /**
614      * Indicates that the display should show its content when non-secure keyguard is shown.
615      * <p>
616      * This flag identifies secondary displays that will continue showing content if keyguard can be
617      * dismissed without entering credentials.
618      * </p><p>
619      * An example of usage is a virtual display which content is displayed on external hardware
620      * display that is not visible to the system directly.
621      * </p>
622      *
623      * @param displayId The id of the display.
624      * @return {@code true} if the display should show its content when non-secure keyguard is
625      *         shown.
626      * @see KeyguardManager#isDeviceSecure()
627      * @see KeyguardManager#isDeviceLocked()
628      */
shouldShowWithInsecureKeyguard(int displayId)629     boolean shouldShowWithInsecureKeyguard(int displayId);
630 
631     /**
632      * Sets that the display should show its content when non-secure keyguard is shown.
633      *
634      * @param displayId The id of the display.
635      * @param shouldShow Indicates that the display should show its content when non-secure keyguard
636      *                  is shown.
637      * @see KeyguardManager#isDeviceSecure()
638      * @see KeyguardManager#isDeviceLocked()
639      */
setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow)640     void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow);
641 
642     /**
643      * Indicates the display should show system decors.
644      * <p>
645      * System decors include status bar, navigation bar, launcher.
646      * </p>
647      *
648      * @param displayId The id of the display.
649      * @return {@code true} if the display should show system decors.
650      */
shouldShowSystemDecors(int displayId)651     boolean shouldShowSystemDecors(int displayId);
652 
653     /**
654      * Sets that the display should show system decors.
655      * <p>
656      * System decors include status bar, navigation bar, launcher.
657      * </p>
658      *
659      * @param displayId The id of the display.
660      * @param shouldShow Indicates that the display should show system decors.
661      */
setShouldShowSystemDecors(int displayId, boolean shouldShow)662     void setShouldShowSystemDecors(int displayId, boolean shouldShow);
663 
664     /**
665      * Indicates the policy for how the display should show IME.
666      *
667      * @param displayId The id of the display.
668      * @return The policy for how the display should show IME.
669      * @see KeyguardManager#isDeviceSecure()
670      * @see KeyguardManager#isDeviceLocked()
671      */
getDisplayImePolicy(int displayId)672     int getDisplayImePolicy(int displayId);
673 
674     /**
675      * Sets the policy for how the display should show IME.
676      *
677      * @param displayId The id of the display.
678      * @param imePolicy Indicates the policy for how the display should show IME.
679      * @see KeyguardManager#isDeviceSecure()
680      * @see KeyguardManager#isDeviceLocked()
681      */
setDisplayImePolicy(int displayId, int imePolicy)682     void setDisplayImePolicy(int displayId, int imePolicy);
683 
684     /**
685      * Waits for transactions to get applied before injecting input, optionally waiting for
686      * animations to complete. This includes waiting for the input windows to get sent to
687      * InputManager.
688      *
689      * This is needed for testing since the system add windows and injects input
690      * quick enough that the windows don't have time to get sent to InputManager.
691      */
injectInputAfterTransactionsApplied(in InputEvent ev, int mode, boolean waitForAnimations)692     boolean injectInputAfterTransactionsApplied(in InputEvent ev, int mode,
693             boolean waitForAnimations);
694 
695     /**
696      * Waits until input information has been sent from WindowManager to native InputManager,
697      * optionally waiting for animations to complete.
698      *
699      * This is needed for testing since we need to ensure input information has been propagated to
700      * native InputManager before proceeding with tests.
701      */
syncInputTransactions(boolean waitForAnimations)702     void syncInputTransactions(boolean waitForAnimations);
703 
704     /**
705      * Returns whether SurfaceFlinger layer tracing is enabled.
706      */
isLayerTracing()707     boolean isLayerTracing();
708 
709     /**
710      * Enables/disables SurfaceFlinger layer tracing.
711      */
setLayerTracing(boolean enabled)712     void setLayerTracing(boolean enabled);
713 
714     /**
715      * Mirrors a specified display. The root of the mirrored hierarchy will be stored in
716      * outSurfaceControl.
717      * Requires the ACCESS_SURFACE_FLINGER permission.
718      *
719      * @param displayId The id of the display to mirror
720      * @param outSurfaceControl The SurfaceControl for the root of the mirrored hierarchy.
721      *
722      * @return true if the display was successfully mirrored.
723      */
mirrorDisplay(int displayId, out SurfaceControl outSurfaceControl)724     boolean mirrorDisplay(int displayId, out SurfaceControl outSurfaceControl);
725 
726     /**
727      * When in multi-window mode, the provided displayWindowInsetsController will control insets
728      * animations.
729      */
setDisplayWindowInsetsController( int displayId, in IDisplayWindowInsetsController displayWindowInsetsController)730     void setDisplayWindowInsetsController(
731             int displayId, in IDisplayWindowInsetsController displayWindowInsetsController);
732 
733     /**
734      * Called when a remote process updates the requested visibilities of insets on a display window
735      * container.
736      */
updateDisplayWindowRequestedVisibilities(int displayId, in InsetsVisibilities vis)737     void updateDisplayWindowRequestedVisibilities(int displayId, in InsetsVisibilities vis);
738 
739     /**
740      * Called to get the expected window insets.
741      *
742      * @return {@code true} if system bars are always consumed.
743      */
getWindowInsets(in WindowManager.LayoutParams attrs, int displayId, out InsetsState outInsetsState)744     boolean getWindowInsets(in WindowManager.LayoutParams attrs, int displayId,
745             out InsetsState outInsetsState);
746 
747     /**
748      * Called to show global actions.
749      */
showGlobalActions()750     void showGlobalActions();
751 
752     /**
753      * Sets layer tracing flags for SurfaceFlingerTrace.
754      *
755      * @param flags see definition in SurfaceTracing.cpp
756      */
setLayerTracingFlags(int flags)757     void setLayerTracingFlags(int flags);
758 
759     /**
760      * Forwards a scroll capture request to the appropriate window, if available.
761      *
762      * @param displayId the id of the display to target
763      * @param behindClient token for a window, used to filter the search to windows behind it, or
764      *                     {@code null} to accept a window at any zOrder
765      * @param taskId specifies the id of a task the result must belong to, or -1 to ignore task ids
766      * @param listener the object to receive the response
767      */
requestScrollCapture(int displayId, IBinder behindClient, int taskId, IScrollCaptureResponseListener listener)768     void requestScrollCapture(int displayId, IBinder behindClient, int taskId,
769             IScrollCaptureResponseListener listener);
770 
771     /**
772      * Holds the WM lock for the specified amount of milliseconds.
773      * Intended for use by the tests that need to imitate lock contention.
774      * The token should be obtained by
775      * {@link android.content.pm.PackageManager#getHoldLockToken()}.
776      */
holdLock(in IBinder token, in int durationMs)777     void holdLock(in IBinder token, in int durationMs);
778 
779     /**
780      * Gets an array of support hash algorithms that can be used to generate a DisplayHash. The
781      * String value of one algorithm should be used when requesting to generate
782      * the DisplayHash.
783      *
784      * @return a String array of supported hash algorithms.
785      */
getSupportedDisplayHashAlgorithms()786     String[] getSupportedDisplayHashAlgorithms();
787 
788     /**
789      * Validate the DisplayHash was generated by the system. The DisplayHash passed in should be
790      * the object generated when calling {@link IWindowSession#generateDisplayHash}
791      *
792      * @param DisplayHash The hash to verify that it was generated by the system.
793      * @return a {@link VerifiedDisplayHash} if the hash was generated by the system or null
794      * if the token cannot be verified.
795      */
verifyDisplayHash(in DisplayHash displayHash)796     VerifiedDisplayHash verifyDisplayHash(in DisplayHash displayHash);
797 
798     /**
799      * Call to enable or disable the throttling when generating a display hash. This should only be
800      * used for testing. Throttling is enabled by default.
801      *
802      * Must be called from a process that has {@link android.Manifest.permission#READ_FRAME_BUFFER}
803      * permission.
804      */
setDisplayHashThrottlingEnabled(boolean enable)805      void setDisplayHashThrottlingEnabled(boolean enable);
806 
807     /**
808      * Attaches a {@link android.window.WindowContext} to the DisplayArea specified by {@code type},
809      * {@code displayId} and {@code options}.
810      * <p>
811      * Note that this API should be invoked after calling
812      * {@link android.window.WindowTokenClient#attachContext(Context)}
813      * </p><p>
814      * Generally, this API is used for initializing a {@link android.window.WindowContext}
815      * before obtaining a valid {@link com.android.server.wm.WindowToken}. A WindowToken is usually
816      * generated when calling {@link android.view.WindowManager#addView(View, LayoutParams)}, or
817      * obtained from {@link android.view.WindowManager.LayoutParams#token}.
818      * </p><p>
819      * In some cases, the WindowToken is passed from the server side because it is managed by the
820      * system server. {@link #attachWindowContextToWindowToken(IBinder, IBinder)} could be used in
821      * this case to attach the WindowContext to the WindowToken.</p>
822      *
823      * @param clientToken {@link android.window.WindowContext#getWindowContextToken()
824      * the WindowContext's token}
825      * @param type Window type of the window context
826      * @param displayId The display associated with the window context
827      * @param options A bundle used to pass window-related options and choose the right DisplayArea
828      *
829      * @return the DisplayArea's {@link android.app.res.Configuration} if the WindowContext is
830      * attached to the DisplayArea successfully. {@code null}, otherwise.
831      */
attachWindowContextToDisplayArea(IBinder clientToken, int type, int displayId, in Bundle options)832     Configuration attachWindowContextToDisplayArea(IBinder clientToken, int type, int displayId,
833             in Bundle options);
834 
835     /**
836      * Attaches a {@link android.window.WindowContext} to a {@code WindowToken}.
837      * <p>
838      * This API is used when we hold a valid WindowToken and want to associate with the token and
839      * receive its configuration updates.
840      * </p><p>
841      * Note that this API should be invoked after calling
842      * {@link android.window.WindowTokenClient#attachContext(Context)}
843      * </p>
844      *
845      * @param clientToken {@link android.window.WindowContext#getWindowContextToken()
846      * the WindowContext's token}
847      * @param token the WindowToken to attach
848      *
849      * @throws IllegalArgumentException if the {@code clientToken} have not been attached to
850      * the server or the WindowContext's type doesn't match WindowToken {@code token}'s type.
851      *
852      * @see #attachWindowContextToDisplayArea(IBinder, int, int, Bundle)
853      */
attachWindowContextToWindowToken(IBinder clientToken, IBinder token)854     void attachWindowContextToWindowToken(IBinder clientToken, IBinder token);
855 
856     /**
857      * Attaches a {@code clientToken} to associate with DisplayContent.
858      * <p>
859      * Note that this API should be invoked after calling
860      * {@link android.window.WindowTokenClient#attachContext(Context)}
861      * </p>
862      *
863      * @param clientToken {@link android.window.WindowContext#getWindowContextToken()
864      * the WindowContext's token}
865      * @param displayId The display associated with the window context
866      *
867      * @return the DisplayContent's {@link android.app.res.Configuration} if the Context is
868      * attached to the DisplayContent successfully. {@code null}, otherwise.
869      * @throws android.view.WindowManager.InvalidDisplayException if the display ID is invalid
870      */
attachToDisplayContent(IBinder clientToken, int displayId)871     Configuration attachToDisplayContent(IBinder clientToken, int displayId);
872 
873     /**
874      * Detaches {@link android.window.WindowContext} from the window manager node it's currently
875      * attached to. It is no-op if the WindowContext is not attached to a window manager node.
876      *
877      * @param clientToken the window context's token
878      */
detachWindowContextFromWindowContainer(IBinder clientToken)879     void detachWindowContextFromWindowContainer(IBinder clientToken);
880 
881     /**
882      * Registers a listener, which is to be called whenever cross-window blur is enabled/disabled.
883      *
884      * @param listener the listener to be registered
885      * @return true if cross-window blur is currently enabled; false otherwise
886      */
registerCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener)887     boolean registerCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener);
888 
889     /**
890      * Unregisters a listener which was registered with
891      * {@link #registerCrossWindowBlurEnabledListener()}.
892      *
893      * @param listener the listener to be unregistered
894      */
unregisterCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener)895     void unregisterCrossWindowBlurEnabledListener(ICrossWindowBlurEnabledListener listener);
896 
isTaskSnapshotSupported()897     boolean isTaskSnapshotSupported();
898 
899     /**
900      * Returns the preferred display ID to show software keyboard.
901      *
902      * @see android.window.WindowProviderService#getLaunchedDisplayId
903      */
getImeDisplayId()904     int getImeDisplayId();
905 
906     /**
907      * Customized the task transition animation with a task transition spec.
908      *
909      * @param spec the spec that will be used to customize the task animations
910      */
setTaskTransitionSpec(in TaskTransitionSpec spec)911     void setTaskTransitionSpec(in TaskTransitionSpec spec);
912 
913     /**
914      * Clears any task transition spec that has been previously set and
915      * reverts to using the default task transition with no spec changes.
916      */
clearTaskTransitionSpec()917     void clearTaskTransitionSpec();
918 }
919