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 static android.content.pm.ActivityInfo.COLOR_MODE_DEFAULT;
     20 import static android.view.WindowLayoutParamsProto.ALPHA;
     21 import static android.view.WindowLayoutParamsProto.BUTTON_BRIGHTNESS;
     22 import static android.view.WindowLayoutParamsProto.COLOR_MODE;
     23 import static android.view.WindowLayoutParamsProto.FLAGS;
     24 import static android.view.WindowLayoutParamsProto.FORMAT;
     25 import static android.view.WindowLayoutParamsProto.GRAVITY;
     26 import static android.view.WindowLayoutParamsProto.HAS_SYSTEM_UI_LISTENERS;
     27 import static android.view.WindowLayoutParamsProto.HEIGHT;
     28 import static android.view.WindowLayoutParamsProto.HORIZONTAL_MARGIN;
     29 import static android.view.WindowLayoutParamsProto.INPUT_FEATURE_FLAGS;
     30 import static android.view.WindowLayoutParamsProto.NEEDS_MENU_KEY;
     31 import static android.view.WindowLayoutParamsProto.PREFERRED_REFRESH_RATE;
     32 import static android.view.WindowLayoutParamsProto.PRIVATE_FLAGS;
     33 import static android.view.WindowLayoutParamsProto.ROTATION_ANIMATION;
     34 import static android.view.WindowLayoutParamsProto.SCREEN_BRIGHTNESS;
     35 import static android.view.WindowLayoutParamsProto.SOFT_INPUT_MODE;
     36 import static android.view.WindowLayoutParamsProto.SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS;
     37 import static android.view.WindowLayoutParamsProto.SYSTEM_UI_VISIBILITY_FLAGS;
     38 import static android.view.WindowLayoutParamsProto.TYPE;
     39 import static android.view.WindowLayoutParamsProto.USER_ACTIVITY_TIMEOUT;
     40 import static android.view.WindowLayoutParamsProto.VERTICAL_MARGIN;
     41 import static android.view.WindowLayoutParamsProto.WIDTH;
     42 import static android.view.WindowLayoutParamsProto.WINDOW_ANIMATIONS;
     43 import static android.view.WindowLayoutParamsProto.X;
     44 import static android.view.WindowLayoutParamsProto.Y;
     45 
     46 import android.Manifest.permission;
     47 import android.annotation.IntDef;
     48 import android.annotation.NonNull;
     49 import android.annotation.RequiresPermission;
     50 import android.annotation.SystemApi;
     51 import android.annotation.SystemService;
     52 import android.annotation.TestApi;
     53 import android.annotation.UnsupportedAppUsage;
     54 import android.app.KeyguardManager;
     55 import android.app.Presentation;
     56 import android.content.Context;
     57 import android.content.pm.ActivityInfo;
     58 import android.graphics.PixelFormat;
     59 import android.graphics.Rect;
     60 import android.graphics.Region;
     61 import android.os.IBinder;
     62 import android.os.Parcel;
     63 import android.os.Parcelable;
     64 import android.text.TextUtils;
     65 import android.util.Log;
     66 import android.util.proto.ProtoOutputStream;
     67 import android.view.accessibility.AccessibilityNodeInfo;
     68 
     69 import java.lang.annotation.Retention;
     70 import java.lang.annotation.RetentionPolicy;
     71 import java.util.List;
     72 import java.util.Objects;
     73 
     74 /**
     75  * The interface that apps use to talk to the window manager.
     76  * </p><p>
     77  * Each window manager instance is bound to a particular {@link Display}.
     78  * To obtain a {@link WindowManager} for a different display, use
     79  * {@link Context#createDisplayContext} to obtain a {@link Context} for that
     80  * display, then use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code>
     81  * to get the WindowManager.
     82  * </p><p>
     83  * The simplest way to show a window on another display is to create a
     84  * {@link Presentation}.  The presentation will automatically obtain a
     85  * {@link WindowManager} and {@link Context} for that display.
     86  * </p>
     87  */
     88 @SystemService(Context.WINDOW_SERVICE)
     89 public interface WindowManager extends ViewManager {
     90 
     91     /** @hide */
     92     int DOCKED_INVALID = -1;
     93     /** @hide */
     94     int DOCKED_LEFT = 1;
     95     /** @hide */
     96     int DOCKED_TOP = 2;
     97     /** @hide */
     98     int DOCKED_RIGHT = 3;
     99     /** @hide */
    100     int DOCKED_BOTTOM = 4;
    101 
    102     /** @hide */
    103     String INPUT_CONSUMER_PIP = "pip_input_consumer";
    104     /** @hide */
    105     String INPUT_CONSUMER_NAVIGATION = "nav_input_consumer";
    106     /** @hide */
    107     String INPUT_CONSUMER_WALLPAPER = "wallpaper_input_consumer";
    108     /** @hide */
    109     String INPUT_CONSUMER_RECENTS_ANIMATION = "recents_animation_input_consumer";
    110 
    111     /**
    112      * Not set up for a transition.
    113      * @hide
    114      */
    115     int TRANSIT_UNSET = -1;
    116 
    117     /**
    118      * No animation for transition.
    119      * @hide
    120      */
    121     int TRANSIT_NONE = 0;
    122 
    123     /**
    124      * A window in a new activity is being opened on top of an existing one in the same task.
    125      * @hide
    126      */
    127     int TRANSIT_ACTIVITY_OPEN = 6;
    128 
    129     /**
    130      * The window in the top-most activity is being closed to reveal the previous activity in the
    131      * same task.
    132      * @hide
    133      */
    134     int TRANSIT_ACTIVITY_CLOSE = 7;
    135 
    136     /**
    137      * A window in a new task is being opened on top of an existing one in another activity's task.
    138      * @hide
    139      */
    140     int TRANSIT_TASK_OPEN = 8;
    141 
    142     /**
    143      * A window in the top-most activity is being closed to reveal the previous activity in a
    144      * different task.
    145      * @hide
    146      */
    147     int TRANSIT_TASK_CLOSE = 9;
    148 
    149     /**
    150      * A window in an existing task is being displayed on top of an existing one in another
    151      * activity's task.
    152      * @hide
    153      */
    154     int TRANSIT_TASK_TO_FRONT = 10;
    155 
    156     /**
    157      * A window in an existing task is being put below all other tasks.
    158      * @hide
    159      */
    160     int TRANSIT_TASK_TO_BACK = 11;
    161 
    162     /**
    163      * A window in a new activity that doesn't have a wallpaper is being opened on top of one that
    164      * does, effectively closing the wallpaper.
    165      * @hide
    166      */
    167     int TRANSIT_WALLPAPER_CLOSE = 12;
    168 
    169     /**
    170      * A window in a new activity that does have a wallpaper is being opened on one that didn't,
    171      * effectively opening the wallpaper.
    172      * @hide
    173      */
    174     int TRANSIT_WALLPAPER_OPEN = 13;
    175 
    176     /**
    177      * A window in a new activity is being opened on top of an existing one, and both are on top
    178      * of the wallpaper.
    179      * @hide
    180      */
    181     int TRANSIT_WALLPAPER_INTRA_OPEN = 14;
    182 
    183     /**
    184      * The window in the top-most activity is being closed to reveal the previous activity, and
    185      * both are on top of the wallpaper.
    186      * @hide
    187      */
    188     int TRANSIT_WALLPAPER_INTRA_CLOSE = 15;
    189 
    190     /**
    191      * A window in a new task is being opened behind an existing one in another activity's task.
    192      * The new window will show briefly and then be gone.
    193      * @hide
    194      */
    195     int TRANSIT_TASK_OPEN_BEHIND = 16;
    196 
    197     /**
    198      * A window in a task is being animated in-place.
    199      * @hide
    200      */
    201     int TRANSIT_TASK_IN_PLACE = 17;
    202 
    203     /**
    204      * An activity is being relaunched (e.g. due to configuration change).
    205      * @hide
    206      */
    207     int TRANSIT_ACTIVITY_RELAUNCH = 18;
    208 
    209     /**
    210      * A task is being docked from recents.
    211      * @hide
    212      */
    213     int TRANSIT_DOCK_TASK_FROM_RECENTS = 19;
    214 
    215     /**
    216      * Keyguard is going away.
    217      * @hide
    218      */
    219     int TRANSIT_KEYGUARD_GOING_AWAY = 20;
    220 
    221     /**
    222      * Keyguard is going away with showing an activity behind that requests wallpaper.
    223      * @hide
    224      */
    225     int TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER = 21;
    226 
    227     /**
    228      * Keyguard is being occluded.
    229      * @hide
    230      */
    231     int TRANSIT_KEYGUARD_OCCLUDE = 22;
    232 
    233     /**
    234      * Keyguard is being unoccluded.
    235      * @hide
    236      */
    237     int TRANSIT_KEYGUARD_UNOCCLUDE = 23;
    238 
    239     /**
    240      * A translucent activity is being opened.
    241      * @hide
    242      */
    243     int TRANSIT_TRANSLUCENT_ACTIVITY_OPEN = 24;
    244 
    245     /**
    246      * A translucent activity is being closed.
    247      * @hide
    248      */
    249     int TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE = 25;
    250 
    251     /**
    252      * A crashing activity is being closed.
    253      * @hide
    254      */
    255     int TRANSIT_CRASHING_ACTIVITY_CLOSE = 26;
    256 
    257     /**
    258      * A task is changing windowing modes
    259      * @hide
    260      */
    261     int TRANSIT_TASK_CHANGE_WINDOWING_MODE = 27;
    262 
    263     /**
    264      * @hide
    265      */
    266     @IntDef(prefix = { "TRANSIT_" }, value = {
    267             TRANSIT_UNSET,
    268             TRANSIT_NONE,
    269             TRANSIT_ACTIVITY_OPEN,
    270             TRANSIT_ACTIVITY_CLOSE,
    271             TRANSIT_TASK_OPEN,
    272             TRANSIT_TASK_CLOSE,
    273             TRANSIT_TASK_TO_FRONT,
    274             TRANSIT_TASK_TO_BACK,
    275             TRANSIT_WALLPAPER_CLOSE,
    276             TRANSIT_WALLPAPER_OPEN,
    277             TRANSIT_WALLPAPER_INTRA_OPEN,
    278             TRANSIT_WALLPAPER_INTRA_CLOSE,
    279             TRANSIT_TASK_OPEN_BEHIND,
    280             TRANSIT_TASK_IN_PLACE,
    281             TRANSIT_ACTIVITY_RELAUNCH,
    282             TRANSIT_DOCK_TASK_FROM_RECENTS,
    283             TRANSIT_KEYGUARD_GOING_AWAY,
    284             TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER,
    285             TRANSIT_KEYGUARD_OCCLUDE,
    286             TRANSIT_KEYGUARD_UNOCCLUDE,
    287             TRANSIT_TRANSLUCENT_ACTIVITY_OPEN,
    288             TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE,
    289             TRANSIT_CRASHING_ACTIVITY_CLOSE,
    290             TRANSIT_TASK_CHANGE_WINDOWING_MODE
    291     })
    292     @Retention(RetentionPolicy.SOURCE)
    293     @interface TransitionType {}
    294 
    295     /**
    296      * Transition flag: Keyguard is going away, but keeping the notification shade open
    297      * @hide
    298      */
    299     int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE = 0x1;
    300 
    301     /**
    302      * Transition flag: Keyguard is going away, but doesn't want an animation for it
    303      * @hide
    304      */
    305     int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION = 0x2;
    306 
    307     /**
    308      * Transition flag: Keyguard is going away while it was showing the system wallpaper.
    309      * @hide
    310      */
    311     int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER = 0x4;
    312 
    313     /**
    314      * @hide
    315      */
    316     @IntDef(flag = true, prefix = { "TRANSIT_FLAG_" }, value = {
    317             TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE,
    318             TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION,
    319             TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER,
    320     })
    321     @Retention(RetentionPolicy.SOURCE)
    322     @interface TransitionFlags {}
    323 
    324     /**
    325      * Remove content mode: Indicates remove content mode is currently not defined.
    326      * @hide
    327      */
    328     int REMOVE_CONTENT_MODE_UNDEFINED = 0;
    329 
    330     /**
    331      * Remove content mode: Indicates that when display is removed, all its activities will be moved
    332      * to the primary display and the topmost activity should become focused.
    333      * @hide
    334      */
    335     int REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY = 1;
    336 
    337     /**
    338      * Remove content mode: Indicates that when display is removed, all its stacks and tasks will be
    339      * removed, all activities will be destroyed according to the usual lifecycle.
    340      * @hide
    341      */
    342     int REMOVE_CONTENT_MODE_DESTROY = 2;
    343 
    344     /**
    345      * @hide
    346      */
    347     @IntDef(prefix = { "REMOVE_CONTENT_MODE_" }, value = {
    348             REMOVE_CONTENT_MODE_UNDEFINED,
    349             REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY,
    350             REMOVE_CONTENT_MODE_DESTROY,
    351     })
    352     @interface RemoveContentMode {}
    353 
    354     /**
    355      * Exception that is thrown when trying to add view whose
    356      * {@link LayoutParams} {@link LayoutParams#token}
    357      * is invalid.
    358      */
    359     public static class BadTokenException extends RuntimeException {
    360         public BadTokenException() {
    361         }
    362 
    363         public BadTokenException(String name) {
    364             super(name);
    365         }
    366     }
    367 
    368     /**
    369      * Exception that is thrown when calling {@link #addView} to a secondary display that cannot
    370      * be found. See {@link android.app.Presentation} for more information on secondary displays.
    371      */
    372     public static class InvalidDisplayException extends RuntimeException {
    373         public InvalidDisplayException() {
    374         }
    375 
    376         public InvalidDisplayException(String name) {
    377             super(name);
    378         }
    379     }
    380 
    381     /**
    382      * Returns the {@link Display} upon which this {@link WindowManager} instance
    383      * will create new windows.
    384      * <p>
    385      * Despite the name of this method, the display that is returned is not
    386      * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}).
    387      * The returned display could instead be a secondary display that this
    388      * window manager instance is managing.  Think of it as the display that
    389      * this {@link WindowManager} instance uses by default.
    390      * </p><p>
    391      * To create windows on a different display, you need to obtain a
    392      * {@link WindowManager} for that {@link Display}.  (See the {@link WindowManager}
    393      * class documentation for more information.)
    394      * </p>
    395      *
    396      * @return The display that this window manager is managing.
    397      */
    398     public Display getDefaultDisplay();
    399 
    400     /**
    401      * Special variation of {@link #removeView} that immediately invokes
    402      * the given view hierarchy's {@link View#onDetachedFromWindow()
    403      * View.onDetachedFromWindow()} methods before returning.  This is not
    404      * for normal applications; using it correctly requires great care.
    405      *
    406      * @param view The view to be removed.
    407      */
    408     public void removeViewImmediate(View view);
    409 
    410     /**
    411      * Used to asynchronously request Keyboard Shortcuts from the focused window.
    412      *
    413      * @hide
    414      */
    415     public interface KeyboardShortcutsReceiver {
    416         /**
    417          * Callback used when the focused window keyboard shortcuts are ready to be displayed.
    418          *
    419          * @param result The keyboard shortcuts to be displayed.
    420          */
    421         void onKeyboardShortcutsReceived(List<KeyboardShortcutGroup> result);
    422     }
    423 
    424     /**
    425      * Message for taking fullscreen screenshot
    426      * @hide
    427      */
    428     final int TAKE_SCREENSHOT_FULLSCREEN = 1;
    429 
    430     /**
    431      * Message for taking screenshot of selected region.
    432      * @hide
    433      */
    434     final int TAKE_SCREENSHOT_SELECTED_REGION = 2;
    435 
    436     /**
    437      * @hide
    438      */
    439     public static final String PARCEL_KEY_SHORTCUTS_ARRAY = "shortcuts_array";
    440 
    441     /**
    442      * Request for keyboard shortcuts to be retrieved asynchronously.
    443      *
    444      * @param receiver The callback to be triggered when the result is ready.
    445      *
    446      * @hide
    447      */
    448     public void requestAppKeyboardShortcuts(final KeyboardShortcutsReceiver receiver, int deviceId);
    449 
    450     /**
    451      * Return the touch region for the current IME window, or an empty region if there is none.
    452      *
    453      * @return The region of the IME that is accepting touch inputs, or null if there is no IME, no
    454      *         region or there was an error.
    455      *
    456      * @hide
    457      */
    458     @SystemApi
    459     @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS)
    460     public Region getCurrentImeTouchRegion();
    461 
    462     /**
    463      * Sets that the display should show its content when non-secure keyguard is shown.
    464      *
    465      * @param displayId Display ID.
    466      * @param shouldShow Indicates that the display should show its content when non-secure keyguard
    467      *                  is shown.
    468      * @see KeyguardManager#isDeviceSecure()
    469      * @see KeyguardManager#isDeviceLocked()
    470      * @hide
    471      */
    472     @TestApi
    473     default void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow) {
    474     }
    475 
    476     /**
    477      * Sets that the display should show system decors.
    478      * <p>
    479      * System decors include status bar, navigation bar, launcher.
    480      * </p>
    481      *
    482      * @param displayId The id of the display.
    483      * @param shouldShow Indicates that the display should show system decors.
    484      * @see #shouldShowSystemDecors(int)
    485      * @hide
    486      */
    487     @TestApi
    488     default void setShouldShowSystemDecors(int displayId, boolean shouldShow) {
    489     }
    490 
    491     /**
    492      * Checks if the display supports showing system decors.
    493      * <p>
    494      * System decors include status bar, navigation bar, launcher.
    495      * </p>
    496      *
    497      * @param displayId The id of the display.
    498      * @see #setShouldShowSystemDecors(int, boolean)
    499      * @hide
    500      */
    501     @TestApi
    502     default boolean shouldShowSystemDecors(int displayId) {
    503         return false;
    504     }
    505 
    506     /**
    507      * Sets that the display should show IME.
    508      *
    509      * @param displayId Display ID.
    510      * @param shouldShow Indicates that the display should show IME.
    511      * @hide
    512      */
    513     @TestApi
    514     default void setShouldShowIme(int displayId, boolean shouldShow) {
    515     }
    516 
    517     /**
    518      * Indicates that the display should show IME.
    519      *
    520      * @param displayId The id of the display.
    521      * @return {@code true} if the display should show IME when an input field becomes
    522      * focused on it.
    523      * @hide
    524      */
    525     @TestApi
    526     default boolean shouldShowIme(int displayId) {
    527         return false;
    528     }
    529 
    530     public static class LayoutParams extends ViewGroup.LayoutParams implements Parcelable {
    531         /**
    532          * X position for this window.  With the default gravity it is ignored.
    533          * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or
    534          * {@link Gravity#END} it provides an offset from the given edge.
    535          */
    536         @ViewDebug.ExportedProperty
    537         public int x;
    538 
    539         /**
    540          * Y position for this window.  With the default gravity it is ignored.
    541          * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
    542          * an offset from the given edge.
    543          */
    544         @ViewDebug.ExportedProperty
    545         public int y;
    546 
    547         /**
    548          * Indicates how much of the extra space will be allocated horizontally
    549          * to the view associated with these LayoutParams. Specify 0 if the view
    550          * should not be stretched. Otherwise the extra pixels will be pro-rated
    551          * among all views whose weight is greater than 0.
    552          */
    553         @ViewDebug.ExportedProperty
    554         public float horizontalWeight;
    555 
    556         /**
    557          * Indicates how much of the extra space will be allocated vertically
    558          * to the view associated with these LayoutParams. Specify 0 if the view
    559          * should not be stretched. Otherwise the extra pixels will be pro-rated
    560          * among all views whose weight is greater than 0.
    561          */
    562         @ViewDebug.ExportedProperty
    563         public float verticalWeight;
    564 
    565         /**
    566          * The general type of window.  There are three main classes of
    567          * window types:
    568          * <ul>
    569          * <li> <strong>Application windows</strong> (ranging from
    570          * {@link #FIRST_APPLICATION_WINDOW} to
    571          * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application
    572          * windows.  For these types of windows, the {@link #token} must be
    573          * set to the token of the activity they are a part of (this will
    574          * normally be done for you if {@link #token} is null).
    575          * <li> <strong>Sub-windows</strong> (ranging from
    576          * {@link #FIRST_SUB_WINDOW} to
    577          * {@link #LAST_SUB_WINDOW}) are associated with another top-level
    578          * window.  For these types of windows, the {@link #token} must be
    579          * the token of the window it is attached to.
    580          * <li> <strong>System windows</strong> (ranging from
    581          * {@link #FIRST_SYSTEM_WINDOW} to
    582          * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for
    583          * use by the system for specific purposes.  They should not normally
    584          * be used by applications, and a special permission is required
    585          * to use them.
    586          * </ul>
    587          *
    588          * @see #TYPE_BASE_APPLICATION
    589          * @see #TYPE_APPLICATION
    590          * @see #TYPE_APPLICATION_STARTING
    591          * @see #TYPE_DRAWN_APPLICATION
    592          * @see #TYPE_APPLICATION_PANEL
    593          * @see #TYPE_APPLICATION_MEDIA
    594          * @see #TYPE_APPLICATION_SUB_PANEL
    595          * @see #TYPE_APPLICATION_ATTACHED_DIALOG
    596          * @see #TYPE_STATUS_BAR
    597          * @see #TYPE_SEARCH_BAR
    598          * @see #TYPE_PHONE
    599          * @see #TYPE_SYSTEM_ALERT
    600          * @see #TYPE_TOAST
    601          * @see #TYPE_SYSTEM_OVERLAY
    602          * @see #TYPE_PRIORITY_PHONE
    603          * @see #TYPE_STATUS_BAR_PANEL
    604          * @see #TYPE_SYSTEM_DIALOG
    605          * @see #TYPE_KEYGUARD_DIALOG
    606          * @see #TYPE_SYSTEM_ERROR
    607          * @see #TYPE_INPUT_METHOD
    608          * @see #TYPE_INPUT_METHOD_DIALOG
    609          */
    610         @ViewDebug.ExportedProperty(mapping = {
    611                 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION,
    612                         to = "BASE_APPLICATION"),
    613                 @ViewDebug.IntToString(from = TYPE_APPLICATION,
    614                         to = "APPLICATION"),
    615                 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING,
    616                         to = "APPLICATION_STARTING"),
    617                 @ViewDebug.IntToString(from = TYPE_DRAWN_APPLICATION,
    618                         to = "DRAWN_APPLICATION"),
    619                 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL,
    620                         to = "APPLICATION_PANEL"),
    621                 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA,
    622                         to = "APPLICATION_MEDIA"),
    623                 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL,
    624                         to = "APPLICATION_SUB_PANEL"),
    625                 @ViewDebug.IntToString(from = TYPE_APPLICATION_ABOVE_SUB_PANEL,
    626                         to = "APPLICATION_ABOVE_SUB_PANEL"),
    627                 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG,
    628                         to = "APPLICATION_ATTACHED_DIALOG"),
    629                 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY,
    630                         to = "APPLICATION_MEDIA_OVERLAY"),
    631                 @ViewDebug.IntToString(from = TYPE_STATUS_BAR,
    632                         to = "STATUS_BAR"),
    633                 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR,
    634                         to = "SEARCH_BAR"),
    635                 @ViewDebug.IntToString(from = TYPE_PHONE,
    636                         to = "PHONE"),
    637                 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT,
    638                         to = "SYSTEM_ALERT"),
    639                 @ViewDebug.IntToString(from = TYPE_TOAST,
    640                         to = "TOAST"),
    641                 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY,
    642                         to = "SYSTEM_OVERLAY"),
    643                 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE,
    644                         to = "PRIORITY_PHONE"),
    645                 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG,
    646                         to = "SYSTEM_DIALOG"),
    647                 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG,
    648                         to = "KEYGUARD_DIALOG"),
    649                 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR,
    650                         to = "SYSTEM_ERROR"),
    651                 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD,
    652                         to = "INPUT_METHOD"),
    653                 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG,
    654                         to = "INPUT_METHOD_DIALOG"),
    655                 @ViewDebug.IntToString(from = TYPE_WALLPAPER,
    656                         to = "WALLPAPER"),
    657                 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL,
    658                         to = "STATUS_BAR_PANEL"),
    659                 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY,
    660                         to = "SECURE_SYSTEM_OVERLAY"),
    661                 @ViewDebug.IntToString(from = TYPE_DRAG,
    662                         to = "DRAG"),
    663                 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL,
    664                         to = "STATUS_BAR_SUB_PANEL"),
    665                 @ViewDebug.IntToString(from = TYPE_POINTER,
    666                         to = "POINTER"),
    667                 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR,
    668                         to = "NAVIGATION_BAR"),
    669                 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY,
    670                         to = "VOLUME_OVERLAY"),
    671                 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS,
    672                         to = "BOOT_PROGRESS"),
    673                 @ViewDebug.IntToString(from = TYPE_INPUT_CONSUMER,
    674                         to = "INPUT_CONSUMER"),
    675                 @ViewDebug.IntToString(from = TYPE_DREAM,
    676                         to = "DREAM"),
    677                 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL,
    678                         to = "NAVIGATION_BAR_PANEL"),
    679                 @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY,
    680                         to = "DISPLAY_OVERLAY"),
    681                 @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY,
    682                         to = "MAGNIFICATION_OVERLAY"),
    683                 @ViewDebug.IntToString(from = TYPE_PRESENTATION,
    684                         to = "PRESENTATION"),
    685                 @ViewDebug.IntToString(from = TYPE_PRIVATE_PRESENTATION,
    686                         to = "PRIVATE_PRESENTATION"),
    687                 @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION,
    688                         to = "VOICE_INTERACTION"),
    689                 @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION_STARTING,
    690                         to = "VOICE_INTERACTION_STARTING"),
    691                 @ViewDebug.IntToString(from = TYPE_DOCK_DIVIDER,
    692                         to = "DOCK_DIVIDER"),
    693                 @ViewDebug.IntToString(from = TYPE_QS_DIALOG,
    694                         to = "QS_DIALOG"),
    695                 @ViewDebug.IntToString(from = TYPE_SCREENSHOT,
    696                         to = "SCREENSHOT"),
    697                 @ViewDebug.IntToString(from = TYPE_APPLICATION_OVERLAY,
    698                         to = "APPLICATION_OVERLAY")
    699         })
    700         public int type;
    701 
    702         /**
    703          * Start of window types that represent normal application windows.
    704          */
    705         public static final int FIRST_APPLICATION_WINDOW = 1;
    706 
    707         /**
    708          * Window type: an application window that serves as the "base" window
    709          * of the overall application; all other application windows will
    710          * appear on top of it.
    711          * In multiuser systems shows only on the owning user's window.
    712          */
    713         public static final int TYPE_BASE_APPLICATION   = 1;
    714 
    715         /**
    716          * Window type: a normal application window.  The {@link #token} must be
    717          * an Activity token identifying who the window belongs to.
    718          * In multiuser systems shows only on the owning user's window.
    719          */
    720         public static final int TYPE_APPLICATION        = 2;
    721 
    722         /**
    723          * Window type: special application window that is displayed while the
    724          * application is starting.  Not for use by applications themselves;
    725          * this is used by the system to display something until the
    726          * application can show its own windows.
    727          * In multiuser systems shows on all users' windows.
    728          */
    729         public static final int TYPE_APPLICATION_STARTING = 3;
    730 
    731         /**
    732          * Window type: a variation on TYPE_APPLICATION that ensures the window
    733          * manager will wait for this window to be drawn before the app is shown.
    734          * In multiuser systems shows only on the owning user's window.
    735          */
    736         public static final int TYPE_DRAWN_APPLICATION = 4;
    737 
    738         /**
    739          * End of types of application windows.
    740          */
    741         public static final int LAST_APPLICATION_WINDOW = 99;
    742 
    743         /**
    744          * Start of types of sub-windows.  The {@link #token} of these windows
    745          * must be set to the window they are attached to.  These types of
    746          * windows are kept next to their attached window in Z-order, and their
    747          * coordinate space is relative to their attached window.
    748          */
    749         public static final int FIRST_SUB_WINDOW = 1000;
    750 
    751         /**
    752          * Window type: a panel on top of an application window.  These windows
    753          * appear on top of their attached window.
    754          */
    755         public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
    756 
    757         /**
    758          * Window type: window for showing media (such as video).  These windows
    759          * are displayed behind their attached window.
    760          */
    761         public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1;
    762 
    763         /**
    764          * Window type: a sub-panel on top of an application window.  These
    765          * windows are displayed on top their attached window and any
    766          * {@link #TYPE_APPLICATION_PANEL} panels.
    767          */
    768         public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2;
    769 
    770         /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
    771          * of the window happens as that of a top-level window, <em>not</em>
    772          * as a child of its container.
    773          */
    774         public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3;
    775 
    776         /**
    777          * Window type: window for showing overlays on top of media windows.
    778          * These windows are displayed between TYPE_APPLICATION_MEDIA and the
    779          * application window.  They should be translucent to be useful.  This
    780          * is a big ugly hack so:
    781          * @hide
    782          */
    783         @UnsupportedAppUsage
    784         public static final int TYPE_APPLICATION_MEDIA_OVERLAY  = FIRST_SUB_WINDOW + 4;
    785 
    786         /**
    787          * Window type: a above sub-panel on top of an application window and it's
    788          * sub-panel windows. These windows are displayed on top of their attached window
    789          * and any {@link #TYPE_APPLICATION_SUB_PANEL} panels.
    790          * @hide
    791          */
    792         public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5;
    793 
    794         /**
    795          * End of types of sub-windows.
    796          */
    797         public static final int LAST_SUB_WINDOW = 1999;
    798 
    799         /**
    800          * Start of system-specific window types.  These are not normally
    801          * created by applications.
    802          */
    803         public static final int FIRST_SYSTEM_WINDOW     = 2000;
    804 
    805         /**
    806          * Window type: the status bar.  There can be only one status bar
    807          * window; it is placed at the top of the screen, and all other
    808          * windows are shifted down so they are below it.
    809          * In multiuser systems shows on all users' windows.
    810          */
    811         public static final int TYPE_STATUS_BAR         = FIRST_SYSTEM_WINDOW;
    812 
    813         /**
    814          * Window type: the search bar.  There can be only one search bar
    815          * window; it is placed at the top of the screen.
    816          * In multiuser systems shows on all users' windows.
    817          */
    818         public static final int TYPE_SEARCH_BAR         = FIRST_SYSTEM_WINDOW+1;
    819 
    820         /**
    821          * Window type: phone.  These are non-application windows providing
    822          * user interaction with the phone (in particular incoming calls).
    823          * These windows are normally placed above all applications, but behind
    824          * the status bar.
    825          * In multiuser systems shows on all users' windows.
    826          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
    827          */
    828         @Deprecated
    829         public static final int TYPE_PHONE              = FIRST_SYSTEM_WINDOW+2;
    830 
    831         /**
    832          * Window type: system window, such as low power alert. These windows
    833          * are always on top of application windows.
    834          * In multiuser systems shows only on the owning user's window.
    835          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
    836          */
    837         @Deprecated
    838         public static final int TYPE_SYSTEM_ALERT       = FIRST_SYSTEM_WINDOW+3;
    839 
    840         /**
    841          * Window type: keyguard window.
    842          * In multiuser systems shows on all users' windows.
    843          * @removed
    844          */
    845         public static final int TYPE_KEYGUARD           = FIRST_SYSTEM_WINDOW+4;
    846 
    847         /**
    848          * Window type: transient notifications.
    849          * In multiuser systems shows only on the owning user's window.
    850          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
    851          */
    852         @Deprecated
    853         public static final int TYPE_TOAST              = FIRST_SYSTEM_WINDOW+5;
    854 
    855         /**
    856          * Window type: system overlay windows, which need to be displayed
    857          * on top of everything else.  These windows must not take input
    858          * focus, or they will interfere with the keyguard.
    859          * In multiuser systems shows only on the owning user's window.
    860          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
    861          */
    862         @Deprecated
    863         public static final int TYPE_SYSTEM_OVERLAY     = FIRST_SYSTEM_WINDOW+6;
    864 
    865         /**
    866          * Window type: priority phone UI, which needs to be displayed even if
    867          * the keyguard is active.  These windows must not take input
    868          * focus, or they will interfere with the keyguard.
    869          * In multiuser systems shows on all users' windows.
    870          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
    871          */
    872         @Deprecated
    873         public static final int TYPE_PRIORITY_PHONE     = FIRST_SYSTEM_WINDOW+7;
    874 
    875         /**
    876          * Window type: panel that slides out from the status bar
    877          * In multiuser systems shows on all users' windows.
    878          */
    879         public static final int TYPE_SYSTEM_DIALOG      = FIRST_SYSTEM_WINDOW+8;
    880 
    881         /**
    882          * Window type: dialogs that the keyguard shows
    883          * In multiuser systems shows on all users' windows.
    884          */
    885         public static final int TYPE_KEYGUARD_DIALOG    = FIRST_SYSTEM_WINDOW+9;
    886 
    887         /**
    888          * Window type: internal system error windows, appear on top of
    889          * everything they can.
    890          * In multiuser systems shows only on the owning user's window.
    891          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
    892          */
    893         @Deprecated
    894         public static final int TYPE_SYSTEM_ERROR       = FIRST_SYSTEM_WINDOW+10;
    895 
    896         /**
    897          * Window type: internal input methods windows, which appear above
    898          * the normal UI.  Application windows may be resized or panned to keep
    899          * the input focus visible while this window is displayed.
    900          * In multiuser systems shows only on the owning user's window.
    901          */
    902         public static final int TYPE_INPUT_METHOD       = FIRST_SYSTEM_WINDOW+11;
    903 
    904         /**
    905          * Window type: internal input methods dialog windows, which appear above
    906          * the current input method window.
    907          * In multiuser systems shows only on the owning user's window.
    908          */
    909         public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
    910 
    911         /**
    912          * Window type: wallpaper window, placed behind any window that wants
    913          * to sit on top of the wallpaper.
    914          * In multiuser systems shows only on the owning user's window.
    915          */
    916         public static final int TYPE_WALLPAPER          = FIRST_SYSTEM_WINDOW+13;
    917 
    918         /**
    919          * Window type: panel that slides out from over the status bar
    920          * In multiuser systems shows on all users' windows.
    921          */
    922         public static final int TYPE_STATUS_BAR_PANEL   = FIRST_SYSTEM_WINDOW+14;
    923 
    924         /**
    925          * Window type: secure system overlay windows, which need to be displayed
    926          * on top of everything else.  These windows must not take input
    927          * focus, or they will interfere with the keyguard.
    928          *
    929          * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
    930          * system itself is allowed to create these overlays.  Applications cannot
    931          * obtain permission to create secure system overlays.
    932          *
    933          * In multiuser systems shows only on the owning user's window.
    934          * @hide
    935          */
    936         @UnsupportedAppUsage
    937         public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
    938 
    939         /**
    940          * Window type: the drag-and-drop pseudowindow.  There is only one
    941          * drag layer (at most), and it is placed on top of all other windows.
    942          * In multiuser systems shows only on the owning user's window.
    943          * @hide
    944          */
    945         public static final int TYPE_DRAG               = FIRST_SYSTEM_WINDOW+16;
    946 
    947         /**
    948          * Window type: panel that slides out from over the status bar
    949          * In multiuser systems shows on all users' windows. These windows
    950          * are displayed on top of the stauts bar and any {@link #TYPE_STATUS_BAR_PANEL}
    951          * windows.
    952          * @hide
    953          */
    954         public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
    955 
    956         /**
    957          * Window type: (mouse) pointer
    958          * In multiuser systems shows on all users' windows.
    959          * @hide
    960          */
    961         public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
    962 
    963         /**
    964          * Window type: Navigation bar (when distinct from status bar)
    965          * In multiuser systems shows on all users' windows.
    966          * @hide
    967          */
    968         public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
    969 
    970         /**
    971          * Window type: The volume level overlay/dialog shown when the user
    972          * changes the system volume.
    973          * In multiuser systems shows on all users' windows.
    974          * @hide
    975          */
    976         public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
    977 
    978         /**
    979          * Window type: The boot progress dialog, goes on top of everything
    980          * in the world.
    981          * In multiuser systems shows on all users' windows.
    982          * @hide
    983          */
    984         public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
    985 
    986         /**
    987          * Window type to consume input events when the systemUI bars are hidden.
    988          * In multiuser systems shows on all users' windows.
    989          * @hide
    990          */
    991         public static final int TYPE_INPUT_CONSUMER = FIRST_SYSTEM_WINDOW+22;
    992 
    993         /**
    994          * Window type: Dreams (screen saver) window, just above keyguard.
    995          * In multiuser systems shows only on the owning user's window.
    996          * @hide
    997          */
    998         public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23;
    999 
   1000         /**
   1001          * Window type: Navigation bar panel (when navigation bar is distinct from status bar)
   1002          * In multiuser systems shows on all users' windows.
   1003          * @hide
   1004          */
   1005         public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24;
   1006 
   1007         /**
   1008          * Window type: Display overlay window.  Used to simulate secondary display devices.
   1009          * In multiuser systems shows on all users' windows.
   1010          * @hide
   1011          */
   1012         @UnsupportedAppUsage
   1013         public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26;
   1014 
   1015         /**
   1016          * Window type: Magnification overlay window. Used to highlight the magnified
   1017          * portion of a display when accessibility magnification is enabled.
   1018          * In multiuser systems shows on all users' windows.
   1019          * @hide
   1020          */
   1021         public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27;
   1022 
   1023         /**
   1024          * Window type: Window for Presentation on top of private
   1025          * virtual display.
   1026          */
   1027         public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30;
   1028 
   1029         /**
   1030          * Window type: Windows in the voice interaction layer.
   1031          * @hide
   1032          */
   1033         public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31;
   1034 
   1035         /**
   1036          * Window type: Windows that are overlaid <em>only</em> by a connected {@link
   1037          * android.accessibilityservice.AccessibilityService} for interception of
   1038          * user interactions without changing the windows an accessibility service
   1039          * can introspect. In particular, an accessibility service can introspect
   1040          * only windows that a sighted user can interact with which is they can touch
   1041          * these windows or can type into these windows. For example, if there
   1042          * is a full screen accessibility overlay that is touchable, the windows
   1043          * below it will be introspectable by an accessibility service even though
   1044          * they are covered by a touchable window.
   1045          */
   1046         public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32;
   1047 
   1048         /**
   1049          * Window type: Starting window for voice interaction layer.
   1050          * @hide
   1051          */
   1052         public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33;
   1053 
   1054         /**
   1055          * Window for displaying a handle used for resizing docked stacks. This window is owned
   1056          * by the system process.
   1057          * @hide
   1058          */
   1059         public static final int TYPE_DOCK_DIVIDER = FIRST_SYSTEM_WINDOW+34;
   1060 
   1061         /**
   1062          * Window type: like {@link #TYPE_APPLICATION_ATTACHED_DIALOG}, but used
   1063          * by Quick Settings Tiles.
   1064          * @hide
   1065          */
   1066         public static final int TYPE_QS_DIALOG = FIRST_SYSTEM_WINDOW+35;
   1067 
   1068         /**
   1069          * Window type: shares similar characteristics with {@link #TYPE_DREAM}. The layer is
   1070          * reserved for screenshot region selection. These windows must not take input focus.
   1071          * @hide
   1072          */
   1073         public static final int TYPE_SCREENSHOT = FIRST_SYSTEM_WINDOW + 36;
   1074 
   1075         /**
   1076          * Window type: Window for Presentation on an external display.
   1077          * @see android.app.Presentation
   1078          * @hide
   1079          */
   1080         public static final int TYPE_PRESENTATION = FIRST_SYSTEM_WINDOW + 37;
   1081 
   1082         /**
   1083          * Window type: Application overlay windows are displayed above all activity windows
   1084          * (types between {@link #FIRST_APPLICATION_WINDOW} and {@link #LAST_APPLICATION_WINDOW})
   1085          * but below critical system windows like the status bar or IME.
   1086          * <p>
   1087          * The system may change the position, size, or visibility of these windows at anytime
   1088          * to reduce visual clutter to the user and also manage resources.
   1089          * <p>
   1090          * Requires {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} permission.
   1091          * <p>
   1092          * The system will adjust the importance of processes with this window type to reduce the
   1093          * chance of the low-memory-killer killing them.
   1094          * <p>
   1095          * In multi-user systems shows only on the owning user's screen.
   1096          */
   1097         public static final int TYPE_APPLICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 38;
   1098 
   1099         /**
   1100          * End of types of system windows.
   1101          */
   1102         public static final int LAST_SYSTEM_WINDOW      = 2999;
   1103 
   1104         /**
   1105          * @hide
   1106          * Used internally when there is no suitable type available.
   1107          */
   1108         public static final int INVALID_WINDOW_TYPE = -1;
   1109 
   1110         /**
   1111          * Return true if the window type is an alert window.
   1112          *
   1113          * @param type The window type.
   1114          * @return If the window type is an alert window.
   1115          * @hide
   1116          */
   1117         public static boolean isSystemAlertWindowType(int type) {
   1118             switch (type) {
   1119                 case TYPE_PHONE:
   1120                 case TYPE_PRIORITY_PHONE:
   1121                 case TYPE_SYSTEM_ALERT:
   1122                 case TYPE_SYSTEM_ERROR:
   1123                 case TYPE_SYSTEM_OVERLAY:
   1124                 case TYPE_APPLICATION_OVERLAY:
   1125                     return true;
   1126             }
   1127             return false;
   1128         }
   1129 
   1130         /** @deprecated this is ignored, this value is set automatically when needed. */
   1131         @Deprecated
   1132         public static final int MEMORY_TYPE_NORMAL = 0;
   1133         /** @deprecated this is ignored, this value is set automatically when needed. */
   1134         @Deprecated
   1135         public static final int MEMORY_TYPE_HARDWARE = 1;
   1136         /** @deprecated this is ignored, this value is set automatically when needed. */
   1137         @Deprecated
   1138         public static final int MEMORY_TYPE_GPU = 2;
   1139         /** @deprecated this is ignored, this value is set automatically when needed. */
   1140         @Deprecated
   1141         public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
   1142 
   1143         /**
   1144          * @deprecated this is ignored
   1145          */
   1146         @Deprecated
   1147         public int memoryType;
   1148 
   1149         /** Window flag: as long as this window is visible to the user, allow
   1150          *  the lock screen to activate while the screen is on.
   1151          *  This can be used independently, or in combination with
   1152          *  {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
   1153         public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001;
   1154 
   1155         /** Window flag: everything behind this window will be dimmed.
   1156          *  Use {@link #dimAmount} to control the amount of dim. */
   1157         public static final int FLAG_DIM_BEHIND        = 0x00000002;
   1158 
   1159         /** Window flag: blur everything behind this window.
   1160          * @deprecated Blurring is no longer supported. */
   1161         @Deprecated
   1162         public static final int FLAG_BLUR_BEHIND        = 0x00000004;
   1163 
   1164         /** Window flag: this window won't ever get key input focus, so the
   1165          * user can not send key or other button events to it.  Those will
   1166          * instead go to whatever focusable window is behind it.  This flag
   1167          * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
   1168          * is explicitly set.
   1169          *
   1170          * <p>Setting this flag also implies that the window will not need to
   1171          * interact with
   1172          * a soft input method, so it will be Z-ordered and positioned
   1173          * independently of any active input method (typically this means it
   1174          * gets Z-ordered on top of the input method, so it can use the full
   1175          * screen for its content and cover the input method if needed.  You
   1176          * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
   1177         public static final int FLAG_NOT_FOCUSABLE      = 0x00000008;
   1178 
   1179         /** Window flag: this window can never receive touch events. */
   1180         public static final int FLAG_NOT_TOUCHABLE      = 0x00000010;
   1181 
   1182         /** Window flag: even when this window is focusable (its
   1183          * {@link #FLAG_NOT_FOCUSABLE} is not set), allow any pointer events
   1184          * outside of the window to be sent to the windows behind it.  Otherwise
   1185          * it will consume all pointer events itself, regardless of whether they
   1186          * are inside of the window. */
   1187         public static final int FLAG_NOT_TOUCH_MODAL    = 0x00000020;
   1188 
   1189         /** Window flag: when set, if the device is asleep when the touch
   1190          * screen is pressed, you will receive this first touch event.  Usually
   1191          * the first touch event is consumed by the system since the user can
   1192          * not see what they are pressing on.
   1193          *
   1194          * @deprecated This flag has no effect.
   1195          */
   1196         @Deprecated
   1197         public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
   1198 
   1199         /** Window flag: as long as this window is visible to the user, keep
   1200          *  the device's screen turned on and bright. */
   1201         public static final int FLAG_KEEP_SCREEN_ON     = 0x00000080;
   1202 
   1203         /** Window flag: place the window within the entire screen, ignoring
   1204          *  decorations around the border (such as the status bar).  The
   1205          *  window must correctly position its contents to take the screen
   1206          *  decoration into account.  This flag is normally set for you
   1207          *  by Window as described in {@link Window#setFlags}.
   1208          *
   1209          *  <p>Note: on displays that have a {@link DisplayCutout}, the window may be placed
   1210          *  such that it avoids the {@link DisplayCutout} area if necessary according to the
   1211          *  {@link #layoutInDisplayCutoutMode}.
   1212          */
   1213         public static final int FLAG_LAYOUT_IN_SCREEN   = 0x00000100;
   1214 
   1215         /** Window flag: allow window to extend outside of the screen. */
   1216         public static final int FLAG_LAYOUT_NO_LIMITS   = 0x00000200;
   1217 
   1218         /**
   1219          * Window flag: hide all screen decorations (such as the status bar) while
   1220          * this window is displayed.  This allows the window to use the entire
   1221          * display space for itself -- the status bar will be hidden when
   1222          * an app window with this flag set is on the top layer. A fullscreen window
   1223          * will ignore a value of {@link #SOFT_INPUT_ADJUST_RESIZE} for the window's
   1224          * {@link #softInputMode} field; the window will stay fullscreen
   1225          * and will not resize.
   1226          *
   1227          * <p>This flag can be controlled in your theme through the
   1228          * {@link android.R.attr#windowFullscreen} attribute; this attribute
   1229          * is automatically set for you in the standard fullscreen themes
   1230          * such as {@link android.R.style#Theme_NoTitleBar_Fullscreen},
   1231          * {@link android.R.style#Theme_Black_NoTitleBar_Fullscreen},
   1232          * {@link android.R.style#Theme_Light_NoTitleBar_Fullscreen},
   1233          * {@link android.R.style#Theme_Holo_NoActionBar_Fullscreen},
   1234          * {@link android.R.style#Theme_Holo_Light_NoActionBar_Fullscreen},
   1235          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Fullscreen}, and
   1236          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Fullscreen}.</p>
   1237          */
   1238         public static final int FLAG_FULLSCREEN      = 0x00000400;
   1239 
   1240         /** Window flag: override {@link #FLAG_FULLSCREEN} and force the
   1241          *  screen decorations (such as the status bar) to be shown. */
   1242         public static final int FLAG_FORCE_NOT_FULLSCREEN   = 0x00000800;
   1243 
   1244         /** Window flag: turn on dithering when compositing this window to
   1245          *  the screen.
   1246          * @deprecated This flag is no longer used. */
   1247         @Deprecated
   1248         public static final int FLAG_DITHER             = 0x00001000;
   1249 
   1250         /** Window flag: treat the content of the window as secure, preventing
   1251          * it from appearing in screenshots or from being viewed on non-secure
   1252          * displays.
   1253          *
   1254          * <p>See {@link android.view.Display#FLAG_SECURE} for more details about
   1255          * secure surfaces and secure displays.
   1256          */
   1257         public static final int FLAG_SECURE             = 0x00002000;
   1258 
   1259         /** Window flag: a special mode where the layout parameters are used
   1260          * to perform scaling of the surface when it is composited to the
   1261          * screen. */
   1262         public static final int FLAG_SCALED             = 0x00004000;
   1263 
   1264         /** Window flag: intended for windows that will often be used when the user is
   1265          * holding the screen against their face, it will aggressively filter the event
   1266          * stream to prevent unintended presses in this situation that may not be
   1267          * desired for a particular window, when such an event stream is detected, the
   1268          * application will receive a CANCEL motion event to indicate this so applications
   1269          * can handle this accordingly by taking no action on the event
   1270          * until the finger is released. */
   1271         public static final int FLAG_IGNORE_CHEEK_PRESSES    = 0x00008000;
   1272 
   1273         /** Window flag: a special option only for use in combination with
   1274          * {@link #FLAG_LAYOUT_IN_SCREEN}.  When requesting layout in the
   1275          * screen your window may appear on top of or behind screen decorations
   1276          * such as the status bar.  By also including this flag, the window
   1277          * manager will report the inset rectangle needed to ensure your
   1278          * content is not covered by screen decorations.  This flag is normally
   1279          * set for you by Window as described in {@link Window#setFlags}.*/
   1280         public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
   1281 
   1282         /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
   1283          * respect to how this window interacts with the current method.  That
   1284          * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
   1285          * window will behave as if it needs to interact with the input method
   1286          * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
   1287          * not set and this flag is set, then the window will behave as if it
   1288          * doesn't need to interact with the input method and can be placed
   1289          * to use more space and cover the input method.
   1290          */
   1291         public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
   1292 
   1293         /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
   1294          * can set this flag to receive a single special MotionEvent with
   1295          * the action
   1296          * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
   1297          * touches that occur outside of your window.  Note that you will not
   1298          * receive the full down/move/up gesture, only the location of the
   1299          * first down as an ACTION_OUTSIDE.
   1300          */
   1301         public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
   1302 
   1303         /** Window flag: special flag to let windows be shown when the screen
   1304          * is locked. This will let application windows take precedence over
   1305          * key guard or any other lock screens. Can be used with
   1306          * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
   1307          * directly before showing the key guard window.  Can be used with
   1308          * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
   1309          * non-secure keyguards.  This flag only applies to the top-most
   1310          * full-screen window.
   1311          * @deprecated Use {@link android.R.attr#showWhenLocked} or
   1312          * {@link android.app.Activity#setShowWhenLocked(boolean)} instead to prevent an
   1313          * unintentional double life-cycle event.
   1314          */
   1315         @Deprecated
   1316         public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
   1317 
   1318         /** Window flag: ask that the system wallpaper be shown behind
   1319          * your window.  The window surface must be translucent to be able
   1320          * to actually see the wallpaper behind it; this flag just ensures
   1321          * that the wallpaper surface will be there if this window actually
   1322          * has translucent regions.
   1323          *
   1324          * <p>This flag can be controlled in your theme through the
   1325          * {@link android.R.attr#windowShowWallpaper} attribute; this attribute
   1326          * is automatically set for you in the standard wallpaper themes
   1327          * such as {@link android.R.style#Theme_Wallpaper},
   1328          * {@link android.R.style#Theme_Wallpaper_NoTitleBar},
   1329          * {@link android.R.style#Theme_Wallpaper_NoTitleBar_Fullscreen},
   1330          * {@link android.R.style#Theme_Holo_Wallpaper},
   1331          * {@link android.R.style#Theme_Holo_Wallpaper_NoTitleBar},
   1332          * {@link android.R.style#Theme_DeviceDefault_Wallpaper}, and
   1333          * {@link android.R.style#Theme_DeviceDefault_Wallpaper_NoTitleBar}.</p>
   1334          */
   1335         public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
   1336 
   1337         /** Window flag: when set as a window is being added or made
   1338          * visible, once the window has been shown then the system will
   1339          * poke the power manager's user activity (as if the user had woken
   1340          * up the device) to turn the screen on.
   1341          * @deprecated Use {@link android.R.attr#turnScreenOn} or
   1342          * {@link android.app.Activity#setTurnScreenOn(boolean)} instead to prevent an
   1343          * unintentional double life-cycle event.
   1344          */
   1345         @Deprecated
   1346         public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
   1347 
   1348         /**
   1349          * Window flag: when set the window will cause the keyguard to be
   1350          * dismissed, only if it is not a secure lock keyguard. Because such a
   1351          * keyguard is not needed for security, it will never re-appear if the
   1352          * user navigates to another window (in contrast to
   1353          * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily hide both
   1354          * secure and non-secure keyguards but ensure they reappear when the
   1355          * user moves to another UI that doesn't hide them). If the keyguard is
   1356          * currently active and is secure (requires an unlock credential) than
   1357          * the user will still need to confirm it before seeing this window,
   1358          * unless {@link #FLAG_SHOW_WHEN_LOCKED} has also been set.
   1359          *
   1360          * @deprecated Use {@link #FLAG_SHOW_WHEN_LOCKED} or
   1361          *             {@link KeyguardManager#requestDismissKeyguard} instead.
   1362          *             Since keyguard was dismissed all the time as long as an
   1363          *             activity with this flag on its window was focused,
   1364          *             keyguard couldn't guard against unintentional touches on
   1365          *             the screen, which isn't desired.
   1366          */
   1367         @Deprecated
   1368         public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
   1369 
   1370         /** Window flag: when set the window will accept for touch events
   1371          * outside of its bounds to be sent to other windows that also
   1372          * support split touch.  When this flag is not set, the first pointer
   1373          * that goes down determines the window to which all subsequent touches
   1374          * go until all pointers go up.  When this flag is set, each pointer
   1375          * (not necessarily the first) that goes down determines the window
   1376          * to which all subsequent touches of that pointer will go until that
   1377          * pointer goes up thereby enabling touches with multiple pointers
   1378          * to be split across multiple windows.
   1379          */
   1380         public static final int FLAG_SPLIT_TOUCH = 0x00800000;
   1381 
   1382         /**
   1383          * <p>Indicates whether this window should be hardware accelerated.
   1384          * Requesting hardware acceleration does not guarantee it will happen.</p>
   1385          *
   1386          * <p>This flag can be controlled programmatically <em>only</em> to enable
   1387          * hardware acceleration. To enable hardware acceleration for a given
   1388          * window programmatically, do the following:</p>
   1389          *
   1390          * <pre>
   1391          * Window w = activity.getWindow(); // in Activity's onCreate() for instance
   1392          * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
   1393          *         WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
   1394          * </pre>
   1395          *
   1396          * <p>It is important to remember that this flag <strong>must</strong>
   1397          * be set before setting the content view of your activity or dialog.</p>
   1398          *
   1399          * <p>This flag cannot be used to disable hardware acceleration after it
   1400          * was enabled in your manifest using
   1401          * {@link android.R.attr#hardwareAccelerated}. If you need to selectively
   1402          * and programmatically disable hardware acceleration (for automated testing
   1403          * for instance), make sure it is turned off in your manifest and enable it
   1404          * on your activity or dialog when you need it instead, using the method
   1405          * described above.</p>
   1406          *
   1407          * <p>This flag is automatically set by the system if the
   1408          * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
   1409          * XML attribute is set to true on an activity or on the application.</p>
   1410          */
   1411         public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
   1412 
   1413         /**
   1414          * Window flag: allow window contents to extend in to the screen's
   1415          * overscan area, if there is one.  The window should still correctly
   1416          * position its contents to take the overscan area into account.
   1417          *
   1418          * <p>This flag can be controlled in your theme through the
   1419          * {@link android.R.attr#windowOverscan} attribute; this attribute
   1420          * is automatically set for you in the standard overscan themes
   1421          * such as
   1422          * {@link android.R.style#Theme_Holo_NoActionBar_Overscan},
   1423          * {@link android.R.style#Theme_Holo_Light_NoActionBar_Overscan},
   1424          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Overscan}, and
   1425          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Overscan}.</p>
   1426          *
   1427          * <p>When this flag is enabled for a window, its normal content may be obscured
   1428          * to some degree by the overscan region of the display.  To ensure key parts of
   1429          * that content are visible to the user, you can use
   1430          * {@link View#setFitsSystemWindows(boolean) View.setFitsSystemWindows(boolean)}
   1431          * to set the point in the view hierarchy where the appropriate offsets should
   1432          * be applied.  (This can be done either by directly calling this function, using
   1433          * the {@link android.R.attr#fitsSystemWindows} attribute in your view hierarchy,
   1434          * or implementing you own {@link View#fitSystemWindows(android.graphics.Rect)
   1435          * View.fitSystemWindows(Rect)} method).</p>
   1436          *
   1437          * <p>This mechanism for positioning content elements is identical to its equivalent
   1438          * use with layout and {@link View#setSystemUiVisibility(int)
   1439          * View.setSystemUiVisibility(int)}; here is an example layout that will correctly
   1440          * position its UI elements with this overscan flag is set:</p>
   1441          *
   1442          * {@sample development/samples/ApiDemos/res/layout/overscan_activity.xml complete}
   1443          */
   1444         public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000;
   1445 
   1446         /**
   1447          * Window flag: request a translucent status bar with minimal system-provided
   1448          * background protection.
   1449          *
   1450          * <p>This flag can be controlled in your theme through the
   1451          * {@link android.R.attr#windowTranslucentStatus} attribute; this attribute
   1452          * is automatically set for you in the standard translucent decor themes
   1453          * such as
   1454          * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor},
   1455          * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor},
   1456          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and
   1457          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p>
   1458          *
   1459          * <p>When this flag is enabled for a window, it automatically sets
   1460          * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
   1461          * {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p>
   1462          */
   1463         public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000;
   1464 
   1465         /**
   1466          * Window flag: request a translucent navigation bar with minimal system-provided
   1467          * background protection.
   1468          *
   1469          * <p>This flag can be controlled in your theme through the
   1470          * {@link android.R.attr#windowTranslucentNavigation} attribute; this attribute
   1471          * is automatically set for you in the standard translucent decor themes
   1472          * such as
   1473          * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor},
   1474          * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor},
   1475          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and
   1476          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p>
   1477          *
   1478          * <p>When this flag is enabled for a window, it automatically sets
   1479          * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
   1480          * {@link View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.</p>
   1481          */
   1482         public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000;
   1483 
   1484         /**
   1485          * Flag for a window in local focus mode.
   1486          * Window in local focus mode can control focus independent of window manager using
   1487          * {@link Window#setLocalFocus(boolean, boolean)}.
   1488          * Usually window in this mode will not get touch/key events from window manager, but will
   1489          * get events only via local injection using {@link Window#injectInputEvent(InputEvent)}.
   1490          */
   1491         public static final int FLAG_LOCAL_FOCUS_MODE = 0x10000000;
   1492 
   1493         /** Window flag: Enable touches to slide out of a window into neighboring
   1494          * windows in mid-gesture instead of being captured for the duration of
   1495          * the gesture.
   1496          *
   1497          * This flag changes the behavior of touch focus for this window only.
   1498          * Touches can slide out of the window but they cannot necessarily slide
   1499          * back in (unless the other window with touch focus permits it).
   1500          *
   1501          * {@hide}
   1502          */
   1503         @UnsupportedAppUsage
   1504         public static final int FLAG_SLIPPERY = 0x20000000;
   1505 
   1506         /**
   1507          * Window flag: When requesting layout with an attached window, the attached window may
   1508          * overlap with the screen decorations of the parent window such as the navigation bar. By
   1509          * including this flag, the window manager will layout the attached window within the decor
   1510          * frame of the parent window such that it doesn't overlap with screen decorations.
   1511          */
   1512         public static final int FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000;
   1513 
   1514         /**
   1515          * Flag indicating that this Window is responsible for drawing the background for the
   1516          * system bars. If set, the system bars are drawn with a transparent background and the
   1517          * corresponding areas in this window are filled with the colors specified in
   1518          * {@link Window#getStatusBarColor()} and {@link Window#getNavigationBarColor()}.
   1519          */
   1520         public static final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000;
   1521 
   1522         /**
   1523          * Various behavioral options/flags.  Default is none.
   1524          *
   1525          * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
   1526          * @see #FLAG_DIM_BEHIND
   1527          * @see #FLAG_NOT_FOCUSABLE
   1528          * @see #FLAG_NOT_TOUCHABLE
   1529          * @see #FLAG_NOT_TOUCH_MODAL
   1530          * @see #FLAG_TOUCHABLE_WHEN_WAKING
   1531          * @see #FLAG_KEEP_SCREEN_ON
   1532          * @see #FLAG_LAYOUT_IN_SCREEN
   1533          * @see #FLAG_LAYOUT_NO_LIMITS
   1534          * @see #FLAG_FULLSCREEN
   1535          * @see #FLAG_FORCE_NOT_FULLSCREEN
   1536          * @see #FLAG_SECURE
   1537          * @see #FLAG_SCALED
   1538          * @see #FLAG_IGNORE_CHEEK_PRESSES
   1539          * @see #FLAG_LAYOUT_INSET_DECOR
   1540          * @see #FLAG_ALT_FOCUSABLE_IM
   1541          * @see #FLAG_WATCH_OUTSIDE_TOUCH
   1542          * @see #FLAG_SHOW_WHEN_LOCKED
   1543          * @see #FLAG_SHOW_WALLPAPER
   1544          * @see #FLAG_TURN_SCREEN_ON
   1545          * @see #FLAG_DISMISS_KEYGUARD
   1546          * @see #FLAG_SPLIT_TOUCH
   1547          * @see #FLAG_HARDWARE_ACCELERATED
   1548          * @see #FLAG_LOCAL_FOCUS_MODE
   1549          * @see #FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
   1550          */
   1551         @ViewDebug.ExportedProperty(flagMapping = {
   1552             @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
   1553                     name = "ALLOW_LOCK_WHILE_SCREEN_ON"),
   1554             @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
   1555                     name = "DIM_BEHIND"),
   1556             @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
   1557                     name = "BLUR_BEHIND"),
   1558             @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
   1559                     name = "NOT_FOCUSABLE"),
   1560             @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
   1561                     name = "NOT_TOUCHABLE"),
   1562             @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
   1563                     name = "NOT_TOUCH_MODAL"),
   1564             @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING,
   1565                     name = "TOUCHABLE_WHEN_WAKING"),
   1566             @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
   1567                     name = "KEEP_SCREEN_ON"),
   1568             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
   1569                     name = "LAYOUT_IN_SCREEN"),
   1570             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS,
   1571                     name = "LAYOUT_NO_LIMITS"),
   1572             @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
   1573                     name = "FULLSCREEN"),
   1574             @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN,
   1575                     name = "FORCE_NOT_FULLSCREEN"),
   1576             @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
   1577                     name = "DITHER"),
   1578             @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE,
   1579                     name = "SECURE"),
   1580             @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED,
   1581                     name = "SCALED"),
   1582             @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES,
   1583                     name = "IGNORE_CHEEK_PRESSES"),
   1584             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR,
   1585                     name = "LAYOUT_INSET_DECOR"),
   1586             @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM,
   1587                     name = "ALT_FOCUSABLE_IM"),
   1588             @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH,
   1589                     name = "WATCH_OUTSIDE_TOUCH"),
   1590             @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
   1591                     name = "SHOW_WHEN_LOCKED"),
   1592             @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER,
   1593                     name = "SHOW_WALLPAPER"),
   1594             @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
   1595                     name = "TURN_SCREEN_ON"),
   1596             @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
   1597                     name = "DISMISS_KEYGUARD"),
   1598             @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH,
   1599                     name = "SPLIT_TOUCH"),
   1600             @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
   1601                     name = "HARDWARE_ACCELERATED"),
   1602             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_OVERSCAN, equals = FLAG_LAYOUT_IN_OVERSCAN,
   1603                     name = "LOCAL_FOCUS_MODE"),
   1604             @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_STATUS, equals = FLAG_TRANSLUCENT_STATUS,
   1605                     name = "TRANSLUCENT_STATUS"),
   1606             @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_NAVIGATION, equals = FLAG_TRANSLUCENT_NAVIGATION,
   1607                     name = "TRANSLUCENT_NAVIGATION"),
   1608             @ViewDebug.FlagToString(mask = FLAG_LOCAL_FOCUS_MODE, equals = FLAG_LOCAL_FOCUS_MODE,
   1609                     name = "LOCAL_FOCUS_MODE"),
   1610             @ViewDebug.FlagToString(mask = FLAG_SLIPPERY, equals = FLAG_SLIPPERY,
   1611                     name = "FLAG_SLIPPERY"),
   1612             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_ATTACHED_IN_DECOR, equals = FLAG_LAYOUT_ATTACHED_IN_DECOR,
   1613                     name = "FLAG_LAYOUT_ATTACHED_IN_DECOR"),
   1614             @ViewDebug.FlagToString(mask = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, equals = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
   1615                     name = "DRAWS_SYSTEM_BAR_BACKGROUNDS")
   1616         }, formatToHexString = true)
   1617         public int flags;
   1618 
   1619         /**
   1620          * If the window has requested hardware acceleration, but this is not
   1621          * allowed in the process it is in, then still render it as if it is
   1622          * hardware accelerated.  This is used for the starting preview windows
   1623          * in the system process, which don't need to have the overhead of
   1624          * hardware acceleration (they are just a static rendering), but should
   1625          * be rendered as such to match the actual window of the app even if it
   1626          * is hardware accelerated.
   1627          * Even if the window isn't hardware accelerated, still do its rendering
   1628          * as if it was.
   1629          * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
   1630          * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
   1631          * is generally disabled. This flag must be specified in addition to
   1632          * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
   1633          * windows.
   1634          *
   1635          * @hide
   1636          */
   1637         public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
   1638 
   1639         /**
   1640          * In the system process, we globally do not use hardware acceleration
   1641          * because there are many threads doing UI there and they conflict.
   1642          * If certain parts of the UI that really do want to use hardware
   1643          * acceleration, this flag can be set to force it.  This is basically
   1644          * for the lock screen.  Anyone else using it, you are probably wrong.
   1645          *
   1646          * @hide
   1647          */
   1648         public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002;
   1649 
   1650         /**
   1651          * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers
   1652          * may elect to skip these notifications if they are not doing anything productive with
   1653          * them (they do not affect the wallpaper scrolling operation) by calling
   1654          * {@link
   1655          * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}.
   1656          *
   1657          * @hide
   1658          */
   1659         public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004;
   1660 
   1661         /** In a multiuser system if this flag is set and the owner is a system process then this
   1662          * window will appear on all user screens. This overrides the default behavior of window
   1663          * types that normally only appear on the owning user's screen. Refer to each window type
   1664          * to determine its default behavior.
   1665          *
   1666          * {@hide} */
   1667         @UnsupportedAppUsage
   1668         public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010;
   1669 
   1670         /**
   1671          * Never animate position changes of the window.
   1672          *
   1673          * {@hide}
   1674          */
   1675         @TestApi
   1676         public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 0x00000040;
   1677 
   1678         /** Window flag: special flag to limit the size of the window to be
   1679          * original size ([320x480] x density). Used to create window for applications
   1680          * running under compatibility mode.
   1681          *
   1682          * {@hide} */
   1683         public static final int PRIVATE_FLAG_COMPATIBLE_WINDOW = 0x00000080;
   1684 
   1685         /** Window flag: a special option intended for system dialogs.  When
   1686          * this flag is set, the window will demand focus unconditionally when
   1687          * it is created.
   1688          * {@hide} */
   1689         public static final int PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100;
   1690 
   1691         /** Window flag: maintain the previous translucent decor state when this window
   1692          * becomes top-most.
   1693          * {@hide} */
   1694         public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200;
   1695 
   1696         /**
   1697          * Flag whether the current window is a keyguard window, meaning that it will hide all other
   1698          * windows behind it except for windows with flag {@link #FLAG_SHOW_WHEN_LOCKED} set.
   1699          * Further, this can only be set by {@link LayoutParams#TYPE_STATUS_BAR}.
   1700          * {@hide}
   1701          */
   1702         public static final int PRIVATE_FLAG_KEYGUARD = 0x00000400;
   1703 
   1704         /**
   1705          * Flag that prevents the wallpaper behind the current window from receiving touch events.
   1706          *
   1707          * {@hide}
   1708          */
   1709         public static final int PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS = 0x00000800;
   1710 
   1711         /**
   1712          * Flag to force the status bar window to be visible all the time. If the bar is hidden when
   1713          * this flag is set it will be shown again and the bar will have a transparent background.
   1714          * This can only be set by {@link LayoutParams#TYPE_STATUS_BAR}.
   1715          *
   1716          * {@hide}
   1717          */
   1718         public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000;
   1719 
   1720         /**
   1721          * Flag indicating that the x, y, width, and height members should be
   1722          * ignored (and thus their previous value preserved). For example
   1723          * because they are being managed externally through repositionChild.
   1724          *
   1725          * {@hide}
   1726          */
   1727         public static final int PRIVATE_FLAG_PRESERVE_GEOMETRY = 0x00002000;
   1728 
   1729         /**
   1730          * Flag that will make window ignore app visibility and instead depend purely on the decor
   1731          * view visibility for determining window visibility. This is used by recents to keep
   1732          * drawing after it launches an app.
   1733          * @hide
   1734          */
   1735         public static final int PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY = 0x00004000;
   1736 
   1737         /**
   1738          * Flag to indicate that this window is not expected to be replaced across
   1739          * configuration change triggered activity relaunches. In general the WindowManager
   1740          * expects Windows to be replaced after relaunch, and thus it will preserve their surfaces
   1741          * until the replacement is ready to show in order to prevent visual glitch. However
   1742          * some windows, such as PopupWindows expect to be cleared across configuration change,
   1743          * and thus should hint to the WindowManager that it should not wait for a replacement.
   1744          * @hide
   1745          */
   1746         public static final int PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH = 0x00008000;
   1747 
   1748         /**
   1749          * Flag to indicate that this child window should always be laid-out in the parent
   1750          * frame regardless of the current windowing mode configuration.
   1751          * @hide
   1752          */
   1753         public static final int PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME = 0x00010000;
   1754 
   1755         /**
   1756          * Flag to indicate that this window is always drawing the status bar background, no matter
   1757          * what the other flags are.
   1758          * @hide
   1759          */
   1760         public static final int PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS = 0x00020000;
   1761 
   1762         /**
   1763          * Flag to indicate that this window needs Sustained Performance Mode if
   1764          * the device supports it.
   1765          * @hide
   1766          */
   1767         public static final int PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE = 0x00040000;
   1768 
   1769         /**
   1770          * Flag to indicate that any window added by an application process that is of type
   1771          * {@link #TYPE_TOAST} or that requires
   1772          * {@link android.app.AppOpsManager#OP_SYSTEM_ALERT_WINDOW} permission should be hidden when
   1773          * this window is visible.
   1774          * @hide
   1775          */
   1776         @SystemApi
   1777         @RequiresPermission(permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS)
   1778         public static final int SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 0x00080000;
   1779 
   1780         /**
   1781          * Indicates that this window is the rounded corners overlay present on some
   1782          * devices this means that it will be excluded from: screenshots,
   1783          * screen magnification, and mirroring.
   1784          * @hide
   1785          */
   1786         public static final int PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY = 0x00100000;
   1787 
   1788         /**
   1789          * Flag to indicate that this window should be considered a screen decoration similar to the
   1790          * nav bar and status bar. This will cause this window to affect the window insets reported
   1791          * to other windows when it is visible.
   1792          * @hide
   1793          */
   1794         @RequiresPermission(permission.STATUS_BAR_SERVICE)
   1795         public static final int PRIVATE_FLAG_IS_SCREEN_DECOR = 0x00400000;
   1796 
   1797         /**
   1798          * Flag to indicate that the status bar window is in a state such that it forces showing
   1799          * the navigation bar unless the navigation bar window is explicitly set to
   1800          * {@link View#GONE}.
   1801          * It only takes effects if this is set by {@link LayoutParams#TYPE_STATUS_BAR}.
   1802          * @hide
   1803          */
   1804         public static final int PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION = 0x00800000;
   1805 
   1806         /**
   1807          * Flag to indicate that the window is color space agnostic, and the color can be
   1808          * interpreted to any color space.
   1809          * @hide
   1810          */
   1811         public static final int PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC = 0x01000000;
   1812 
   1813         /**
   1814          * An internal annotation for flags that can be specified to {@link #softInputMode}.
   1815          *
   1816          * @hide
   1817          */
   1818         @SystemApi
   1819         @Retention(RetentionPolicy.SOURCE)
   1820         @IntDef(flag = true, prefix = { "SYSTEM_FLAG_" }, value = {
   1821                 SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS,
   1822         })
   1823         public @interface SystemFlags {}
   1824 
   1825         /**
   1826          * Control flags that are private to the platform.
   1827          * @hide
   1828          */
   1829         @ViewDebug.ExportedProperty(flagMapping = {
   1830                 @ViewDebug.FlagToString(
   1831                         mask = PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED,
   1832                         equals = PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED,
   1833                         name = "FAKE_HARDWARE_ACCELERATED"),
   1834                 @ViewDebug.FlagToString(
   1835                         mask = PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED,
   1836                         equals = PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED,
   1837                         name = "FORCE_HARDWARE_ACCELERATED"),
   1838                 @ViewDebug.FlagToString(
   1839                         mask = PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS,
   1840                         equals = PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS,
   1841                         name = "WANTS_OFFSET_NOTIFICATIONS"),
   1842                 @ViewDebug.FlagToString(
   1843                         mask = PRIVATE_FLAG_SHOW_FOR_ALL_USERS,
   1844                         equals = PRIVATE_FLAG_SHOW_FOR_ALL_USERS,
   1845                         name = "SHOW_FOR_ALL_USERS"),
   1846                 @ViewDebug.FlagToString(
   1847                         mask = PRIVATE_FLAG_NO_MOVE_ANIMATION,
   1848                         equals = PRIVATE_FLAG_NO_MOVE_ANIMATION,
   1849                         name = "NO_MOVE_ANIMATION"),
   1850                 @ViewDebug.FlagToString(
   1851                         mask = PRIVATE_FLAG_COMPATIBLE_WINDOW,
   1852                         equals = PRIVATE_FLAG_COMPATIBLE_WINDOW,
   1853                         name = "COMPATIBLE_WINDOW"),
   1854                 @ViewDebug.FlagToString(
   1855                         mask = PRIVATE_FLAG_SYSTEM_ERROR,
   1856                         equals = PRIVATE_FLAG_SYSTEM_ERROR,
   1857                         name = "SYSTEM_ERROR"),
   1858                 @ViewDebug.FlagToString(
   1859                         mask = PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR,
   1860                         equals = PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR,
   1861                         name = "INHERIT_TRANSLUCENT_DECOR"),
   1862                 @ViewDebug.FlagToString(
   1863                         mask = PRIVATE_FLAG_KEYGUARD,
   1864                         equals = PRIVATE_FLAG_KEYGUARD,
   1865                         name = "KEYGUARD"),
   1866                 @ViewDebug.FlagToString(
   1867                         mask = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS,
   1868                         equals = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS,
   1869                         name = "DISABLE_WALLPAPER_TOUCH_EVENTS"),
   1870                 @ViewDebug.FlagToString(
   1871                         mask = PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT,
   1872                         equals = PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT,
   1873                         name = "FORCE_STATUS_BAR_VISIBLE_TRANSPARENT"),
   1874                 @ViewDebug.FlagToString(
   1875                         mask = PRIVATE_FLAG_PRESERVE_GEOMETRY,
   1876                         equals = PRIVATE_FLAG_PRESERVE_GEOMETRY,
   1877                         name = "PRESERVE_GEOMETRY"),
   1878                 @ViewDebug.FlagToString(
   1879                         mask = PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY,
   1880                         equals = PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY,
   1881                         name = "FORCE_DECOR_VIEW_VISIBILITY"),
   1882                 @ViewDebug.FlagToString(
   1883                         mask = PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH,
   1884                         equals = PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH,
   1885                         name = "WILL_NOT_REPLACE_ON_RELAUNCH"),
   1886                 @ViewDebug.FlagToString(
   1887                         mask = PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME,
   1888                         equals = PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME,
   1889                         name = "LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME"),
   1890                 @ViewDebug.FlagToString(
   1891                         mask = PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS,
   1892                         equals = PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS,
   1893                         name = "FORCE_DRAW_STATUS_BAR_BACKGROUND"),
   1894                 @ViewDebug.FlagToString(
   1895                         mask = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE,
   1896                         equals = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE,
   1897                         name = "SUSTAINED_PERFORMANCE_MODE"),
   1898                 @ViewDebug.FlagToString(
   1899                         mask = SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS,
   1900                         equals = SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS,
   1901                         name = "HIDE_NON_SYSTEM_OVERLAY_WINDOWS"),
   1902                 @ViewDebug.FlagToString(
   1903                         mask = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY,
   1904                         equals = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY,
   1905                         name = "IS_ROUNDED_CORNERS_OVERLAY"),
   1906                 @ViewDebug.FlagToString(
   1907                         mask = PRIVATE_FLAG_IS_SCREEN_DECOR,
   1908                         equals = PRIVATE_FLAG_IS_SCREEN_DECOR,
   1909                         name = "IS_SCREEN_DECOR"),
   1910                 @ViewDebug.FlagToString(
   1911                         mask = PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION,
   1912                         equals = PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION,
   1913                         name = "STATUS_FORCE_SHOW_NAVIGATION"),
   1914                 @ViewDebug.FlagToString(
   1915                         mask = PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
   1916                         equals = PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
   1917                         name = "COLOR_SPACE_AGNOSTIC")
   1918         })
   1919         @TestApi
   1920         public int privateFlags;
   1921 
   1922         /**
   1923          * Value for {@link #needsMenuKey} for a window that has not explicitly specified if it
   1924          * needs {@link #NEEDS_MENU_SET_TRUE} or doesn't need {@link #NEEDS_MENU_SET_FALSE} a menu
   1925          * key. For this case, we should look at windows behind it to determine the appropriate
   1926          * value.
   1927          *
   1928          * @hide
   1929          */
   1930         public static final int NEEDS_MENU_UNSET = 0;
   1931 
   1932         /**
   1933          * Value for {@link #needsMenuKey} for a window that has explicitly specified it needs a
   1934          * menu key.
   1935          *
   1936          * @hide
   1937          */
   1938         @UnsupportedAppUsage
   1939         public static final int NEEDS_MENU_SET_TRUE = 1;
   1940 
   1941         /**
   1942          * Value for {@link #needsMenuKey} for a window that has explicitly specified it doesn't
   1943          * needs a menu key.
   1944          *
   1945          * @hide
   1946          */
   1947         @UnsupportedAppUsage
   1948         public static final int NEEDS_MENU_SET_FALSE = 2;
   1949 
   1950         /**
   1951          * State variable for a window belonging to an activity that responds to
   1952          * {@link KeyEvent#KEYCODE_MENU} and therefore needs a Menu key. For devices where Menu is a
   1953          * physical button this variable is ignored, but on devices where the Menu key is drawn in
   1954          * software it may be hidden unless this variable is set to {@link #NEEDS_MENU_SET_TRUE}.
   1955          *
   1956          *  (Note that Action Bars, when available, are the preferred way to offer additional
   1957          * functions otherwise accessed via an options menu.)
   1958          *
   1959          * {@hide}
   1960          */
   1961         @UnsupportedAppUsage
   1962         public int needsMenuKey = NEEDS_MENU_UNSET;
   1963 
   1964         /**
   1965          * Given a particular set of window manager flags, determine whether
   1966          * such a window may be a target for an input method when it has
   1967          * focus.  In particular, this checks the
   1968          * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
   1969          * flags and returns true if the combination of the two corresponds
   1970          * to a window that needs to be behind the input method so that the
   1971          * user can type into it.
   1972          *
   1973          * @param flags The current window manager flags.
   1974          *
   1975          * @return Returns true if such a window should be behind/interact
   1976          * with an input method, false if not.
   1977          */
   1978         public static boolean mayUseInputMethod(int flags) {
   1979             switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
   1980                 case 0:
   1981                 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
   1982                     return true;
   1983             }
   1984             return false;
   1985         }
   1986 
   1987         /**
   1988          * Mask for {@link #softInputMode} of the bits that determine the
   1989          * desired visibility state of the soft input area for this window.
   1990          */
   1991         public static final int SOFT_INPUT_MASK_STATE = 0x0f;
   1992 
   1993         /**
   1994          * Visibility state for {@link #softInputMode}: no state has been specified. The system may
   1995          * show or hide the software keyboard for better user experience when the window gains
   1996          * focus.
   1997          */
   1998         public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
   1999 
   2000         /**
   2001          * Visibility state for {@link #softInputMode}: please don't change the state of
   2002          * the soft input area.
   2003          */
   2004         public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
   2005 
   2006         /**
   2007          * Visibility state for {@link #softInputMode}: please hide any soft input
   2008          * area when normally appropriate (when the user is navigating
   2009          * forward to your window).
   2010          */
   2011         public static final int SOFT_INPUT_STATE_HIDDEN = 2;
   2012 
   2013         /**
   2014          * Visibility state for {@link #softInputMode}: please always hide any
   2015          * soft input area when this window receives focus.
   2016          */
   2017         public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
   2018 
   2019         /**
   2020          * Visibility state for {@link #softInputMode}: please show the soft
   2021          * input area when normally appropriate (when the user is navigating
   2022          * forward to your window).
   2023          *
   2024          * <p>Applications that target {@link android.os.Build.VERSION_CODES#P} and later, this flag
   2025          * is ignored unless there is a focused view that returns {@code true} from
   2026          * {@link View#isInEditMode()} when the window is focused.</p>
   2027          */
   2028         public static final int SOFT_INPUT_STATE_VISIBLE = 4;
   2029 
   2030         /**
   2031          * Visibility state for {@link #softInputMode}: please always make the
   2032          * soft input area visible when this window receives input focus.
   2033          *
   2034          * <p>Applications that target {@link android.os.Build.VERSION_CODES#P} and later, this flag
   2035          * is ignored unless there is a focused view that returns {@code true} from
   2036          * {@link View#isInEditMode()} when the window is focused.</p>
   2037          */
   2038         public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
   2039 
   2040         /**
   2041          * Mask for {@link #softInputMode} of the bits that determine the
   2042          * way that the window should be adjusted to accommodate the soft
   2043          * input window.
   2044          */
   2045         public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
   2046 
   2047         /** Adjustment option for {@link #softInputMode}: nothing specified.
   2048          * The system will try to pick one or
   2049          * the other depending on the contents of the window.
   2050          */
   2051         public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
   2052 
   2053         /** Adjustment option for {@link #softInputMode}: set to allow the
   2054          * window to be resized when an input
   2055          * method is shown, so that its contents are not covered by the input
   2056          * method.  This can <em>not</em> be combined with
   2057          * {@link #SOFT_INPUT_ADJUST_PAN}; if
   2058          * neither of these are set, then the system will try to pick one or
   2059          * the other depending on the contents of the window. If the window's
   2060          * layout parameter flags include {@link #FLAG_FULLSCREEN}, this
   2061          * value for {@link #softInputMode} will be ignored; the window will
   2062          * not resize, but will stay fullscreen.
   2063          */
   2064         public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
   2065 
   2066         /** Adjustment option for {@link #softInputMode}: set to have a window
   2067          * pan when an input method is
   2068          * shown, so it doesn't need to deal with resizing but just panned
   2069          * by the framework to ensure the current input focus is visible.  This
   2070          * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
   2071          * neither of these are set, then the system will try to pick one or
   2072          * the other depending on the contents of the window.
   2073          */
   2074         public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
   2075 
   2076         /** Adjustment option for {@link #softInputMode}: set to have a window
   2077          * not adjust for a shown input method.  The window will not be resized,
   2078          * and it will not be panned to make its focus visible.
   2079          */
   2080         public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30;
   2081 
   2082         /**
   2083          * Bit for {@link #softInputMode}: set when the user has navigated
   2084          * forward to the window.  This is normally set automatically for
   2085          * you by the system, though you may want to set it in certain cases
   2086          * when you are displaying a window yourself.  This flag will always
   2087          * be cleared automatically after the window is displayed.
   2088          */
   2089         public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
   2090 
   2091         /**
   2092          * An internal annotation for flags that can be specified to {@link #softInputMode}.
   2093          *
   2094          * @hide
   2095          */
   2096         @Retention(RetentionPolicy.SOURCE)
   2097         @IntDef(flag = true, prefix = { "SOFT_INPUT_" }, value = {
   2098                 SOFT_INPUT_STATE_UNSPECIFIED,
   2099                 SOFT_INPUT_STATE_UNCHANGED,
   2100                 SOFT_INPUT_STATE_HIDDEN,
   2101                 SOFT_INPUT_STATE_ALWAYS_HIDDEN,
   2102                 SOFT_INPUT_STATE_VISIBLE,
   2103                 SOFT_INPUT_STATE_ALWAYS_VISIBLE,
   2104                 SOFT_INPUT_ADJUST_UNSPECIFIED,
   2105                 SOFT_INPUT_ADJUST_RESIZE,
   2106                 SOFT_INPUT_ADJUST_PAN,
   2107                 SOFT_INPUT_ADJUST_NOTHING,
   2108                 SOFT_INPUT_IS_FORWARD_NAVIGATION,
   2109         })
   2110         public @interface SoftInputModeFlags {}
   2111 
   2112         /**
   2113          * Desired operating mode for any soft input area.  May be any combination
   2114          * of:
   2115          *
   2116          * <ul>
   2117          * <li> One of the visibility states
   2118          * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
   2119          * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_HIDDEN},
   2120          * {@link #SOFT_INPUT_STATE_VISIBLE}, or {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}.
   2121          * <li> One of the adjustment options
   2122          * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, {@link #SOFT_INPUT_ADJUST_RESIZE},
   2123          * {@link #SOFT_INPUT_ADJUST_PAN}, or {@link #SOFT_INPUT_ADJUST_NOTHING}.
   2124          * </ul>
   2125          *
   2126          *
   2127          * <p>This flag can be controlled in your theme through the
   2128          * {@link android.R.attr#windowSoftInputMode} attribute.</p>
   2129          */
   2130         @SoftInputModeFlags
   2131         public int softInputMode;
   2132 
   2133         /**
   2134          * Placement of window within the screen as per {@link Gravity}.  Both
   2135          * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
   2136          * android.graphics.Rect) Gravity.apply} and
   2137          * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
   2138          * Gravity.applyDisplay} are used during window layout, with this value
   2139          * given as the desired gravity.  For example you can specify
   2140          * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and
   2141          * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here
   2142          * to control the behavior of
   2143          * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
   2144          * Gravity.applyDisplay}.
   2145          *
   2146          * @see Gravity
   2147          */
   2148         public int gravity;
   2149 
   2150         /**
   2151          * The horizontal margin, as a percentage of the container's width,
   2152          * between the container and the widget.  See
   2153          * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
   2154          * android.graphics.Rect) Gravity.apply} for how this is used.  This
   2155          * field is added with {@link #x} to supply the <var>xAdj</var> parameter.
   2156          */
   2157         public float horizontalMargin;
   2158 
   2159         /**
   2160          * The vertical margin, as a percentage of the container's height,
   2161          * between the container and the widget.  See
   2162          * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
   2163          * android.graphics.Rect) Gravity.apply} for how this is used.  This
   2164          * field is added with {@link #y} to supply the <var>yAdj</var> parameter.
   2165          */
   2166         public float verticalMargin;
   2167 
   2168         /**
   2169          * Positive insets between the drawing surface and window content.
   2170          *
   2171          * @hide
   2172          */
   2173         public final Rect surfaceInsets = new Rect();
   2174 
   2175         /**
   2176          * Whether the surface insets have been manually set. When set to
   2177          * {@code false}, the view root will automatically determine the
   2178          * appropriate surface insets.
   2179          *
   2180          * @see #surfaceInsets
   2181          * @hide
   2182          */
   2183         public boolean hasManualSurfaceInsets;
   2184 
   2185         /**
   2186          * Whether the previous surface insets should be used vs. what is currently set. When set
   2187          * to {@code true}, the view root will ignore surfaces insets in this object and use what
   2188          * it currently has.
   2189          *
   2190          * @see #surfaceInsets
   2191          * @hide
   2192          */
   2193         public boolean preservePreviousSurfaceInsets = true;
   2194 
   2195         /**
   2196          * The desired bitmap format.  May be one of the constants in
   2197          * {@link android.graphics.PixelFormat}. The choice of format
   2198          * might be overridden by {@link #setColorMode(int)}. Default is OPAQUE.
   2199          */
   2200         public int format;
   2201 
   2202         /**
   2203          * A style resource defining the animations to use for this window.
   2204          * This must be a system resource; it can not be an application resource
   2205          * because the window manager does not have access to applications.
   2206          */
   2207         public int windowAnimations;
   2208 
   2209         /**
   2210          * An alpha value to apply to this entire window.
   2211          * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
   2212          */
   2213         public float alpha = 1.0f;
   2214 
   2215         /**
   2216          * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
   2217          * to apply.  Range is from 1.0 for completely opaque to 0.0 for no
   2218          * dim.
   2219          */
   2220         public float dimAmount = 1.0f;
   2221 
   2222         /**
   2223          * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
   2224          * indicating that the brightness value is not overridden for this window
   2225          * and normal brightness policy should be used.
   2226          */
   2227         public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
   2228 
   2229         /**
   2230          * Value for {@link #screenBrightness} and {@link #buttonBrightness}
   2231          * indicating that the screen or button backlight brightness should be set
   2232          * to the lowest value when this window is in front.
   2233          */
   2234         public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
   2235 
   2236         /**
   2237          * Value for {@link #screenBrightness} and {@link #buttonBrightness}
   2238          * indicating that the screen or button backlight brightness should be set
   2239          * to the hightest value when this window is in front.
   2240          */
   2241         public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
   2242 
   2243         /**
   2244          * This can be used to override the user's preferred brightness of
   2245          * the screen.  A value of less than 0, the default, means to use the
   2246          * preferred screen brightness.  0 to 1 adjusts the brightness from
   2247          * dark to full bright.
   2248          */
   2249         public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
   2250 
   2251         /**
   2252          * This can be used to override the standard behavior of the button and
   2253          * keyboard backlights.  A value of less than 0, the default, means to
   2254          * use the standard backlight behavior.  0 to 1 adjusts the brightness
   2255          * from dark to full bright.
   2256          */
   2257         public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
   2258 
   2259         /**
   2260          * Unspecified value for {@link #rotationAnimation} indicating
   2261          * a lack of preference.
   2262          * @hide
   2263          */
   2264         public static final int ROTATION_ANIMATION_UNSPECIFIED = -1;
   2265 
   2266         /**
   2267          * Value for {@link #rotationAnimation} which specifies that this
   2268          * window will visually rotate in or out following a rotation.
   2269          */
   2270         public static final int ROTATION_ANIMATION_ROTATE = 0;
   2271 
   2272         /**
   2273          * Value for {@link #rotationAnimation} which specifies that this
   2274          * window will fade in or out following a rotation.
   2275          */
   2276         public static final int ROTATION_ANIMATION_CROSSFADE = 1;
   2277 
   2278         /**
   2279          * Value for {@link #rotationAnimation} which specifies that this window
   2280          * will immediately disappear or appear following a rotation.
   2281          */
   2282         public static final int ROTATION_ANIMATION_JUMPCUT = 2;
   2283 
   2284         /**
   2285          * Value for {@link #rotationAnimation} to specify seamless rotation mode.
   2286          * This works like JUMPCUT but will fall back to CROSSFADE if rotation
   2287          * can't be applied without pausing the screen. For example, this is ideal
   2288          * for Camera apps which don't want the viewfinder contents to ever rotate
   2289          * or fade (and rather to be seamless) but also don't want ROTATION_ANIMATION_JUMPCUT
   2290          * during app transition scenarios where seamless rotation can't be applied.
   2291          */
   2292         public static final int ROTATION_ANIMATION_SEAMLESS = 3;
   2293 
   2294         /**
   2295          * Define the exit and entry animations used on this window when the device is rotated.
   2296          * This only has an affect if the incoming and outgoing topmost
   2297          * opaque windows have the #FLAG_FULLSCREEN bit set and are not covered
   2298          * by other windows. All other situations default to the
   2299          * {@link #ROTATION_ANIMATION_ROTATE} behavior.
   2300          *
   2301          * @see #ROTATION_ANIMATION_ROTATE
   2302          * @see #ROTATION_ANIMATION_CROSSFADE
   2303          * @see #ROTATION_ANIMATION_JUMPCUT
   2304          */
   2305         public int rotationAnimation = ROTATION_ANIMATION_ROTATE;
   2306 
   2307         /**
   2308          * Identifier for this window.  This will usually be filled in for
   2309          * you.
   2310          */
   2311         public IBinder token = null;
   2312 
   2313         /**
   2314          * Name of the package owning this window.
   2315          */
   2316         public String packageName = null;
   2317 
   2318         /**
   2319          * Specific orientation value for a window.
   2320          * May be any of the same values allowed
   2321          * for {@link android.content.pm.ActivityInfo#screenOrientation}.
   2322          * If not set, a default value of
   2323          * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
   2324          * will be used.
   2325          */
   2326         public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
   2327 
   2328         /**
   2329          * The preferred refresh rate for the window.
   2330          *
   2331          * This must be one of the supported refresh rates obtained for the display(s) the window
   2332          * is on. The selected refresh rate will be applied to the display's default mode.
   2333          *
   2334          * This value is ignored if {@link #preferredDisplayModeId} is set.
   2335          *
   2336          * @see Display#getSupportedRefreshRates()
   2337          * @deprecated use {@link #preferredDisplayModeId} instead
   2338          */
   2339         @Deprecated
   2340         public float preferredRefreshRate;
   2341 
   2342         /**
   2343          * Id of the preferred display mode for the window.
   2344          * <p>
   2345          * This must be one of the supported modes obtained for the display(s) the window is on.
   2346          * A value of {@code 0} means no preference.
   2347          *
   2348          * @see Display#getSupportedModes()
   2349          * @see Display.Mode#getModeId()
   2350          */
   2351         public int preferredDisplayModeId;
   2352 
   2353         /**
   2354          * Control the visibility of the status bar.
   2355          *
   2356          * @see View#STATUS_BAR_VISIBLE
   2357          * @see View#STATUS_BAR_HIDDEN
   2358          */
   2359         public int systemUiVisibility;
   2360 
   2361         /**
   2362          * @hide
   2363          * The ui visibility as requested by the views in this hierarchy.
   2364          * the combined value should be systemUiVisibility | subtreeSystemUiVisibility.
   2365          */
   2366         @UnsupportedAppUsage
   2367         public int subtreeSystemUiVisibility;
   2368 
   2369         /**
   2370          * Get callbacks about the system ui visibility changing.
   2371          *
   2372          * TODO: Maybe there should be a bitfield of optional callbacks that we need.
   2373          *
   2374          * @hide
   2375          */
   2376         @UnsupportedAppUsage
   2377         public boolean hasSystemUiListeners;
   2378 
   2379 
   2380         /** @hide */
   2381         @Retention(RetentionPolicy.SOURCE)
   2382         @IntDef(
   2383                 flag = true,
   2384                 value = {LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT,
   2385                         LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES,
   2386                         LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER})
   2387         @interface LayoutInDisplayCutoutMode {}
   2388 
   2389         /**
   2390          * Controls how the window is laid out if there is a {@link DisplayCutout}.
   2391          *
   2392          * <p>
   2393          * Defaults to {@link #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT}.
   2394          *
   2395          * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
   2396          * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
   2397          * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
   2398          * @see DisplayCutout
   2399          * @see android.R.attr#windowLayoutInDisplayCutoutMode
   2400          *         android:windowLayoutInDisplayCutoutMode
   2401          */
   2402         @LayoutInDisplayCutoutMode
   2403         public int layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
   2404 
   2405         /**
   2406          * The window is allowed to extend into the {@link DisplayCutout} area, only if the
   2407          * {@link DisplayCutout} is fully contained within a system bar. Otherwise, the window is
   2408          * laid out such that it does not overlap with the {@link DisplayCutout} area.
   2409          *
   2410          * <p>
   2411          * In practice, this means that if the window did not set {@link #FLAG_FULLSCREEN} or
   2412          * {@link View#SYSTEM_UI_FLAG_FULLSCREEN}, it can extend into the cutout area in portrait
   2413          * if the cutout is at the top edge. Similarly for
   2414          * {@link View#SYSTEM_UI_FLAG_HIDE_NAVIGATION} and a cutout at the bottom of the screen.
   2415          * Otherwise (i.e. fullscreen or landscape) it is laid out such that it does not overlap the
   2416          * cutout area.
   2417          *
   2418          * <p>
   2419          * The usual precautions for not overlapping with the status and navigation bar are
   2420          * sufficient for ensuring that no important content overlaps with the DisplayCutout.
   2421          *
   2422          * @see DisplayCutout
   2423          * @see WindowInsets
   2424          * @see #layoutInDisplayCutoutMode
   2425          * @see android.R.attr#windowLayoutInDisplayCutoutMode
   2426          *         android:windowLayoutInDisplayCutoutMode
   2427          */
   2428         public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT = 0;
   2429 
   2430         /**
   2431          * @deprecated use {@link #LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES}
   2432          * @hide
   2433          */
   2434         @Deprecated
   2435         public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS = 1;
   2436 
   2437         /**
   2438          * The window is always allowed to extend into the {@link DisplayCutout} areas on the short
   2439          * edges of the screen.
   2440          *
   2441          * The window will never extend into a {@link DisplayCutout} area on the long edges of the
   2442          * screen.
   2443          *
   2444          * <p>
   2445          * The window must make sure that no important content overlaps with the
   2446          * {@link DisplayCutout}.
   2447          *
   2448          * <p>
   2449          * In this mode, the window extends under cutouts on the short edge of the display in both
   2450          * portrait and landscape, regardless of whether the window is hiding the system bars:<br/>
   2451          * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/fullscreen_top_no_letterbox.png"
   2452          * height="720"
   2453          * alt="Screenshot of a fullscreen activity on a display with a cutout at the top edge in
   2454          *         portrait, no letterbox is applied."/>
   2455          *
   2456          * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/landscape_top_no_letterbox.png"
   2457          * width="720"
   2458          * alt="Screenshot of an activity on a display with a cutout at the top edge in landscape,
   2459          *         no letterbox is applied."/>
   2460          *
   2461          * <p>
   2462          * A cutout in the corner is considered to be on the short edge: <br/>
   2463          * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/fullscreen_corner_no_letterbox.png"
   2464          * height="720"
   2465          * alt="Screenshot of a fullscreen activity on a display with a cutout in the corner in
   2466          *         portrait, no letterbox is applied."/>
   2467          *
   2468          * <p>
   2469          * On the other hand, should the cutout be on the long edge of the display, a letterbox will
   2470          * be applied such that the window does not extend into the cutout on either long edge:
   2471          * <br/>
   2472          * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/portrait_side_letterbox.png"
   2473          * height="720"
   2474          * alt="Screenshot of an activity on a display with a cutout on the long edge in portrait,
   2475          *         letterbox is applied."/>
   2476          *
   2477          * @see DisplayCutout
   2478          * @see WindowInsets#getDisplayCutout()
   2479          * @see #layoutInDisplayCutoutMode
   2480          * @see android.R.attr#windowLayoutInDisplayCutoutMode
   2481          *         android:windowLayoutInDisplayCutoutMode
   2482          */
   2483         public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES = 1;
   2484 
   2485         /**
   2486          * The window is never allowed to overlap with the DisplayCutout area.
   2487          *
   2488          * <p>
   2489          * This should be used with windows that transiently set
   2490          * {@link View#SYSTEM_UI_FLAG_FULLSCREEN} or {@link View#SYSTEM_UI_FLAG_HIDE_NAVIGATION}
   2491          * to avoid a relayout of the window when the respective flag is set or cleared.
   2492          *
   2493          * @see DisplayCutout
   2494          * @see #layoutInDisplayCutoutMode
   2495          * @see android.R.attr#windowLayoutInDisplayCutoutMode
   2496          *         android:windowLayoutInDisplayCutoutMode
   2497          */
   2498         public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER = 2;
   2499 
   2500 
   2501         /**
   2502          * When this window has focus, disable touch pad pointer gesture processing.
   2503          * The window will receive raw position updates from the touch pad instead
   2504          * of pointer movements and synthetic touch events.
   2505          *
   2506          * @hide
   2507          */
   2508         public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001;
   2509 
   2510         /**
   2511          * Does not construct an input channel for this window.  The channel will therefore
   2512          * be incapable of receiving input.
   2513          *
   2514          * @hide
   2515          */
   2516         public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002;
   2517 
   2518         /**
   2519          * When this window has focus, does not call user activity for all input events so
   2520          * the application will have to do it itself.  Should only be used by
   2521          * the keyguard and phone app.
   2522          * <p>
   2523          * Should only be used by the keyguard and phone app.
   2524          * </p>
   2525          *
   2526          * @hide
   2527          */
   2528         @UnsupportedAppUsage
   2529         public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004;
   2530 
   2531         /**
   2532          * Control special features of the input subsystem.
   2533          *
   2534          * @see #INPUT_FEATURE_DISABLE_POINTER_GESTURES
   2535          * @see #INPUT_FEATURE_NO_INPUT_CHANNEL
   2536          * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY
   2537          * @hide
   2538          */
   2539         @UnsupportedAppUsage
   2540         public int inputFeatures;
   2541 
   2542         /**
   2543          * Sets the number of milliseconds before the user activity timeout occurs
   2544          * when this window has focus.  A value of -1 uses the standard timeout.
   2545          * A value of 0 uses the minimum support display timeout.
   2546          * <p>
   2547          * This property can only be used to reduce the user specified display timeout;
   2548          * it can never make the timeout longer than it normally would be.
   2549          * </p><p>
   2550          * Should only be used by the keyguard and phone app.
   2551          * </p>
   2552          *
   2553          * @hide
   2554          */
   2555         @UnsupportedAppUsage
   2556         public long userActivityTimeout = -1;
   2557 
   2558         /**
   2559          * For windows with an anchor (e.g. PopupWindow), keeps track of the View that anchors the
   2560          * window.
   2561          *
   2562          * @hide
   2563          */
   2564         public long accessibilityIdOfAnchor = AccessibilityNodeInfo.UNDEFINED_NODE_ID;
   2565 
   2566         /**
   2567          * The window title isn't kept in sync with what is displayed in the title bar, so we
   2568          * separately track the currently shown title to provide to accessibility.
   2569          *
   2570          * @hide
   2571          */
   2572         @TestApi
   2573         public CharSequence accessibilityTitle;
   2574 
   2575         /**
   2576          * Sets a timeout in milliseconds before which the window will be hidden
   2577          * by the window manager. Useful for transient notifications like toasts
   2578          * so we don't have to rely on client cooperation to ensure the window
   2579          * is hidden. Must be specified at window creation time. Note that apps
   2580          * are not prepared to handle their windows being removed without their
   2581          * explicit request and may try to interact with the removed window
   2582          * resulting in undefined behavior and crashes. Therefore, we do hide
   2583          * such windows to prevent them from overlaying other apps.
   2584          *
   2585          * @hide
   2586          */
   2587         @UnsupportedAppUsage
   2588         public long hideTimeoutMilliseconds = -1;
   2589 
   2590         /**
   2591          * The color mode requested by this window. The target display may
   2592          * not be able to honor the request. When the color mode is not set
   2593          * to {@link ActivityInfo#COLOR_MODE_DEFAULT}, it might override the
   2594          * pixel format specified in {@link #format}.
   2595          *
   2596          * @hide
   2597          */
   2598         @ActivityInfo.ColorMode
   2599         private int mColorMode = COLOR_MODE_DEFAULT;
   2600 
   2601         public LayoutParams() {
   2602             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
   2603             type = TYPE_APPLICATION;
   2604             format = PixelFormat.OPAQUE;
   2605         }
   2606 
   2607         public LayoutParams(int _type) {
   2608             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
   2609             type = _type;
   2610             format = PixelFormat.OPAQUE;
   2611         }
   2612 
   2613         public LayoutParams(int _type, int _flags) {
   2614             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
   2615             type = _type;
   2616             flags = _flags;
   2617             format = PixelFormat.OPAQUE;
   2618         }
   2619 
   2620         public LayoutParams(int _type, int _flags, int _format) {
   2621             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
   2622             type = _type;
   2623             flags = _flags;
   2624             format = _format;
   2625         }
   2626 
   2627         public LayoutParams(int w, int h, int _type, int _flags, int _format) {
   2628             super(w, h);
   2629             type = _type;
   2630             flags = _flags;
   2631             format = _format;
   2632         }
   2633 
   2634         public LayoutParams(int w, int h, int xpos, int ypos, int _type,
   2635                 int _flags, int _format) {
   2636             super(w, h);
   2637             x = xpos;
   2638             y = ypos;
   2639             type = _type;
   2640             flags = _flags;
   2641             format = _format;
   2642         }
   2643 
   2644         public final void setTitle(CharSequence title) {
   2645             if (null == title)
   2646                 title = "";
   2647 
   2648             mTitle = TextUtils.stringOrSpannedString(title);
   2649         }
   2650 
   2651         public final CharSequence getTitle() {
   2652             return mTitle != null ? mTitle : "";
   2653         }
   2654 
   2655         /**
   2656          * Sets the surface insets based on the elevation (visual z position) of the input view.
   2657          * @hide
   2658          */
   2659         public final void setSurfaceInsets(View view, boolean manual, boolean preservePrevious) {
   2660             final int surfaceInset = (int) Math.ceil(view.getZ() * 2);
   2661             // Partial workaround for b/28318973. Every inset change causes a freeform window
   2662             // to jump a little for a few frames. If we never allow surface insets to decrease,
   2663             // they will stabilize quickly (often from the very beginning, as most windows start
   2664             // as focused).
   2665             // TODO(b/22668382) to fix this properly.
   2666             if (surfaceInset == 0) {
   2667                 // OK to have 0 (this is the case for non-freeform windows).
   2668                 surfaceInsets.set(0, 0, 0, 0);
   2669             } else {
   2670                 surfaceInsets.set(
   2671                         Math.max(surfaceInset, surfaceInsets.left),
   2672                         Math.max(surfaceInset, surfaceInsets.top),
   2673                         Math.max(surfaceInset, surfaceInsets.right),
   2674                         Math.max(surfaceInset, surfaceInsets.bottom));
   2675             }
   2676             hasManualSurfaceInsets = manual;
   2677             preservePreviousSurfaceInsets = preservePrevious;
   2678         }
   2679 
   2680         /**
   2681          * <p>Set the color mode of the window. Setting the color mode might
   2682          * override the window's pixel {@link WindowManager.LayoutParams#format format}.</p>
   2683          *
   2684          * <p>The color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
   2685          * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or
   2686          * {@link ActivityInfo#COLOR_MODE_HDR}.</p>
   2687          *
   2688          * @see #getColorMode()
   2689          */
   2690         public void setColorMode(@ActivityInfo.ColorMode int colorMode) {
   2691             mColorMode = colorMode;
   2692         }
   2693 
   2694         /**
   2695          * Returns the color mode of the window, one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
   2696          * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}.
   2697          *
   2698          * @see #setColorMode(int)
   2699          */
   2700         @ActivityInfo.ColorMode
   2701         public int getColorMode() {
   2702             return mColorMode;
   2703         }
   2704 
   2705         /** @hide */
   2706         @SystemApi
   2707         public final void setUserActivityTimeout(long timeout) {
   2708             userActivityTimeout = timeout;
   2709         }
   2710 
   2711         /** @hide */
   2712         @SystemApi
   2713         public final long getUserActivityTimeout() {
   2714             return userActivityTimeout;
   2715         }
   2716 
   2717         public int describeContents() {
   2718             return 0;
   2719         }
   2720 
   2721         public void writeToParcel(Parcel out, int parcelableFlags) {
   2722             out.writeInt(width);
   2723             out.writeInt(height);
   2724             out.writeInt(x);
   2725             out.writeInt(y);
   2726             out.writeInt(type);
   2727             out.writeInt(flags);
   2728             out.writeInt(privateFlags);
   2729             out.writeInt(softInputMode);
   2730             out.writeInt(layoutInDisplayCutoutMode);
   2731             out.writeInt(gravity);
   2732             out.writeFloat(horizontalMargin);
   2733             out.writeFloat(verticalMargin);
   2734             out.writeInt(format);
   2735             out.writeInt(windowAnimations);
   2736             out.writeFloat(alpha);
   2737             out.writeFloat(dimAmount);
   2738             out.writeFloat(screenBrightness);
   2739             out.writeFloat(buttonBrightness);
   2740             out.writeInt(rotationAnimation);
   2741             out.writeStrongBinder(token);
   2742             out.writeString(packageName);
   2743             TextUtils.writeToParcel(mTitle, out, parcelableFlags);
   2744             out.writeInt(screenOrientation);
   2745             out.writeFloat(preferredRefreshRate);
   2746             out.writeInt(preferredDisplayModeId);
   2747             out.writeInt(systemUiVisibility);
   2748             out.writeInt(subtreeSystemUiVisibility);
   2749             out.writeInt(hasSystemUiListeners ? 1 : 0);
   2750             out.writeInt(inputFeatures);
   2751             out.writeLong(userActivityTimeout);
   2752             out.writeInt(surfaceInsets.left);
   2753             out.writeInt(surfaceInsets.top);
   2754             out.writeInt(surfaceInsets.right);
   2755             out.writeInt(surfaceInsets.bottom);
   2756             out.writeInt(hasManualSurfaceInsets ? 1 : 0);
   2757             out.writeInt(preservePreviousSurfaceInsets ? 1 : 0);
   2758             out.writeInt(needsMenuKey);
   2759             out.writeLong(accessibilityIdOfAnchor);
   2760             TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags);
   2761             out.writeInt(mColorMode);
   2762             out.writeLong(hideTimeoutMilliseconds);
   2763         }
   2764 
   2765         public static final @android.annotation.NonNull Parcelable.Creator<LayoutParams> CREATOR
   2766                     = new Parcelable.Creator<LayoutParams>() {
   2767             public LayoutParams createFromParcel(Parcel in) {
   2768                 return new LayoutParams(in);
   2769             }
   2770 
   2771             public LayoutParams[] newArray(int size) {
   2772                 return new LayoutParams[size];
   2773             }
   2774         };
   2775 
   2776 
   2777         public LayoutParams(Parcel in) {
   2778             width = in.readInt();
   2779             height = in.readInt();
   2780             x = in.readInt();
   2781             y = in.readInt();
   2782             type = in.readInt();
   2783             flags = in.readInt();
   2784             privateFlags = in.readInt();
   2785             softInputMode = in.readInt();
   2786             layoutInDisplayCutoutMode = in.readInt();
   2787             gravity = in.readInt();
   2788             horizontalMargin = in.readFloat();
   2789             verticalMargin = in.readFloat();
   2790             format = in.readInt();
   2791             windowAnimations = in.readInt();
   2792             alpha = in.readFloat();
   2793             dimAmount = in.readFloat();
   2794             screenBrightness = in.readFloat();
   2795             buttonBrightness = in.readFloat();
   2796             rotationAnimation = in.readInt();
   2797             token = in.readStrongBinder();
   2798             packageName = in.readString();
   2799             mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
   2800             screenOrientation = in.readInt();
   2801             preferredRefreshRate = in.readFloat();
   2802             preferredDisplayModeId = in.readInt();
   2803             systemUiVisibility = in.readInt();
   2804             subtreeSystemUiVisibility = in.readInt();
   2805             hasSystemUiListeners = in.readInt() != 0;
   2806             inputFeatures = in.readInt();
   2807             userActivityTimeout = in.readLong();
   2808             surfaceInsets.left = in.readInt();
   2809             surfaceInsets.top = in.readInt();
   2810             surfaceInsets.right = in.readInt();
   2811             surfaceInsets.bottom = in.readInt();
   2812             hasManualSurfaceInsets = in.readInt() != 0;
   2813             preservePreviousSurfaceInsets = in.readInt() != 0;
   2814             needsMenuKey = in.readInt();
   2815             accessibilityIdOfAnchor = in.readLong();
   2816             accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
   2817             mColorMode = in.readInt();
   2818             hideTimeoutMilliseconds = in.readLong();
   2819         }
   2820 
   2821         @SuppressWarnings({"PointlessBitwiseExpression"})
   2822         public static final int LAYOUT_CHANGED = 1<<0;
   2823         public static final int TYPE_CHANGED = 1<<1;
   2824         public static final int FLAGS_CHANGED = 1<<2;
   2825         public static final int FORMAT_CHANGED = 1<<3;
   2826         public static final int ANIMATION_CHANGED = 1<<4;
   2827         public static final int DIM_AMOUNT_CHANGED = 1<<5;
   2828         public static final int TITLE_CHANGED = 1<<6;
   2829         public static final int ALPHA_CHANGED = 1<<7;
   2830         public static final int MEMORY_TYPE_CHANGED = 1<<8;
   2831         public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
   2832         public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
   2833         public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
   2834         public static final int ROTATION_ANIMATION_CHANGED = 1<<12;
   2835         /** {@hide} */
   2836         public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<13;
   2837         /** {@hide} */
   2838         public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<14;
   2839         /** {@hide} */
   2840         public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<15;
   2841         /** {@hide} */
   2842         public static final int INPUT_FEATURES_CHANGED = 1<<16;
   2843         /** {@hide} */
   2844         public static final int PRIVATE_FLAGS_CHANGED = 1<<17;
   2845         /** {@hide} */
   2846         public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<18;
   2847         /** {@hide} */
   2848         public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19;
   2849         /** {@hide} */
   2850         public static final int SURFACE_INSETS_CHANGED = 1<<20;
   2851         /** {@hide} */
   2852         public static final int PREFERRED_REFRESH_RATE_CHANGED = 1 << 21;
   2853         /** {@hide} */
   2854         public static final int NEEDS_MENU_KEY_CHANGED = 1 << 22;
   2855         /** {@hide} */
   2856         public static final int PREFERRED_DISPLAY_MODE_ID = 1 << 23;
   2857         /** {@hide} */
   2858         public static final int ACCESSIBILITY_ANCHOR_CHANGED = 1 << 24;
   2859         /** {@hide} */
   2860         @TestApi
   2861         public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25;
   2862         /** {@hide} */
   2863         public static final int COLOR_MODE_CHANGED = 1 << 26;
   2864         /** {@hide} */
   2865         public static final int EVERYTHING_CHANGED = 0xffffffff;
   2866 
   2867         // internal buffer to backup/restore parameters under compatibility mode.
   2868         private int[] mCompatibilityParamsBackup = null;
   2869 
   2870         public final int copyFrom(LayoutParams o) {
   2871             int changes = 0;
   2872 
   2873             if (width != o.width) {
   2874                 width = o.width;
   2875                 changes |= LAYOUT_CHANGED;
   2876             }
   2877             if (height != o.height) {
   2878                 height = o.height;
   2879                 changes |= LAYOUT_CHANGED;
   2880             }
   2881             if (x != o.x) {
   2882                 x = o.x;
   2883                 changes |= LAYOUT_CHANGED;
   2884             }
   2885             if (y != o.y) {
   2886                 y = o.y;
   2887                 changes |= LAYOUT_CHANGED;
   2888             }
   2889             if (horizontalWeight != o.horizontalWeight) {
   2890                 horizontalWeight = o.horizontalWeight;
   2891                 changes |= LAYOUT_CHANGED;
   2892             }
   2893             if (verticalWeight != o.verticalWeight) {
   2894                 verticalWeight = o.verticalWeight;
   2895                 changes |= LAYOUT_CHANGED;
   2896             }
   2897             if (horizontalMargin != o.horizontalMargin) {
   2898                 horizontalMargin = o.horizontalMargin;
   2899                 changes |= LAYOUT_CHANGED;
   2900             }
   2901             if (verticalMargin != o.verticalMargin) {
   2902                 verticalMargin = o.verticalMargin;
   2903                 changes |= LAYOUT_CHANGED;
   2904             }
   2905             if (type != o.type) {
   2906                 type = o.type;
   2907                 changes |= TYPE_CHANGED;
   2908             }
   2909             if (flags != o.flags) {
   2910                 final int diff = flags ^ o.flags;
   2911                 if ((diff & (FLAG_TRANSLUCENT_STATUS | FLAG_TRANSLUCENT_NAVIGATION)) != 0) {
   2912                     changes |= TRANSLUCENT_FLAGS_CHANGED;
   2913                 }
   2914                 flags = o.flags;
   2915                 changes |= FLAGS_CHANGED;
   2916             }
   2917             if (privateFlags != o.privateFlags) {
   2918                 privateFlags = o.privateFlags;
   2919                 changes |= PRIVATE_FLAGS_CHANGED;
   2920             }
   2921             if (softInputMode != o.softInputMode) {
   2922                 softInputMode = o.softInputMode;
   2923                 changes |= SOFT_INPUT_MODE_CHANGED;
   2924             }
   2925             if (layoutInDisplayCutoutMode != o.layoutInDisplayCutoutMode) {
   2926                 layoutInDisplayCutoutMode = o.layoutInDisplayCutoutMode;
   2927                 changes |= LAYOUT_CHANGED;
   2928             }
   2929             if (gravity != o.gravity) {
   2930                 gravity = o.gravity;
   2931                 changes |= LAYOUT_CHANGED;
   2932             }
   2933             if (format != o.format) {
   2934                 format = o.format;
   2935                 changes |= FORMAT_CHANGED;
   2936             }
   2937             if (windowAnimations != o.windowAnimations) {
   2938                 windowAnimations = o.windowAnimations;
   2939                 changes |= ANIMATION_CHANGED;
   2940             }
   2941             if (token == null) {
   2942                 // NOTE: token only copied if the recipient doesn't
   2943                 // already have one.
   2944                 token = o.token;
   2945             }
   2946             if (packageName == null) {
   2947                 // NOTE: packageName only copied if the recipient doesn't
   2948                 // already have one.
   2949                 packageName = o.packageName;
   2950             }
   2951             if (!Objects.equals(mTitle, o.mTitle) && o.mTitle != null) {
   2952                 // NOTE: mTitle only copied if the originator set one.
   2953                 mTitle = o.mTitle;
   2954                 changes |= TITLE_CHANGED;
   2955             }
   2956             if (alpha != o.alpha) {
   2957                 alpha = o.alpha;
   2958                 changes |= ALPHA_CHANGED;
   2959             }
   2960             if (dimAmount != o.dimAmount) {
   2961                 dimAmount = o.dimAmount;
   2962                 changes |= DIM_AMOUNT_CHANGED;
   2963             }
   2964             if (screenBrightness != o.screenBrightness) {
   2965                 screenBrightness = o.screenBrightness;
   2966                 changes |= SCREEN_BRIGHTNESS_CHANGED;
   2967             }
   2968             if (buttonBrightness != o.buttonBrightness) {
   2969                 buttonBrightness = o.buttonBrightness;
   2970                 changes |= BUTTON_BRIGHTNESS_CHANGED;
   2971             }
   2972             if (rotationAnimation != o.rotationAnimation) {
   2973                 rotationAnimation = o.rotationAnimation;
   2974                 changes |= ROTATION_ANIMATION_CHANGED;
   2975             }
   2976 
   2977             if (screenOrientation != o.screenOrientation) {
   2978                 screenOrientation = o.screenOrientation;
   2979                 changes |= SCREEN_ORIENTATION_CHANGED;
   2980             }
   2981 
   2982             if (preferredRefreshRate != o.preferredRefreshRate) {
   2983                 preferredRefreshRate = o.preferredRefreshRate;
   2984                 changes |= PREFERRED_REFRESH_RATE_CHANGED;
   2985             }
   2986 
   2987             if (preferredDisplayModeId != o.preferredDisplayModeId) {
   2988                 preferredDisplayModeId = o.preferredDisplayModeId;
   2989                 changes |= PREFERRED_DISPLAY_MODE_ID;
   2990             }
   2991 
   2992             if (systemUiVisibility != o.systemUiVisibility
   2993                     || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
   2994                 systemUiVisibility = o.systemUiVisibility;
   2995                 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility;
   2996                 changes |= SYSTEM_UI_VISIBILITY_CHANGED;
   2997             }
   2998 
   2999             if (hasSystemUiListeners != o.hasSystemUiListeners) {
   3000                 hasSystemUiListeners = o.hasSystemUiListeners;
   3001                 changes |= SYSTEM_UI_LISTENER_CHANGED;
   3002             }
   3003 
   3004             if (inputFeatures != o.inputFeatures) {
   3005                 inputFeatures = o.inputFeatures;
   3006                 changes |= INPUT_FEATURES_CHANGED;
   3007             }
   3008 
   3009             if (userActivityTimeout != o.userActivityTimeout) {
   3010                 userActivityTimeout = o.userActivityTimeout;
   3011                 changes |= USER_ACTIVITY_TIMEOUT_CHANGED;
   3012             }
   3013 
   3014             if (!surfaceInsets.equals(o.surfaceInsets)) {
   3015                 surfaceInsets.set(o.surfaceInsets);
   3016                 changes |= SURFACE_INSETS_CHANGED;
   3017             }
   3018 
   3019             if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) {
   3020                 hasManualSurfaceInsets = o.hasManualSurfaceInsets;
   3021                 changes |= SURFACE_INSETS_CHANGED;
   3022             }
   3023 
   3024             if (preservePreviousSurfaceInsets != o.preservePreviousSurfaceInsets) {
   3025                 preservePreviousSurfaceInsets = o.preservePreviousSurfaceInsets;
   3026                 changes |= SURFACE_INSETS_CHANGED;
   3027             }
   3028 
   3029             if (needsMenuKey != o.needsMenuKey) {
   3030                 needsMenuKey = o.needsMenuKey;
   3031                 changes |= NEEDS_MENU_KEY_CHANGED;
   3032             }
   3033 
   3034             if (accessibilityIdOfAnchor != o.accessibilityIdOfAnchor) {
   3035                 accessibilityIdOfAnchor = o.accessibilityIdOfAnchor;
   3036                 changes |= ACCESSIBILITY_ANCHOR_CHANGED;
   3037             }
   3038 
   3039             if (!Objects.equals(accessibilityTitle, o.accessibilityTitle)
   3040                     && o.accessibilityTitle != null) {
   3041                 // NOTE: accessibilityTitle only copied if the originator set one.
   3042                 accessibilityTitle = o.accessibilityTitle;
   3043                 changes |= ACCESSIBILITY_TITLE_CHANGED;
   3044             }
   3045 
   3046             if (mColorMode != o.mColorMode) {
   3047                 mColorMode = o.mColorMode;
   3048                 changes |= COLOR_MODE_CHANGED;
   3049             }
   3050 
   3051             // This can't change, it's only set at window creation time.
   3052             hideTimeoutMilliseconds = o.hideTimeoutMilliseconds;
   3053 
   3054             return changes;
   3055         }
   3056 
   3057         @Override
   3058         public String debug(String output) {
   3059             output += "Contents of " + this + ":";
   3060             Log.d("Debug", output);
   3061             output = super.debug("");
   3062             Log.d("Debug", output);
   3063             Log.d("Debug", "");
   3064             Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
   3065             return "";
   3066         }
   3067 
   3068         @Override
   3069         public String toString() {
   3070             return toString("");
   3071         }
   3072 
   3073         /**
   3074          * @hide
   3075          */
   3076         public void dumpDimensions(StringBuilder sb) {
   3077             sb.append('(');
   3078             sb.append(x);
   3079             sb.append(',');
   3080             sb.append(y);
   3081             sb.append(")(");
   3082             sb.append((width == MATCH_PARENT ? "fill" : (width == WRAP_CONTENT
   3083                     ? "wrap" : String.valueOf(width))));
   3084             sb.append('x');
   3085             sb.append((height == MATCH_PARENT ? "fill" : (height == WRAP_CONTENT
   3086                     ? "wrap" : String.valueOf(height))));
   3087             sb.append(")");
   3088         }
   3089 
   3090         /**
   3091          * @hide
   3092          */
   3093         public String toString(String prefix) {
   3094             StringBuilder sb = new StringBuilder(256);
   3095             sb.append('{');
   3096             dumpDimensions(sb);
   3097             if (horizontalMargin != 0) {
   3098                 sb.append(" hm=");
   3099                 sb.append(horizontalMargin);
   3100             }
   3101             if (verticalMargin != 0) {
   3102                 sb.append(" vm=");
   3103                 sb.append(verticalMargin);
   3104             }
   3105             if (gravity != 0) {
   3106                 sb.append(" gr=");
   3107                 sb.append(Gravity.toString(gravity));
   3108             }
   3109             if (softInputMode != 0) {
   3110                 sb.append(" sim={");
   3111                 sb.append(softInputModeToString(softInputMode));
   3112                 sb.append('}');
   3113             }
   3114             if (layoutInDisplayCutoutMode != 0) {
   3115                 sb.append(" layoutInDisplayCutoutMode=");
   3116                 sb.append(layoutInDisplayCutoutModeToString(layoutInDisplayCutoutMode));
   3117             }
   3118             sb.append(" ty=");
   3119             sb.append(ViewDebug.intToString(LayoutParams.class, "type", type));
   3120             if (format != PixelFormat.OPAQUE) {
   3121                 sb.append(" fmt=");
   3122                 sb.append(PixelFormat.formatToString(format));
   3123             }
   3124             if (windowAnimations != 0) {
   3125                 sb.append(" wanim=0x");
   3126                 sb.append(Integer.toHexString(windowAnimations));
   3127             }
   3128             if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
   3129                 sb.append(" or=");
   3130                 sb.append(ActivityInfo.screenOrientationToString(screenOrientation));
   3131             }
   3132             if (alpha != 1.0f) {
   3133                 sb.append(" alpha=");
   3134                 sb.append(alpha);
   3135             }
   3136             if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) {
   3137                 sb.append(" sbrt=");
   3138                 sb.append(screenBrightness);
   3139             }
   3140             if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) {
   3141                 sb.append(" bbrt=");
   3142                 sb.append(buttonBrightness);
   3143             }
   3144             if (rotationAnimation != ROTATION_ANIMATION_ROTATE) {
   3145                 sb.append(" rotAnim=");
   3146                 sb.append(rotationAnimationToString(rotationAnimation));
   3147             }
   3148             if (preferredRefreshRate != 0) {
   3149                 sb.append(" preferredRefreshRate=");
   3150                 sb.append(preferredRefreshRate);
   3151             }
   3152             if (preferredDisplayModeId != 0) {
   3153                 sb.append(" preferredDisplayMode=");
   3154                 sb.append(preferredDisplayModeId);
   3155             }
   3156             if (hasSystemUiListeners) {
   3157                 sb.append(" sysuil=");
   3158                 sb.append(hasSystemUiListeners);
   3159             }
   3160             if (inputFeatures != 0) {
   3161                 sb.append(" if=").append(inputFeatureToString(inputFeatures));
   3162             }
   3163             if (userActivityTimeout >= 0) {
   3164                 sb.append(" userActivityTimeout=").append(userActivityTimeout);
   3165             }
   3166             if (surfaceInsets.left != 0 || surfaceInsets.top != 0 || surfaceInsets.right != 0 ||
   3167                     surfaceInsets.bottom != 0 || hasManualSurfaceInsets
   3168                     || !preservePreviousSurfaceInsets) {
   3169                 sb.append(" surfaceInsets=").append(surfaceInsets);
   3170                 if (hasManualSurfaceInsets) {
   3171                     sb.append(" (manual)");
   3172                 }
   3173                 if (!preservePreviousSurfaceInsets) {
   3174                     sb.append(" (!preservePreviousSurfaceInsets)");
   3175                 }
   3176             }
   3177             if (needsMenuKey == NEEDS_MENU_SET_TRUE) {
   3178                 sb.append(" needsMenuKey");
   3179             }
   3180             if (mColorMode != COLOR_MODE_DEFAULT) {
   3181                 sb.append(" colorMode=").append(ActivityInfo.colorModeToString(mColorMode));
   3182             }
   3183             sb.append(System.lineSeparator());
   3184             sb.append(prefix).append("  fl=").append(
   3185                     ViewDebug.flagsToString(LayoutParams.class, "flags", flags));
   3186             if (privateFlags != 0) {
   3187                 sb.append(System.lineSeparator());
   3188                 sb.append(prefix).append("  pfl=").append(ViewDebug.flagsToString(
   3189                         LayoutParams.class, "privateFlags", privateFlags));
   3190             }
   3191             if (systemUiVisibility != 0) {
   3192                 sb.append(System.lineSeparator());
   3193                 sb.append(prefix).append("  sysui=").append(ViewDebug.flagsToString(
   3194                         View.class, "mSystemUiVisibility", systemUiVisibility));
   3195             }
   3196             if (subtreeSystemUiVisibility != 0) {
   3197                 sb.append(System.lineSeparator());
   3198                 sb.append(prefix).append("  vsysui=").append(ViewDebug.flagsToString(
   3199                         View.class, "mSystemUiVisibility", subtreeSystemUiVisibility));
   3200             }
   3201             sb.append('}');
   3202             return sb.toString();
   3203         }
   3204 
   3205         /**
   3206          * @hide
   3207          */
   3208         public void writeToProto(ProtoOutputStream proto, long fieldId) {
   3209             final long token = proto.start(fieldId);
   3210             proto.write(TYPE, type);
   3211             proto.write(X, x);
   3212             proto.write(Y, y);
   3213             proto.write(WIDTH, width);
   3214             proto.write(HEIGHT, height);
   3215             proto.write(HORIZONTAL_MARGIN, horizontalMargin);
   3216             proto.write(VERTICAL_MARGIN, verticalMargin);
   3217             proto.write(GRAVITY, gravity);
   3218             proto.write(SOFT_INPUT_MODE, softInputMode);
   3219             proto.write(FORMAT, format);
   3220             proto.write(WINDOW_ANIMATIONS, windowAnimations);
   3221             proto.write(ALPHA, alpha);
   3222             proto.write(SCREEN_BRIGHTNESS, screenBrightness);
   3223             proto.write(BUTTON_BRIGHTNESS, buttonBrightness);
   3224             proto.write(ROTATION_ANIMATION, rotationAnimation);
   3225             proto.write(PREFERRED_REFRESH_RATE, preferredRefreshRate);
   3226             proto.write(WindowLayoutParamsProto.PREFERRED_DISPLAY_MODE_ID, preferredDisplayModeId);
   3227             proto.write(HAS_SYSTEM_UI_LISTENERS, hasSystemUiListeners);
   3228             proto.write(INPUT_FEATURE_FLAGS, inputFeatures);
   3229             proto.write(USER_ACTIVITY_TIMEOUT, userActivityTimeout);
   3230             proto.write(NEEDS_MENU_KEY, needsMenuKey);
   3231             proto.write(COLOR_MODE, mColorMode);
   3232             proto.write(FLAGS, flags);
   3233             proto.write(PRIVATE_FLAGS, privateFlags);
   3234             proto.write(SYSTEM_UI_VISIBILITY_FLAGS, systemUiVisibility);
   3235             proto.write(SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS, subtreeSystemUiVisibility);
   3236             proto.end(token);
   3237         }
   3238 
   3239         /**
   3240          * Scale the layout params' coordinates and size.
   3241          * @hide
   3242          */
   3243         public void scale(float scale) {
   3244             x = (int) (x * scale + 0.5f);
   3245             y = (int) (y * scale + 0.5f);
   3246             if (width > 0) {
   3247                 width = (int) (width * scale + 0.5f);
   3248             }
   3249             if (height > 0) {
   3250                 height = (int) (height * scale + 0.5f);
   3251             }
   3252         }
   3253 
   3254         /**
   3255          * Backup the layout parameters used in compatibility mode.
   3256          * @see LayoutParams#restore()
   3257          */
   3258         @UnsupportedAppUsage
   3259         void backup() {
   3260             int[] backup = mCompatibilityParamsBackup;
   3261             if (backup == null) {
   3262                 // we backup 4 elements, x, y, width, height
   3263                 backup = mCompatibilityParamsBackup = new int[4];
   3264             }
   3265             backup[0] = x;
   3266             backup[1] = y;
   3267             backup[2] = width;
   3268             backup[3] = height;
   3269         }
   3270 
   3271         /**
   3272          * Restore the layout params' coordinates, size and gravity
   3273          * @see LayoutParams#backup()
   3274          */
   3275         @UnsupportedAppUsage
   3276         void restore() {
   3277             int[] backup = mCompatibilityParamsBackup;
   3278             if (backup != null) {
   3279                 x = backup[0];
   3280                 y = backup[1];
   3281                 width = backup[2];
   3282                 height = backup[3];
   3283             }
   3284         }
   3285 
   3286         private CharSequence mTitle = null;
   3287 
   3288         /** @hide */
   3289         @Override
   3290         protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) {
   3291             super.encodeProperties(encoder);
   3292 
   3293             encoder.addProperty("x", x);
   3294             encoder.addProperty("y", y);
   3295             encoder.addProperty("horizontalWeight", horizontalWeight);
   3296             encoder.addProperty("verticalWeight", verticalWeight);
   3297             encoder.addProperty("type", type);
   3298             encoder.addProperty("flags", flags);
   3299         }
   3300 
   3301         /**
   3302          * @hide
   3303          * @return True if the layout parameters will cause the window to cover the full screen;
   3304          *         false otherwise.
   3305          */
   3306         public boolean isFullscreen() {
   3307             return x == 0 && y == 0
   3308                     && width == WindowManager.LayoutParams.MATCH_PARENT
   3309                     && height == WindowManager.LayoutParams.MATCH_PARENT;
   3310         }
   3311 
   3312         private static String layoutInDisplayCutoutModeToString(
   3313                 @LayoutInDisplayCutoutMode int mode) {
   3314             switch (mode) {
   3315                 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT:
   3316                     return "default";
   3317                 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS:
   3318                     return "always";
   3319                 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER:
   3320                     return "never";
   3321                 default:
   3322                     return "unknown(" + mode + ")";
   3323             }
   3324         }
   3325 
   3326         private static String softInputModeToString(@SoftInputModeFlags int softInputMode) {
   3327             final StringBuilder result = new StringBuilder();
   3328             final int state = softInputMode & SOFT_INPUT_MASK_STATE;
   3329             if (state != 0) {
   3330                 result.append("state=");
   3331                 switch (state) {
   3332                     case SOFT_INPUT_STATE_UNCHANGED:
   3333                         result.append("unchanged");
   3334                         break;
   3335                     case SOFT_INPUT_STATE_HIDDEN:
   3336                         result.append("hidden");
   3337                         break;
   3338                     case SOFT_INPUT_STATE_ALWAYS_HIDDEN:
   3339                         result.append("always_hidden");
   3340                         break;
   3341                     case SOFT_INPUT_STATE_VISIBLE:
   3342                         result.append("visible");
   3343                         break;
   3344                     case SOFT_INPUT_STATE_ALWAYS_VISIBLE:
   3345                         result.append("always_visible");
   3346                         break;
   3347                     default:
   3348                         result.append(state);
   3349                         break;
   3350                 }
   3351                 result.append(' ');
   3352             }
   3353             final int adjust = softInputMode & SOFT_INPUT_MASK_ADJUST;
   3354             if (adjust != 0) {
   3355                 result.append("adjust=");
   3356                 switch (adjust) {
   3357                     case SOFT_INPUT_ADJUST_RESIZE:
   3358                         result.append("resize");
   3359                         break;
   3360                     case SOFT_INPUT_ADJUST_PAN:
   3361                         result.append("pan");
   3362                         break;
   3363                     case SOFT_INPUT_ADJUST_NOTHING:
   3364                         result.append("nothing");
   3365                         break;
   3366                     default:
   3367                         result.append(adjust);
   3368                         break;
   3369                 }
   3370                 result.append(' ');
   3371             }
   3372             if ((softInputMode & SOFT_INPUT_IS_FORWARD_NAVIGATION) != 0) {
   3373                 result.append("forwardNavigation").append(' ');
   3374             }
   3375             result.deleteCharAt(result.length() - 1);
   3376             return result.toString();
   3377         }
   3378 
   3379         private static String rotationAnimationToString(int rotationAnimation) {
   3380             switch (rotationAnimation) {
   3381                 case ROTATION_ANIMATION_UNSPECIFIED:
   3382                     return "UNSPECIFIED";
   3383                 case ROTATION_ANIMATION_ROTATE:
   3384                     return "ROTATE";
   3385                 case ROTATION_ANIMATION_CROSSFADE:
   3386                     return "CROSSFADE";
   3387                 case ROTATION_ANIMATION_JUMPCUT:
   3388                     return "JUMPCUT";
   3389                 case ROTATION_ANIMATION_SEAMLESS:
   3390                     return "SEAMLESS";
   3391                 default:
   3392                     return Integer.toString(rotationAnimation);
   3393             }
   3394         }
   3395 
   3396         private static String inputFeatureToString(int inputFeature) {
   3397             switch (inputFeature) {
   3398                 case INPUT_FEATURE_DISABLE_POINTER_GESTURES:
   3399                     return "DISABLE_POINTER_GESTURES";
   3400                 case INPUT_FEATURE_NO_INPUT_CHANNEL:
   3401                     return "NO_INPUT_CHANNEL";
   3402                 case INPUT_FEATURE_DISABLE_USER_ACTIVITY:
   3403                     return "DISABLE_USER_ACTIVITY";
   3404                 default:
   3405                     return Integer.toString(inputFeature);
   3406             }
   3407         }
   3408     }
   3409 }
   3410