import android.content.pm.ActivityInfo;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
* instance of it is created by the window manager when it starts up, and allows
* customization of window layering, special window types, key dispatching, and
* layout.
- *
+ *
* <p>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
* 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.
- *
+ *
* <p>The current suffixes are:
- *
+ *
* <dl>
* <dt> Ti <dd> Called from the input thread. This is the thread that
* collects pending input events and dispatches them to the appropriate window.
* acquired by the window manager while it holds the window lock, so this is
* even more restrictive than <var>Lw</var>.
* </dl>
- *
+ *
* @hide
*/
public interface WindowManagerPolicy {
* Perform standard frame computation. The result can be obtained with
* getFrame() if so desired. Must be called with the window manager
* lock held.
- *
+ *
* @param parentFrame The frame of the parent container this window
* is in, used for computing its basic position.
* @param displayFrame The frame of the overall display in which this
/**
* Retrieve the current frame of the window that has been assigned by
* the window manager. Must be called with the window manager lock held.
- *
+ *
* @return Rect The rectangle holding the window frame.
*/
public Rect getFrameLw();
/**
- * Retrieve the current frame of the window that is actually shown.
+ * Retrieve the current position of the window that is actually shown.
* Must be called with the window manager lock held.
- *
- * @return Rect The rectangle holding the shown window frame.
+ *
+ * @return Point The point holding the shown window position.
*/
- public RectF getShownFrameLw();
+ public Point getShownPositionLw();
/**
* Retrieve the frame of the display that this window was last
* account for screen decorations such as a status bar or soft
* keyboard. Must be called with the
* window manager lock held.
- *
+ *
* @return Rect The rectangle holding the content frame.
*/
public Rect getContentFrameLw();
* content frame to account for transient UI elements blocking it
* such as an input method's candidates UI. Must be called with the
* window manager lock held.
- *
+ *
* @return Rect The rectangle holding the visible frame.
*/
public Rect getVisibleFrameLw();
* layout of other windows.
*/
public boolean getGivenInsetsPendingLw();
-
+
/**
* Retrieve the insets given by this window's client for the content
* area of windows behind it. Must be called with the
* window manager lock held.
- *
+ *
* @return Rect The left, top, right, and bottom insets, relative
* to the window's frame, of the actual contents.
*/
* Retrieve the insets given by this window's client for the visible
* area of windows behind it. Must be called with the
* window manager lock held.
- *
+ *
* @return Rect The left, top, right, and bottom insets, relative
* to the window's frame, of the actual visible area.
*/
/**
* Retrieve the current LayoutParams of the window.
- *
+ *
* @return WindowManager.LayoutParams The window's internal LayoutParams
* instance.
*/
public boolean isVoiceInteraction();
/**
- * Return true if, at any point, the application token associated with
- * this window has actually displayed any windows. This is most useful
- * with the "starting up" window to determine if any windows were
- * displayed when it is closed.
- *
- * @return Returns true if one or more windows have been displayed,
+ * Return true if, at any point, the application token associated with
+ * this window has actually displayed any windows. This is most useful
+ * with the "starting up" window to determine if any windows were
+ * displayed when it is closed.
+ *
+ * @return Returns true if one or more windows have been displayed,
* else false.
*/
public boolean hasAppShownWindows();
* that will remove the surface.
*/
boolean isVisibleLw();
-
+
/**
* Like {@link #isVisibleLw}, but also counts a window that is currently
* "hidden" behind the keyguard as visible. This allows us to apply
* things like window flags that impact the keyguard.
*/
boolean isVisibleOrBehindKeyguardLw();
-
+
/**
- * Is this window currently visible to the user on-screen? It is
- * displayed either if it is visible or it is currently running an
+ * Is this window currently visible to the user on-screen? It is
+ * displayed either if it is visible or it is currently running an
* animation before no longer being visible. Must be called with the
* window manager lock held.
*/
boolean isDrawnLw();
/**
- * Returns true if this window has been shown on screen at some time in
+ * Returns true if this window has been shown on screen at some time in
* the past. Must be called with the window manager lock held.
*/
public boolean hasDrawnLw();
* Returns true if {@link #showLw} was last called for the window.
*/
public boolean hideLw(boolean doAnimation);
-
+
/**
* Can be called to undo the effect of {@link #hideLw}, allowing a
* window to be shown as long as the window manager and client would
// NOTE: screen off reasons are in order of significance, with more
// important ones lower than less important ones.
-
+
/** Screen turned off because of a device admin */
public final int OFF_BECAUSE_OF_ADMIN = 1;
/** Screen turned off because of power button */
/** When not otherwise specified by the activity's screenOrientation, rotation is set by
* the user. */
public final int USER_ROTATION_LOCKED = 1;
-
+
/**
* Perform initialization of the policy.
- *
+ *
* @param context The system context we are running in.
*/
public void init(Context context, IWindowManager windowManager,
/**
* Check permissions when adding a window.
- *
+ *
* @param attrs The window's LayoutParams.
* @param outAppOp First element will be filled with the app op corresponding to
* this window, or OP_NONE.
- *
+ *
* @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
* else an error code, usually
* {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
* Sanitize the layout parameters coming from a client. Allows the policy
* to do things like ensure that windows of a specific type can't take
* input focus.
- *
+ *
* @param attrs The window layout parameters to be modified. These values
* are modified in-place.
*/
public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
-
+
/**
* 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. If you want to
* leave it as-is, simply do nothing.
- *
+ *
* <p>This method may be called by any thread in the window manager, but
* no internal locks in the window manager will be held.
- *
+ *
* @param config The Configuration being computed, for you to change as
* desired.
* @param keyboardPresence Flags that indicate whether internal or external
*/
public void adjustConfigurationLw(Configuration config, int keyboardPresence,
int navigationPresence);
-
+
/**
* Assign a window type to a layer. Allows you to control how different
* kinds of windows are ordered on-screen.
- *
+ *
* @param type The type of window being assigned.
- *
+ *
* @return int An arbitrary integer used to order windows, with lower
* numbers below higher ones.
*/
* Return how to Z-order sub-windows in relation to the window they are
* attached to. Return positive to have them ordered in front, negative for
* behind.
- *
+ *
* @param type The sub-window type code.
- *
+ *
* @return int Layer in relation to the attached window, where positive is
* above and negative is below.
*/
* manager (using the normal window manager APIs) that will be shown until
* the application displays its own window. This is called without the
* window manager locked so that you can call back into it.
- *
+ *
* @param appToken Token of the application being started.
- * @param packageName The name of the application package being started.
+ * @param packageName The name of the application package being started.
* @param theme Resource defining the application's overall visual theme.
* @param nonLocalizedLabel The default title label of the application if
* no data is found in the resource.
* @param labelRes The resource ID the application would like to use as its name.
* @param icon The resource ID the application would like to use as its icon.
* @param windowFlags Window layout flags.
- *
+ *
* @return Optionally you can return the View that was used to create the
* window, for easy removal in removeStartingWindow.
- *
+ *
* @see #removeStartingWindow
*/
public View addStartingWindow(IBinder appToken, String packageName,
* 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.
- *
+ *
* <p>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.
- *
+ *
* @param appToken Token of the application that has started.
* @param window Window View that was returned by createStartingWindow.
- *
+ *
* @see #addStartingWindow
*/
public void removeStartingWindow(IBinder appToken, View window);
* Prepare for a window being added to the window manager. You can throw an
* exception here to prevent the window being added, or do whatever setup
* you need to keep track of the window.
- *
+ *
* @param win The window being added.
- * @param attrs The window's LayoutParams.
- *
+ * @param attrs The window's LayoutParams.
+ *
* @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an
* error code to abort the add.
*/
/**
* Called when a window is being removed from a window manager. Must not
* throw an exception -- clean up as much as possible.
- *
+ *
* @param win The window being removed.
*/
public void removeWindowLw(WindowState win);
* Control the animation to run when a window's state changes. Return a
* non-0 number to force the animation to a specific resource ID, or 0
* to use the default animation.
- *
+ *
* @param win The window that is changing.
* @param transit What is happening to the window: {@link #TRANSIT_ENTER},
* {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
* {@link #TRANSIT_HIDE}.
- *
+ *
* @return Resource ID of the actual animation to use, or 0 for none.
*/
public int selectAnimationLw(WindowState win, int transit);
* Determine the animation to run for a rotation transition based on the
* top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation}
* and whether it is currently fullscreen and frontmost.
- *
- * @param anim The exiting animation resource id is stored in anim[0], the
+ *
+ * @param anim The exiting animation resource id is stored in anim[0], the
* entering animation resource id is stored in anim[1].
*/
public void selectRotationAnimationLw(int anim[]);
* <p>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.
- *
+ *
* @param win The window that currently has focus. This is where the key
* event will normally go.
* @param event The key event.
*
* <p>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.
- *
+ *
* @param win The window that currently has focus. This is where the key
* event will normally go.
* @param event The key event.
/**
* Called when layout of the windows is about to start.
- *
+ *
* @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}.
* @param displayWidth The current full width of the screen.
* @param displayHeight The current full height of the screen.
* Called for each window attached to the window manager as layout is
* proceeding. The implementation of this function must take care of
* setting the window's frame, either here or in finishLayout().
- *
+ *
* @param win The window being positioned.
* @param attached For sub-windows, the window it is attached to; this
* window will already have had layoutWindow() called on it
*/
public void layoutWindowLw(WindowState win, WindowState attached);
-
+
/**
* Return the insets for the areas covered by system windows. These values
* are computed on the most recent layout, so they are not guaranteed to
static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
/** Need to recompute animations */
static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
-
+
/**
* Called following layout of all windows before each window has policy applied.
- *
+ *
* @param displayWidth The current full width of the screen.
* @param displayHeight The current full height of the screen.
*/
* to each window. If in this function you do
* something that may have modified the animation state of another window,
* be sure to return non-zero in order to perform another pass through layout.
- *
+ *
* @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
* {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
* or {@link #FINISH_LAYOUT_REDO_ANIM}.
* the system should go into safe mode.
*/
public void setSafeMode(boolean safeMode);
-
+
/**
* Called when the system is mostly done booting.
*/
* this point the display is active.
*/
public void enableScreenAfterBoot();
-
+
public void setCurrentOrientationLw(@ActivityInfo.ScreenOrientation int newOrientation);
-
+
/**
* Call from application to perform haptic feedback on its window.
*/
public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
-
+
/**
* Called when we have started keeping the screen on because a window
* requesting this has become visible.
public void keepScreenOnStoppedLw();
/**
- * Gets the current user rotation mode.
+ * Gets the current user rotation mode.
*
* @return The rotation mode.
*
* @see WindowManagerPolicy#USER_ROTATION_LOCKED
- * @see WindowManagerPolicy#USER_ROTATION_FREE
+ * @see WindowManagerPolicy#USER_ROTATION_FREE
*/
@UserRotationMode
public int getUserRotationMode();
/**
- * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
+ * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
*
* @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
- * {@link WindowManagerPolicy#USER_ROTATION_FREE}.
+ * {@link WindowManagerPolicy#USER_ROTATION_FREE}.
* @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
* {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
*/