• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 android.annotation.IntDef;
20 import android.annotation.SystemApi;
21 import android.app.ActivityManager.StackId;
22 import android.content.Context;
23 import android.content.pm.ActivityInfo;
24 import android.content.res.CompatibilityInfo;
25 import android.content.res.Configuration;
26 import android.graphics.Point;
27 import android.graphics.Rect;
28 import android.graphics.RectF;
29 import android.os.Bundle;
30 import android.os.IBinder;
31 import android.os.Looper;
32 import android.os.RemoteException;
33 import android.view.animation.Animation;
34 import com.android.internal.policy.IShortcutService;
35 
36 import java.io.PrintWriter;
37 import java.lang.annotation.Retention;
38 import java.lang.annotation.RetentionPolicy;
39 
40 /**
41  * This interface supplies all UI-specific behavior of the window manager.  An
42  * instance of it is created by the window manager when it starts up, and allows
43  * customization of window layering, special window types, key dispatching, and
44  * layout.
45  *
46  * <p>Because this provides deep interaction with the system window manager,
47  * specific methods on this interface can be called from a variety of contexts
48  * with various restrictions on what they can do.  These are encoded through
49  * a suffixes at the end of a method encoding the thread the method is called
50  * from and any locks that are held when it is being called; if no suffix
51  * is attached to a method, then it is not called with any locks and may be
52  * called from the main window manager thread or another thread calling into
53  * the window manager.
54  *
55  * <p>The current suffixes are:
56  *
57  * <dl>
58  * <dt> Ti <dd> Called from the input thread.  This is the thread that
59  * collects pending input events and dispatches them to the appropriate window.
60  * It may block waiting for events to be processed, so that the input stream is
61  * properly serialized.
62  * <dt> Tq <dd> Called from the low-level input queue thread.  This is the
63  * thread that reads events out of the raw input devices and places them
64  * into the global input queue that is read by the <var>Ti</var> thread.
65  * This thread should not block for a long period of time on anything but the
66  * key driver.
67  * <dt> Lw <dd> Called with the main window manager lock held.  Because the
68  * window manager is a very low-level system service, there are few other
69  * system services you can call with this lock held.  It is explicitly okay to
70  * make calls into the package manager and power manager; it is explicitly not
71  * okay to make calls into the activity manager or most other services.  Note that
72  * {@link android.content.Context#checkPermission(String, int, int)} and
73  * variations require calling into the activity manager.
74  * <dt> Li <dd> Called with the input thread lock held.  This lock can be
75  * acquired by the window manager while it holds the window lock, so this is
76  * even more restrictive than <var>Lw</var>.
77  * </dl>
78  *
79  * @hide
80  */
81 public interface WindowManagerPolicy {
82     // Policy flags.  These flags are also defined in frameworks/base/include/ui/Input.h.
83     public final static int FLAG_WAKE = 0x00000001;
84     public final static int FLAG_VIRTUAL = 0x00000002;
85 
86     public final static int FLAG_INJECTED = 0x01000000;
87     public final static int FLAG_TRUSTED = 0x02000000;
88     public final static int FLAG_FILTERED = 0x04000000;
89     public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000;
90 
91     public final static int FLAG_INTERACTIVE = 0x20000000;
92     public final static int FLAG_PASS_TO_USER = 0x40000000;
93 
94     // Flags for IActivityManager.keyguardGoingAway()
95     public final static int KEYGUARD_GOING_AWAY_FLAG_TO_SHADE = 1 << 0;
96     public final static int KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS = 1 << 1;
97     public final static int KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER = 1 << 2;
98 
99     // Flags used for indicating whether the internal and/or external input devices
100     // of some type are available.
101     public final static int PRESENCE_INTERNAL = 1 << 0;
102     public final static int PRESENCE_EXTERNAL = 1 << 1;
103 
104     public final static boolean WATCH_POINTER = false;
105 
106     /**
107      * Sticky broadcast of the current HDMI plugged state.
108      */
109     public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
110 
111     /**
112      * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
113      * plugged in to HDMI, false if not.
114      */
115     public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
116 
117     /**
118      * Set to {@code true} when intent was invoked from pressing the home key.
119      * @hide
120      */
121     @SystemApi
122     public static final String EXTRA_FROM_HOME_KEY = "android.intent.extra.FROM_HOME_KEY";
123 
124     /**
125      * Pass this event to the user / app.  To be returned from
126      * {@link #interceptKeyBeforeQueueing}.
127      */
128     public final static int ACTION_PASS_TO_USER = 0x00000001;
129 
130     /**
131      * Register shortcuts for window manager to dispatch.
132      * Shortcut code is packed as (metaState << Integer.SIZE) | keyCode
133      * @hide
134      */
registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)135     void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)
136             throws RemoteException;
137 
138     /**
139      * @return true if windows with FLAG_DISMISS_KEYGUARD should be allowed to show even if
140      *         the keyguard is locked.
141      */
canShowDismissingWindowWhileLockedLw()142     boolean canShowDismissingWindowWhileLockedLw();
143 
144     /**
145      * Interface to the Window Manager state associated with a particular
146      * window.  You can hold on to an instance of this interface from the call
147      * to prepareAddWindow() until removeWindow().
148      */
149     public interface WindowState {
150         /**
151          * Return the uid of the app that owns this window.
152          */
getOwningUid()153         int getOwningUid();
154 
155         /**
156          * Return the package name of the app that owns this window.
157          */
getOwningPackage()158         String getOwningPackage();
159 
160         /**
161          * Perform standard frame computation.  The result can be obtained with
162          * getFrame() if so desired.  Must be called with the window manager
163          * lock held.
164          *
165          * @param parentFrame The frame of the parent container this window
166          * is in, used for computing its basic position.
167          * @param displayFrame The frame of the overall display in which this
168          * window can appear, used for constraining the overall dimensions
169          * of the window.
170          * @param overlayFrame The frame within the display that is inside
171          * of the overlay region.
172          * @param contentFrame The frame within the display in which we would
173          * like active content to appear.  This will cause windows behind to
174          * be resized to match the given content frame.
175          * @param visibleFrame The frame within the display that the window
176          * is actually visible, used for computing its visible insets to be
177          * given to windows behind.
178          * This can be used as a hint for scrolling (avoiding resizing)
179          * the window to make certain that parts of its content
180          * are visible.
181          * @param decorFrame The decor frame specified by policy specific to this window,
182          * to use for proper cropping during animation.
183          * @param stableFrame The frame around which stable system decoration is positioned.
184          * @param outsetFrame The frame that includes areas that aren't part of the surface but we
185          * want to treat them as such.
186          */
computeFrameLw(Rect parentFrame, Rect displayFrame, Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame, Rect stableFrame, Rect outsetFrame)187         public void computeFrameLw(Rect parentFrame, Rect displayFrame,
188                 Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame,
189                 Rect stableFrame, Rect outsetFrame);
190 
191         /**
192          * Retrieve the current frame of the window that has been assigned by
193          * the window manager.  Must be called with the window manager lock held.
194          *
195          * @return Rect The rectangle holding the window frame.
196          */
getFrameLw()197         public Rect getFrameLw();
198 
199         /**
200          * Retrieve the current position of the window that is actually shown.
201          * Must be called with the window manager lock held.
202          *
203          * @return Point The point holding the shown window position.
204          */
getShownPositionLw()205         public Point getShownPositionLw();
206 
207         /**
208          * Retrieve the frame of the display that this window was last
209          * laid out in.  Must be called with the
210          * window manager lock held.
211          *
212          * @return Rect The rectangle holding the display frame.
213          */
getDisplayFrameLw()214         public Rect getDisplayFrameLw();
215 
216         /**
217          * Retrieve the frame of the area inside the overscan region of the
218          * display that this window was last laid out in.  Must be called with the
219          * window manager lock held.
220          *
221          * @return Rect The rectangle holding the display overscan frame.
222          */
getOverscanFrameLw()223         public Rect getOverscanFrameLw();
224 
225         /**
226          * Retrieve the frame of the content area that this window was last
227          * laid out in.  This is the area in which the content of the window
228          * should be placed.  It will be smaller than the display frame to
229          * account for screen decorations such as a status bar or soft
230          * keyboard.  Must be called with the
231          * window manager lock held.
232          *
233          * @return Rect The rectangle holding the content frame.
234          */
getContentFrameLw()235         public Rect getContentFrameLw();
236 
237         /**
238          * Retrieve the frame of the visible area that this window was last
239          * laid out in.  This is the area of the screen in which the window
240          * will actually be fully visible.  It will be smaller than the
241          * content frame to account for transient UI elements blocking it
242          * such as an input method's candidates UI.  Must be called with the
243          * window manager lock held.
244          *
245          * @return Rect The rectangle holding the visible frame.
246          */
getVisibleFrameLw()247         public Rect getVisibleFrameLw();
248 
249         /**
250          * Returns true if this window is waiting to receive its given
251          * internal insets from the client app, and so should not impact the
252          * layout of other windows.
253          */
getGivenInsetsPendingLw()254         public boolean getGivenInsetsPendingLw();
255 
256         /**
257          * Retrieve the insets given by this window's client for the content
258          * area of windows behind it.  Must be called with the
259          * window manager lock held.
260          *
261          * @return Rect The left, top, right, and bottom insets, relative
262          * to the window's frame, of the actual contents.
263          */
getGivenContentInsetsLw()264         public Rect getGivenContentInsetsLw();
265 
266         /**
267          * Retrieve the insets given by this window's client for the visible
268          * area of windows behind it.  Must be called with the
269          * window manager lock held.
270          *
271          * @return Rect The left, top, right, and bottom insets, relative
272          * to the window's frame, of the actual visible area.
273          */
getGivenVisibleInsetsLw()274         public Rect getGivenVisibleInsetsLw();
275 
276         /**
277          * Retrieve the current LayoutParams of the window.
278          *
279          * @return WindowManager.LayoutParams The window's internal LayoutParams
280          *         instance.
281          */
getAttrs()282         public WindowManager.LayoutParams getAttrs();
283 
284         /**
285          * Return whether this window needs the menu key shown.  Must be called
286          * with window lock held, because it may need to traverse down through
287          * window list to determine the result.
288          * @param bottom The bottom-most window to consider when determining this.
289          */
getNeedsMenuLw(WindowState bottom)290         public boolean getNeedsMenuLw(WindowState bottom);
291 
292         /**
293          * Retrieve the current system UI visibility flags associated with
294          * this window.
295          */
getSystemUiVisibility()296         public int getSystemUiVisibility();
297 
298         /**
299          * Get the layer at which this window's surface will be Z-ordered.
300          */
getSurfaceLayer()301         public int getSurfaceLayer();
302 
303         /**
304          * Retrieve the type of the top-level window.
305          *
306          * @return the base type of the parent window if attached or its own type otherwise
307          */
getBaseType()308         public int getBaseType();
309 
310         /**
311          * Return the token for the application (actually activity) that owns
312          * this window.  May return null for system windows.
313          *
314          * @return An IApplicationToken identifying the owning activity.
315          */
getAppToken()316         public IApplicationToken getAppToken();
317 
318         /**
319          * Return true if this window is participating in voice interaction.
320          */
isVoiceInteraction()321         public boolean isVoiceInteraction();
322 
323         /**
324          * Return true if, at any point, the application token associated with
325          * this window has actually displayed any windows.  This is most useful
326          * with the "starting up" window to determine if any windows were
327          * displayed when it is closed.
328          *
329          * @return Returns true if one or more windows have been displayed,
330          *         else false.
331          */
hasAppShownWindows()332         public boolean hasAppShownWindows();
333 
334         /**
335          * Is this window visible?  It is not visible if there is no
336          * surface, or we are in the process of running an exit animation
337          * that will remove the surface.
338          */
isVisibleLw()339         boolean isVisibleLw();
340 
341         /**
342          * Like {@link #isVisibleLw}, but also counts a window that is currently
343          * "hidden" behind the keyguard as visible.  This allows us to apply
344          * things like window flags that impact the keyguard.
345          */
isVisibleOrBehindKeyguardLw()346         boolean isVisibleOrBehindKeyguardLw();
347 
348         /**
349          * Is this window currently visible to the user on-screen?  It is
350          * displayed either if it is visible or it is currently running an
351          * animation before no longer being visible.  Must be called with the
352          * window manager lock held.
353          */
isDisplayedLw()354         boolean isDisplayedLw();
355 
356         /**
357          * Return true if this window (or a window it is attached to, but not
358          * considering its app token) is currently animating.
359          */
isAnimatingLw()360         boolean isAnimatingLw();
361 
362         /**
363          * Is this window considered to be gone for purposes of layout?
364          */
isGoneForLayoutLw()365         boolean isGoneForLayoutLw();
366 
367         /**
368          * Returns true if the window has a surface that it has drawn a
369          * complete UI in to. Note that this is different from {@link #hasDrawnLw()}
370          * in that it also returns true if the window is READY_TO_SHOW, but was not yet
371          * promoted to HAS_DRAWN.
372          */
isDrawnLw()373         boolean isDrawnLw();
374 
375         /**
376          * Returns true if this window has been shown on screen at some time in
377          * the past.  Must be called with the window manager lock held.
378          */
hasDrawnLw()379         public boolean hasDrawnLw();
380 
381         /**
382          * Can be called by the policy to force a window to be hidden,
383          * regardless of whether the client or window manager would like
384          * it shown.  Must be called with the window manager lock held.
385          * Returns true if {@link #showLw} was last called for the window.
386          */
hideLw(boolean doAnimation)387         public boolean hideLw(boolean doAnimation);
388 
389         /**
390          * Can be called to undo the effect of {@link #hideLw}, allowing a
391          * window to be shown as long as the window manager and client would
392          * also like it to be shown.  Must be called with the window manager
393          * lock held.
394          * Returns true if {@link #hideLw} was last called for the window.
395          */
showLw(boolean doAnimation)396         public boolean showLw(boolean doAnimation);
397 
398         /**
399          * Check whether the process hosting this window is currently alive.
400          */
isAlive()401         public boolean isAlive();
402 
403         /**
404          * Check if window is on {@link Display#DEFAULT_DISPLAY}.
405          * @return true if window is on default display.
406          */
isDefaultDisplay()407         public boolean isDefaultDisplay();
408 
409         /**
410          * Check whether the window is currently dimming.
411          */
isDimming()412         public boolean isDimming();
413 
414         /**
415          * @return the stack id this windows belongs to, or {@link StackId#INVALID_STACK_ID} if
416          *         not attached to any stack.
417          */
getStackId()418         int getStackId();
419 
420         /**
421          * Returns true if the window is current in multi-windowing mode. i.e. it shares the
422          * screen with other application windows.
423          */
isInMultiWindowMode()424         public boolean isInMultiWindowMode();
425 
getRotationAnimationHint()426         public int getRotationAnimationHint();
427     }
428 
429     /**
430      * Representation of a input consumer that the policy has added to the
431      * window manager to consume input events going to windows below it.
432      */
433     public interface InputConsumer {
434         /**
435          * Remove the input consumer from the window manager.
436          */
dismiss()437         void dismiss();
438     }
439 
440     /**
441      * Interface for calling back in to the window manager that is private
442      * between it and the policy.
443      */
444     public interface WindowManagerFuncs {
445         public static final int LID_ABSENT = -1;
446         public static final int LID_CLOSED = 0;
447         public static final int LID_OPEN = 1;
448 
449         public static final int CAMERA_LENS_COVER_ABSENT = -1;
450         public static final int CAMERA_LENS_UNCOVERED = 0;
451         public static final int CAMERA_LENS_COVERED = 1;
452 
453         /**
454          * Ask the window manager to re-evaluate the system UI flags.
455          */
reevaluateStatusBarVisibility()456         public void reevaluateStatusBarVisibility();
457 
458         /**
459          * Add a input consumer which will consume all input events going to any window below it.
460          */
addInputConsumer(Looper looper, InputEventReceiver.Factory inputEventReceiverFactory)461         public InputConsumer addInputConsumer(Looper looper,
462                 InputEventReceiver.Factory inputEventReceiverFactory);
463 
464         /**
465          * Returns a code that describes the current state of the lid switch.
466          */
getLidState()467         public int getLidState();
468 
469         /**
470          * Lock the device now.
471          */
lockDeviceNow()472         public void lockDeviceNow();
473 
474         /**
475          * Returns a code that descripbes whether the camera lens is covered or not.
476          */
getCameraLensCoverState()477         public int getCameraLensCoverState();
478 
479         /**
480          * Switch the input method, to be precise, input method subtype.
481          *
482          * @param forwardDirection {@code true} to rotate in a forward direction.
483          */
switchInputMethod(boolean forwardDirection)484         public void switchInputMethod(boolean forwardDirection);
485 
shutdown(boolean confirm)486         public void shutdown(boolean confirm);
reboot(boolean confirm)487         public void reboot(boolean confirm);
rebootSafeMode(boolean confirm)488         public void rebootSafeMode(boolean confirm);
489 
490         /**
491          * Return the window manager lock needed to correctly call "Lw" methods.
492          */
getWindowManagerLock()493         public Object getWindowManagerLock();
494 
495         /** Register a system listener for touch events */
registerPointerEventListener(PointerEventListener listener)496         void registerPointerEventListener(PointerEventListener listener);
497 
498         /** Unregister a system listener for touch events */
unregisterPointerEventListener(PointerEventListener listener)499         void unregisterPointerEventListener(PointerEventListener listener);
500 
501         /**
502          * @return The content insets of the docked divider window.
503          */
getDockedDividerInsetsLw()504         int getDockedDividerInsetsLw();
505 
506         /**
507          * Retrieves the {@param outBounds} from the stack with id {@param stackId}.
508          */
getStackBounds(int stackId, Rect outBounds)509         void getStackBounds(int stackId, Rect outBounds);
510     }
511 
512     public interface PointerEventListener {
513         /**
514          * 1. onPointerEvent will be called on the service.UiThread.
515          * 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a
516          * copy() must be made and the copy must be recycled.
517          **/
onPointerEvent(MotionEvent motionEvent)518         public void onPointerEvent(MotionEvent motionEvent);
519     }
520 
521     /** Window has been added to the screen. */
522     public static final int TRANSIT_ENTER = 1;
523     /** Window has been removed from the screen. */
524     public static final int TRANSIT_EXIT = 2;
525     /** Window has been made visible. */
526     public static final int TRANSIT_SHOW = 3;
527     /** Window has been made invisible.
528      * TODO: Consider removal as this is unused. */
529     public static final int TRANSIT_HIDE = 4;
530     /** The "application starting" preview window is no longer needed, and will
531      * animate away to show the real window. */
532     public static final int TRANSIT_PREVIEW_DONE = 5;
533 
534     // NOTE: screen off reasons are in order of significance, with more
535     // important ones lower than less important ones.
536 
537     /** Screen turned off because of a device admin */
538     public final int OFF_BECAUSE_OF_ADMIN = 1;
539     /** Screen turned off because of power button */
540     public final int OFF_BECAUSE_OF_USER = 2;
541     /** Screen turned off because of timeout */
542     public final int OFF_BECAUSE_OF_TIMEOUT = 3;
543 
544     /** @hide */
545     @IntDef({USER_ROTATION_FREE, USER_ROTATION_LOCKED})
546     @Retention(RetentionPolicy.SOURCE)
547     public @interface UserRotationMode {}
548 
549     /** When not otherwise specified by the activity's screenOrientation, rotation should be
550      * determined by the system (that is, using sensors). */
551     public final int USER_ROTATION_FREE = 0;
552     /** When not otherwise specified by the activity's screenOrientation, rotation is set by
553      * the user. */
554     public final int USER_ROTATION_LOCKED = 1;
555 
556     /**
557      * Perform initialization of the policy.
558      *
559      * @param context The system context we are running in.
560      */
init(Context context, IWindowManager windowManager, WindowManagerFuncs windowManagerFuncs)561     public void init(Context context, IWindowManager windowManager,
562             WindowManagerFuncs windowManagerFuncs);
563 
564     /**
565      * @return true if com.android.internal.R.bool#config_forceDefaultOrientation is true.
566      */
isDefaultOrientationForced()567     public boolean isDefaultOrientationForced();
568 
569     /**
570      * Called by window manager once it has the initial, default native
571      * display dimensions.
572      */
setInitialDisplaySize(Display display, int width, int height, int density)573     public void setInitialDisplaySize(Display display, int width, int height, int density);
574 
575     /**
576      * Called by window manager to set the overscan region that should be used for the
577      * given display.
578      */
setDisplayOverscan(Display display, int left, int top, int right, int bottom)579     public void setDisplayOverscan(Display display, int left, int top, int right, int bottom);
580 
581     /**
582      * Check permissions when adding a window.
583      *
584      * @param attrs The window's LayoutParams.
585      * @param outAppOp First element will be filled with the app op corresponding to
586      *                 this window, or OP_NONE.
587      *
588      * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
589      *      else an error code, usually
590      *      {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
591      */
checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp)592     public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp);
593 
594     /**
595      * Check permissions when adding a window.
596      *
597      * @param attrs The window's LayoutParams.
598      *
599      * @return True if the window may only be shown to the current user, false if the window can
600      * be shown on all users' windows.
601      */
checkShowToOwnerOnly(WindowManager.LayoutParams attrs)602     public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs);
603 
604     /**
605      * Sanitize the layout parameters coming from a client.  Allows the policy
606      * to do things like ensure that windows of a specific type can't take
607      * input focus.
608      *
609      * @param attrs The window layout parameters to be modified.  These values
610      * are modified in-place.
611      */
adjustWindowParamsLw(WindowManager.LayoutParams attrs)612     public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
613 
614     /**
615      * After the window manager has computed the current configuration based
616      * on its knowledge of the display and input devices, it gives the policy
617      * a chance to adjust the information contained in it.  If you want to
618      * leave it as-is, simply do nothing.
619      *
620      * <p>This method may be called by any thread in the window manager, but
621      * no internal locks in the window manager will be held.
622      *
623      * @param config The Configuration being computed, for you to change as
624      * desired.
625      * @param keyboardPresence Flags that indicate whether internal or external
626      * keyboards are present.
627      * @param navigationPresence Flags that indicate whether internal or external
628      * navigation devices are present.
629      */
adjustConfigurationLw(Configuration config, int keyboardPresence, int navigationPresence)630     public void adjustConfigurationLw(Configuration config, int keyboardPresence,
631             int navigationPresence);
632 
633     /**
634      * Assign a window type to a layer.  Allows you to control how different
635      * kinds of windows are ordered on-screen.
636      *
637      * @param type The type of window being assigned.
638      *
639      * @return int An arbitrary integer used to order windows, with lower
640      *         numbers below higher ones.
641      */
windowTypeToLayerLw(int type)642     public int windowTypeToLayerLw(int type);
643 
644     /**
645      * Return how to Z-order sub-windows in relation to the window they are
646      * attached to.  Return positive to have them ordered in front, negative for
647      * behind.
648      *
649      * @param type The sub-window type code.
650      *
651      * @return int Layer in relation to the attached window, where positive is
652      *         above and negative is below.
653      */
subWindowTypeToLayerLw(int type)654     public int subWindowTypeToLayerLw(int type);
655 
656     /**
657      * Get the highest layer (actually one more than) that the wallpaper is
658      * allowed to be in.
659      */
getMaxWallpaperLayer()660     public int getMaxWallpaperLayer();
661 
662     /**
663      * Return the display width available after excluding any screen
664      * decorations that could never be removed in Honeycomb. That is, system bar or
665      * button bar.
666      */
getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode)667     public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation,
668             int uiMode);
669 
670     /**
671      * Return the display height available after excluding any screen
672      * decorations that could never be removed in Honeycomb. That is, system bar or
673      * button bar.
674      */
getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode)675     public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation,
676             int uiMode);
677 
678     /**
679      * Return the available screen width that we should report for the
680      * configuration.  This must be no larger than
681      * {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than
682      * that to account for more transient decoration like a status bar.
683      */
getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode)684     public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation,
685             int uiMode);
686 
687     /**
688      * Return the available screen height that we should report for the
689      * configuration.  This must be no larger than
690      * {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than
691      * that to account for more transient decoration like a status bar.
692      */
getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode)693     public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation,
694             int uiMode);
695 
696     /**
697      * Return whether the given window is forcibly hiding all windows except windows with
698      * FLAG_SHOW_WHEN_LOCKED set.  Typically returns true for the keyguard.
699      */
isForceHiding(WindowManager.LayoutParams attrs)700     public boolean isForceHiding(WindowManager.LayoutParams attrs);
701 
702 
703     /**
704      * Return whether the given window can become one that passes isForceHiding() test.
705      * Typically returns true for the StatusBar.
706      */
isKeyguardHostWindow(WindowManager.LayoutParams attrs)707     public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs);
708 
709     /**
710      * Determine if a window that is behind one that is force hiding
711      * (as determined by {@link #isForceHiding}) should actually be hidden.
712      * For example, typically returns false for the status bar.  Be careful
713      * to return false for any window that you may hide yourself, since this
714      * will conflict with what you set.
715      */
canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs)716     public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs);
717 
718     /**
719      * Return the window that is hiding the keyguard, if such a thing exists.
720      */
getWinShowWhenLockedLw()721     public WindowState getWinShowWhenLockedLw();
722 
723     /**
724      * Called when the system would like to show a UI to indicate that an
725      * application is starting.  You can use this to add a
726      * APPLICATION_STARTING_TYPE window with the given appToken to the window
727      * manager (using the normal window manager APIs) that will be shown until
728      * the application displays its own window.  This is called without the
729      * window manager locked so that you can call back into it.
730      *
731      * @param appToken Token of the application being started.
732      * @param packageName The name of the application package being started.
733      * @param theme Resource defining the application's overall visual theme.
734      * @param nonLocalizedLabel The default title label of the application if
735      *        no data is found in the resource.
736      * @param labelRes The resource ID the application would like to use as its name.
737      * @param icon The resource ID the application would like to use as its icon.
738      * @param windowFlags Window layout flags.
739      * @param overrideConfig override configuration to consider when generating
740      *        context to for resources.
741      *
742      * @return Optionally you can return the View that was used to create the
743      *         window, for easy removal in removeStartingWindow.
744      *
745      * @see #removeStartingWindow
746      */
addStartingWindow(IBinder appToken, String packageName, int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig)747     public View addStartingWindow(IBinder appToken, String packageName,
748             int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel,
749             int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig);
750 
751     /**
752      * Called when the first window of an application has been displayed, while
753      * {@link #addStartingWindow} has created a temporary initial window for
754      * that application.  You should at this point remove the window from the
755      * window manager.  This is called without the window manager locked so
756      * that you can call back into it.
757      *
758      * <p>Note: due to the nature of these functions not being called with the
759      * window manager locked, you must be prepared for this function to be
760      * called multiple times and/or an initial time with a null View window
761      * even if you previously returned one.
762      *
763      * @param appToken Token of the application that has started.
764      * @param window Window View that was returned by createStartingWindow.
765      *
766      * @see #addStartingWindow
767      */
removeStartingWindow(IBinder appToken, View window)768     public void removeStartingWindow(IBinder appToken, View window);
769 
770     /**
771      * Prepare for a window being added to the window manager.  You can throw an
772      * exception here to prevent the window being added, or do whatever setup
773      * you need to keep track of the window.
774      *
775      * @param win The window being added.
776      * @param attrs The window's LayoutParams.
777      *
778      * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an
779      *         error code to abort the add.
780      */
prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs)781     public int prepareAddWindowLw(WindowState win,
782             WindowManager.LayoutParams attrs);
783 
784     /**
785      * Called when a window is being removed from a window manager.  Must not
786      * throw an exception -- clean up as much as possible.
787      *
788      * @param win The window being removed.
789      */
removeWindowLw(WindowState win)790     public void removeWindowLw(WindowState win);
791 
792     /**
793      * Control the animation to run when a window's state changes.  Return a
794      * non-0 number to force the animation to a specific resource ID, or 0
795      * to use the default animation.
796      *
797      * @param win The window that is changing.
798      * @param transit What is happening to the window: {@link #TRANSIT_ENTER},
799      *                {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
800      *                {@link #TRANSIT_HIDE}.
801      *
802      * @return Resource ID of the actual animation to use, or 0 for none.
803      */
selectAnimationLw(WindowState win, int transit)804     public int selectAnimationLw(WindowState win, int transit);
805 
806     /**
807      * Determine the animation to run for a rotation transition based on the
808      * top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation}
809      * and whether it is currently fullscreen and frontmost.
810      *
811      * @param anim The exiting animation resource id is stored in anim[0], the
812      * entering animation resource id is stored in anim[1].
813      */
selectRotationAnimationLw(int anim[])814     public void selectRotationAnimationLw(int anim[]);
815 
816     /**
817      * Validate whether the current top fullscreen has specified the same
818      * {@link WindowManager.LayoutParams#rotationAnimation} value as that
819      * being passed in from the previous top fullscreen window.
820      *
821      * @param exitAnimId exiting resource id from the previous window.
822      * @param enterAnimId entering resource id from the previous window.
823      * @param forceDefault For rotation animations only, if true ignore the
824      * animation values and just return false.
825      * @return true if the previous values are still valid, false if they
826      * should be replaced with the default.
827      */
validateRotationAnimationLw(int exitAnimId, int enterAnimId, boolean forceDefault)828     public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId,
829             boolean forceDefault);
830 
831     /**
832      * Create and return an animation to re-display a force hidden window.
833      */
createForceHideEnterAnimation(boolean onWallpaper, boolean goingToNotificationShade)834     public Animation createForceHideEnterAnimation(boolean onWallpaper,
835             boolean goingToNotificationShade);
836 
837     /**
838      * Create and return an animation to let the wallpaper disappear after being shown on a force
839      * hiding window.
840      */
createForceHideWallpaperExitAnimation(boolean goingToNotificationShade)841     public Animation createForceHideWallpaperExitAnimation(boolean goingToNotificationShade);
842 
843     /**
844      * Called from the input reader thread before a key is enqueued.
845      *
846      * <p>There are some actions that need to be handled here because they
847      * affect the power state of the device, for example, the power keys.
848      * Generally, it's best to keep as little as possible in the queue thread
849      * because it's the most fragile.
850      * @param event The key event.
851      * @param policyFlags The policy flags associated with the key.
852      *
853      * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
854      */
interceptKeyBeforeQueueing(KeyEvent event, int policyFlags)855     public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags);
856 
857     /**
858      * Called from the input reader thread before a motion is enqueued when the device is in a
859      * non-interactive state.
860      *
861      * <p>There are some actions that need to be handled here because they
862      * affect the power state of the device, for example, waking on motions.
863      * Generally, it's best to keep as little as possible in the queue thread
864      * because it's the most fragile.
865      * @param policyFlags The policy flags associated with the motion.
866      *
867      * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
868      */
interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags)869     public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags);
870 
871     /**
872      * Called from the input dispatcher thread before a key is dispatched to a window.
873      *
874      * <p>Allows you to define
875      * behavior for keys that can not be overridden by applications.
876      * This method is called from the input thread, with no locks held.
877      *
878      * @param win The window that currently has focus.  This is where the key
879      *            event will normally go.
880      * @param event The key event.
881      * @param policyFlags The policy flags associated with the key.
882      * @return 0 if the key should be dispatched immediately, -1 if the key should
883      * not be dispatched ever, or a positive value indicating the number of
884      * milliseconds by which the key dispatch should be delayed before trying
885      * again.
886      */
interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags)887     public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
888 
889     /**
890      * Called from the input dispatcher thread when an application did not handle
891      * a key that was dispatched to it.
892      *
893      * <p>Allows you to define default global behavior for keys that were not handled
894      * by applications.  This method is called from the input thread, with no locks held.
895      *
896      * @param win The window that currently has focus.  This is where the key
897      *            event will normally go.
898      * @param event The key event.
899      * @param policyFlags The policy flags associated with the key.
900      * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
901      * The caller is responsible for recycling the key event.
902      */
dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags)903     public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
904 
905     /**
906      * Called when layout of the windows is about to start.
907      *
908      * @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}.
909      * @param displayWidth The current full width of the screen.
910      * @param displayHeight The current full height of the screen.
911      * @param displayRotation The current rotation being applied to the base window.
912      * @param uiMode The current uiMode in configuration.
913      */
beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, int displayRotation, int uiMode)914     public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
915                               int displayRotation, int uiMode);
916 
917     /**
918      * Returns the bottom-most layer of the system decor, above which no policy decor should
919      * be applied.
920      */
getSystemDecorLayerLw()921     public int getSystemDecorLayerLw();
922 
923     /**
924      * Return the rectangle of the screen that is available for applications to run in.
925      * This will be called immediately after {@link #beginLayoutLw}.
926      *
927      * @param r The rectangle to be filled with the boundaries available to applications.
928      */
getContentRectLw(Rect r)929     public void getContentRectLw(Rect r);
930 
931     /**
932      * Called for each window attached to the window manager as layout is
933      * proceeding.  The implementation of this function must take care of
934      * setting the window's frame, either here or in finishLayout().
935      *
936      * @param win The window being positioned.
937      * @param attached For sub-windows, the window it is attached to; this
938      *                 window will already have had layoutWindow() called on it
939      *                 so you can use its Rect.  Otherwise null.
940      */
layoutWindowLw(WindowState win, WindowState attached)941     public void layoutWindowLw(WindowState win, WindowState attached);
942 
943 
944     /**
945      * Return the insets for the areas covered by system windows. These values
946      * are computed on the most recent layout, so they are not guaranteed to
947      * be correct.
948      *
949      * @param attrs The LayoutParams of the window.
950      * @param taskBounds The bounds of the task this window is on or {@code null} if no task is
951      *                   associated with the window.
952      * @param displayRotation Rotation of the display.
953      * @param displayWidth The width of the display.
954      * @param displayHeight The height of the display.
955      * @param outContentInsets The areas covered by system windows, expressed as positive insets.
956      * @param outStableInsets The areas covered by stable system windows irrespective of their
957      *                        current visibility. Expressed as positive insets.
958      * @param outOutsets The areas that are not real display, but we would like to treat as such.
959      * @return Whether to always consume the navigation bar.
960      *         See {@link #isNavBarForcedShownLw(WindowState)}.
961      */
getInsetHintLw(WindowManager.LayoutParams attrs, Rect taskBounds, int displayRotation, int displayWidth, int displayHeight, Rect outContentInsets, Rect outStableInsets, Rect outOutsets)962     public boolean getInsetHintLw(WindowManager.LayoutParams attrs, Rect taskBounds,
963             int displayRotation, int displayWidth, int displayHeight, Rect outContentInsets,
964             Rect outStableInsets, Rect outOutsets);
965 
966     /**
967      * Called when layout of the windows is finished.  After this function has
968      * returned, all windows given to layoutWindow() <em>must</em> have had a
969      * frame assigned.
970      */
finishLayoutLw()971     public void finishLayoutLw();
972 
973     /** Layout state may have changed (so another layout will be performed) */
974     static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
975     /** Configuration state may have changed */
976     static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
977     /** Wallpaper may need to move */
978     static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
979     /** Need to recompute animations */
980     static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
981 
982     /**
983      * Called following layout of all windows before each window has policy applied.
984      *
985      * @param displayWidth The current full width of the screen.
986      * @param displayHeight The current full height of the screen.
987      */
beginPostLayoutPolicyLw(int displayWidth, int displayHeight)988     public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight);
989 
990     /**
991      * Called following layout of all window to apply policy to each window.
992      *
993      * @param win The window being positioned.
994      * @param attrs The LayoutParams of the window.
995      * @param attached For sub-windows, the window it is attached to. Otherwise null.
996      */
applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams attrs, WindowState attached)997     public void applyPostLayoutPolicyLw(WindowState win,
998             WindowManager.LayoutParams attrs, WindowState attached);
999 
1000     /**
1001      * Called following layout of all windows and after policy has been applied
1002      * to each window. If in this function you do
1003      * something that may have modified the animation state of another window,
1004      * be sure to return non-zero in order to perform another pass through layout.
1005      *
1006      * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
1007      * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
1008      * or {@link #FINISH_LAYOUT_REDO_ANIM}.
1009      */
finishPostLayoutPolicyLw()1010     public int finishPostLayoutPolicyLw();
1011 
1012     /**
1013      * Return true if it is okay to perform animations for an app transition
1014      * that is about to occur.  You may return false for this if, for example,
1015      * the lock screen is currently displayed so the switch should happen
1016      * immediately.
1017      */
allowAppAnimationsLw()1018     public boolean allowAppAnimationsLw();
1019 
1020 
1021     /**
1022      * A new window has been focused.
1023      */
focusChangedLw(WindowState lastFocus, WindowState newFocus)1024     public int focusChangedLw(WindowState lastFocus, WindowState newFocus);
1025 
1026     /**
1027      * Called when the device has started waking up.
1028      */
startedWakingUp()1029     public void startedWakingUp();
1030 
1031     /**
1032      * Called when the device has finished waking up.
1033      */
finishedWakingUp()1034     public void finishedWakingUp();
1035 
1036     /**
1037      * Called when the device has started going to sleep.
1038      *
1039      * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
1040      * or {@link #OFF_BECAUSE_OF_TIMEOUT}.
1041      */
startedGoingToSleep(int why)1042     public void startedGoingToSleep(int why);
1043 
1044     /**
1045      * Called when the device has finished going to sleep.
1046      *
1047      * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
1048      * or {@link #OFF_BECAUSE_OF_TIMEOUT}.
1049      */
finishedGoingToSleep(int why)1050     public void finishedGoingToSleep(int why);
1051 
1052     /**
1053      * Called when the device is about to turn on the screen to show content.
1054      * When waking up, this method will be called once after the call to wakingUp().
1055      * When dozing, the method will be called sometime after the call to goingToSleep() and
1056      * may be called repeatedly in the case where the screen is pulsing on and off.
1057      *
1058      * Must call back on the listener to tell it when the higher-level system
1059      * is ready for the screen to go on (i.e. the lock screen is shown).
1060      */
screenTurningOn(ScreenOnListener screenOnListener)1061     public void screenTurningOn(ScreenOnListener screenOnListener);
1062 
1063     /**
1064      * Called when the device has actually turned on the screen, i.e. the display power state has
1065      * been set to ON and the screen is unblocked.
1066      */
screenTurnedOn()1067     public void screenTurnedOn();
1068 
1069     /**
1070      * Called when the device has turned the screen off.
1071      */
screenTurnedOff()1072     public void screenTurnedOff();
1073 
1074     public interface ScreenOnListener {
onScreenOn()1075         void onScreenOn();
1076     }
1077 
1078     /**
1079      * Return whether the default display is on and not blocked by a black surface.
1080      */
isScreenOn()1081     public boolean isScreenOn();
1082 
1083     /**
1084      * Tell the policy that the lid switch has changed state.
1085      * @param whenNanos The time when the change occurred in uptime nanoseconds.
1086      * @param lidOpen True if the lid is now open.
1087      */
notifyLidSwitchChanged(long whenNanos, boolean lidOpen)1088     public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
1089 
1090     /**
1091      * Tell the policy that the camera lens has been covered or uncovered.
1092      * @param whenNanos The time when the change occurred in uptime nanoseconds.
1093      * @param lensCovered True if the lens is covered.
1094      */
notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered)1095     public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered);
1096 
1097     /**
1098      * Tell the policy if anyone is requesting that keyguard not come on.
1099      *
1100      * @param enabled Whether keyguard can be on or not.  does not actually
1101      * turn it on, unless it was previously disabled with this function.
1102      *
1103      * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
1104      * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
1105      */
1106     @SuppressWarnings("javadoc")
enableKeyguard(boolean enabled)1107     public void enableKeyguard(boolean enabled);
1108 
1109     /**
1110      * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely}
1111      */
1112     interface OnKeyguardExitResult {
onKeyguardExitResult(boolean success)1113         void onKeyguardExitResult(boolean success);
1114     }
1115 
1116     /**
1117      * Tell the policy if anyone is requesting the keyguard to exit securely
1118      * (this would be called after the keyguard was disabled)
1119      * @param callback Callback to send the result back.
1120      * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
1121      */
1122     @SuppressWarnings("javadoc")
exitKeyguardSecurely(OnKeyguardExitResult callback)1123     void exitKeyguardSecurely(OnKeyguardExitResult callback);
1124 
1125     /**
1126      * isKeyguardLocked
1127      *
1128      * Return whether the keyguard is currently locked.
1129      *
1130      * @return true if in keyguard is locked.
1131      */
isKeyguardLocked()1132     public boolean isKeyguardLocked();
1133 
1134     /**
1135      * isKeyguardSecure
1136      *
1137      * Return whether the keyguard requires a password to unlock.
1138      * @param userId
1139      *
1140      * @return true if in keyguard is secure.
1141      */
isKeyguardSecure(int userId)1142     public boolean isKeyguardSecure(int userId);
1143 
1144     /**
1145      * Return whether the keyguard is on.
1146      *
1147      * @return true if in keyguard is on.
1148      */
isKeyguardShowingOrOccluded()1149     public boolean isKeyguardShowingOrOccluded();
1150 
1151     /**
1152      * inKeyguardRestrictedKeyInputMode
1153      *
1154      * if keyguard screen is showing or in restricted key input mode (i.e. in
1155      * keyguard password emergency screen). When in such mode, certain keys,
1156      * such as the Home key and the right soft keys, don't work.
1157      *
1158      * @return true if in keyguard restricted input mode.
1159      */
inKeyguardRestrictedKeyInputMode()1160     public boolean inKeyguardRestrictedKeyInputMode();
1161 
1162     /**
1163      * Ask the policy to dismiss the keyguard, if it is currently shown.
1164      */
dismissKeyguardLw()1165     public void dismissKeyguardLw();
1166 
1167     /**
1168      * Notifies the keyguard that the activity has drawn it was waiting for.
1169      */
notifyActivityDrawnForKeyguardLw()1170     public void notifyActivityDrawnForKeyguardLw();
1171 
1172     /**
1173      * Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method
1174      * returns true as soon as we know that Keyguard is disabled.
1175      *
1176      * @return true if the keyguard has drawn.
1177      */
isKeyguardDrawnLw()1178     public boolean isKeyguardDrawnLw();
1179 
1180     /**
1181      * Given an orientation constant, returns the appropriate surface rotation,
1182      * taking into account sensors, docking mode, rotation lock, and other factors.
1183      *
1184      * @param orientation An orientation constant, such as
1185      * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
1186      * @param lastRotation The most recently used rotation.
1187      * @return The surface rotation to use.
1188      */
rotationForOrientationLw(@ctivityInfo.ScreenOrientation int orientation, int lastRotation)1189     public int rotationForOrientationLw(@ActivityInfo.ScreenOrientation int orientation,
1190             int lastRotation);
1191 
1192     /**
1193      * Given an orientation constant and a rotation, returns true if the rotation
1194      * has compatible metrics to the requested orientation.  For example, if
1195      * the application requested landscape and got seascape, then the rotation
1196      * has compatible metrics; if the application requested portrait and got landscape,
1197      * then the rotation has incompatible metrics; if the application did not specify
1198      * a preference, then anything goes.
1199      *
1200      * @param orientation An orientation constant, such as
1201      * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
1202      * @param rotation The rotation to check.
1203      * @return True if the rotation is compatible with the requested orientation.
1204      */
rotationHasCompatibleMetricsLw(@ctivityInfo.ScreenOrientation int orientation, int rotation)1205     public boolean rotationHasCompatibleMetricsLw(@ActivityInfo.ScreenOrientation int orientation,
1206             int rotation);
1207 
1208     /**
1209      * Called by the window manager when the rotation changes.
1210      *
1211      * @param rotation The new rotation.
1212      */
setRotationLw(int rotation)1213     public void setRotationLw(int rotation);
1214 
1215     /**
1216      * Called when the system is mostly done booting to set whether
1217      * the system should go into safe mode.
1218      */
setSafeMode(boolean safeMode)1219     public void setSafeMode(boolean safeMode);
1220 
1221     /**
1222      * Called when the system is mostly done booting.
1223      */
systemReady()1224     public void systemReady();
1225 
1226     /**
1227      * Called when the system is done booting to the point where the
1228      * user can start interacting with it.
1229      */
systemBooted()1230     public void systemBooted();
1231 
1232     /**
1233      * Show boot time message to the user.
1234      */
showBootMessage(final CharSequence msg, final boolean always)1235     public void showBootMessage(final CharSequence msg, final boolean always);
1236 
1237     /**
1238      * Hide the UI for showing boot messages, never to be displayed again.
1239      */
hideBootMessages()1240     public void hideBootMessages();
1241 
1242     /**
1243      * Called when userActivity is signalled in the power manager.
1244      * This is safe to call from any thread, with any window manager locks held or not.
1245      */
userActivity()1246     public void userActivity();
1247 
1248     /**
1249      * Called when we have finished booting and can now display the home
1250      * screen to the user.  This will happen after systemReady(), and at
1251      * this point the display is active.
1252      */
enableScreenAfterBoot()1253     public void enableScreenAfterBoot();
1254 
setCurrentOrientationLw(@ctivityInfo.ScreenOrientation int newOrientation)1255     public void setCurrentOrientationLw(@ActivityInfo.ScreenOrientation int newOrientation);
1256 
1257     /**
1258      * Call from application to perform haptic feedback on its window.
1259      */
performHapticFeedbackLw(WindowState win, int effectId, boolean always)1260     public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
1261 
1262     /**
1263      * Called when we have started keeping the screen on because a window
1264      * requesting this has become visible.
1265      */
keepScreenOnStartedLw()1266     public void keepScreenOnStartedLw();
1267 
1268     /**
1269      * Called when we have stopped keeping the screen on because the last window
1270      * requesting this is no longer visible.
1271      */
keepScreenOnStoppedLw()1272     public void keepScreenOnStoppedLw();
1273 
1274     /**
1275      * Gets the current user rotation mode.
1276      *
1277      * @return The rotation mode.
1278      *
1279      * @see WindowManagerPolicy#USER_ROTATION_LOCKED
1280      * @see WindowManagerPolicy#USER_ROTATION_FREE
1281      */
1282     @UserRotationMode
getUserRotationMode()1283     public int getUserRotationMode();
1284 
1285     /**
1286      * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
1287      *
1288      * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
1289      *             {@link WindowManagerPolicy#USER_ROTATION_FREE}.
1290      * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
1291      *                 {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
1292      */
setUserRotationMode(@serRotationMode int mode, @Surface.Rotation int rotation)1293     public void setUserRotationMode(@UserRotationMode int mode, @Surface.Rotation int rotation);
1294 
1295     /**
1296      * Called when a new system UI visibility is being reported, allowing
1297      * the policy to adjust what is actually reported.
1298      * @param visibility The raw visibility reported by the status bar.
1299      * @return The new desired visibility.
1300      */
adjustSystemUiVisibilityLw(int visibility)1301     public int adjustSystemUiVisibilityLw(int visibility);
1302 
1303     /**
1304      * Specifies whether there is an on-screen navigation bar separate from the status bar.
1305      */
hasNavigationBar()1306     public boolean hasNavigationBar();
1307 
1308     /**
1309      * Lock the device now.
1310      */
lockNow(Bundle options)1311     public void lockNow(Bundle options);
1312 
1313     /**
1314      * Set the last used input method window state. This state is used to make IME transition
1315      * smooth.
1316      * @hide
1317      */
setLastInputMethodWindowLw(WindowState ime, WindowState target)1318     public void setLastInputMethodWindowLw(WindowState ime, WindowState target);
1319 
1320     /**
1321      * Show the recents task list app.
1322      * @hide
1323      */
showRecentApps(boolean fromHome)1324     public void showRecentApps(boolean fromHome);
1325 
1326     /**
1327      * Show the global actions dialog.
1328      * @hide
1329      */
showGlobalActions()1330     public void showGlobalActions();
1331 
1332     /**
1333      * @return The current height of the input method window.
1334      */
getInputMethodWindowVisibleHeightLw()1335     public int getInputMethodWindowVisibleHeightLw();
1336 
1337     /**
1338      * Called when the current user changes. Guaranteed to be called before the broadcast
1339      * of the new user id is made to all listeners.
1340      *
1341      * @param newUserId The id of the incoming user.
1342      */
setCurrentUserLw(int newUserId)1343     public void setCurrentUserLw(int newUserId);
1344 
1345     /**
1346      * Print the WindowManagerPolicy's state into the given stream.
1347      *
1348      * @param prefix Text to print at the front of each line.
1349      * @param writer The PrintWriter to which you should dump your state.  This will be
1350      * closed for you after you return.
1351      * @param args additional arguments to the dump request.
1352      */
dump(String prefix, PrintWriter writer, String[] args)1353     public void dump(String prefix, PrintWriter writer, String[] args);
1354 
1355     /**
1356      * Returns whether a given window type can be magnified.
1357      *
1358      * @param windowType The window type.
1359      * @return True if the window can be magnified.
1360      */
canMagnifyWindow(int windowType)1361     public boolean canMagnifyWindow(int windowType);
1362 
1363     /**
1364      * Returns whether a given window type is considered a top level one.
1365      * A top level window does not have a container, i.e. attached window,
1366      * or if it has a container it is laid out as a top-level window, not
1367      * as a child of its container.
1368      *
1369      * @param windowType The window type.
1370      * @return True if the window is a top level one.
1371      */
isTopLevelWindow(int windowType)1372     public boolean isTopLevelWindow(int windowType);
1373 
1374     /**
1375      * Notifies the keyguard to start fading out.
1376      *
1377      * @param startTime the start time of the animation in uptime milliseconds
1378      * @param fadeoutDuration the duration of the exit animation, in milliseconds
1379      */
startKeyguardExitAnimation(long startTime, long fadeoutDuration)1380     public void startKeyguardExitAnimation(long startTime, long fadeoutDuration);
1381 
1382     /**
1383      * Calculates the stable insets without running a layout.
1384      *
1385      * @param displayRotation the current display rotation
1386      * @param displayWidth the current display width
1387      * @param displayHeight the current display height
1388      * @param outInsets the insets to return
1389      */
getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets)1390     public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight,
1391             Rect outInsets);
1392 
1393 
1394     /**
1395      * @return true if the navigation bar is forced to stay visible
1396      */
isNavBarForcedShownLw(WindowState win)1397     public boolean isNavBarForcedShownLw(WindowState win);
1398 
1399     /**
1400      * Calculates the insets for the areas that could never be removed in Honeycomb, i.e. system
1401      * bar or button bar. See {@link #getNonDecorDisplayWidth}.
1402      *
1403      * @param displayRotation the current display rotation
1404      * @param displayWidth the current display width
1405      * @param displayHeight the current display height
1406      * @param outInsets the insets to return
1407      */
getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets)1408     public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight,
1409             Rect outInsets);
1410 
1411     /**
1412      * @return True if a specified {@param dockSide} is allowed on the current device, or false
1413      *         otherwise. It is guaranteed that at least one dock side for a particular orientation
1414      *         is allowed, so for example, if DOCKED_RIGHT is not allowed, DOCKED_LEFT is allowed.
1415      */
isDockSideAllowed(int dockSide)1416     public boolean isDockSideAllowed(int dockSide);
1417 
1418     /**
1419      * Called when the configuration has changed, and it's safe to load new values from resources.
1420      */
onConfigurationChanged()1421     public void onConfigurationChanged();
1422 
shouldRotateSeamlessly(int oldRotation, int newRotation)1423     public boolean shouldRotateSeamlessly(int oldRotation, int newRotation);
1424 }
1425