public interface WindowManagerPolicy
Because this provides deep interaction with the system window manager, specific methods on this interface can be called from a variety of contexts with various restrictions on what they can do. These are encoded through a suffixes at the end of a method encoding the thread the method is called from and any locks that are held when it is being called; if no suffix is attached to a method, then it is not called with any locks and may be called from the main window manager thread or another thread calling into the window manager.
The current suffixes are:
Context.checkPermission(String, int, int)
and
variations require calling into the activity manager.
Modifier and Type | Interface and Description |
---|---|
static interface |
WindowManagerPolicy.InputConsumer
Representation of a input consumer that the policy has added to the
window manager to consume input events going to windows below it.
|
static interface |
WindowManagerPolicy.OnKeyguardExitResult
|
static interface |
WindowManagerPolicy.PointerEventListener |
static interface |
WindowManagerPolicy.ScreenOnListener |
static interface |
WindowManagerPolicy.UserRotationMode |
static interface |
WindowManagerPolicy.WindowManagerFuncs
Interface for calling back in to the window manager that is private
between it and the policy.
|
static interface |
WindowManagerPolicy.WindowState
Interface to the Window Manager state associated with a particular
window.
|
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_HDMI_PLUGGED
Sticky broadcast of the current HDMI plugged state.
|
static int |
ACTION_PASS_TO_USER
Pass this event to the user / app.
|
static String |
EXTRA_FROM_HOME_KEY
Set to
true when intent was invoked from pressing the home key. |
static String |
EXTRA_HDMI_PLUGGED_STATE
Extra in
ACTION_HDMI_PLUGGED indicating the state: true if
plugged in to HDMI, false if not. |
static int |
FINISH_LAYOUT_REDO_ANIM
Need to recompute animations
|
static int |
FINISH_LAYOUT_REDO_CONFIG
Configuration state may have changed
|
static int |
FINISH_LAYOUT_REDO_LAYOUT
Layout state may have changed (so another layout will be performed)
|
static int |
FINISH_LAYOUT_REDO_WALLPAPER
Wallpaper may need to move
|
static int |
FLAG_DISABLE_KEY_REPEAT |
static int |
FLAG_FILTERED |
static int |
FLAG_INJECTED |
static int |
FLAG_INTERACTIVE |
static int |
FLAG_PASS_TO_USER |
static int |
FLAG_TRUSTED |
static int |
FLAG_VIRTUAL |
static int |
FLAG_WAKE |
static int |
KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS |
static int |
KEYGUARD_GOING_AWAY_FLAG_TO_SHADE |
static int |
KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER |
static int |
OFF_BECAUSE_OF_ADMIN
Screen turned off because of a device admin
|
static int |
OFF_BECAUSE_OF_TIMEOUT
Screen turned off because of timeout
|
static int |
OFF_BECAUSE_OF_USER
Screen turned off because of power button
|
static int |
PRESENCE_EXTERNAL |
static int |
PRESENCE_INTERNAL |
static int |
TRANSIT_ENTER
Window has been added to the screen.
|
static int |
TRANSIT_EXIT
Window has been removed from the screen.
|
static int |
TRANSIT_HIDE
Window has been made invisible.
|
static int |
TRANSIT_PREVIEW_DONE
The "application starting" preview window is no longer needed, and will
animate away to show the real window.
|
static int |
TRANSIT_SHOW
Window has been made visible.
|
static int |
USER_ROTATION_FREE
When not otherwise specified by the activity's screenOrientation, rotation should be
determined by the system (that is, using sensors).
|
static int |
USER_ROTATION_LOCKED
When not otherwise specified by the activity's screenOrientation, rotation is set by
the user.
|
static boolean |
WATCH_POINTER |
Modifier and Type | Method and Description |
---|---|
View |
addStartingWindow(IBinder appToken,
String packageName,
int theme,
CompatibilityInfo compatInfo,
CharSequence nonLocalizedLabel,
int labelRes,
int icon,
int logo,
int windowFlags,
Configuration overrideConfig)
Called when the system would like to show a UI to indicate that an
application is starting.
|
void |
adjustConfigurationLw(Configuration config,
int keyboardPresence,
int navigationPresence)
After the window manager has computed the current configuration based
on its knowledge of the display and input devices, it gives the policy
a chance to adjust the information contained in it.
|
int |
adjustSystemUiVisibilityLw(int visibility)
Called when a new system UI visibility is being reported, allowing
the policy to adjust what is actually reported.
|
void |
adjustWindowParamsLw(WindowManager.LayoutParams attrs)
Sanitize the layout parameters coming from a client.
|
boolean |
allowAppAnimationsLw()
Return true if it is okay to perform animations for an app transition
that is about to occur.
|
void |
applyPostLayoutPolicyLw(WindowManagerPolicy.WindowState win,
WindowManager.LayoutParams attrs,
WindowManagerPolicy.WindowState attached)
Called following layout of all window to apply policy to each window.
|
void |
beginLayoutLw(boolean isDefaultDisplay,
int displayWidth,
int displayHeight,
int displayRotation,
int uiMode)
Called when layout of the windows is about to start.
|
void |
beginPostLayoutPolicyLw(int displayWidth,
int displayHeight)
Called following layout of all windows before each window has policy applied.
|
boolean |
canBeForceHidden(WindowManagerPolicy.WindowState win,
WindowManager.LayoutParams attrs)
Determine if a window that is behind one that is force hiding
(as determined by
isForceHiding(android.view.WindowManager.LayoutParams) ) should actually be hidden. |
boolean |
canMagnifyWindow(int windowType)
Returns whether a given window type can be magnified.
|
boolean |
canShowDismissingWindowWhileLockedLw() |
int |
checkAddPermission(WindowManager.LayoutParams attrs,
int[] outAppOp)
Check permissions when adding a window.
|
boolean |
checkShowToOwnerOnly(WindowManager.LayoutParams attrs)
Check permissions when adding a window.
|
Animation |
createForceHideEnterAnimation(boolean onWallpaper,
boolean goingToNotificationShade)
Create and return an animation to re-display a force hidden window.
|
Animation |
createForceHideWallpaperExitAnimation(boolean goingToNotificationShade)
Create and return an animation to let the wallpaper disappear after being shown on a force
hiding window.
|
void |
dismissKeyguardLw()
Ask the policy to dismiss the keyguard, if it is currently shown.
|
KeyEvent |
dispatchUnhandledKey(WindowManagerPolicy.WindowState win,
KeyEvent event,
int policyFlags)
Called from the input dispatcher thread when an application did not handle
a key that was dispatched to it.
|
void |
dump(String prefix,
PrintWriter writer,
String[] args)
Print the WindowManagerPolicy's state into the given stream.
|
void |
enableKeyguard(boolean enabled)
Tell the policy if anyone is requesting that keyguard not come on.
|
void |
enableScreenAfterBoot()
Called when we have finished booting and can now display the home
screen to the user.
|
void |
exitKeyguardSecurely(WindowManagerPolicy.OnKeyguardExitResult callback)
Tell the policy if anyone is requesting the keyguard to exit securely
(this would be called after the keyguard was disabled)
|
void |
finishedGoingToSleep(int why)
Called when the device has finished going to sleep.
|
void |
finishedWakingUp()
Called when the device has finished waking up.
|
void |
finishLayoutLw()
Called when layout of the windows is finished.
|
int |
finishPostLayoutPolicyLw()
Called following layout of all windows and after policy has been applied
to each window.
|
int |
focusChangedLw(WindowManagerPolicy.WindowState lastFocus,
WindowManagerPolicy.WindowState newFocus)
A new window has been focused.
|
int |
getConfigDisplayHeight(int fullWidth,
int fullHeight,
int rotation,
int uiMode)
Return the available screen height that we should report for the
configuration.
|
int |
getConfigDisplayWidth(int fullWidth,
int fullHeight,
int rotation,
int uiMode)
Return the available screen width that we should report for the
configuration.
|
void |
getContentRectLw(Rect r)
Return the rectangle of the screen that is available for applications to run in.
|
int |
getInputMethodWindowVisibleHeightLw() |
boolean |
getInsetHintLw(WindowManager.LayoutParams attrs,
Rect taskBounds,
int displayRotation,
int displayWidth,
int displayHeight,
Rect outContentInsets,
Rect outStableInsets,
Rect outOutsets)
Return the insets for the areas covered by system windows.
|
int |
getMaxWallpaperLayer()
Get the highest layer (actually one more than) that the wallpaper is
allowed to be in.
|
int |
getNonDecorDisplayHeight(int fullWidth,
int fullHeight,
int rotation,
int uiMode)
Return the display height available after excluding any screen
decorations that could never be removed in Honeycomb.
|
int |
getNonDecorDisplayWidth(int fullWidth,
int fullHeight,
int rotation,
int uiMode)
Return the display width available after excluding any screen
decorations that could never be removed in Honeycomb.
|
void |
getNonDecorInsetsLw(int displayRotation,
int displayWidth,
int displayHeight,
Rect outInsets)
Calculates the insets for the areas that could never be removed in Honeycomb, i.e. system
bar or button bar.
|
void |
getStableInsetsLw(int displayRotation,
int displayWidth,
int displayHeight,
Rect outInsets)
Calculates the stable insets without running a layout.
|
int |
getSystemDecorLayerLw()
Returns the bottom-most layer of the system decor, above which no policy decor should
be applied.
|
int |
getUserRotationMode()
Gets the current user rotation mode.
|
WindowManagerPolicy.WindowState |
getWinShowWhenLockedLw()
Return the window that is hiding the keyguard, if such a thing exists.
|
boolean |
hasNavigationBar()
Specifies whether there is an on-screen navigation bar separate from the status bar.
|
void |
hideBootMessages()
Hide the UI for showing boot messages, never to be displayed again.
|
void |
init(Context context,
IWindowManager windowManager,
WindowManagerPolicy.WindowManagerFuncs windowManagerFuncs)
Perform initialization of the policy.
|
boolean |
inKeyguardRestrictedKeyInputMode()
inKeyguardRestrictedKeyInputMode
if keyguard screen is showing or in restricted key input mode (i.e. in
keyguard password emergency screen).
|
long |
interceptKeyBeforeDispatching(WindowManagerPolicy.WindowState win,
KeyEvent event,
int policyFlags)
Called from the input dispatcher thread before a key is dispatched to a window.
|
int |
interceptKeyBeforeQueueing(KeyEvent event,
int policyFlags)
Called from the input reader thread before a key is enqueued.
|
int |
interceptMotionBeforeQueueingNonInteractive(long whenNanos,
int policyFlags)
Called from the input reader thread before a motion is enqueued when the device is in a
non-interactive state.
|
boolean |
isDefaultOrientationForced() |
boolean |
isDockSideAllowed(int dockSide) |
boolean |
isForceHiding(WindowManager.LayoutParams attrs)
Return whether the given window is forcibly hiding all windows except windows with
FLAG_SHOW_WHEN_LOCKED set.
|
boolean |
isKeyguardDrawnLw()
Ask the policy whether the Keyguard has drawn.
|
boolean |
isKeyguardHostWindow(WindowManager.LayoutParams attrs)
Return whether the given window can become one that passes isForceHiding() test.
|
boolean |
isKeyguardLocked()
isKeyguardLocked
Return whether the keyguard is currently locked.
|
boolean |
isKeyguardSecure(int userId)
isKeyguardSecure
Return whether the keyguard requires a password to unlock.
|
boolean |
isKeyguardShowingOrOccluded()
Return whether the keyguard is on.
|
boolean |
isNavBarForcedShownLw(WindowManagerPolicy.WindowState win) |
boolean |
isScreenOn()
Return whether the default display is on and not blocked by a black surface.
|
boolean |
isTopLevelWindow(int windowType)
Returns whether a given window type is considered a top level one.
|
void |
keepScreenOnStartedLw()
Called when we have started keeping the screen on because a window
requesting this has become visible.
|
void |
keepScreenOnStoppedLw()
Called when we have stopped keeping the screen on because the last window
requesting this is no longer visible.
|
void |
layoutWindowLw(WindowManagerPolicy.WindowState win,
WindowManagerPolicy.WindowState attached)
Called for each window attached to the window manager as layout is
proceeding.
|
void |
lockNow(Bundle options)
Lock the device now.
|
void |
notifyActivityDrawnForKeyguardLw()
Notifies the keyguard that the activity has drawn it was waiting for.
|
void |
notifyCameraLensCoverSwitchChanged(long whenNanos,
boolean lensCovered)
Tell the policy that the camera lens has been covered or uncovered.
|
void |
notifyLidSwitchChanged(long whenNanos,
boolean lidOpen)
Tell the policy that the lid switch has changed state.
|
void |
onConfigurationChanged()
Called when the configuration has changed, and it's safe to load new values from resources.
|
boolean |
performHapticFeedbackLw(WindowManagerPolicy.WindowState win,
int effectId,
boolean always)
Call from application to perform haptic feedback on its window.
|
int |
prepareAddWindowLw(WindowManagerPolicy.WindowState win,
WindowManager.LayoutParams attrs)
Prepare for a window being added to the window manager.
|
void |
registerShortcutKey(long shortcutCode,
IShortcutService shortcutKeyReceiver)
Register shortcuts for window manager to dispatch.
|
void |
removeStartingWindow(IBinder appToken,
View window)
Called when the first window of an application has been displayed, while
addStartingWindow(android.os.IBinder, java.lang.String, int, android.content.res.CompatibilityInfo, java.lang.CharSequence, int, int, int, int, android.content.res.Configuration) has created a temporary initial window for
that application. |
void |
removeWindowLw(WindowManagerPolicy.WindowState win)
Called when a window is being removed from a window manager.
|
int |
rotationForOrientationLw(int orientation,
int lastRotation)
Given an orientation constant, returns the appropriate surface rotation,
taking into account sensors, docking mode, rotation lock, and other factors.
|
boolean |
rotationHasCompatibleMetricsLw(int orientation,
int rotation)
Given an orientation constant and a rotation, returns true if the rotation
has compatible metrics to the requested orientation.
|
void |
screenTurnedOff()
Called when the device has turned the screen off.
|
void |
screenTurnedOn()
Called when the device has actually turned on the screen, i.e. the display power state has
been set to ON and the screen is unblocked.
|
void |
screenTurningOn(WindowManagerPolicy.ScreenOnListener screenOnListener)
Called when the device is about to turn on the screen to show content.
|
int |
selectAnimationLw(WindowManagerPolicy.WindowState win,
int transit)
Control the animation to run when a window's state changes.
|
void |
selectRotationAnimationLw(int[] anim)
Determine the animation to run for a rotation transition based on the
top fullscreen windows
WindowManager.LayoutParams.rotationAnimation
and whether it is currently fullscreen and frontmost. |
void |
setCurrentOrientationLw(int newOrientation) |
void |
setCurrentUserLw(int newUserId)
Called when the current user changes.
|
void |
setDisplayOverscan(Display display,
int left,
int top,
int right,
int bottom)
Called by window manager to set the overscan region that should be used for the
given display.
|
void |
setInitialDisplaySize(Display display,
int width,
int height,
int density)
Called by window manager once it has the initial, default native
display dimensions.
|
void |
setLastInputMethodWindowLw(WindowManagerPolicy.WindowState ime,
WindowManagerPolicy.WindowState target)
Set the last used input method window state.
|
void |
setRecentsVisibilityLw(boolean visible)
Called by System UI to notify of changes to the visibility of Recents.
|
void |
setRotationLw(int rotation)
Called by the window manager when the rotation changes.
|
void |
setSafeMode(boolean safeMode)
Called when the system is mostly done booting to set whether
the system should go into safe mode.
|
void |
setTvPipVisibilityLw(boolean visible)
Called by System UI to notify of changes to the visibility of PIP.
|
void |
setUserRotationMode(int mode,
int rotation)
Inform the policy that the user has chosen a preferred orientation ("rotation lock").
|
boolean |
shouldRotateSeamlessly(int oldRotation,
int newRotation) |
void |
showBootMessage(CharSequence msg,
boolean always)
Show boot time message to the user.
|
void |
showGlobalActions()
Show the global actions dialog.
|
void |
showRecentApps(boolean fromHome)
Show the recents task list app.
|
void |
startedGoingToSleep(int why)
Called when the device has started going to sleep.
|
void |
startedWakingUp()
Called when the device has started waking up.
|
void |
startKeyguardExitAnimation(long startTime,
long fadeoutDuration)
Notifies the keyguard to start fading out.
|
int |
subWindowTypeToLayerLw(int type)
Return how to Z-order sub-windows in relation to the window they are
attached to.
|
void |
systemBooted()
Called when the system is done booting to the point where the
user can start interacting with it.
|
void |
systemReady()
Called when the system is mostly done booting.
|
void |
userActivity()
Called when userActivity is signalled in the power manager.
|
boolean |
validateRotationAnimationLw(int exitAnimId,
int enterAnimId,
boolean forceDefault)
Validate whether the current top fullscreen has specified the same
WindowManager.LayoutParams.rotationAnimation value as that
being passed in from the previous top fullscreen window. |
int |
windowTypeToLayerLw(int type)
Assign a window type to a layer.
|
static final int FLAG_WAKE
static final int FLAG_VIRTUAL
static final int FLAG_INJECTED
static final int FLAG_TRUSTED
static final int FLAG_FILTERED
static final int FLAG_DISABLE_KEY_REPEAT
static final int FLAG_INTERACTIVE
static final int FLAG_PASS_TO_USER
static final int KEYGUARD_GOING_AWAY_FLAG_TO_SHADE
static final int KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS
static final int KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER
static final int PRESENCE_INTERNAL
static final int PRESENCE_EXTERNAL
static final boolean WATCH_POINTER
static final String ACTION_HDMI_PLUGGED
static final String EXTRA_HDMI_PLUGGED_STATE
ACTION_HDMI_PLUGGED
indicating the state: true if
plugged in to HDMI, false if not.static final String EXTRA_FROM_HOME_KEY
true
when intent was invoked from pressing the home key.static final int ACTION_PASS_TO_USER
interceptKeyBeforeQueueing(android.view.KeyEvent, int)
.static final int TRANSIT_ENTER
static final int TRANSIT_EXIT
static final int TRANSIT_SHOW
static final int TRANSIT_HIDE
static final int TRANSIT_PREVIEW_DONE
static final int OFF_BECAUSE_OF_ADMIN
static final int OFF_BECAUSE_OF_USER
static final int OFF_BECAUSE_OF_TIMEOUT
static final int USER_ROTATION_FREE
static final int USER_ROTATION_LOCKED
static final int FINISH_LAYOUT_REDO_LAYOUT
static final int FINISH_LAYOUT_REDO_CONFIG
static final int FINISH_LAYOUT_REDO_WALLPAPER
static final int FINISH_LAYOUT_REDO_ANIM
void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver) throws RemoteException
RemoteException
boolean canShowDismissingWindowWhileLockedLw()
void init(Context context, IWindowManager windowManager, WindowManagerPolicy.WindowManagerFuncs windowManagerFuncs)
context
- The system context we are running in.boolean isDefaultOrientationForced()
void setInitialDisplaySize(Display display, int width, int height, int density)
void setDisplayOverscan(Display display, int left, int top, int right, int bottom)
int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp)
attrs
- The window's LayoutParams.outAppOp
- First element will be filled with the app op corresponding to
this window, or OP_NONE.WindowManagerGlobal.ADD_OKAY
if the add can proceed;
else an error code, usually
WindowManagerGlobal.ADD_PERMISSION_DENIED
, to abort the add.boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs)
attrs
- The window's LayoutParams.void adjustWindowParamsLw(WindowManager.LayoutParams attrs)
attrs
- The window layout parameters to be modified. These values
are modified in-place.void adjustConfigurationLw(Configuration config, int keyboardPresence, int navigationPresence)
This method may be called by any thread in the window manager, but no internal locks in the window manager will be held.
config
- The Configuration being computed, for you to change as
desired.keyboardPresence
- Flags that indicate whether internal or external
keyboards are present.navigationPresence
- Flags that indicate whether internal or external
navigation devices are present.int windowTypeToLayerLw(int type)
type
- The type of window being assigned.int subWindowTypeToLayerLw(int type)
type
- The sub-window type code.int getMaxWallpaperLayer()
int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode)
int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode)
int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode)
#getNonDecorDisplayWidth(int, int, int)
; it may be smaller than
that to account for more transient decoration like a status bar.int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode)
#getNonDecorDisplayHeight(int, int, int)
; it may be smaller than
that to account for more transient decoration like a status bar.boolean isForceHiding(WindowManager.LayoutParams attrs)
boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs)
boolean canBeForceHidden(WindowManagerPolicy.WindowState win, WindowManager.LayoutParams attrs)
isForceHiding(android.view.WindowManager.LayoutParams)
) should actually be hidden.
For example, typically returns false for the status bar. Be careful
to return false for any window that you may hide yourself, since this
will conflict with what you set.WindowManagerPolicy.WindowState getWinShowWhenLockedLw()
View addStartingWindow(IBinder appToken, String packageName, int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, int logo, int windowFlags, Configuration overrideConfig)
appToken
- Token of the application being started.packageName
- The name of the application package being started.theme
- Resource defining the application's overall visual theme.nonLocalizedLabel
- The default title label of the application if
no data is found in the resource.labelRes
- The resource ID the application would like to use as its name.icon
- The resource ID the application would like to use as its icon.windowFlags
- Window layout flags.overrideConfig
- override configuration to consider when generating
context to for resources.removeStartingWindow(android.os.IBinder, android.view.View)
void removeStartingWindow(IBinder appToken, View window)
addStartingWindow(android.os.IBinder, java.lang.String, int, android.content.res.CompatibilityInfo, java.lang.CharSequence, int, int, int, int, android.content.res.Configuration)
has created a temporary initial window for
that application. You should at this point remove the window from the
window manager. This is called without the window manager locked so
that you can call back into it.
Note: due to the nature of these functions not being called with the window manager locked, you must be prepared for this function to be called multiple times and/or an initial time with a null View window even if you previously returned one.
appToken
- Token of the application that has started.window
- Window View that was returned by createStartingWindow.addStartingWindow(android.os.IBinder, java.lang.String, int, android.content.res.CompatibilityInfo, java.lang.CharSequence, int, int, int, int, android.content.res.Configuration)
int prepareAddWindowLw(WindowManagerPolicy.WindowState win, WindowManager.LayoutParams attrs)
win
- The window being added.attrs
- The window's LayoutParams.WindowManagerGlobal.ADD_OKAY
if the add can proceed, else an
error code to abort the add.void removeWindowLw(WindowManagerPolicy.WindowState win)
win
- The window being removed.int selectAnimationLw(WindowManagerPolicy.WindowState win, int transit)
win
- The window that is changing.transit
- What is happening to the window: TRANSIT_ENTER
,
TRANSIT_EXIT
, TRANSIT_SHOW
, or
TRANSIT_HIDE
.void selectRotationAnimationLw(int[] anim)
WindowManager.LayoutParams.rotationAnimation
and whether it is currently fullscreen and frontmost.anim
- The exiting animation resource id is stored in anim[0], the
entering animation resource id is stored in anim[1].boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, boolean forceDefault)
WindowManager.LayoutParams.rotationAnimation
value as that
being passed in from the previous top fullscreen window.exitAnimId
- exiting resource id from the previous window.enterAnimId
- entering resource id from the previous window.forceDefault
- For rotation animations only, if true ignore the
animation values and just return false.Animation createForceHideEnterAnimation(boolean onWallpaper, boolean goingToNotificationShade)
Animation createForceHideWallpaperExitAnimation(boolean goingToNotificationShade)
int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags)
There are some actions that need to be handled here because they affect the power state of the device, for example, the power keys. Generally, it's best to keep as little as possible in the queue thread because it's the most fragile.
event
- The key event.policyFlags
- The policy flags associated with the key.ACTION_PASS_TO_USER
.int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags)
There are some actions that need to be handled here because they affect the power state of the device, for example, waking on motions. Generally, it's best to keep as little as possible in the queue thread because it's the most fragile.
policyFlags
- The policy flags associated with the motion.ACTION_PASS_TO_USER
.long interceptKeyBeforeDispatching(WindowManagerPolicy.WindowState win, KeyEvent event, int policyFlags)
Allows you to define behavior for keys that can not be overridden by applications. This method is called from the input thread, with no locks held.
win
- The window that currently has focus. This is where the key
event will normally go.event
- The key event.policyFlags
- The policy flags associated with the key.KeyEvent dispatchUnhandledKey(WindowManagerPolicy.WindowState win, KeyEvent event, int policyFlags)
Allows you to define default global behavior for keys that were not handled by applications. This method is called from the input thread, with no locks held.
win
- The window that currently has focus. This is where the key
event will normally go.event
- The key event.policyFlags
- The policy flags associated with the key.void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, int displayRotation, int uiMode)
isDefaultDisplay
- true if window is on Display.DEFAULT_DISPLAY
.displayWidth
- The current full width of the screen.displayHeight
- The current full height of the screen.displayRotation
- The current rotation being applied to the base window.uiMode
- The current uiMode in configuration.int getSystemDecorLayerLw()
void getContentRectLw(Rect r)
beginLayoutLw(boolean, int, int, int, int)
.r
- The rectangle to be filled with the boundaries available to applications.void layoutWindowLw(WindowManagerPolicy.WindowState win, WindowManagerPolicy.WindowState attached)
win
- The window being positioned.attached
- For sub-windows, the window it is attached to; this
window will already have had layoutWindow() called on it
so you can use its Rect. Otherwise null.boolean getInsetHintLw(WindowManager.LayoutParams attrs, Rect taskBounds, int displayRotation, int displayWidth, int displayHeight, Rect outContentInsets, Rect outStableInsets, Rect outOutsets)
attrs
- The LayoutParams of the window.taskBounds
- The bounds of the task this window is on or null
if no task is
associated with the window.displayRotation
- Rotation of the display.displayWidth
- The width of the display.displayHeight
- The height of the display.outContentInsets
- The areas covered by system windows, expressed as positive insets.outStableInsets
- The areas covered by stable system windows irrespective of their
current visibility. Expressed as positive insets.outOutsets
- The areas that are not real display, but we would like to treat as such.isNavBarForcedShownLw(WindowState)
.void finishLayoutLw()
void beginPostLayoutPolicyLw(int displayWidth, int displayHeight)
displayWidth
- The current full width of the screen.displayHeight
- The current full height of the screen.void applyPostLayoutPolicyLw(WindowManagerPolicy.WindowState win, WindowManager.LayoutParams attrs, WindowManagerPolicy.WindowState attached)
win
- The window being positioned.attrs
- The LayoutParams of the window.attached
- For sub-windows, the window it is attached to. Otherwise null.int finishPostLayoutPolicyLw()
FINISH_LAYOUT_REDO_LAYOUT
,
FINISH_LAYOUT_REDO_CONFIG
, FINISH_LAYOUT_REDO_WALLPAPER
,
or FINISH_LAYOUT_REDO_ANIM
.boolean allowAppAnimationsLw()
int focusChangedLw(WindowManagerPolicy.WindowState lastFocus, WindowManagerPolicy.WindowState newFocus)
void startedWakingUp()
void finishedWakingUp()
void startedGoingToSleep(int why)
why
- OFF_BECAUSE_OF_USER
, OFF_BECAUSE_OF_ADMIN
,
or OFF_BECAUSE_OF_TIMEOUT
.void finishedGoingToSleep(int why)
why
- OFF_BECAUSE_OF_USER
, OFF_BECAUSE_OF_ADMIN
,
or OFF_BECAUSE_OF_TIMEOUT
.void screenTurningOn(WindowManagerPolicy.ScreenOnListener screenOnListener)
void screenTurnedOn()
void screenTurnedOff()
boolean isScreenOn()
void notifyLidSwitchChanged(long whenNanos, boolean lidOpen)
whenNanos
- The time when the change occurred in uptime nanoseconds.lidOpen
- True if the lid is now open.void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered)
whenNanos
- The time when the change occurred in uptime nanoseconds.lensCovered
- True if the lens is covered.void enableKeyguard(boolean enabled)
enabled
- Whether keyguard can be on or not. does not actually
turn it on, unless it was previously disabled with this function.KeyguardManager.KeyguardLock.disableKeyguard()
,
KeyguardManager.KeyguardLock.reenableKeyguard()
void exitKeyguardSecurely(WindowManagerPolicy.OnKeyguardExitResult callback)
callback
- Callback to send the result back.KeyguardManager.exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
boolean isKeyguardLocked()
boolean isKeyguardSecure(int userId)
userId
- boolean isKeyguardShowingOrOccluded()
boolean inKeyguardRestrictedKeyInputMode()
void dismissKeyguardLw()
void notifyActivityDrawnForKeyguardLw()
boolean isKeyguardDrawnLw()
int rotationForOrientationLw(int orientation, int lastRotation)
orientation
- An orientation constant, such as
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
.lastRotation
- The most recently used rotation.boolean rotationHasCompatibleMetricsLw(int orientation, int rotation)
orientation
- An orientation constant, such as
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
.rotation
- The rotation to check.void setRotationLw(int rotation)
rotation
- The new rotation.void setSafeMode(boolean safeMode)
void systemReady()
void systemBooted()
void showBootMessage(CharSequence msg, boolean always)
void hideBootMessages()
void userActivity()
void enableScreenAfterBoot()
void setCurrentOrientationLw(int newOrientation)
boolean performHapticFeedbackLw(WindowManagerPolicy.WindowState win, int effectId, boolean always)
void keepScreenOnStartedLw()
void keepScreenOnStoppedLw()
int getUserRotationMode()
USER_ROTATION_LOCKED
,
USER_ROTATION_FREE
void setUserRotationMode(int mode, int rotation)
mode
- One of USER_ROTATION_LOCKED
or
USER_ROTATION_FREE
.rotation
- One of Surface.ROTATION_0
, Surface.ROTATION_90
,
Surface.ROTATION_180
, Surface.ROTATION_270
.int adjustSystemUiVisibilityLw(int visibility)
visibility
- The raw visibility reported by the status bar.void setRecentsVisibilityLw(boolean visible)
void setTvPipVisibilityLw(boolean visible)
boolean hasNavigationBar()
void lockNow(Bundle options)
void setLastInputMethodWindowLw(WindowManagerPolicy.WindowState ime, WindowManagerPolicy.WindowState target)
void showRecentApps(boolean fromHome)
void showGlobalActions()
int getInputMethodWindowVisibleHeightLw()
void setCurrentUserLw(int newUserId)
newUserId
- The id of the incoming user.void dump(String prefix, PrintWriter writer, String[] args)
prefix
- Text to print at the front of each line.writer
- The PrintWriter to which you should dump your state. This will be
closed for you after you return.args
- additional arguments to the dump request.boolean canMagnifyWindow(int windowType)
windowType
- The window type.boolean isTopLevelWindow(int windowType)
windowType
- The window type.void startKeyguardExitAnimation(long startTime, long fadeoutDuration)
startTime
- the start time of the animation in uptime millisecondsfadeoutDuration
- the duration of the exit animation, in millisecondsvoid getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets)
displayRotation
- the current display rotationdisplayWidth
- the current display widthdisplayHeight
- the current display heightoutInsets
- the insets to returnboolean isNavBarForcedShownLw(WindowManagerPolicy.WindowState win)
void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets)
getNonDecorDisplayWidth(int, int, int, int)
.displayRotation
- the current display rotationdisplayWidth
- the current display widthdisplayHeight
- the current display heightoutInsets
- the insets to returnboolean isDockSideAllowed(int dockSide)
void onConfigurationChanged()
boolean shouldRotateSeamlessly(int oldRotation, int newRotation)