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