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