Home | History | Annotate | Download | only in view
      1 /*
      2 ** Copyright 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 com.android.internal.os.IResultReceiver;
     20 import com.android.internal.policy.IKeyguardDismissCallback;
     21 import com.android.internal.policy.IShortcutService;
     22 
     23 import android.app.IAssistDataReceiver;
     24 import android.content.res.CompatibilityInfo;
     25 import android.content.res.Configuration;
     26 import android.graphics.Bitmap;
     27 import android.graphics.GraphicBuffer;
     28 import android.graphics.Insets;
     29 import android.graphics.Point;
     30 import android.graphics.Rect;
     31 import android.graphics.Region;
     32 import android.os.Bundle;
     33 import android.os.IRemoteCallback;
     34 import android.os.ParcelFileDescriptor;
     35 import android.view.IApplicationToken;
     36 import android.view.IAppTransitionAnimationSpecsFuture;
     37 import android.view.IDockedStackListener;
     38 import android.view.IDisplayFoldListener;
     39 import android.view.IOnKeyguardExitResult;
     40 import android.view.IPinnedStackListener;
     41 import android.view.RemoteAnimationAdapter;
     42 import android.view.IRotationWatcher;
     43 import android.view.ISystemGestureExclusionListener;
     44 import android.view.IWallpaperVisibilityListener;
     45 import android.view.IWindowSession;
     46 import android.view.IWindowSessionCallback;
     47 import android.view.KeyEvent;
     48 import android.view.InputEvent;
     49 import android.view.MagnificationSpec;
     50 import android.view.MotionEvent;
     51 import android.view.InputChannel;
     52 import android.view.InputDevice;
     53 import android.view.IInputFilter;
     54 import android.view.AppTransitionAnimationSpec;
     55 import android.view.WindowContentFrameStats;
     56 import android.view.WindowManager;
     57 import android.view.SurfaceControl;
     58 
     59 /**
     60  * System private interface to the window manager.
     61  *
     62  * {@hide}
     63  */
     64 interface IWindowManager
     65 {
     66     /**
     67      * ===== NOTICE =====
     68      * The first three methods must remain the first three methods. Scripts
     69      * and tools rely on their transaction number to work properly.
     70      */
     71     // This is used for debugging
     72     boolean startViewServer(int port);   // Transaction #1
     73     boolean stopViewServer();            // Transaction #2
     74     boolean isViewServerRunning();       // Transaction #3
     75 
     76     IWindowSession openSession(in IWindowSessionCallback callback);
     77 
     78     @UnsupportedAppUsage
     79     void getInitialDisplaySize(int displayId, out Point size);
     80     @UnsupportedAppUsage
     81     void getBaseDisplaySize(int displayId, out Point size);
     82     void setForcedDisplaySize(int displayId, int width, int height);
     83     void clearForcedDisplaySize(int displayId);
     84     @UnsupportedAppUsage
     85     int getInitialDisplayDensity(int displayId);
     86     int getBaseDisplayDensity(int displayId);
     87     void setForcedDisplayDensityForUser(int displayId, int density, int userId);
     88     void clearForcedDisplayDensityForUser(int displayId, int userId);
     89     void setForcedDisplayScalingMode(int displayId, int mode); // 0 = auto, 1 = disable
     90 
     91     void setOverscan(int displayId, int left, int top, int right, int bottom);
     92 
     93     // These can only be called when holding the MANAGE_APP_TOKENS permission.
     94     void setEventDispatching(boolean enabled);
     95     void addWindowToken(IBinder token, int type, int displayId);
     96     void removeWindowToken(IBinder token, int displayId);
     97     void prepareAppTransition(int transit, boolean alwaysKeepCurrent);
     98 
     99     /**
    100      * Like overridePendingAppTransitionMultiThumb, but uses a future to supply the specs. This is
    101      * used for recents, where generating the thumbnails of the specs takes a non-trivial amount of
    102      * time, so we want to move that off the critical path for starting the new activity.
    103      */
    104     @UnsupportedAppUsage
    105     void overridePendingAppTransitionMultiThumbFuture(
    106             IAppTransitionAnimationSpecsFuture specsFuture, IRemoteCallback startedCallback,
    107             boolean scaleUp, int displayId);
    108     @UnsupportedAppUsage
    109     void overridePendingAppTransitionRemote(in RemoteAnimationAdapter remoteAnimationAdapter,
    110             int displayId);
    111     @UnsupportedAppUsage
    112     void executeAppTransition();
    113 
    114     /**
    115       * Used by system ui to report that recents has shown itself.
    116       * @deprecated to be removed once prebuilts are updated
    117       */
    118     @UnsupportedAppUsage
    119     void endProlongedAnimations();
    120 
    121     void startFreezingScreen(int exitAnim, int enterAnim);
    122     void stopFreezingScreen();
    123 
    124     // these require DISABLE_KEYGUARD permission
    125     /** @deprecated use Activity.setShowWhenLocked instead. */
    126     void disableKeyguard(IBinder token, String tag, int userId);
    127     /** @deprecated use Activity.setShowWhenLocked instead. */
    128     void reenableKeyguard(IBinder token, int userId);
    129     void exitKeyguardSecurely(IOnKeyguardExitResult callback);
    130     @UnsupportedAppUsage
    131     boolean isKeyguardLocked();
    132     @UnsupportedAppUsage
    133     boolean isKeyguardSecure(int userId);
    134     void dismissKeyguard(IKeyguardDismissCallback callback, CharSequence message);
    135 
    136     // Requires INTERACT_ACROSS_USERS_FULL permission
    137     void setSwitchingUser(boolean switching);
    138 
    139     void closeSystemDialogs(String reason);
    140 
    141     // These can only be called with the SET_ANIMATON_SCALE permission.
    142     @UnsupportedAppUsage
    143     float getAnimationScale(int which);
    144     @UnsupportedAppUsage
    145     float[] getAnimationScales();
    146     @UnsupportedAppUsage
    147     void setAnimationScale(int which, float scale);
    148     @UnsupportedAppUsage
    149     void setAnimationScales(in float[] scales);
    150 
    151     float getCurrentAnimatorScale();
    152 
    153     // For testing
    154     void setInTouchMode(boolean showFocus);
    155 
    156     // For StrictMode flashing a red border on violations from the UI
    157     // thread.  The uid/pid is implicit from the Binder call, and the Window
    158     // Manager uses that to determine whether or not the red border should
    159     // actually be shown.  (it will be ignored that pid doesn't have windows
    160     // on screen)
    161     void showStrictModeViolation(boolean on);
    162 
    163     // Proxy to set the system property for whether the flashing
    164     // should be enabled.  The 'enabled' value is null or blank for
    165     // the system default (differs per build variant) or any valid
    166     // boolean string as parsed by SystemProperties.getBoolean().
    167     @UnsupportedAppUsage
    168     void setStrictModeVisualIndicatorPreference(String enabled);
    169 
    170     /**
    171      * Set whether screen capture is disabled for all windows of a specific user from
    172      * the device policy cache.
    173      */
    174     void refreshScreenCaptureDisabled(int userId);
    175 
    176     // These can only be called with the SET_ORIENTATION permission.
    177     /**
    178      * Update the current screen rotation based on the current state of
    179      * the world.
    180      * @param alwaysSendConfiguration Flag to force a new configuration to
    181      * be evaluated.  This can be used when there are other parameters in
    182      * configuration that are changing.
    183      * @param forceRelayout If true, the window manager will always do a relayout
    184      * of its windows even if the rotation hasn't changed.
    185      */
    186     void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout);
    187 
    188     /**
    189      * Retrieve the current orientation of the primary screen.
    190      * @return Constant as per {@link android.view.Surface.Rotation}.
    191      *
    192      * @see android.view.Display#DEFAULT_DISPLAY
    193      */
    194     int getDefaultDisplayRotation();
    195 
    196     /**
    197      * Watch the rotation of the specified screen.  Returns the current rotation,
    198      * calls back when it changes.
    199      */
    200     int watchRotation(IRotationWatcher watcher, int displayId);
    201 
    202     /**
    203      * Remove a rotation watcher set using watchRotation.
    204      * @hide
    205      */
    206     @UnsupportedAppUsage
    207     void removeRotationWatcher(IRotationWatcher watcher);
    208 
    209     /**
    210      * Determine the preferred edge of the screen to pin the compact options menu against.
    211      *
    212      * @param displayId Id of the display where the menu window currently resides.
    213      * @return a Gravity value for the options menu panel.
    214      * @hide
    215      */
    216     int getPreferredOptionsPanelGravity(int displayId);
    217 
    218     /**
    219      * Equivalent to calling {@link #freezeDisplayRotation(int, int)} with {@link
    220      * android.view.Display#DEFAULT_DISPLAY} and given rotation.
    221      */
    222     @UnsupportedAppUsage
    223     void freezeRotation(int rotation);
    224 
    225     /**
    226      * Equivalent to calling {@link #thawDisplayRotation(int)} with {@link
    227      * android.view.Display#DEFAULT_DISPLAY}.
    228      */
    229     @UnsupportedAppUsage
    230     void thawRotation();
    231 
    232     /**
    233      * Equivelant to call {@link #isDisplayRotationFrozen(int)} with {@link
    234      * android.view.Display#DEFAULT_DISPLAY}.
    235      */
    236     boolean isRotationFrozen();
    237 
    238     /**
    239      * Lock the display orientation to the specified rotation, or to the current
    240      * rotation if -1. Sensor input will be ignored until thawRotation() is called.
    241      *
    242      * @param displayId the ID of display which rotation should be frozen.
    243      * @param rotation one of {@link android.view.Surface#ROTATION_0},
    244      *        {@link android.view.Surface#ROTATION_90}, {@link android.view.Surface#ROTATION_180},
    245      *        {@link android.view.Surface#ROTATION_270} or -1 to freeze it to current rotation.
    246      * @hide
    247      */
    248     void freezeDisplayRotation(int displayId, int rotation);
    249 
    250     /**
    251      * Release the orientation lock imposed by freezeRotation() on the display.
    252      *
    253      * @param displayId the ID of display which rotation should be thawed.
    254      * @hide
    255      */
    256     void thawDisplayRotation(int displayId);
    257 
    258     /**
    259      * Gets whether the rotation is frozen on the display.
    260      *
    261      * @param displayId the ID of display which frozen is needed.
    262      * @return Whether the rotation is frozen.
    263      */
    264     boolean isDisplayRotationFrozen(int displayId);
    265 
    266     /**
    267      * Screenshot the current wallpaper layer, including the whole screen.
    268      */
    269     Bitmap screenshotWallpaper();
    270 
    271     /**
    272      * Registers a wallpaper visibility listener.
    273      * @return Current visibility.
    274      */
    275     boolean registerWallpaperVisibilityListener(IWallpaperVisibilityListener listener,
    276         int displayId);
    277 
    278     /**
    279      * Remove a visibility watcher that was added using registerWallpaperVisibilityListener.
    280      */
    281     void unregisterWallpaperVisibilityListener(IWallpaperVisibilityListener listener,
    282         int displayId);
    283 
    284     /**
    285      * Registers a system gesture exclusion listener for a given display.
    286      */
    287     void registerSystemGestureExclusionListener(ISystemGestureExclusionListener listener,
    288         int displayId);
    289 
    290     /**
    291      * Unregisters a system gesture exclusion listener for a given display.
    292      */
    293     void unregisterSystemGestureExclusionListener(ISystemGestureExclusionListener listener,
    294         int displayId);
    295 
    296     /**
    297      * Used only for assist -- request a screenshot of the current application.
    298      */
    299     boolean requestAssistScreenshot(IAssistDataReceiver receiver);
    300 
    301     /**
    302      * Called by the status bar to notify Views of changes to System UI visiblity.
    303      */
    304     oneway void statusBarVisibilityChanged(int displayId, int visibility);
    305 
    306     /**
    307     * When set to {@code true} the system bars will always be shown. This is true even if an app
    308     * requests to be fullscreen by setting the system ui visibility flags. The
    309     * functionality was added for the automotive case as a way to guarantee required content stays
    310     * on screen at all times.
    311     *
    312     * @hide
    313     */
    314     oneway void setForceShowSystemBars(boolean show);
    315 
    316     /**
    317      * Called by System UI to notify of changes to the visibility of Recents.
    318      */
    319     oneway void setRecentsVisibility(boolean visible);
    320 
    321     /**
    322      * Called by System UI to notify of changes to the visibility of PIP.
    323      */
    324     oneway void setPipVisibility(boolean visible);
    325 
    326     /**
    327      * Called by System UI to notify of changes to the visibility and height of the shelf.
    328      */
    329     @UnsupportedAppUsage
    330     void setShelfHeight(boolean visible, int shelfHeight);
    331 
    332     /**
    333      * Called by System UI to enable or disable haptic feedback on the navigation bar buttons.
    334      */
    335     @UnsupportedAppUsage
    336     void setNavBarVirtualKeyHapticFeedbackEnabled(boolean enabled);
    337 
    338     /**
    339      * Device has a software navigation bar (separate from the status bar) on specific display.
    340      *
    341      * @param displayId the id of display to check if there is a software navigation bar.
    342      */
    343     @UnsupportedAppUsage
    344     boolean hasNavigationBar(int displayId);
    345 
    346     /**
    347      * Get the position of the nav bar
    348      */
    349     int getNavBarPosition(int displayId);
    350 
    351     /**
    352      * Lock the device immediately with the specified options (can be null).
    353      */
    354     @UnsupportedAppUsage
    355     void lockNow(in Bundle options);
    356 
    357     /**
    358      * Device is in safe mode.
    359      */
    360     @UnsupportedAppUsage
    361     boolean isSafeModeEnabled();
    362 
    363     /**
    364      * Enables the screen if all conditions are met.
    365      */
    366     void enableScreenIfNeeded();
    367 
    368     /**
    369      * Clears the frame statistics for a given window.
    370      *
    371      * @param token The window token.
    372      * @return Whether the frame statistics were cleared.
    373      */
    374     boolean clearWindowContentFrameStats(IBinder token);
    375 
    376     /**
    377      * Gets the content frame statistics for a given window.
    378      *
    379      * @param token The window token.
    380      * @return The frame statistics or null if the window does not exist.
    381      */
    382     WindowContentFrameStats getWindowContentFrameStats(IBinder token);
    383 
    384     /**
    385      * @return the dock side the current docked stack is at; must be one of the
    386      *         WindowManagerGlobal.DOCKED_* values
    387      */
    388     @UnsupportedAppUsage
    389     int getDockedStackSide();
    390 
    391     /**
    392      * Sets the region the user can touch the divider. This region will be excluded from the region
    393      * which is used to cause a focus switch when dispatching touch.
    394      */
    395     void setDockedStackDividerTouchRegion(in Rect touchableRegion);
    396 
    397     /**
    398      * Registers a listener that will be called when the dock divider changes its visibility or when
    399      * the docked stack gets added/removed.
    400      */
    401     @UnsupportedAppUsage
    402     void registerDockedStackListener(IDockedStackListener listener);
    403 
    404     /**
    405      * Registers a listener that will be called when the pinned stack state changes.
    406      */
    407     void registerPinnedStackListener(int displayId, IPinnedStackListener listener);
    408 
    409     /**
    410      * Updates the dim layer used while resizing.
    411      *
    412      * @param visible Whether the dim layer should be visible.
    413      * @param targetWindowingMode The windowing mode of the stack the dim layer should be placed on.
    414      * @param alpha The translucency of the dim layer, between 0 and 1.
    415      */
    416     void setResizeDimLayer(boolean visible, int targetWindowingMode, float alpha);
    417 
    418     /**
    419      * Requests Keyboard Shortcuts from the displayed window.
    420      *
    421      * @param receiver The receiver to deliver the results to.
    422      */
    423     void requestAppKeyboardShortcuts(IResultReceiver receiver, int deviceId);
    424 
    425     /**
    426      * Retrieves the current stable insets from the primary display.
    427      */
    428     @UnsupportedAppUsage
    429     void getStableInsets(int displayId, out Rect outInsets);
    430 
    431     /**
    432      * Set the forwarded insets on the display.
    433      * <p>
    434      * This is only used in case a virtual display is displayed on another display that has insets,
    435      * and the bounds of the virtual display is overlapping with the insets from the host display.
    436      * In that case, the contents on the virtual display won't be placed over the forwarded insets.
    437      * Only the owner of the display is permitted to set the forwarded insets on it.
    438      */
    439     void setForwardedInsets(int displayId, in Insets insets);
    440 
    441     /**
    442      * Register shortcut key. Shortcut code is packed as:
    443      * (MetaState << Integer.SIZE) | KeyCode
    444      * @hide
    445      */
    446     void registerShortcutKey(in long shortcutCode, IShortcutService keySubscriber);
    447 
    448     /**
    449      * Create an input consumer by name and display id.
    450      */
    451     @UnsupportedAppUsage
    452     void createInputConsumer(IBinder token, String name, int displayId,
    453         out InputChannel inputChannel);
    454 
    455     /**
    456      * Destroy an input consumer by name and display id.
    457      * This method will also dispose the input channels associated with that InputConsumer.
    458      */
    459     @UnsupportedAppUsage
    460     boolean destroyInputConsumer(String name, int displayId);
    461 
    462     /**
    463      * Return the touch region for the current IME window, or an empty region if there is none.
    464      */
    465     Region getCurrentImeTouchRegion();
    466 
    467     /**
    468      * Registers an IDisplayFoldListener.
    469      */
    470     void registerDisplayFoldListener(IDisplayFoldListener listener);
    471 
    472     /**
    473      * Unregisters an IDisplayFoldListener.
    474      */
    475     void unregisterDisplayFoldListener(IDisplayFoldListener listener);
    476 
    477     /**
    478      * Starts a window trace.
    479      */
    480     void startWindowTrace();
    481 
    482     /**
    483      * Stops a window trace.
    484      */
    485     void stopWindowTrace();
    486 
    487     /**
    488      * Returns true if window trace is enabled.
    489      */
    490     boolean isWindowTraceEnabled();
    491 
    492     /**
    493      * Requests that the WindowManager sends
    494      * WindowManagerPolicyConstants#ACTION_USER_ACTIVITY_NOTIFICATION on the next user activity.
    495      */
    496     void requestUserActivityNotification();
    497 
    498     /**
    499      * Notify WindowManager that it should not override the info in DisplayManager for the specified
    500      * display. This can disable letter- or pillar-boxing applied in DisplayManager when the metrics
    501      * of the logical display reported from WindowManager do not correspond to the metrics of the
    502      * physical display it is based on.
    503      *
    504      * @param displayId The id of the display.
    505      */
    506     void dontOverrideDisplayInfo(int displayId);
    507 
    508     /**
    509      * Gets the windowing mode of the display.
    510      *
    511      * @param displayId The id of the display.
    512      * @return {@link WindowConfiguration.WindowingMode}
    513      */
    514     int getWindowingMode(int displayId);
    515 
    516     /**
    517      * Sets the windowing mode of the display.
    518      *
    519      * @param displayId The id of the display.
    520      * @param mode {@link WindowConfiguration.WindowingMode}
    521      */
    522     void setWindowingMode(int displayId, int mode);
    523 
    524     /**
    525      * Gets current remove content mode of the display.
    526      * <p>
    527      * What actions should be performed with the display's content when it is removed. Default
    528      * behavior for public displays in this case is to move all activities to the primary display
    529      * and make it focused. For private display is to destroy all activities.
    530      * </p>
    531      *
    532      * @param displayId The id of the display.
    533      * @return The remove content mode of the display.
    534      * @see WindowManager#REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY
    535      * @see WindowManager#REMOVE_CONTENT_MODE_DESTROY
    536      */
    537     int getRemoveContentMode(int displayId);
    538 
    539     /**
    540      * Sets the remove content mode of the display.
    541      * <p>
    542      * This mode indicates what actions should be performed with the display's content when it is
    543      * removed.
    544      * </p>
    545      *
    546      * @param displayId The id of the display.
    547      * @param mode Remove content mode.
    548      * @see WindowManager#REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY
    549      * @see WindowManager#REMOVE_CONTENT_MODE_DESTROY
    550      */
    551     void setRemoveContentMode(int displayId, int mode);
    552 
    553     /**
    554      * Indicates that the display should show its content when non-secure keyguard is shown.
    555      * <p>
    556      * This flag identifies secondary displays that will continue showing content if keyguard can be
    557      * dismissed without entering credentials.
    558      * </p><p>
    559      * An example of usage is a virtual display which content is displayed on external hardware
    560      * display that is not visible to the system directly.
    561      * </p>
    562      *
    563      * @param displayId The id of the display.
    564      * @return {@code true} if the display should show its content when non-secure keyguard is
    565      *         shown.
    566      * @see KeyguardManager#isDeviceSecure()
    567      * @see KeyguardManager#isDeviceLocked()
    568      */
    569     boolean shouldShowWithInsecureKeyguard(int displayId);
    570 
    571     /**
    572      * Sets that the display should show its content when non-secure keyguard is shown.
    573      *
    574      * @param displayId The id of the display.
    575      * @param shouldShow Indicates that the display should show its content when non-secure keyguard
    576      *                  is shown.
    577      * @see KeyguardManager#isDeviceSecure()
    578      * @see KeyguardManager#isDeviceLocked()
    579      */
    580     void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow);
    581 
    582     /**
    583      * Indicates the display should show system decors.
    584      * <p>
    585      * System decors include status bar, navigation bar, launcher.
    586      * </p>
    587      *
    588      * @param displayId The id of the display.
    589      * @return {@code true} if the display should show system decors.
    590      */
    591     boolean shouldShowSystemDecors(int displayId);
    592 
    593     /**
    594      * Sets that the display should show system decors.
    595      * <p>
    596      * System decors include status bar, navigation bar, launcher.
    597      * </p>
    598      *
    599      * @param displayId The id of the display.
    600      * @param shouldShow Indicates that the display should show system decors.
    601      */
    602     void setShouldShowSystemDecors(int displayId, boolean shouldShow);
    603 
    604     /**
    605      * Indicates that the display should show IME.
    606      *
    607      * @param displayId The id of the display.
    608      * @return {@code true} if the display should show IME.
    609      * @see KeyguardManager#isDeviceSecure()
    610      * @see KeyguardManager#isDeviceLocked()
    611      */
    612     boolean shouldShowIme(int displayId);
    613 
    614     /**
    615      * Sets that the display should show IME.
    616      *
    617      * @param displayId The id of the display.
    618      * @param shouldShow Indicates that the display should show IME.
    619      * @see KeyguardManager#isDeviceSecure()
    620      * @see KeyguardManager#isDeviceLocked()
    621      */
    622     void setShouldShowIme(int displayId, boolean shouldShow);
    623 
    624     /**
    625      * Waits for transactions to get applied before injecting input.
    626      * This includes waiting for the input windows to get sent to InputManager.
    627      *
    628      * This is needed for testing since the system add windows and injects input
    629      * quick enough that the windows don't have time to get sent to InputManager.
    630      */
    631     boolean injectInputAfterTransactionsApplied(in InputEvent ev, int mode);
    632 
    633     /**
    634      * Waits until all animations have completed and input information has been sent from
    635      * WindowManager to native InputManager.
    636      *
    637      * This is needed for testing since we need to ensure input information has been propagated to
    638      * native InputManager before proceeding with tests.
    639      */
    640     void syncInputTransactions();
    641 }
    642