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