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