• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.policy;
18 
19 import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
20 import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
21 import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY;
22 import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
23 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL;
24 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
25 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
26 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY;
27 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
28 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
29 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
30 import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS;
31 import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY;
32 import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
33 import static android.view.WindowManager.LayoutParams.TYPE_DRAG;
34 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER;
35 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
36 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
37 import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
38 import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY;
39 import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
40 import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
41 import static android.view.WindowManager.LayoutParams.TYPE_NOTIFICATION_SHADE;
42 import static android.view.WindowManager.LayoutParams.TYPE_PHONE;
43 import static android.view.WindowManager.LayoutParams.TYPE_POINTER;
44 import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION;
45 import static android.view.WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
46 import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;
47 import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG;
48 import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT;
49 import static android.view.WindowManager.LayoutParams.TYPE_SEARCH_BAR;
50 import static android.view.WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY;
51 import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
52 import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL;
53 import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL;
54 import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
55 import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
56 import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
57 import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
58 import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
59 import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION;
60 import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION_STARTING;
61 import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
62 import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
63 import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType;
64 
65 import static java.lang.annotation.RetentionPolicy.SOURCE;
66 
67 import android.annotation.IntDef;
68 import android.annotation.NonNull;
69 import android.annotation.Nullable;
70 import android.content.Context;
71 import android.content.res.Configuration;
72 import android.graphics.Rect;
73 import android.os.Bundle;
74 import android.os.IBinder;
75 import android.os.PowerManager;
76 import android.os.RemoteException;
77 import android.util.Slog;
78 import android.util.proto.ProtoOutputStream;
79 import android.view.Display;
80 import android.view.IDisplayFoldListener;
81 import android.view.KeyEvent;
82 import android.view.WindowManager;
83 import android.view.WindowManagerGlobal;
84 import android.view.WindowManagerPolicyConstants;
85 import android.view.animation.Animation;
86 
87 import com.android.internal.policy.IKeyguardDismissCallback;
88 import com.android.internal.policy.IShortcutService;
89 import com.android.server.wm.DisplayRotation;
90 
91 import java.io.PrintWriter;
92 import java.lang.annotation.Retention;
93 import java.lang.annotation.RetentionPolicy;
94 
95 /**
96  * This interface supplies all UI-specific behavior of the window manager.  An
97  * instance of it is created by the window manager when it starts up, and allows
98  * customization of window layering, special window types, key dispatching, and
99  * layout.
100  *
101  * <p>Because this provides deep interaction with the system window manager,
102  * specific methods on this interface can be called from a variety of contexts
103  * with various restrictions on what they can do.  These are encoded through
104  * a suffixes at the end of a method encoding the thread the method is called
105  * from and any locks that are held when it is being called; if no suffix
106  * is attached to a method, then it is not called with any locks and may be
107  * called from the main window manager thread or another thread calling into
108  * the window manager.
109  *
110  * <p>The current suffixes are:
111  *
112  * <dl>
113  * <dt> Ti <dd> Called from the input thread.  This is the thread that
114  * collects pending input events and dispatches them to the appropriate window.
115  * It may block waiting for events to be processed, so that the input stream is
116  * properly serialized.
117  * <dt> Tq <dd> Called from the low-level input queue thread.  This is the
118  * thread that reads events out of the raw input devices and places them
119  * into the global input queue that is read by the <var>Ti</var> thread.
120  * This thread should not block for a long period of time on anything but the
121  * key driver.
122  * <dt> Lw <dd> Called with the main window manager lock held.  Because the
123  * window manager is a very low-level system service, there are few other
124  * system services you can call with this lock held.  It is explicitly okay to
125  * make calls into the package manager and power manager; it is explicitly not
126  * okay to make calls into the activity manager or most other services.  Note that
127  * {@link android.content.Context#checkPermission(String, int, int)} and
128  * variations require calling into the activity manager.
129  * <dt> Li <dd> Called with the input thread lock held.  This lock can be
130  * acquired by the window manager while it holds the window lock, so this is
131  * even more restrictive than <var>Lw</var>.
132  * </dl>
133  */
134 public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
135     @Retention(SOURCE)
136     @IntDef({NAV_BAR_LEFT, NAV_BAR_RIGHT, NAV_BAR_BOTTOM})
137     @interface NavigationBarPosition {}
138 
139     @Retention(SOURCE)
140     @IntDef({ALT_BAR_UNKNOWN, ALT_BAR_LEFT, ALT_BAR_RIGHT, ALT_BAR_BOTTOM, ALT_BAR_TOP})
141     @interface AltBarPosition {}
142 
143     /**
144      * Pass this event to the user / app.  To be returned from
145      * {@link #interceptKeyBeforeQueueing}.
146      */
147     int ACTION_PASS_TO_USER = 0x00000001;
148     /** Layout state may have changed (so another layout will be performed) */
149     int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
150     /** Configuration state may have changed */
151     int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
152     /** Wallpaper may need to move */
153     int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
154     /** Need to recompute animations */
155     int FINISH_LAYOUT_REDO_ANIM = 0x0008;
156     /** Layer for the screen off animation */
157     int COLOR_FADE_LAYER = 0x40000001;
158 
159     /**
160      * Register shortcuts for window manager to dispatch.
161      * Shortcut code is packed as (metaState << Integer.SIZE) | keyCode
162      * @hide
163      */
registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)164     void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)
165             throws RemoteException;
166 
167     /**
168      * Called when the Keyguard occluded state changed.
169      *
170      * @param occluded Whether Keyguard is currently occluded or not.
171      */
onKeyguardOccludedChangedLw(boolean occluded, boolean waitAppTransition)172     void onKeyguardOccludedChangedLw(boolean occluded, boolean waitAppTransition);
173 
174     /**
175      * Applies a keyguard occlusion change if one happened.
176      * @param transitionStarted Whether keyguard (un)occlude transition is starting or not.
177      */
applyKeyguardOcclusionChange(boolean transitionStarted)178     int applyKeyguardOcclusionChange(boolean transitionStarted);
179 
180     /**
181      * Interface to the Window Manager state associated with a particular
182      * window. You can hold on to an instance of this interface from the call
183      * to prepareAddWindow() until removeWindow().
184      */
185     public interface WindowState {
186         /**
187          * Return the package name of the app that owns this window.
188          */
getOwningPackage()189         String getOwningPackage();
190 
191         /**
192          * Retrieve the type of the top-level window.
193          *
194          * @return the base type of the parent window if attached or its own type otherwise
195          */
getBaseType()196         public int getBaseType();
197 
198         /**
199          * Return true if this window (or a window it is attached to, but not
200          * considering its app token) is currently animating.
201          */
isAnimatingLw()202         boolean isAnimatingLw();
203 
204         /**
205          * Returns true if the window owner can add internal system windows.
206          * That is, they have {@link Manifest.permission#INTERNAL_SYSTEM_WINDOW}.
207          */
canAddInternalSystemWindow()208         default boolean canAddInternalSystemWindow() {
209             return false;
210         }
211 
212         /** @return true if the window can show over keyguard. */
canShowWhenLocked()213         boolean canShowWhenLocked();
214     }
215 
216     /**
217      * Interface for calling back in to the window manager that is private
218      * between it and the policy.
219      */
220     public interface WindowManagerFuncs {
221         public static final int LID_ABSENT = -1;
222         public static final int LID_CLOSED = 0;
223         public static final int LID_OPEN = 1;
224 
225         public static final int LID_BEHAVIOR_NONE = 0;
226         public static final int LID_BEHAVIOR_SLEEP = 1;
227         public static final int LID_BEHAVIOR_LOCK = 2;
228 
229         public static final int CAMERA_LENS_COVER_ABSENT = -1;
230         public static final int CAMERA_LENS_UNCOVERED = 0;
231         public static final int CAMERA_LENS_COVERED = 1;
232 
233         /**
234          * Returns a code that describes the current state of the lid switch.
235          */
getLidState()236         public int getLidState();
237 
238         /**
239          * Lock the device now.
240          */
lockDeviceNow()241         public void lockDeviceNow();
242 
243         /**
244          * Returns a code that descripbes whether the camera lens is covered or not.
245          */
getCameraLensCoverState()246         public int getCameraLensCoverState();
247 
248         /**
249          * Switch the keyboard layout for the given device.
250          * Direction should be +1 or -1 to go to the next or previous keyboard layout.
251          */
switchKeyboardLayout(int deviceId, int direction)252         public void switchKeyboardLayout(int deviceId, int direction);
253 
shutdown(boolean confirm)254         public void shutdown(boolean confirm);
reboot(boolean confirm)255         public void reboot(boolean confirm);
rebootSafeMode(boolean confirm)256         public void rebootSafeMode(boolean confirm);
257 
258         /**
259          * Return the window manager lock needed to correctly call "Lw" methods.
260          */
getWindowManagerLock()261         public Object getWindowManagerLock();
262 
263         /** Register a system listener for touch events */
registerPointerEventListener(PointerEventListener listener, int displayId)264         void registerPointerEventListener(PointerEventListener listener, int displayId);
265 
266         /** Unregister a system listener for touch events */
unregisterPointerEventListener(PointerEventListener listener, int displayId)267         void unregisterPointerEventListener(PointerEventListener listener, int displayId);
268 
269         /**
270          * Notifies window manager that {@link #isKeyguardTrustedLw} has changed.
271          */
notifyKeyguardTrustedChanged()272         void notifyKeyguardTrustedChanged();
273 
274         /**
275          * Notifies the window manager that screen is being turned off.
276          *
277          * @param displayId the ID of the display which is turning off
278          * @param listener callback to call when display can be turned off
279          */
screenTurningOff(int displayId, ScreenOffListener listener)280         void screenTurningOff(int displayId, ScreenOffListener listener);
281 
282         /**
283          * Convert the lid state to a human readable format.
284          */
lidStateToString(int lid)285         static String lidStateToString(int lid) {
286             switch (lid) {
287                 case LID_ABSENT:
288                     return "LID_ABSENT";
289                 case LID_CLOSED:
290                     return "LID_CLOSED";
291                 case LID_OPEN:
292                     return "LID_OPEN";
293                 default:
294                     return Integer.toString(lid);
295             }
296         }
297 
298         /**
299          * Convert the camera lens state to a human readable format.
300          */
cameraLensStateToString(int lens)301         static String cameraLensStateToString(int lens) {
302             switch (lens) {
303                 case CAMERA_LENS_COVER_ABSENT:
304                     return "CAMERA_LENS_COVER_ABSENT";
305                 case CAMERA_LENS_UNCOVERED:
306                     return "CAMERA_LENS_UNCOVERED";
307                 case CAMERA_LENS_COVERED:
308                     return "CAMERA_LENS_COVERED";
309                 default:
310                     return Integer.toString(lens);
311             }
312         }
313 
314         /**
315          * Hint to window manager that the user has started a navigation action that should
316          * abort animations that have no timeout, in case they got stuck.
317          */
triggerAnimationFailsafe()318         void triggerAnimationFailsafe();
319 
320         /**
321          * The keyguard showing state has changed
322          */
onKeyguardShowingAndNotOccludedChanged()323         void onKeyguardShowingAndNotOccludedChanged();
324 
325         /**
326          * Notifies window manager that power key is being pressed.
327          */
onPowerKeyDown(boolean isScreenOn)328         void onPowerKeyDown(boolean isScreenOn);
329 
330         /**
331          * Notifies window manager that user is switched.
332          */
onUserSwitched()333         void onUserSwitched();
334 
335         /**
336          * Hint to window manager that the user is interacting with a display that should be treated
337          * as the top display.
338          */
moveDisplayToTop(int displayId)339         void moveDisplayToTop(int displayId);
340 
341         /**
342          * Return whether the app transition state is idle.
343          * @return {@code true} if app transition state is idle on the default display.
344          */
isAppTransitionStateIdle()345         boolean isAppTransitionStateIdle();
346 
347         /**
348          * Enables the screen if all conditions are met.
349          */
enableScreenIfNeeded()350         void enableScreenIfNeeded();
351 
352         /**
353          * Updates the current screen rotation based on the current state of the world.
354          *
355          * @param alwaysSendConfiguration Flag to force a new configuration to be evaluated.
356          *                                This can be used when there are other parameters in
357          *                                configuration that are changing.
358          * @param forceRelayout If true, the window manager will always do a relayout of its
359          *                      windows even if the rotation hasn't changed.
360          */
updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout)361         void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout);
362     }
363 
364     /**
365      * Interface to get public information of a display content.
366      */
367     public interface DisplayContentInfo {
getDisplayRotation()368         DisplayRotation getDisplayRotation();
getDisplay()369         Display getDisplay();
370     }
371 
372     /** Window has been added to the screen. */
373     public static final int TRANSIT_ENTER = 1;
374     /** Window has been removed from the screen. */
375     public static final int TRANSIT_EXIT = 2;
376     /** Window has been made visible. */
377     public static final int TRANSIT_SHOW = 3;
378     /** Window has been made invisible.
379      * TODO: Consider removal as this is unused. */
380     public static final int TRANSIT_HIDE = 4;
381     /** The "application starting" preview window is no longer needed, and will
382      * animate away to show the real window. */
383     public static final int TRANSIT_PREVIEW_DONE = 5;
384 
385     // NOTE: screen off reasons are in order of significance, with more
386     // important ones lower than less important ones.
387 
388     /** @hide */
389     @IntDef({USER_ROTATION_FREE, USER_ROTATION_LOCKED})
390     @Retention(RetentionPolicy.SOURCE)
391     public @interface UserRotationMode {}
392 
393     /** When not otherwise specified by the activity's screenOrientation, rotation should be
394      * determined by the system (that is, using sensors). */
395     public final int USER_ROTATION_FREE = 0;
396     /** When not otherwise specified by the activity's screenOrientation, rotation is set by
397      * the user. */
398     public final int USER_ROTATION_LOCKED = 1;
399 
400     /**
401      * Set the default display content to provide basic functions for the policy.
402      */
setDefaultDisplay(DisplayContentInfo displayContentInfo)403     public void setDefaultDisplay(DisplayContentInfo displayContentInfo);
404 
405     /**
406      * Perform initialization of the policy.
407      *
408      * @param context The system context we are running in.
409      */
init(Context context, WindowManagerFuncs windowManagerFuncs)410     void init(Context context, WindowManagerFuncs windowManagerFuncs);
411 
412     /**
413      * Check permissions when adding a window.
414      *
415      * @param type The window type
416      * @param isRoundedCornerOverlay {@code true} to indicate the adding window is
417      *                                           round corner overlay.
418      * @param packageName package name
419      * @param outAppOp First element will be filled with the app op corresponding to
420      *                 this window, or OP_NONE.
421      *
422      * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
423      *      else an error code, usually
424      *      {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
425      *
426      * @see WindowManager.LayoutParams#PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY
427      */
checkAddPermission(int type, boolean isRoundedCornerOverlay, String packageName, int[] outAppOp)428     int checkAddPermission(int type, boolean isRoundedCornerOverlay, String packageName,
429             int[] outAppOp);
430 
431     /**
432      * After the window manager has computed the current configuration based
433      * on its knowledge of the display and input devices, it gives the policy
434      * a chance to adjust the information contained in it.  If you want to
435      * leave it as-is, simply do nothing.
436      *
437      * <p>This method may be called by any thread in the window manager, but
438      * no internal locks in the window manager will be held.
439      *
440      * @param config The Configuration being computed, for you to change as
441      * desired.
442      * @param keyboardPresence Flags that indicate whether internal or external
443      * keyboards are present.
444      * @param navigationPresence Flags that indicate whether internal or external
445      * navigation devices are present.
446      */
adjustConfigurationLw(Configuration config, int keyboardPresence, int navigationPresence)447     public void adjustConfigurationLw(Configuration config, int keyboardPresence,
448             int navigationPresence);
449 
450     /**
451      * Returns the layer assignment for the window state. Allows you to control how different
452      * kinds of windows are ordered on-screen.
453      *
454      * @param win The window state
455      * @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
456      */
getWindowLayerLw(WindowState win)457     default int getWindowLayerLw(WindowState win) {
458         return getWindowLayerFromTypeLw(win.getBaseType(), win.canAddInternalSystemWindow());
459     }
460 
461     /**
462      * Returns the layer assignment for the window type. Allows you to control how different
463      * kinds of windows are ordered on-screen.
464      *
465      * @param type The type of window being assigned.
466      * @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
467      */
getWindowLayerFromTypeLw(int type)468     default int getWindowLayerFromTypeLw(int type) {
469         if (isSystemAlertWindowType(type)) {
470             throw new IllegalArgumentException("Use getWindowLayerFromTypeLw() or"
471                     + " getWindowLayerLw() for alert window types");
472         }
473         return getWindowLayerFromTypeLw(type, false /* canAddInternalSystemWindow */);
474     }
475 
476     /**
477      * Returns the layer assignment for the window type. Allows you to control how different
478      * kinds of windows are ordered on-screen.
479      *
480      * @param type The type of window being assigned.
481      * @param canAddInternalSystemWindow If the owner window associated with the type we are
482      *        evaluating can add internal system windows. I.e they have
483      *        {@link Manifest.permission#INTERNAL_SYSTEM_WINDOW}. If true, alert window
484      *        types {@link android.view.WindowManager.LayoutParams#isSystemAlertWindowType(int)}
485      *        can be assigned layers greater than the layer for
486      *        {@link android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY} Else, their
487      *        layers would be lesser.
488      * @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
489      */
getWindowLayerFromTypeLw(int type, boolean canAddInternalSystemWindow)490     default int getWindowLayerFromTypeLw(int type, boolean canAddInternalSystemWindow) {
491         return getWindowLayerFromTypeLw(type, canAddInternalSystemWindow,
492                 false /* roundedCornerOverlay */);
493     }
494 
495     /**
496      * Returns the layer assignment for the window type. Allows you to control how different
497      * kinds of windows are ordered on-screen.
498      *
499      * @param type The type of window being assigned.
500      * @param canAddInternalSystemWindow If the owner window associated with the type we are
501      *        evaluating can add internal system windows. I.e they have
502      *        {@link Manifest.permission#INTERNAL_SYSTEM_WINDOW}. If true, alert window
503      *        types {@link android.view.WindowManager.LayoutParams#isSystemAlertWindowType(int)}
504      *        can be assigned layers greater than the layer for
505      *        {@link android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY} Else, their
506      *        layers would be lesser.
507      * @param roundedCornerOverlay {#code true} to indicate that the owner window is rounded corner
508      *                             overlay.
509      * @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
510      */
getWindowLayerFromTypeLw(int type, boolean canAddInternalSystemWindow, boolean roundedCornerOverlay)511     default int getWindowLayerFromTypeLw(int type, boolean canAddInternalSystemWindow,
512             boolean roundedCornerOverlay) {
513         // Always put the rounded corner layer to the top most.
514         if (roundedCornerOverlay && canAddInternalSystemWindow) {
515             return getMaxWindowLayer();
516         }
517         if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
518             return APPLICATION_LAYER;
519         }
520 
521         switch (type) {
522             case TYPE_WALLPAPER:
523                 // wallpaper is at the bottom, though the window manager may move it.
524                 return  1;
525             case TYPE_PRESENTATION:
526             case TYPE_PRIVATE_PRESENTATION:
527             case TYPE_DOCK_DIVIDER:
528             case TYPE_QS_DIALOG:
529             case TYPE_PHONE:
530                 return  3;
531             case TYPE_SEARCH_BAR:
532                 return  4;
533             case TYPE_INPUT_CONSUMER:
534                 return  5;
535             case TYPE_SYSTEM_DIALOG:
536                 return  6;
537             case TYPE_TOAST:
538                 // toasts and the plugged-in battery thing
539                 return  7;
540             case TYPE_PRIORITY_PHONE:
541                 // SIM errors and unlock.  Not sure if this really should be in a high layer.
542                 return  8;
543             case TYPE_SYSTEM_ALERT:
544                 // like the ANR / app crashed dialogs
545                 // Type is deprecated for non-system apps. For system apps, this type should be
546                 // in a higher layer than TYPE_APPLICATION_OVERLAY.
547                 return  canAddInternalSystemWindow ? 12 : 9;
548             case TYPE_APPLICATION_OVERLAY:
549                 return  11;
550             case TYPE_INPUT_METHOD:
551                 // on-screen keyboards and other such input method user interfaces go here.
552                 return  13;
553             case TYPE_INPUT_METHOD_DIALOG:
554                 // on-screen keyboards and other such input method user interfaces go here.
555                 return  14;
556             case TYPE_STATUS_BAR:
557                 return  15;
558             case TYPE_STATUS_BAR_ADDITIONAL:
559                 return  16;
560             case TYPE_NOTIFICATION_SHADE:
561                 return  17;
562             case TYPE_STATUS_BAR_SUB_PANEL:
563                 return  18;
564             case TYPE_KEYGUARD_DIALOG:
565                 return  19;
566             case TYPE_VOICE_INTERACTION_STARTING:
567                 return  20;
568             case TYPE_VOICE_INTERACTION:
569                 // voice interaction layer should show above the lock screen.
570                 return  21;
571             case TYPE_VOLUME_OVERLAY:
572                 // the on-screen volume indicator and controller shown when the user
573                 // changes the device volume
574                 return  22;
575             case TYPE_SYSTEM_OVERLAY:
576                 // the on-screen volume indicator and controller shown when the user
577                 // changes the device volume
578                 return  canAddInternalSystemWindow ? 23 : 10;
579             case TYPE_NAVIGATION_BAR:
580                 // the navigation bar, if available, shows atop most things
581                 return  24;
582             case TYPE_NAVIGATION_BAR_PANEL:
583                 // some panels (e.g. search) need to show on top of the navigation bar
584                 return  25;
585             case TYPE_SCREENSHOT:
586                 // screenshot selection layer shouldn't go above system error, but it should cover
587                 // navigation bars at the very least.
588                 return  26;
589             case TYPE_SYSTEM_ERROR:
590                 // system-level error dialogs
591                 return  canAddInternalSystemWindow ? 27 : 9;
592             case TYPE_MAGNIFICATION_OVERLAY:
593                 // used to highlight the magnified portion of a display
594                 return  28;
595             case TYPE_DISPLAY_OVERLAY:
596                 // used to simulate secondary display devices
597                 return  29;
598             case TYPE_DRAG:
599                 // the drag layer: input for drag-and-drop is associated with this window,
600                 // which sits above all other focusable windows
601                 return  30;
602             case TYPE_ACCESSIBILITY_OVERLAY:
603                 // overlay put by accessibility services to intercept user interaction
604                 return  31;
605             case TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY:
606                 return 32;
607             case TYPE_SECURE_SYSTEM_OVERLAY:
608                 return  33;
609             case TYPE_BOOT_PROGRESS:
610                 return  34;
611             case TYPE_POINTER:
612                 // the (mouse) pointer layer
613                 return  35;
614             default:
615                 Slog.e("WindowManager", "Unknown window type: " + type);
616                 return 3;
617         }
618     }
619 
620     // TODO(b/155340867): consider to remove the logic after using pure Surface for rounded corner
621     //  overlay.
622     /**
623      * Returns the max window layer.
624      * <p>Note that the max window layer should be higher that the maximum value which reported
625      * by {@link #getWindowLayerFromTypeLw(int, boolean)} to contain rounded corner overlay.</p>
626      *
627      * @see WindowManager.LayoutParams#PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY
628      */
getMaxWindowLayer()629     default int getMaxWindowLayer() {
630         return 36;
631     }
632 
633     /**
634      * Return how to Z-order sub-windows in relation to the window they are attached to.
635      * Return positive to have them ordered in front, negative for behind.
636      *
637      * @param type The sub-window type code.
638      *
639      * @return int Layer in relation to the attached window, where positive is
640      *         above and negative is below.
641      */
getSubWindowLayerFromTypeLw(int type)642     default int getSubWindowLayerFromTypeLw(int type) {
643         switch (type) {
644             case TYPE_APPLICATION_PANEL:
645             case TYPE_APPLICATION_ATTACHED_DIALOG:
646                 return APPLICATION_PANEL_SUBLAYER;
647             case TYPE_APPLICATION_MEDIA:
648                 return APPLICATION_MEDIA_SUBLAYER;
649             case TYPE_APPLICATION_MEDIA_OVERLAY:
650                 return APPLICATION_MEDIA_OVERLAY_SUBLAYER;
651             case TYPE_APPLICATION_SUB_PANEL:
652                 return APPLICATION_SUB_PANEL_SUBLAYER;
653             case TYPE_APPLICATION_ABOVE_SUB_PANEL:
654                 return APPLICATION_ABOVE_SUB_PANEL_SUBLAYER;
655         }
656         Slog.e("WindowManager", "Unknown sub-window type: " + type);
657         return 0;
658     }
659 
660     /**
661      * Return whether the given window can become the Keyguard window. Typically returns true for
662      * the StatusBar.
663      */
isKeyguardHostWindow(WindowManager.LayoutParams attrs)664     public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs);
665 
666     /**
667      * Create and return an animation to re-display a window that was force hidden by Keyguard.
668      */
createHiddenByKeyguardExit(boolean onWallpaper, boolean goingToNotificationShade, boolean subtleAnimation)669     public Animation createHiddenByKeyguardExit(boolean onWallpaper,
670             boolean goingToNotificationShade, boolean subtleAnimation);
671 
672     /**
673      * Create and return an animation to let the wallpaper disappear after being shown behind
674      * Keyguard.
675      */
createKeyguardWallpaperExit(boolean goingToNotificationShade)676     public Animation createKeyguardWallpaperExit(boolean goingToNotificationShade);
677 
678     /**
679      * Called from the input reader thread before a key is enqueued.
680      *
681      * <p>There are some actions that need to be handled here because they
682      * affect the power state of the device, for example, the power keys.
683      * Generally, it's best to keep as little as possible in the queue thread
684      * because it's the most fragile.
685      * @param event The key event.
686      * @param policyFlags The policy flags associated with the key.
687      *
688      * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
689      */
interceptKeyBeforeQueueing(KeyEvent event, int policyFlags)690     public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags);
691 
692     /**
693      * Called from the input reader thread before a motion is enqueued when the device is in a
694      * non-interactive state.
695      *
696      * <p>There are some actions that need to be handled here because they
697      * affect the power state of the device, for example, waking on motions.
698      * Generally, it's best to keep as little as possible in the queue thread
699      * because it's the most fragile.
700      * @param displayId The display ID of the motion event.
701      * @param policyFlags The policy flags associated with the motion.
702      *
703      * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
704      */
interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos, int policyFlags)705     int interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos,
706             int policyFlags);
707 
708     /**
709      * Called from the input dispatcher thread before a key is dispatched to a window.
710      *
711      * <p>Allows you to define
712      * behavior for keys that can not be overridden by applications.
713      * This method is called from the input thread, with no locks held.
714      *
715      * @param focusedToken Client window token that currently has focus. This is where the key
716      *            event will normally go.
717      * @param event The key event.
718      * @param policyFlags The policy flags associated with the key.
719      * @return 0 if the key should be dispatched immediately, -1 if the key should
720      * not be dispatched ever, or a positive value indicating the number of
721      * milliseconds by which the key dispatch should be delayed before trying
722      * again.
723      */
interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event, int policyFlags)724     long interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event, int policyFlags);
725 
726     /**
727      * Called from the input dispatcher thread when an application did not handle
728      * a key that was dispatched to it.
729      *
730      * <p>Allows you to define default global behavior for keys that were not handled
731      * by applications.  This method is called from the input thread, with no locks held.
732      *
733      * @param focusedToken Client window token that currently has focus. This is where the key
734      *            event will normally go.
735      * @param event The key event.
736      * @param policyFlags The policy flags associated with the key.
737      * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
738      * The caller is responsible for recycling the key event.
739      */
dispatchUnhandledKey(IBinder focusedToken, KeyEvent event, int policyFlags)740     KeyEvent dispatchUnhandledKey(IBinder focusedToken, KeyEvent event, int policyFlags);
741 
742     /**
743      * Called when the top focused display is changed.
744      *
745      * @param displayId The ID of the top focused display.
746      */
setTopFocusedDisplay(int displayId)747     void setTopFocusedDisplay(int displayId);
748 
749     /**
750      * Called when the state of allow-lockscreen-when-on of the display is changed. See
751      * {@link WindowManager.LayoutParams#FLAG_ALLOW_LOCK_WHILE_SCREEN_ON}
752      *
753      * @param displayId The ID of the display.
754      * @param allow Whether the display allows showing lockscreen when it is on.
755      */
setAllowLockscreenWhenOn(int displayId, boolean allow)756     void setAllowLockscreenWhenOn(int displayId, boolean allow);
757 
758     /**
759      * Called when the device has started waking up.
760      *
761      * @param pmWakeReason One of PowerManager.WAKE_REASON_*, detailing the specific reason we're
762      * waking up, such as WAKE_REASON_POWER_BUTTON or WAKE_REASON_GESTURE.
763      */
startedWakingUp(@owerManager.WakeReason int pmWakeReason)764     void startedWakingUp(@PowerManager.WakeReason int pmWakeReason);
765 
766     /**
767      * Called when the device has finished waking up.
768      *
769      * @param pmWakeReason One of PowerManager.WAKE_REASON_*, detailing the specific reason we're
770      * waking up, such as WAKE_REASON_POWER_BUTTON or WAKE_REASON_GESTURE.
771      */
finishedWakingUp(@owerManager.WakeReason int pmWakeReason)772     void finishedWakingUp(@PowerManager.WakeReason int pmWakeReason);
773 
774     /**
775      * Called when the device has started going to sleep.
776      *
777      * @param pmSleepReason One of PowerManager.GO_TO_SLEEP_REASON_*, detailing the specific reason
778      * we're going to sleep, such as GO_TO_SLEEP_REASON_POWER_BUTTON or GO_TO_SLEEP_REASON_TIMEOUT.
779      */
startedGoingToSleep(@owerManager.GoToSleepReason int pmSleepReason)780     public void startedGoingToSleep(@PowerManager.GoToSleepReason int pmSleepReason);
781 
782     /**
783      * Called when the device has finished going to sleep.
784      *
785      * @param pmSleepReason One of PowerManager.GO_TO_SLEEP_REASON_*, detailing the specific reason
786      * we're going to sleep, such as GO_TO_SLEEP_REASON_POWER_BUTTON or GO_TO_SLEEP_REASON_TIMEOUT.
787      */
finishedGoingToSleep(@owerManager.GoToSleepReason int pmSleepReason)788     public void finishedGoingToSleep(@PowerManager.GoToSleepReason int pmSleepReason);
789 
790     /**
791      * Called when a particular PowerGroup has changed wakefulness.
792      *
793      * @param groupId The id of the PowerGroup.
794      * @param wakefulness One of PowerManagerInternal.WAKEFULNESS_* indicating the wake state for
795      * the group
796      * @param pmSleepReason One of PowerManager.GO_TO_SLEEP_REASON_*, detailing the reason this
797      * group is going to sleep.
798      * @param globalWakefulness The global wakefulness, which may or may not match that of this
799      * group. One of PowerManagerInternal.WAKEFULNESS_*
800      */
onPowerGroupWakefulnessChanged(int groupId, int wakefulness, @PowerManager.GoToSleepReason int pmSleepReason, int globalWakefulness)801     void onPowerGroupWakefulnessChanged(int groupId, int wakefulness,
802             @PowerManager.GoToSleepReason int pmSleepReason, int globalWakefulness);
803 
804     /**
805      * Called when the display is about to turn on to show content.
806      * When waking up, this method will be called once after the call to wakingUp().
807      * When dozing, the method will be called sometime after the call to goingToSleep() and
808      * may be called repeatedly in the case where the screen is pulsing on and off.
809      *
810      * Must call back on the listener to tell it when the higher-level system
811      * is ready for the screen to go on (i.e. the lock screen is shown).
812      */
screenTurningOn(int displayId, ScreenOnListener screenOnListener)813     public void screenTurningOn(int displayId, ScreenOnListener screenOnListener);
814 
815     /**
816      * Called when the display has actually turned on, i.e. the display power state has been set to
817      * ON and the screen is unblocked.
818      */
screenTurnedOn(int displayId)819     public void screenTurnedOn(int displayId);
820 
821     /**
822      * Called when the display would like to be turned off. This gives policy a chance to do some
823      * things before the display power state is actually changed to off.
824      *
825      * @param screenOffListener Must be called to tell that the display power state can actually be
826      *                          changed now after policy has done its work.
827      */
screenTurningOff(int displayId, ScreenOffListener screenOffListener)828     public void screenTurningOff(int displayId, ScreenOffListener screenOffListener);
829 
830     /**
831      * Called when the display has turned off.
832      */
screenTurnedOff(int displayId)833     public void screenTurnedOff(int displayId);
834 
835     public interface ScreenOnListener {
onScreenOn()836         void onScreenOn();
837     }
838 
839     /**
840      * See {@link #screenTurnedOff}
841      */
842     public interface ScreenOffListener {
onScreenOff()843         void onScreenOff();
844     }
845 
846     /**
847      * Return whether the default display is on and not blocked by a black surface.
848      */
isScreenOn()849     public boolean isScreenOn();
850 
851     /**
852      * @param ignoreScreenOn {@code true} if screen state should be ignored.
853      * @return whether the device is currently allowed to animate.
854      *
855      * Note: this can be true even if it is not appropriate to animate for reasons that are outside
856      *       of the policy's authority.
857      */
okToAnimate(boolean ignoreScreenOn)858     boolean okToAnimate(boolean ignoreScreenOn);
859 
860     /**
861      * Tell the policy that the lid switch has changed state.
862      * @param whenNanos The time when the change occurred in uptime nanoseconds.
863      * @param lidOpen True if the lid is now open.
864      */
notifyLidSwitchChanged(long whenNanos, boolean lidOpen)865     public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
866 
867     /**
868      * Tell the policy that the camera lens has been covered or uncovered.
869      * @param whenNanos The time when the change occurred in uptime nanoseconds.
870      * @param lensCovered True if the lens is covered.
871      */
notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered)872     public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered);
873 
874     /**
875      * Tell the policy if anyone is requesting that keyguard not come on.
876      *
877      * @param enabled Whether keyguard can be on or not.  does not actually
878      * turn it on, unless it was previously disabled with this function.
879      *
880      * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
881      * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
882      */
883     @SuppressWarnings("javadoc")
enableKeyguard(boolean enabled)884     public void enableKeyguard(boolean enabled);
885 
886     /**
887      * Callback used by {@link #exitKeyguardSecurely}
888      */
889     interface OnKeyguardExitResult {
onKeyguardExitResult(boolean success)890         void onKeyguardExitResult(boolean success);
891     }
892 
893     /**
894      * Tell the policy if anyone is requesting the keyguard to exit securely
895      * (this would be called after the keyguard was disabled)
896      * @param callback Callback to send the result back.
897      * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
898      */
899     @SuppressWarnings("javadoc")
exitKeyguardSecurely(OnKeyguardExitResult callback)900     void exitKeyguardSecurely(OnKeyguardExitResult callback);
901 
902     /**
903      * isKeyguardLocked
904      *
905      * Return whether the keyguard is currently locked.
906      *
907      * @return true if in keyguard is locked.
908      */
isKeyguardLocked()909     public boolean isKeyguardLocked();
910 
911     /**
912      * isKeyguardSecure
913      *
914      * Return whether the keyguard requires a password to unlock.
915      * @param userId
916      *
917      * @return true if in keyguard is secure.
918      */
isKeyguardSecure(int userId)919     public boolean isKeyguardSecure(int userId);
920 
921     /**
922      * Return whether the keyguard is currently occluded.
923      *
924      * @return true if in keyguard is occluded, false otherwise
925      */
isKeyguardOccluded()926     public boolean isKeyguardOccluded();
927 
928     /**
929      * Return whether the keyguard is unoccluding.
930      * @return {@code true} if the keyguard is unoccluding.
931      */
isKeyguardUnoccluding()932     default boolean isKeyguardUnoccluding() {
933         return false;
934     }
935 
936     /**
937      * @return true if in keyguard is on.
938      */
isKeyguardShowing()939     boolean isKeyguardShowing();
940 
941     /**
942      * @return true if in keyguard is on and not occluded.
943      */
isKeyguardShowingAndNotOccluded()944     public boolean isKeyguardShowingAndNotOccluded();
945 
946     /**
947      * @return whether Keyguard is in trusted state and can be dismissed without credentials
948      */
isKeyguardTrustedLw()949     public boolean isKeyguardTrustedLw();
950 
951     /**
952      * inKeyguardRestrictedKeyInputMode
953      *
954      * If keyguard screen is showing or in restricted key input mode (i.e. in
955      * keyguard password emergency screen). When in such mode, certain keys,
956      * such as the Home key and the right soft keys, don't work.
957      *
958      * @return true if in keyguard restricted input mode.
959      */
inKeyguardRestrictedKeyInputMode()960     public boolean inKeyguardRestrictedKeyInputMode();
961 
962     /**
963      * Ask the policy to dismiss the keyguard, if it is currently shown.
964      *
965      * @param callback Callback to be informed about the result.
966      * @param message A message that should be displayed in the keyguard.
967      */
dismissKeyguardLw(@ullable IKeyguardDismissCallback callback, CharSequence message)968     public void dismissKeyguardLw(@Nullable IKeyguardDismissCallback callback,
969             CharSequence message);
970 
971     /**
972      * Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method
973      * returns true as soon as we know that Keyguard is disabled.
974      *
975      * @return true if the keyguard has drawn.
976      */
isKeyguardDrawnLw()977     public boolean isKeyguardDrawnLw();
978 
979     /**
980      * Called when the system is mostly done booting to set whether
981      * the system should go into safe mode.
982      */
setSafeMode(boolean safeMode)983     public void setSafeMode(boolean safeMode);
984 
985     /**
986      * Called when the system is mostly done booting.
987      */
systemReady()988     public void systemReady();
989 
990     /**
991      * Called when the system is done booting to the point where the
992      * user can start interacting with it.
993      */
systemBooted()994     public void systemBooted();
995 
996     /**
997      * Show boot time message to the user.
998      */
showBootMessage(final CharSequence msg, final boolean always)999     public void showBootMessage(final CharSequence msg, final boolean always);
1000 
1001     /**
1002      * Hide the UI for showing boot messages, never to be displayed again.
1003      */
hideBootMessages()1004     public void hideBootMessages();
1005 
1006     /**
1007      * Called when userActivity is signalled in the power manager.
1008      * This is safe to call from any thread, with any window manager locks held or not.
1009      */
userActivity(int displayGroupId, int event)1010     void userActivity(int displayGroupId, int event);
1011 
1012     /**
1013      * Called when we have finished booting and can now display the home
1014      * screen to the user.  This will happen after systemReady(), and at
1015      * this point the display is active.
1016      */
enableScreenAfterBoot()1017     public void enableScreenAfterBoot();
1018 
1019     /**
1020      * Call from application to perform haptic feedback on its window.
1021      */
performHapticFeedback(int uid, String packageName, int effectId, boolean always, String reason)1022     public boolean performHapticFeedback(int uid, String packageName, int effectId,
1023             boolean always, String reason);
1024 
1025     /**
1026      * Called when we have started keeping the screen on because a window
1027      * requesting this has become visible.
1028      */
keepScreenOnStartedLw()1029     public void keepScreenOnStartedLw();
1030 
1031     /**
1032      * Called when we have stopped keeping the screen on because the last window
1033      * requesting this is no longer visible.
1034      */
keepScreenOnStoppedLw()1035     public void keepScreenOnStoppedLw();
1036 
1037     /**
1038      * Called by System UI to notify of changes to the visibility of Recents.
1039      */
setRecentsVisibilityLw(boolean visible)1040     public void setRecentsVisibilityLw(boolean visible);
1041 
1042     /**
1043      * Called by System UI to notify of changes to the visibility of PIP.
1044      */
setPipVisibilityLw(boolean visible)1045     void setPipVisibilityLw(boolean visible);
1046 
1047     /**
1048      * Called by System UI to enable or disable haptic feedback on the navigation bar buttons.
1049      */
setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled)1050     void setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled);
1051 
1052     /**
1053      * Specifies whether there is an on-screen navigation bar separate from the status bar.
1054      */
hasNavigationBar()1055     public boolean hasNavigationBar();
1056 
1057     /**
1058      * Lock the device now.
1059      */
lockNow(Bundle options)1060     public void lockNow(Bundle options);
1061 
1062     /**
1063      * An internal callback (from InputMethodManagerService) to notify a state change regarding
1064      * whether the back key should dismiss the software keyboard (IME) or not.
1065      *
1066      * @param newValue {@code true} if the software keyboard is shown and the back key is expected
1067      *                 to dismiss the software keyboard.
1068      * @hide
1069      */
setDismissImeOnBackKeyPressed(boolean newValue)1070     default void setDismissImeOnBackKeyPressed(boolean newValue) {
1071         // Default implementation does nothing.
1072     }
1073 
1074     /**
1075      * Show the recents task list app.
1076      * @hide
1077      */
showRecentApps()1078     public void showRecentApps();
1079 
1080     /**
1081      * Show the global actions dialog.
1082      * @hide
1083      */
showGlobalActions()1084     public void showGlobalActions();
1085 
1086     /**
1087      * Returns whether the user setup is complete.
1088      */
isUserSetupComplete()1089     boolean isUserSetupComplete();
1090 
1091     /**
1092      * Returns the current UI mode.
1093      */
getUiMode()1094     int getUiMode();
1095 
1096     /**
1097      * Called when the current user changes. Guaranteed to be called before the broadcast
1098      * of the new user id is made to all listeners.
1099      *
1100      * @param newUserId The id of the incoming user.
1101      */
setCurrentUserLw(int newUserId)1102     public void setCurrentUserLw(int newUserId);
1103 
1104     /**
1105      * For a given user-switch operation, this will be called once with switching=true before the
1106      * user-switch and once with switching=false afterwards (or if the user-switch was cancelled).
1107      * This gives the policy a chance to alter its behavior for the duration of a user-switch.
1108      *
1109      * @param switching true if a user-switch is in progress
1110      */
setSwitchingUser(boolean switching)1111     void setSwitchingUser(boolean switching);
1112 
1113     /**
1114      * Print the WindowManagerPolicy's state into the given stream.
1115      *
1116      * @param prefix Text to print at the front of each line.
1117      * @param writer The PrintWriter to which you should dump your state.  This will be
1118      * closed for you after you return.
1119      * @param args additional arguments to the dump request.
1120      */
dump(String prefix, PrintWriter writer, String[] args)1121     public void dump(String prefix, PrintWriter writer, String[] args);
1122 
1123     /**
1124      * Write the WindowManagerPolicy's state into the protocol buffer.
1125      * The message is described in {@link com.android.server.wm.WindowManagerPolicyProto}
1126      *
1127      * @param proto The protocol buffer output stream to write to.
1128      */
dumpDebug(ProtoOutputStream proto, long fieldId)1129     void dumpDebug(ProtoOutputStream proto, long fieldId);
1130 
1131     /**
1132      * Notifies the keyguard to start fading out.
1133      *
1134      * @param startTime the start time of the animation in uptime milliseconds
1135      * @param fadeoutDuration the duration of the exit animation, in milliseconds
1136      */
startKeyguardExitAnimation(long startTime, long fadeoutDuration)1137     void startKeyguardExitAnimation(long startTime, long fadeoutDuration);
1138 
1139     /**
1140      * Called when System UI has been started.
1141      */
onSystemUiStarted()1142     void onSystemUiStarted();
1143 
1144     /**
1145      * Checks whether the policy is ready for dismissing the boot animation and completing the boot.
1146      *
1147      * @return true if ready; false otherwise.
1148      */
canDismissBootAnimation()1149     boolean canDismissBootAnimation();
1150 
1151     /**
1152      * Convert the user rotation mode to a human readable format.
1153      */
userRotationModeToString(int mode)1154     static String userRotationModeToString(int mode) {
1155         switch(mode) {
1156             case USER_ROTATION_FREE:
1157                 return "USER_ROTATION_FREE";
1158             case USER_ROTATION_LOCKED:
1159                 return "USER_ROTATION_LOCKED";
1160             default:
1161                 return Integer.toString(mode);
1162         }
1163     }
1164 
1165     /**
1166      * Registers an IDisplayFoldListener.
1167      */
registerDisplayFoldListener(IDisplayFoldListener listener)1168     default void registerDisplayFoldListener(IDisplayFoldListener listener) {}
1169 
1170     /**
1171      * Unregisters an IDisplayFoldListener.
1172      */
unregisterDisplayFoldListener(IDisplayFoldListener listener)1173     default void unregisterDisplayFoldListener(IDisplayFoldListener listener) {}
1174 
1175     /**
1176      * Overrides the folded area.
1177      *
1178      * @param area the overriding folded area or an empty {@code Rect} to clear the override.
1179      */
setOverrideFoldedArea(@onNull Rect area)1180     default void setOverrideFoldedArea(@NonNull Rect area) {}
1181 
1182     /**
1183      * Get the display folded area.
1184      */
getFoldedArea()1185     default @NonNull Rect getFoldedArea() {
1186         return new Rect();
1187     }
1188 
1189     /**
1190      * A new window on default display has been focused.
1191      */
onDefaultDisplayFocusChangedLw(WindowState newFocus)1192     default void onDefaultDisplayFocusChangedLw(WindowState newFocus) {}
1193 }
1194