Home | History | Annotate | Download | only in view
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.view;
     18 
     19 import android.annotation.NonNull;
     20 import android.annotation.SystemApi;
     21 import android.app.Presentation;
     22 import android.content.Context;
     23 import android.content.pm.ActivityInfo;
     24 import android.graphics.PixelFormat;
     25 import android.graphics.Rect;
     26 import android.os.IBinder;
     27 import android.os.Parcel;
     28 import android.os.Parcelable;
     29 import android.text.TextUtils;
     30 import android.util.Log;
     31 
     32 import java.util.List;
     33 import java.util.Objects;
     34 
     35 /**
     36  * The interface that apps use to talk to the window manager.
     37  * <p>
     38  * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these.
     39  * </p><p>
     40  * Each window manager instance is bound to a particular {@link Display}.
     41  * To obtain a {@link WindowManager} for a different display, use
     42  * {@link Context#createDisplayContext} to obtain a {@link Context} for that
     43  * display, then use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code>
     44  * to get the WindowManager.
     45  * </p><p>
     46  * The simplest way to show a window on another display is to create a
     47  * {@link Presentation}.  The presentation will automatically obtain a
     48  * {@link WindowManager} and {@link Context} for that display.
     49  * </p>
     50  *
     51  * @see android.content.Context#getSystemService
     52  * @see android.content.Context#WINDOW_SERVICE
     53  */
     54 public interface WindowManager extends ViewManager {
     55 
     56     /** @hide */
     57     int DOCKED_INVALID = -1;
     58     /** @hide */
     59     int DOCKED_LEFT = 1;
     60     /** @hide */
     61     int DOCKED_TOP = 2;
     62     /** @hide */
     63     int DOCKED_RIGHT = 3;
     64     /** @hide */
     65     int DOCKED_BOTTOM = 4;
     66 
     67     /**
     68      * Exception that is thrown when trying to add view whose
     69      * {@link LayoutParams} {@link LayoutParams#token}
     70      * is invalid.
     71      */
     72     public static class BadTokenException extends RuntimeException {
     73         public BadTokenException() {
     74         }
     75 
     76         public BadTokenException(String name) {
     77             super(name);
     78         }
     79     }
     80 
     81     /**
     82      * Exception that is thrown when calling {@link #addView} to a secondary display that cannot
     83      * be found. See {@link android.app.Presentation} for more information on secondary displays.
     84      */
     85     public static class InvalidDisplayException extends RuntimeException {
     86         public InvalidDisplayException() {
     87         }
     88 
     89         public InvalidDisplayException(String name) {
     90             super(name);
     91         }
     92     }
     93 
     94     /**
     95      * Returns the {@link Display} upon which this {@link WindowManager} instance
     96      * will create new windows.
     97      * <p>
     98      * Despite the name of this method, the display that is returned is not
     99      * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}).
    100      * The returned display could instead be a secondary display that this
    101      * window manager instance is managing.  Think of it as the display that
    102      * this {@link WindowManager} instance uses by default.
    103      * </p><p>
    104      * To create windows on a different display, you need to obtain a
    105      * {@link WindowManager} for that {@link Display}.  (See the {@link WindowManager}
    106      * class documentation for more information.)
    107      * </p>
    108      *
    109      * @return The display that this window manager is managing.
    110      */
    111     public Display getDefaultDisplay();
    112 
    113     /**
    114      * Special variation of {@link #removeView} that immediately invokes
    115      * the given view hierarchy's {@link View#onDetachedFromWindow()
    116      * View.onDetachedFromWindow()} methods before returning.  This is not
    117      * for normal applications; using it correctly requires great care.
    118      *
    119      * @param view The view to be removed.
    120      */
    121     public void removeViewImmediate(View view);
    122 
    123     /**
    124      * Used to asynchronously request Keyboard Shortcuts from the focused window.
    125      *
    126      * @hide
    127      */
    128     public interface KeyboardShortcutsReceiver {
    129         /**
    130          * Callback used when the focused window keyboard shortcuts are ready to be displayed.
    131          *
    132          * @param result The keyboard shortcuts to be displayed.
    133          */
    134         void onKeyboardShortcutsReceived(List<KeyboardShortcutGroup> result);
    135     }
    136 
    137     /**
    138      * Message for taking fullscreen screenshot
    139      * @hide
    140      */
    141     final int TAKE_SCREENSHOT_FULLSCREEN = 1;
    142 
    143     /**
    144      * Message for taking screenshot of selected region.
    145      * @hide
    146      */
    147     final int TAKE_SCREENSHOT_SELECTED_REGION = 2;
    148 
    149     /**
    150      * @hide
    151      */
    152     public static final String PARCEL_KEY_SHORTCUTS_ARRAY = "shortcuts_array";
    153 
    154     /**
    155      * Request for keyboard shortcuts to be retrieved asynchronously.
    156      *
    157      * @param receiver The callback to be triggered when the result is ready.
    158      *
    159      * @hide
    160      */
    161     public void requestAppKeyboardShortcuts(final KeyboardShortcutsReceiver receiver, int deviceId);
    162 
    163     public static class LayoutParams extends ViewGroup.LayoutParams implements Parcelable {
    164         /**
    165          * X position for this window.  With the default gravity it is ignored.
    166          * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or
    167          * {@link Gravity#END} it provides an offset from the given edge.
    168          */
    169         @ViewDebug.ExportedProperty
    170         public int x;
    171 
    172         /**
    173          * Y position for this window.  With the default gravity it is ignored.
    174          * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
    175          * an offset from the given edge.
    176          */
    177         @ViewDebug.ExportedProperty
    178         public int y;
    179 
    180         /**
    181          * Indicates how much of the extra space will be allocated horizontally
    182          * to the view associated with these LayoutParams. Specify 0 if the view
    183          * should not be stretched. Otherwise the extra pixels will be pro-rated
    184          * among all views whose weight is greater than 0.
    185          */
    186         @ViewDebug.ExportedProperty
    187         public float horizontalWeight;
    188 
    189         /**
    190          * Indicates how much of the extra space will be allocated vertically
    191          * to the view associated with these LayoutParams. Specify 0 if the view
    192          * should not be stretched. Otherwise the extra pixels will be pro-rated
    193          * among all views whose weight is greater than 0.
    194          */
    195         @ViewDebug.ExportedProperty
    196         public float verticalWeight;
    197 
    198         /**
    199          * The general type of window.  There are three main classes of
    200          * window types:
    201          * <ul>
    202          * <li> <strong>Application windows</strong> (ranging from
    203          * {@link #FIRST_APPLICATION_WINDOW} to
    204          * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application
    205          * windows.  For these types of windows, the {@link #token} must be
    206          * set to the token of the activity they are a part of (this will
    207          * normally be done for you if {@link #token} is null).
    208          * <li> <strong>Sub-windows</strong> (ranging from
    209          * {@link #FIRST_SUB_WINDOW} to
    210          * {@link #LAST_SUB_WINDOW}) are associated with another top-level
    211          * window.  For these types of windows, the {@link #token} must be
    212          * the token of the window it is attached to.
    213          * <li> <strong>System windows</strong> (ranging from
    214          * {@link #FIRST_SYSTEM_WINDOW} to
    215          * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for
    216          * use by the system for specific purposes.  They should not normally
    217          * be used by applications, and a special permission is required
    218          * to use them.
    219          * </ul>
    220          *
    221          * @see #TYPE_BASE_APPLICATION
    222          * @see #TYPE_APPLICATION
    223          * @see #TYPE_APPLICATION_STARTING
    224          * @see #TYPE_DRAWN_APPLICATION
    225          * @see #TYPE_APPLICATION_PANEL
    226          * @see #TYPE_APPLICATION_MEDIA
    227          * @see #TYPE_APPLICATION_SUB_PANEL
    228          * @see #TYPE_APPLICATION_ABOVE_SUB_PANEL
    229          * @see #TYPE_APPLICATION_ATTACHED_DIALOG
    230          * @see #TYPE_STATUS_BAR
    231          * @see #TYPE_SEARCH_BAR
    232          * @see #TYPE_PHONE
    233          * @see #TYPE_SYSTEM_ALERT
    234          * @see #TYPE_TOAST
    235          * @see #TYPE_SYSTEM_OVERLAY
    236          * @see #TYPE_PRIORITY_PHONE
    237          * @see #TYPE_STATUS_BAR_PANEL
    238          * @see #TYPE_SYSTEM_DIALOG
    239          * @see #TYPE_KEYGUARD_DIALOG
    240          * @see #TYPE_SYSTEM_ERROR
    241          * @see #TYPE_INPUT_METHOD
    242          * @see #TYPE_INPUT_METHOD_DIALOG
    243          */
    244         @ViewDebug.ExportedProperty(mapping = {
    245             @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"),
    246             @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"),
    247             @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"),
    248             @ViewDebug.IntToString(from = TYPE_DRAWN_APPLICATION, to = "TYPE_DRAWN_APPLICATION"),
    249             @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"),
    250             @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"),
    251             @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"),
    252             @ViewDebug.IntToString(from = TYPE_APPLICATION_ABOVE_SUB_PANEL, to = "TYPE_APPLICATION_ABOVE_SUB_PANEL"),
    253             @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"),
    254             @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY, to = "TYPE_APPLICATION_MEDIA_OVERLAY"),
    255             @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"),
    256             @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"),
    257             @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"),
    258             @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"),
    259             @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"),
    260             @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"),
    261             @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"),
    262             @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"),
    263             @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"),
    264             @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"),
    265             @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"),
    266             @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"),
    267             @ViewDebug.IntToString(from = TYPE_WALLPAPER, to = "TYPE_WALLPAPER"),
    268             @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"),
    269             @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY"),
    270             @ViewDebug.IntToString(from = TYPE_DRAG, to = "TYPE_DRAG"),
    271             @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, to = "TYPE_STATUS_BAR_SUB_PANEL"),
    272             @ViewDebug.IntToString(from = TYPE_POINTER, to = "TYPE_POINTER"),
    273             @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR, to = "TYPE_NAVIGATION_BAR"),
    274             @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY, to = "TYPE_VOLUME_OVERLAY"),
    275             @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, to = "TYPE_BOOT_PROGRESS"),
    276             @ViewDebug.IntToString(from = TYPE_INPUT_CONSUMER, to = "TYPE_INPUT_CONSUMER"),
    277             @ViewDebug.IntToString(from = TYPE_DREAM, to = "TYPE_DREAM"),
    278             @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL, to = "TYPE_NAVIGATION_BAR_PANEL"),
    279             @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY, to = "TYPE_DISPLAY_OVERLAY"),
    280             @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY, to = "TYPE_MAGNIFICATION_OVERLAY"),
    281             @ViewDebug.IntToString(from = TYPE_PRIVATE_PRESENTATION, to = "TYPE_PRIVATE_PRESENTATION"),
    282             @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION, to = "TYPE_VOICE_INTERACTION"),
    283             @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION_STARTING, to = "TYPE_VOICE_INTERACTION_STARTING"),
    284             @ViewDebug.IntToString(from = TYPE_DOCK_DIVIDER, to = "TYPE_DOCK_DIVIDER"),
    285             @ViewDebug.IntToString(from = TYPE_QS_DIALOG, to = "TYPE_QS_DIALOG"),
    286             @ViewDebug.IntToString(from = TYPE_SCREENSHOT, to = "TYPE_SCREENSHOT")
    287         })
    288         public int type;
    289 
    290         /**
    291          * Start of window types that represent normal application windows.
    292          */
    293         public static final int FIRST_APPLICATION_WINDOW = 1;
    294 
    295         /**
    296          * Window type: an application window that serves as the "base" window
    297          * of the overall application; all other application windows will
    298          * appear on top of it.
    299          * In multiuser systems shows only on the owning user's window.
    300          */
    301         public static final int TYPE_BASE_APPLICATION   = 1;
    302 
    303         /**
    304          * Window type: a normal application window.  The {@link #token} must be
    305          * an Activity token identifying who the window belongs to.
    306          * In multiuser systems shows only on the owning user's window.
    307          */
    308         public static final int TYPE_APPLICATION        = 2;
    309 
    310         /**
    311          * Window type: special application window that is displayed while the
    312          * application is starting.  Not for use by applications themselves;
    313          * this is used by the system to display something until the
    314          * application can show its own windows.
    315          * In multiuser systems shows on all users' windows.
    316          */
    317         public static final int TYPE_APPLICATION_STARTING = 3;
    318 
    319         /**
    320          * Window type: a variation on TYPE_APPLICATION that ensures the window
    321          * manager will wait for this window to be drawn before the app is shown.
    322          * In multiuser systems shows only on the owning user's window.
    323          */
    324         public static final int TYPE_DRAWN_APPLICATION = 4;
    325 
    326         /**
    327          * End of types of application windows.
    328          */
    329         public static final int LAST_APPLICATION_WINDOW = 99;
    330 
    331         /**
    332          * Start of types of sub-windows.  The {@link #token} of these windows
    333          * must be set to the window they are attached to.  These types of
    334          * windows are kept next to their attached window in Z-order, and their
    335          * coordinate space is relative to their attached window.
    336          */
    337         public static final int FIRST_SUB_WINDOW = 1000;
    338 
    339         /**
    340          * Window type: a panel on top of an application window.  These windows
    341          * appear on top of their attached window.
    342          */
    343         public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
    344 
    345         /**
    346          * Window type: window for showing media (such as video).  These windows
    347          * are displayed behind their attached window.
    348          */
    349         public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1;
    350 
    351         /**
    352          * Window type: a sub-panel on top of an application window.  These
    353          * windows are displayed on top their attached window and any
    354          * {@link #TYPE_APPLICATION_PANEL} panels.
    355          */
    356         public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2;
    357 
    358         /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
    359          * of the window happens as that of a top-level window, <em>not</em>
    360          * as a child of its container.
    361          */
    362         public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3;
    363 
    364         /**
    365          * Window type: window for showing overlays on top of media windows.
    366          * These windows are displayed between TYPE_APPLICATION_MEDIA and the
    367          * application window.  They should be translucent to be useful.  This
    368          * is a big ugly hack so:
    369          * @hide
    370          */
    371         public static final int TYPE_APPLICATION_MEDIA_OVERLAY  = FIRST_SUB_WINDOW + 4;
    372 
    373         /**
    374          * Window type: a above sub-panel on top of an application window and it's
    375          * sub-panel windows. These windows are displayed on top of their attached window
    376          * and any {@link #TYPE_APPLICATION_SUB_PANEL} panels.
    377          * @hide
    378          */
    379         public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5;
    380 
    381         /**
    382          * End of types of sub-windows.
    383          */
    384         public static final int LAST_SUB_WINDOW = 1999;
    385 
    386         /**
    387          * Start of system-specific window types.  These are not normally
    388          * created by applications.
    389          */
    390         public static final int FIRST_SYSTEM_WINDOW     = 2000;
    391 
    392         /**
    393          * Window type: the status bar.  There can be only one status bar
    394          * window; it is placed at the top of the screen, and all other
    395          * windows are shifted down so they are below it.
    396          * In multiuser systems shows on all users' windows.
    397          */
    398         public static final int TYPE_STATUS_BAR         = FIRST_SYSTEM_WINDOW;
    399 
    400         /**
    401          * Window type: the search bar.  There can be only one search bar
    402          * window; it is placed at the top of the screen.
    403          * In multiuser systems shows on all users' windows.
    404          */
    405         public static final int TYPE_SEARCH_BAR         = FIRST_SYSTEM_WINDOW+1;
    406 
    407         /**
    408          * Window type: phone.  These are non-application windows providing
    409          * user interaction with the phone (in particular incoming calls).
    410          * These windows are normally placed above all applications, but behind
    411          * the status bar.
    412          * In multiuser systems shows on all users' windows.
    413          */
    414         public static final int TYPE_PHONE              = FIRST_SYSTEM_WINDOW+2;
    415 
    416         /**
    417          * Window type: system window, such as low power alert. These windows
    418          * are always on top of application windows.
    419          * In multiuser systems shows only on the owning user's window.
    420          */
    421         public static final int TYPE_SYSTEM_ALERT       = FIRST_SYSTEM_WINDOW+3;
    422 
    423         /**
    424          * Window type: keyguard window.
    425          * In multiuser systems shows on all users' windows.
    426          * @removed
    427          */
    428         public static final int TYPE_KEYGUARD           = FIRST_SYSTEM_WINDOW+4;
    429 
    430         /**
    431          * Window type: transient notifications.
    432          * In multiuser systems shows only on the owning user's window.
    433          */
    434         public static final int TYPE_TOAST              = FIRST_SYSTEM_WINDOW+5;
    435 
    436         /**
    437          * Window type: system overlay windows, which need to be displayed
    438          * on top of everything else.  These windows must not take input
    439          * focus, or they will interfere with the keyguard.
    440          * In multiuser systems shows only on the owning user's window.
    441          */
    442         public static final int TYPE_SYSTEM_OVERLAY     = FIRST_SYSTEM_WINDOW+6;
    443 
    444         /**
    445          * Window type: priority phone UI, which needs to be displayed even if
    446          * the keyguard is active.  These windows must not take input
    447          * focus, or they will interfere with the keyguard.
    448          * In multiuser systems shows on all users' windows.
    449          */
    450         public static final int TYPE_PRIORITY_PHONE     = FIRST_SYSTEM_WINDOW+7;
    451 
    452         /**
    453          * Window type: panel that slides out from the status bar
    454          * In multiuser systems shows on all users' windows.
    455          */
    456         public static final int TYPE_SYSTEM_DIALOG      = FIRST_SYSTEM_WINDOW+8;
    457 
    458         /**
    459          * Window type: dialogs that the keyguard shows
    460          * In multiuser systems shows on all users' windows.
    461          */
    462         public static final int TYPE_KEYGUARD_DIALOG    = FIRST_SYSTEM_WINDOW+9;
    463 
    464         /**
    465          * Window type: internal system error windows, appear on top of
    466          * everything they can.
    467          * In multiuser systems shows only on the owning user's window.
    468          */
    469         public static final int TYPE_SYSTEM_ERROR       = FIRST_SYSTEM_WINDOW+10;
    470 
    471         /**
    472          * Window type: internal input methods windows, which appear above
    473          * the normal UI.  Application windows may be resized or panned to keep
    474          * the input focus visible while this window is displayed.
    475          * In multiuser systems shows only on the owning user's window.
    476          */
    477         public static final int TYPE_INPUT_METHOD       = FIRST_SYSTEM_WINDOW+11;
    478 
    479         /**
    480          * Window type: internal input methods dialog windows, which appear above
    481          * the current input method window.
    482          * In multiuser systems shows only on the owning user's window.
    483          */
    484         public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
    485 
    486         /**
    487          * Window type: wallpaper window, placed behind any window that wants
    488          * to sit on top of the wallpaper.
    489          * In multiuser systems shows only on the owning user's window.
    490          */
    491         public static final int TYPE_WALLPAPER          = FIRST_SYSTEM_WINDOW+13;
    492 
    493         /**
    494          * Window type: panel that slides out from over the status bar
    495          * In multiuser systems shows on all users' windows.
    496          */
    497         public static final int TYPE_STATUS_BAR_PANEL   = FIRST_SYSTEM_WINDOW+14;
    498 
    499         /**
    500          * Window type: secure system overlay windows, which need to be displayed
    501          * on top of everything else.  These windows must not take input
    502          * focus, or they will interfere with the keyguard.
    503          *
    504          * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
    505          * system itself is allowed to create these overlays.  Applications cannot
    506          * obtain permission to create secure system overlays.
    507          *
    508          * In multiuser systems shows only on the owning user's window.
    509          * @hide
    510          */
    511         public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
    512 
    513         /**
    514          * Window type: the drag-and-drop pseudowindow.  There is only one
    515          * drag layer (at most), and it is placed on top of all other windows.
    516          * In multiuser systems shows only on the owning user's window.
    517          * @hide
    518          */
    519         public static final int TYPE_DRAG               = FIRST_SYSTEM_WINDOW+16;
    520 
    521         /**
    522          * Window type: panel that slides out from under the status bar
    523          * In multiuser systems shows on all users' windows.
    524          * @hide
    525          */
    526         public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
    527 
    528         /**
    529          * Window type: (mouse) pointer
    530          * In multiuser systems shows on all users' windows.
    531          * @hide
    532          */
    533         public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
    534 
    535         /**
    536          * Window type: Navigation bar (when distinct from status bar)
    537          * In multiuser systems shows on all users' windows.
    538          * @hide
    539          */
    540         public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
    541 
    542         /**
    543          * Window type: The volume level overlay/dialog shown when the user
    544          * changes the system volume.
    545          * In multiuser systems shows on all users' windows.
    546          * @hide
    547          */
    548         public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
    549 
    550         /**
    551          * Window type: The boot progress dialog, goes on top of everything
    552          * in the world.
    553          * In multiuser systems shows on all users' windows.
    554          * @hide
    555          */
    556         public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
    557 
    558         /**
    559          * Window type to consume input events when the systemUI bars are hidden.
    560          * In multiuser systems shows on all users' windows.
    561          * @hide
    562          */
    563         public static final int TYPE_INPUT_CONSUMER = FIRST_SYSTEM_WINDOW+22;
    564 
    565         /**
    566          * Window type: Dreams (screen saver) window, just above keyguard.
    567          * In multiuser systems shows only on the owning user's window.
    568          * @hide
    569          */
    570         public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23;
    571 
    572         /**
    573          * Window type: Navigation bar panel (when navigation bar is distinct from status bar)
    574          * In multiuser systems shows on all users' windows.
    575          * @hide
    576          */
    577         public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24;
    578 
    579         /**
    580          * Window type: Display overlay window.  Used to simulate secondary display devices.
    581          * In multiuser systems shows on all users' windows.
    582          * @hide
    583          */
    584         public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26;
    585 
    586         /**
    587          * Window type: Magnification overlay window. Used to highlight the magnified
    588          * portion of a display when accessibility magnification is enabled.
    589          * In multiuser systems shows on all users' windows.
    590          * @hide
    591          */
    592         public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27;
    593 
    594         /**
    595          * Window type: keyguard scrim window. Shows if keyguard needs to be restarted.
    596          * In multiuser systems shows on all users' windows.
    597          * @hide
    598          */
    599         public static final int TYPE_KEYGUARD_SCRIM           = FIRST_SYSTEM_WINDOW+29;
    600 
    601         /**
    602          * Window type: Window for Presentation on top of private
    603          * virtual display.
    604          */
    605         public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30;
    606 
    607         /**
    608          * Window type: Windows in the voice interaction layer.
    609          * @hide
    610          */
    611         public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31;
    612 
    613         /**
    614          * Window type: Windows that are overlaid <em>only</em> by a connected {@link
    615          * android.accessibilityservice.AccessibilityService} for interception of
    616          * user interactions without changing the windows an accessibility service
    617          * can introspect. In particular, an accessibility service can introspect
    618          * only windows that a sighted user can interact with which is they can touch
    619          * these windows or can type into these windows. For example, if there
    620          * is a full screen accessibility overlay that is touchable, the windows
    621          * below it will be introspectable by an accessibility service even though
    622          * they are covered by a touchable window.
    623          */
    624         public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32;
    625 
    626         /**
    627          * Window type: Starting window for voice interaction layer.
    628          * @hide
    629          */
    630         public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33;
    631 
    632         /**
    633          * Window for displaying a handle used for resizing docked stacks. This window is owned
    634          * by the system process.
    635          * @hide
    636          */
    637         public static final int TYPE_DOCK_DIVIDER = FIRST_SYSTEM_WINDOW+34;
    638 
    639         /**
    640          * Window type: like {@link #TYPE_APPLICATION_ATTACHED_DIALOG}, but used
    641          * by Quick Settings Tiles.
    642          * @hide
    643          */
    644         public static final int TYPE_QS_DIALOG = FIRST_SYSTEM_WINDOW+35;
    645 
    646         /**
    647          * Window type: shares similar characteristics with {@link #TYPE_DREAM}. The layer is
    648          * reserved for screenshot region selection. These windows must not take input focus.
    649          * @hide
    650          */
    651         public static final int TYPE_SCREENSHOT = FIRST_SYSTEM_WINDOW + 36;
    652 
    653         /**
    654          * End of types of system windows.
    655          */
    656         public static final int LAST_SYSTEM_WINDOW      = 2999;
    657 
    658         /** @deprecated this is ignored, this value is set automatically when needed. */
    659         @Deprecated
    660         public static final int MEMORY_TYPE_NORMAL = 0;
    661         /** @deprecated this is ignored, this value is set automatically when needed. */
    662         @Deprecated
    663         public static final int MEMORY_TYPE_HARDWARE = 1;
    664         /** @deprecated this is ignored, this value is set automatically when needed. */
    665         @Deprecated
    666         public static final int MEMORY_TYPE_GPU = 2;
    667         /** @deprecated this is ignored, this value is set automatically when needed. */
    668         @Deprecated
    669         public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
    670 
    671         /**
    672          * @deprecated this is ignored
    673          */
    674         @Deprecated
    675         public int memoryType;
    676 
    677         /** Window flag: as long as this window is visible to the user, allow
    678          *  the lock screen to activate while the screen is on.
    679          *  This can be used independently, or in combination with
    680          *  {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
    681         public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001;
    682 
    683         /** Window flag: everything behind this window will be dimmed.
    684          *  Use {@link #dimAmount} to control the amount of dim. */
    685         public static final int FLAG_DIM_BEHIND        = 0x00000002;
    686 
    687         /** Window flag: blur everything behind this window.
    688          * @deprecated Blurring is no longer supported. */
    689         @Deprecated
    690         public static final int FLAG_BLUR_BEHIND        = 0x00000004;
    691 
    692         /** Window flag: this window won't ever get key input focus, so the
    693          * user can not send key or other button events to it.  Those will
    694          * instead go to whatever focusable window is behind it.  This flag
    695          * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
    696          * is explicitly set.
    697          *
    698          * <p>Setting this flag also implies that the window will not need to
    699          * interact with
    700          * a soft input method, so it will be Z-ordered and positioned
    701          * independently of any active input method (typically this means it
    702          * gets Z-ordered on top of the input method, so it can use the full
    703          * screen for its content and cover the input method if needed.  You
    704          * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
    705         public static final int FLAG_NOT_FOCUSABLE      = 0x00000008;
    706 
    707         /** Window flag: this window can never receive touch events. */
    708         public static final int FLAG_NOT_TOUCHABLE      = 0x00000010;
    709 
    710         /** Window flag: even when this window is focusable (its
    711          * {@link #FLAG_NOT_FOCUSABLE} is not set), allow any pointer events
    712          * outside of the window to be sent to the windows behind it.  Otherwise
    713          * it will consume all pointer events itself, regardless of whether they
    714          * are inside of the window. */
    715         public static final int FLAG_NOT_TOUCH_MODAL    = 0x00000020;
    716 
    717         /** Window flag: when set, if the device is asleep when the touch
    718          * screen is pressed, you will receive this first touch event.  Usually
    719          * the first touch event is consumed by the system since the user can
    720          * not see what they are pressing on.
    721          *
    722          * @deprecated This flag has no effect.
    723          */
    724         @Deprecated
    725         public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
    726 
    727         /** Window flag: as long as this window is visible to the user, keep
    728          *  the device's screen turned on and bright. */
    729         public static final int FLAG_KEEP_SCREEN_ON     = 0x00000080;
    730 
    731         /** Window flag: place the window within the entire screen, ignoring
    732          *  decorations around the border (such as the status bar).  The
    733          *  window must correctly position its contents to take the screen
    734          *  decoration into account.  This flag is normally set for you
    735          *  by Window as described in {@link Window#setFlags}. */
    736         public static final int FLAG_LAYOUT_IN_SCREEN   = 0x00000100;
    737 
    738         /** Window flag: allow window to extend outside of the screen. */
    739         public static final int FLAG_LAYOUT_NO_LIMITS   = 0x00000200;
    740 
    741         /**
    742          * Window flag: hide all screen decorations (such as the status bar) while
    743          * this window is displayed.  This allows the window to use the entire
    744          * display space for itself -- the status bar will be hidden when
    745          * an app window with this flag set is on the top layer. A fullscreen window
    746          * will ignore a value of {@link #SOFT_INPUT_ADJUST_RESIZE} for the window's
    747          * {@link #softInputMode} field; the window will stay fullscreen
    748          * and will not resize.
    749          *
    750          * <p>This flag can be controlled in your theme through the
    751          * {@link android.R.attr#windowFullscreen} attribute; this attribute
    752          * is automatically set for you in the standard fullscreen themes
    753          * such as {@link android.R.style#Theme_NoTitleBar_Fullscreen},
    754          * {@link android.R.style#Theme_Black_NoTitleBar_Fullscreen},
    755          * {@link android.R.style#Theme_Light_NoTitleBar_Fullscreen},
    756          * {@link android.R.style#Theme_Holo_NoActionBar_Fullscreen},
    757          * {@link android.R.style#Theme_Holo_Light_NoActionBar_Fullscreen},
    758          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Fullscreen}, and
    759          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Fullscreen}.</p>
    760          */
    761         public static final int FLAG_FULLSCREEN      = 0x00000400;
    762 
    763         /** Window flag: override {@link #FLAG_FULLSCREEN} and force the
    764          *  screen decorations (such as the status bar) to be shown. */
    765         public static final int FLAG_FORCE_NOT_FULLSCREEN   = 0x00000800;
    766 
    767         /** Window flag: turn on dithering when compositing this window to
    768          *  the screen.
    769          * @deprecated This flag is no longer used. */
    770         @Deprecated
    771         public static final int FLAG_DITHER             = 0x00001000;
    772 
    773         /** Window flag: treat the content of the window as secure, preventing
    774          * it from appearing in screenshots or from being viewed on non-secure
    775          * displays.
    776          *
    777          * <p>See {@link android.view.Display#FLAG_SECURE} for more details about
    778          * secure surfaces and secure displays.
    779          */
    780         public static final int FLAG_SECURE             = 0x00002000;
    781 
    782         /** Window flag: a special mode where the layout parameters are used
    783          * to perform scaling of the surface when it is composited to the
    784          * screen. */
    785         public static final int FLAG_SCALED             = 0x00004000;
    786 
    787         /** Window flag: intended for windows that will often be used when the user is
    788          * holding the screen against their face, it will aggressively filter the event
    789          * stream to prevent unintended presses in this situation that may not be
    790          * desired for a particular window, when such an event stream is detected, the
    791          * application will receive a CANCEL motion event to indicate this so applications
    792          * can handle this accordingly by taking no action on the event
    793          * until the finger is released. */
    794         public static final int FLAG_IGNORE_CHEEK_PRESSES    = 0x00008000;
    795 
    796         /** Window flag: a special option only for use in combination with
    797          * {@link #FLAG_LAYOUT_IN_SCREEN}.  When requesting layout in the
    798          * screen your window may appear on top of or behind screen decorations
    799          * such as the status bar.  By also including this flag, the window
    800          * manager will report the inset rectangle needed to ensure your
    801          * content is not covered by screen decorations.  This flag is normally
    802          * set for you by Window as described in {@link Window#setFlags}.*/
    803         public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
    804 
    805         /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
    806          * respect to how this window interacts with the current method.  That
    807          * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
    808          * window will behave as if it needs to interact with the input method
    809          * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
    810          * not set and this flag is set, then the window will behave as if it
    811          * doesn't need to interact with the input method and can be placed
    812          * to use more space and cover the input method.
    813          */
    814         public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
    815 
    816         /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
    817          * can set this flag to receive a single special MotionEvent with
    818          * the action
    819          * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
    820          * touches that occur outside of your window.  Note that you will not
    821          * receive the full down/move/up gesture, only the location of the
    822          * first down as an ACTION_OUTSIDE.
    823          */
    824         public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
    825 
    826         /** Window flag: special flag to let windows be shown when the screen
    827          * is locked. This will let application windows take precedence over
    828          * key guard or any other lock screens. Can be used with
    829          * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
    830          * directly before showing the key guard window.  Can be used with
    831          * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
    832          * non-secure keyguards.  This flag only applies to the top-most
    833          * full-screen window.
    834          */
    835         public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
    836 
    837         /** Window flag: ask that the system wallpaper be shown behind
    838          * your window.  The window surface must be translucent to be able
    839          * to actually see the wallpaper behind it; this flag just ensures
    840          * that the wallpaper surface will be there if this window actually
    841          * has translucent regions.
    842          *
    843          * <p>This flag can be controlled in your theme through the
    844          * {@link android.R.attr#windowShowWallpaper} attribute; this attribute
    845          * is automatically set for you in the standard wallpaper themes
    846          * such as {@link android.R.style#Theme_Wallpaper},
    847          * {@link android.R.style#Theme_Wallpaper_NoTitleBar},
    848          * {@link android.R.style#Theme_Wallpaper_NoTitleBar_Fullscreen},
    849          * {@link android.R.style#Theme_Holo_Wallpaper},
    850          * {@link android.R.style#Theme_Holo_Wallpaper_NoTitleBar},
    851          * {@link android.R.style#Theme_DeviceDefault_Wallpaper}, and
    852          * {@link android.R.style#Theme_DeviceDefault_Wallpaper_NoTitleBar}.</p>
    853          */
    854         public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
    855 
    856         /** Window flag: when set as a window is being added or made
    857          * visible, once the window has been shown then the system will
    858          * poke the power manager's user activity (as if the user had woken
    859          * up the device) to turn the screen on. */
    860         public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
    861 
    862         /** Window flag: when set the window will cause the keyguard to
    863          * be dismissed, only if it is not a secure lock keyguard.  Because such
    864          * a keyguard is not needed for security, it will never re-appear if
    865          * the user navigates to another window (in contrast to
    866          * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily
    867          * hide both secure and non-secure keyguards but ensure they reappear
    868          * when the user moves to another UI that doesn't hide them).
    869          * If the keyguard is currently active and is secure (requires an
    870          * unlock pattern) than the user will still need to confirm it before
    871          * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has
    872          * also been set.
    873          */
    874         public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
    875 
    876         /** Window flag: when set the window will accept for touch events
    877          * outside of its bounds to be sent to other windows that also
    878          * support split touch.  When this flag is not set, the first pointer
    879          * that goes down determines the window to which all subsequent touches
    880          * go until all pointers go up.  When this flag is set, each pointer
    881          * (not necessarily the first) that goes down determines the window
    882          * to which all subsequent touches of that pointer will go until that
    883          * pointer goes up thereby enabling touches with multiple pointers
    884          * to be split across multiple windows.
    885          */
    886         public static final int FLAG_SPLIT_TOUCH = 0x00800000;
    887 
    888         /**
    889          * <p>Indicates whether this window should be hardware accelerated.
    890          * Requesting hardware acceleration does not guarantee it will happen.</p>
    891          *
    892          * <p>This flag can be controlled programmatically <em>only</em> to enable
    893          * hardware acceleration. To enable hardware acceleration for a given
    894          * window programmatically, do the following:</p>
    895          *
    896          * <pre>
    897          * Window w = activity.getWindow(); // in Activity's onCreate() for instance
    898          * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
    899          *         WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
    900          * </pre>
    901          *
    902          * <p>It is important to remember that this flag <strong>must</strong>
    903          * be set before setting the content view of your activity or dialog.</p>
    904          *
    905          * <p>This flag cannot be used to disable hardware acceleration after it
    906          * was enabled in your manifest using
    907          * {@link android.R.attr#hardwareAccelerated}. If you need to selectively
    908          * and programmatically disable hardware acceleration (for automated testing
    909          * for instance), make sure it is turned off in your manifest and enable it
    910          * on your activity or dialog when you need it instead, using the method
    911          * described above.</p>
    912          *
    913          * <p>This flag is automatically set by the system if the
    914          * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
    915          * XML attribute is set to true on an activity or on the application.</p>
    916          */
    917         public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
    918 
    919         /**
    920          * Window flag: allow window contents to extend in to the screen's
    921          * overscan area, if there is one.  The window should still correctly
    922          * position its contents to take the overscan area into account.
    923          *
    924          * <p>This flag can be controlled in your theme through the
    925          * {@link android.R.attr#windowOverscan} attribute; this attribute
    926          * is automatically set for you in the standard overscan themes
    927          * such as
    928          * {@link android.R.style#Theme_Holo_NoActionBar_Overscan},
    929          * {@link android.R.style#Theme_Holo_Light_NoActionBar_Overscan},
    930          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Overscan}, and
    931          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Overscan}.</p>
    932          *
    933          * <p>When this flag is enabled for a window, its normal content may be obscured
    934          * to some degree by the overscan region of the display.  To ensure key parts of
    935          * that content are visible to the user, you can use
    936          * {@link View#setFitsSystemWindows(boolean) View.setFitsSystemWindows(boolean)}
    937          * to set the point in the view hierarchy where the appropriate offsets should
    938          * be applied.  (This can be done either by directly calling this function, using
    939          * the {@link android.R.attr#fitsSystemWindows} attribute in your view hierarchy,
    940          * or implementing you own {@link View#fitSystemWindows(android.graphics.Rect)
    941          * View.fitSystemWindows(Rect)} method).</p>
    942          *
    943          * <p>This mechanism for positioning content elements is identical to its equivalent
    944          * use with layout and {@link View#setSystemUiVisibility(int)
    945          * View.setSystemUiVisibility(int)}; here is an example layout that will correctly
    946          * position its UI elements with this overscan flag is set:</p>
    947          *
    948          * {@sample development/samples/ApiDemos/res/layout/overscan_activity.xml complete}
    949          */
    950         public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000;
    951 
    952         /**
    953          * Window flag: request a translucent status bar with minimal system-provided
    954          * background protection.
    955          *
    956          * <p>This flag can be controlled in your theme through the
    957          * {@link android.R.attr#windowTranslucentStatus} attribute; this attribute
    958          * is automatically set for you in the standard translucent decor themes
    959          * such as
    960          * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor},
    961          * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor},
    962          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and
    963          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p>
    964          *
    965          * <p>When this flag is enabled for a window, it automatically sets
    966          * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
    967          * {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p>
    968          */
    969         public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000;
    970 
    971         /**
    972          * Window flag: request a translucent navigation bar with minimal system-provided
    973          * background protection.
    974          *
    975          * <p>This flag can be controlled in your theme through the
    976          * {@link android.R.attr#windowTranslucentNavigation} attribute; this attribute
    977          * is automatically set for you in the standard translucent decor themes
    978          * such as
    979          * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor},
    980          * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor},
    981          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and
    982          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p>
    983          *
    984          * <p>When this flag is enabled for a window, it automatically sets
    985          * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
    986          * {@link View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.</p>
    987          */
    988         public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000;
    989 
    990         /**
    991          * Flag for a window in local focus mode.
    992          * Window in local focus mode can control focus independent of window manager using
    993          * {@link Window#setLocalFocus(boolean, boolean)}.
    994          * Usually window in this mode will not get touch/key events from window manager, but will
    995          * get events only via local injection using {@link Window#injectInputEvent(InputEvent)}.
    996          */
    997         public static final int FLAG_LOCAL_FOCUS_MODE = 0x10000000;
    998 
    999         /** Window flag: Enable touches to slide out of a window into neighboring
   1000          * windows in mid-gesture instead of being captured for the duration of
   1001          * the gesture.
   1002          *
   1003          * This flag changes the behavior of touch focus for this window only.
   1004          * Touches can slide out of the window but they cannot necessarily slide
   1005          * back in (unless the other window with touch focus permits it).
   1006          *
   1007          * {@hide}
   1008          */
   1009         public static final int FLAG_SLIPPERY = 0x20000000;
   1010 
   1011         /**
   1012          * Window flag: When requesting layout with an attached window, the attached window may
   1013          * overlap with the screen decorations of the parent window such as the navigation bar. By
   1014          * including this flag, the window manager will layout the attached window within the decor
   1015          * frame of the parent window such that it doesn't overlap with screen decorations.
   1016          */
   1017         public static final int FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000;
   1018 
   1019         /**
   1020          * Flag indicating that this Window is responsible for drawing the background for the
   1021          * system bars. If set, the system bars are drawn with a transparent background and the
   1022          * corresponding areas in this window are filled with the colors specified in
   1023          * {@link Window#getStatusBarColor()} and {@link Window#getNavigationBarColor()}.
   1024          */
   1025         public static final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000;
   1026 
   1027         /**
   1028          * Various behavioral options/flags.  Default is none.
   1029          *
   1030          * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
   1031          * @see #FLAG_DIM_BEHIND
   1032          * @see #FLAG_NOT_FOCUSABLE
   1033          * @see #FLAG_NOT_TOUCHABLE
   1034          * @see #FLAG_NOT_TOUCH_MODAL
   1035          * @see #FLAG_TOUCHABLE_WHEN_WAKING
   1036          * @see #FLAG_KEEP_SCREEN_ON
   1037          * @see #FLAG_LAYOUT_IN_SCREEN
   1038          * @see #FLAG_LAYOUT_NO_LIMITS
   1039          * @see #FLAG_FULLSCREEN
   1040          * @see #FLAG_FORCE_NOT_FULLSCREEN
   1041          * @see #FLAG_SECURE
   1042          * @see #FLAG_SCALED
   1043          * @see #FLAG_IGNORE_CHEEK_PRESSES
   1044          * @see #FLAG_LAYOUT_INSET_DECOR
   1045          * @see #FLAG_ALT_FOCUSABLE_IM
   1046          * @see #FLAG_WATCH_OUTSIDE_TOUCH
   1047          * @see #FLAG_SHOW_WHEN_LOCKED
   1048          * @see #FLAG_SHOW_WALLPAPER
   1049          * @see #FLAG_TURN_SCREEN_ON
   1050          * @see #FLAG_DISMISS_KEYGUARD
   1051          * @see #FLAG_SPLIT_TOUCH
   1052          * @see #FLAG_HARDWARE_ACCELERATED
   1053          * @see #FLAG_LOCAL_FOCUS_MODE
   1054          * @see #FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
   1055          */
   1056         @ViewDebug.ExportedProperty(flagMapping = {
   1057             @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
   1058                     name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
   1059             @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
   1060                     name = "FLAG_DIM_BEHIND"),
   1061             @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
   1062                     name = "FLAG_BLUR_BEHIND"),
   1063             @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
   1064                     name = "FLAG_NOT_FOCUSABLE"),
   1065             @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
   1066                     name = "FLAG_NOT_TOUCHABLE"),
   1067             @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
   1068                     name = "FLAG_NOT_TOUCH_MODAL"),
   1069             @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING,
   1070                     name = "FLAG_TOUCHABLE_WHEN_WAKING"),
   1071             @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
   1072                     name = "FLAG_KEEP_SCREEN_ON"),
   1073             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
   1074                     name = "FLAG_LAYOUT_IN_SCREEN"),
   1075             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS,
   1076                     name = "FLAG_LAYOUT_NO_LIMITS"),
   1077             @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
   1078                     name = "FLAG_FULLSCREEN"),
   1079             @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN,
   1080                     name = "FLAG_FORCE_NOT_FULLSCREEN"),
   1081             @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
   1082                     name = "FLAG_DITHER"),
   1083             @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE,
   1084                     name = "FLAG_SECURE"),
   1085             @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED,
   1086                     name = "FLAG_SCALED"),
   1087             @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES,
   1088                     name = "FLAG_IGNORE_CHEEK_PRESSES"),
   1089             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR,
   1090                     name = "FLAG_LAYOUT_INSET_DECOR"),
   1091             @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM,
   1092                     name = "FLAG_ALT_FOCUSABLE_IM"),
   1093             @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH,
   1094                     name = "FLAG_WATCH_OUTSIDE_TOUCH"),
   1095             @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
   1096                     name = "FLAG_SHOW_WHEN_LOCKED"),
   1097             @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER,
   1098                     name = "FLAG_SHOW_WALLPAPER"),
   1099             @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
   1100                     name = "FLAG_TURN_SCREEN_ON"),
   1101             @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
   1102                     name = "FLAG_DISMISS_KEYGUARD"),
   1103             @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH,
   1104                     name = "FLAG_SPLIT_TOUCH"),
   1105             @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
   1106                     name = "FLAG_HARDWARE_ACCELERATED"),
   1107             @ViewDebug.FlagToString(mask = FLAG_LOCAL_FOCUS_MODE, equals = FLAG_LOCAL_FOCUS_MODE,
   1108                     name = "FLAG_LOCAL_FOCUS_MODE"),
   1109             @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_STATUS, equals = FLAG_TRANSLUCENT_STATUS,
   1110                     name = "FLAG_TRANSLUCENT_STATUS"),
   1111             @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_NAVIGATION, equals = FLAG_TRANSLUCENT_NAVIGATION,
   1112                     name = "FLAG_TRANSLUCENT_NAVIGATION"),
   1113             @ViewDebug.FlagToString(mask = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, equals = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
   1114                     name = "FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS")
   1115         }, formatToHexString = true)
   1116         public int flags;
   1117 
   1118         /**
   1119          * If the window has requested hardware acceleration, but this is not
   1120          * allowed in the process it is in, then still render it as if it is
   1121          * hardware accelerated.  This is used for the starting preview windows
   1122          * in the system process, which don't need to have the overhead of
   1123          * hardware acceleration (they are just a static rendering), but should
   1124          * be rendered as such to match the actual window of the app even if it
   1125          * is hardware accelerated.
   1126          * Even if the window isn't hardware accelerated, still do its rendering
   1127          * as if it was.
   1128          * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
   1129          * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
   1130          * is generally disabled. This flag must be specified in addition to
   1131          * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
   1132          * windows.
   1133          *
   1134          * @hide
   1135          */
   1136         public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
   1137 
   1138         /**
   1139          * In the system process, we globally do not use hardware acceleration
   1140          * because there are many threads doing UI there and they conflict.
   1141          * If certain parts of the UI that really do want to use hardware
   1142          * acceleration, this flag can be set to force it.  This is basically
   1143          * for the lock screen.  Anyone else using it, you are probably wrong.
   1144          *
   1145          * @hide
   1146          */
   1147         public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002;
   1148 
   1149         /**
   1150          * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers
   1151          * may elect to skip these notifications if they are not doing anything productive with
   1152          * them (they do not affect the wallpaper scrolling operation) by calling
   1153          * {@link
   1154          * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}.
   1155          *
   1156          * @hide
   1157          */
   1158         public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004;
   1159 
   1160         /** In a multiuser system if this flag is set and the owner is a system process then this
   1161          * window will appear on all user screens. This overrides the default behavior of window
   1162          * types that normally only appear on the owning user's screen. Refer to each window type
   1163          * to determine its default behavior.
   1164          *
   1165          * {@hide} */
   1166         public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010;
   1167 
   1168         /**
   1169          * Never animate position changes of the window.
   1170          *
   1171          * {@hide} */
   1172         public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 0x00000040;
   1173 
   1174         /** Window flag: special flag to limit the size of the window to be
   1175          * original size ([320x480] x density). Used to create window for applications
   1176          * running under compatibility mode.
   1177          *
   1178          * {@hide} */
   1179         public static final int PRIVATE_FLAG_COMPATIBLE_WINDOW = 0x00000080;
   1180 
   1181         /** Window flag: a special option intended for system dialogs.  When
   1182          * this flag is set, the window will demand focus unconditionally when
   1183          * it is created.
   1184          * {@hide} */
   1185         public static final int PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100;
   1186 
   1187         /** Window flag: maintain the previous translucent decor state when this window
   1188          * becomes top-most.
   1189          * {@hide} */
   1190         public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200;
   1191 
   1192         /**
   1193          * Flag whether the current window is a keyguard window, meaning that it will hide all other
   1194          * windows behind it except for windows with flag {@link #FLAG_SHOW_WHEN_LOCKED} set.
   1195          * Further, this can only be set by {@link LayoutParams#TYPE_STATUS_BAR}.
   1196          * {@hide}
   1197          */
   1198         public static final int PRIVATE_FLAG_KEYGUARD = 0x00000400;
   1199 
   1200         /**
   1201          * Flag that prevents the wallpaper behind the current window from receiving touch events.
   1202          *
   1203          * {@hide}
   1204          */
   1205         public static final int PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS = 0x00000800;
   1206 
   1207         /**
   1208          * Flag to force the status bar window to be visible all the time. If the bar is hidden when
   1209          * this flag is set it will be shown again and the bar will have a transparent background.
   1210          * This can only be set by {@link LayoutParams#TYPE_STATUS_BAR}.
   1211          *
   1212          * {@hide}
   1213          */
   1214         public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000;
   1215 
   1216         /**
   1217          * Flag indicating that the x, y, width, and height members should be
   1218          * ignored (and thus their previous value preserved). For example
   1219          * because they are being managed externally through repositionChild.
   1220          *
   1221          * {@hide}
   1222          */
   1223         public static final int PRIVATE_FLAG_PRESERVE_GEOMETRY = 0x00002000;
   1224 
   1225         /**
   1226          * Flag that will make window ignore app visibility and instead depend purely on the decor
   1227          * view visibility for determining window visibility. This is used by recents to keep
   1228          * drawing after it launches an app.
   1229          * @hide
   1230          */
   1231         public static final int PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY = 0x00004000;
   1232 
   1233         /**
   1234          * Flag to indicate that this window is not expected to be replaced across
   1235          * configuration change triggered activity relaunches. In general the WindowManager
   1236          * expects Windows to be replaced after relaunch, and thus it will preserve their surfaces
   1237          * until the replacement is ready to show in order to prevent visual glitch. However
   1238          * some windows, such as PopupWindows expect to be cleared across configuration change,
   1239          * and thus should hint to the WindowManager that it should not wait for a replacement.
   1240          * @hide
   1241          */
   1242         public static final int PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH = 0x00008000;
   1243 
   1244         /**
   1245          * Flag to indicate that this child window should always be laid-out in the parent
   1246          * frame regardless of the current windowing mode configuration.
   1247          * @hide
   1248          */
   1249         public static final int PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME = 0x00010000;
   1250 
   1251         /**
   1252          * Flag to indicate that this window is always drawing the status bar background, no matter
   1253          * what the other flags are.
   1254          * @hide
   1255          */
   1256         public static final int PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND = 0x00020000;
   1257 
   1258         /**
   1259          * Flag to indicate that this window needs Sustained Performance Mode if
   1260          * the device supports it.
   1261          * @hide
   1262          */
   1263         public static final int PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE = 0x00040000;
   1264 
   1265         /**
   1266          * Control flags that are private to the platform.
   1267          * @hide
   1268          */
   1269         public int privateFlags;
   1270 
   1271         /**
   1272          * Value for {@link #needsMenuKey} for a window that has not explicitly specified if it
   1273          * needs {@link #NEEDS_MENU_SET_TRUE} or doesn't need {@link #NEEDS_MENU_SET_FALSE} a menu
   1274          * key. For this case, we should look at windows behind it to determine the appropriate
   1275          * value.
   1276          *
   1277          * @hide
   1278          */
   1279         public static final int NEEDS_MENU_UNSET = 0;
   1280 
   1281         /**
   1282          * Value for {@link #needsMenuKey} for a window that has explicitly specified it needs a
   1283          * menu key.
   1284          *
   1285          * @hide
   1286          */
   1287         public static final int NEEDS_MENU_SET_TRUE = 1;
   1288 
   1289         /**
   1290          * Value for {@link #needsMenuKey} for a window that has explicitly specified it doesn't
   1291          * needs a menu key.
   1292          *
   1293          * @hide
   1294          */
   1295         public static final int NEEDS_MENU_SET_FALSE = 2;
   1296 
   1297         /**
   1298          * State variable for a window belonging to an activity that responds to
   1299          * {@link KeyEvent#KEYCODE_MENU} and therefore needs a Menu key. For devices where Menu is a
   1300          * physical button this variable is ignored, but on devices where the Menu key is drawn in
   1301          * software it may be hidden unless this variable is set to {@link #NEEDS_MENU_SET_TRUE}.
   1302          *
   1303          *  (Note that Action Bars, when available, are the preferred way to offer additional
   1304          * functions otherwise accessed via an options menu.)
   1305          *
   1306          * {@hide}
   1307          */
   1308         public int needsMenuKey = NEEDS_MENU_UNSET;
   1309 
   1310         /**
   1311          * Given a particular set of window manager flags, determine whether
   1312          * such a window may be a target for an input method when it has
   1313          * focus.  In particular, this checks the
   1314          * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
   1315          * flags and returns true if the combination of the two corresponds
   1316          * to a window that needs to be behind the input method so that the
   1317          * user can type into it.
   1318          *
   1319          * @param flags The current window manager flags.
   1320          *
   1321          * @return Returns true if such a window should be behind/interact
   1322          * with an input method, false if not.
   1323          */
   1324         public static boolean mayUseInputMethod(int flags) {
   1325             switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
   1326                 case 0:
   1327                 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
   1328                     return true;
   1329             }
   1330             return false;
   1331         }
   1332 
   1333         /**
   1334          * Mask for {@link #softInputMode} of the bits that determine the
   1335          * desired visibility state of the soft input area for this window.
   1336          */
   1337         public static final int SOFT_INPUT_MASK_STATE = 0x0f;
   1338 
   1339         /**
   1340          * Visibility state for {@link #softInputMode}: no state has been specified.
   1341          */
   1342         public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
   1343 
   1344         /**
   1345          * Visibility state for {@link #softInputMode}: please don't change the state of
   1346          * the soft input area.
   1347          */
   1348         public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
   1349 
   1350         /**
   1351          * Visibility state for {@link #softInputMode}: please hide any soft input
   1352          * area when normally appropriate (when the user is navigating
   1353          * forward to your window).
   1354          */
   1355         public static final int SOFT_INPUT_STATE_HIDDEN = 2;
   1356 
   1357         /**
   1358          * Visibility state for {@link #softInputMode}: please always hide any
   1359          * soft input area when this window receives focus.
   1360          */
   1361         public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
   1362 
   1363         /**
   1364          * Visibility state for {@link #softInputMode}: please show the soft
   1365          * input area when normally appropriate (when the user is navigating
   1366          * forward to your window).
   1367          */
   1368         public static final int SOFT_INPUT_STATE_VISIBLE = 4;
   1369 
   1370         /**
   1371          * Visibility state for {@link #softInputMode}: please always make the
   1372          * soft input area visible when this window receives input focus.
   1373          */
   1374         public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
   1375 
   1376         /**
   1377          * Mask for {@link #softInputMode} of the bits that determine the
   1378          * way that the window should be adjusted to accommodate the soft
   1379          * input window.
   1380          */
   1381         public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
   1382 
   1383         /** Adjustment option for {@link #softInputMode}: nothing specified.
   1384          * The system will try to pick one or
   1385          * the other depending on the contents of the window.
   1386          */
   1387         public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
   1388 
   1389         /** Adjustment option for {@link #softInputMode}: set to allow the
   1390          * window to be resized when an input
   1391          * method is shown, so that its contents are not covered by the input
   1392          * method.  This can <em>not</em> be combined with
   1393          * {@link #SOFT_INPUT_ADJUST_PAN}; if
   1394          * neither of these are set, then the system will try to pick one or
   1395          * the other depending on the contents of the window. If the window's
   1396          * layout parameter flags include {@link #FLAG_FULLSCREEN}, this
   1397          * value for {@link #softInputMode} will be ignored; the window will
   1398          * not resize, but will stay fullscreen.
   1399          */
   1400         public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
   1401 
   1402         /** Adjustment option for {@link #softInputMode}: set to have a window
   1403          * pan when an input method is
   1404          * shown, so it doesn't need to deal with resizing but just panned
   1405          * by the framework to ensure the current input focus is visible.  This
   1406          * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
   1407          * neither of these are set, then the system will try to pick one or
   1408          * the other depending on the contents of the window.
   1409          */
   1410         public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
   1411 
   1412         /** Adjustment option for {@link #softInputMode}: set to have a window
   1413          * not adjust for a shown input method.  The window will not be resized,
   1414          * and it will not be panned to make its focus visible.
   1415          */
   1416         public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30;
   1417 
   1418         /**
   1419          * Bit for {@link #softInputMode}: set when the user has navigated
   1420          * forward to the window.  This is normally set automatically for
   1421          * you by the system, though you may want to set it in certain cases
   1422          * when you are displaying a window yourself.  This flag will always
   1423          * be cleared automatically after the window is displayed.
   1424          */
   1425         public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
   1426 
   1427         /**
   1428          * Desired operating mode for any soft input area.  May be any combination
   1429          * of:
   1430          *
   1431          * <ul>
   1432          * <li> One of the visibility states
   1433          * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
   1434          * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or
   1435          * {@link #SOFT_INPUT_STATE_VISIBLE}.
   1436          * <li> One of the adjustment options
   1437          * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED},
   1438          * {@link #SOFT_INPUT_ADJUST_RESIZE}, or
   1439          * {@link #SOFT_INPUT_ADJUST_PAN}.
   1440          * </ul>
   1441          *
   1442          *
   1443          * <p>This flag can be controlled in your theme through the
   1444          * {@link android.R.attr#windowSoftInputMode} attribute.</p>
   1445          */
   1446         public int softInputMode;
   1447 
   1448         /**
   1449          * Placement of window within the screen as per {@link Gravity}.  Both
   1450          * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
   1451          * android.graphics.Rect) Gravity.apply} and
   1452          * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
   1453          * Gravity.applyDisplay} are used during window layout, with this value
   1454          * given as the desired gravity.  For example you can specify
   1455          * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and
   1456          * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here
   1457          * to control the behavior of
   1458          * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
   1459          * Gravity.applyDisplay}.
   1460          *
   1461          * @see Gravity
   1462          */
   1463         public int gravity;
   1464 
   1465         /**
   1466          * The horizontal margin, as a percentage of the container's width,
   1467          * between the container and the widget.  See
   1468          * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
   1469          * android.graphics.Rect) Gravity.apply} for how this is used.  This
   1470          * field is added with {@link #x} to supply the <var>xAdj</var> parameter.
   1471          */
   1472         public float horizontalMargin;
   1473 
   1474         /**
   1475          * The vertical margin, as a percentage of the container's height,
   1476          * between the container and the widget.  See
   1477          * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
   1478          * android.graphics.Rect) Gravity.apply} for how this is used.  This
   1479          * field is added with {@link #y} to supply the <var>yAdj</var> parameter.
   1480          */
   1481         public float verticalMargin;
   1482 
   1483         /**
   1484          * Positive insets between the drawing surface and window content.
   1485          *
   1486          * @hide
   1487          */
   1488         public final Rect surfaceInsets = new Rect();
   1489 
   1490         /**
   1491          * Whether the surface insets have been manually set. When set to
   1492          * {@code false}, the view root will automatically determine the
   1493          * appropriate surface insets.
   1494          *
   1495          * @see #surfaceInsets
   1496          * @hide
   1497          */
   1498         public boolean hasManualSurfaceInsets;
   1499 
   1500         /**
   1501          * Whether the previous surface insets should be used vs. what is currently set. When set
   1502          * to {@code true}, the view root will ignore surfaces insets in this object and use what
   1503          * it currently has.
   1504          *
   1505          * @see #surfaceInsets
   1506          * @hide
   1507          */
   1508         public boolean preservePreviousSurfaceInsets = true;
   1509 
   1510         /**
   1511          * The desired bitmap format.  May be one of the constants in
   1512          * {@link android.graphics.PixelFormat}.  Default is OPAQUE.
   1513          */
   1514         public int format;
   1515 
   1516         /**
   1517          * A style resource defining the animations to use for this window.
   1518          * This must be a system resource; it can not be an application resource
   1519          * because the window manager does not have access to applications.
   1520          */
   1521         public int windowAnimations;
   1522 
   1523         /**
   1524          * An alpha value to apply to this entire window.
   1525          * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
   1526          */
   1527         public float alpha = 1.0f;
   1528 
   1529         /**
   1530          * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
   1531          * to apply.  Range is from 1.0 for completely opaque to 0.0 for no
   1532          * dim.
   1533          */
   1534         public float dimAmount = 1.0f;
   1535 
   1536         /**
   1537          * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
   1538          * indicating that the brightness value is not overridden for this window
   1539          * and normal brightness policy should be used.
   1540          */
   1541         public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
   1542 
   1543         /**
   1544          * Value for {@link #screenBrightness} and {@link #buttonBrightness}
   1545          * indicating that the screen or button backlight brightness should be set
   1546          * to the lowest value when this window is in front.
   1547          */
   1548         public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
   1549 
   1550         /**
   1551          * Value for {@link #screenBrightness} and {@link #buttonBrightness}
   1552          * indicating that the screen or button backlight brightness should be set
   1553          * to the hightest value when this window is in front.
   1554          */
   1555         public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
   1556 
   1557         /**
   1558          * This can be used to override the user's preferred brightness of
   1559          * the screen.  A value of less than 0, the default, means to use the
   1560          * preferred screen brightness.  0 to 1 adjusts the brightness from
   1561          * dark to full bright.
   1562          */
   1563         public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
   1564 
   1565         /**
   1566          * This can be used to override the standard behavior of the button and
   1567          * keyboard backlights.  A value of less than 0, the default, means to
   1568          * use the standard backlight behavior.  0 to 1 adjusts the brightness
   1569          * from dark to full bright.
   1570          */
   1571         public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
   1572 
   1573         /**
   1574          * Value for {@link #rotationAnimation} to define the animation used to
   1575          * specify that this window will rotate in or out following a rotation.
   1576          */
   1577         public static final int ROTATION_ANIMATION_ROTATE = 0;
   1578 
   1579         /**
   1580          * Value for {@link #rotationAnimation} to define the animation used to
   1581          * specify that this window will fade in or out following a rotation.
   1582          */
   1583         public static final int ROTATION_ANIMATION_CROSSFADE = 1;
   1584 
   1585         /**
   1586          * Value for {@link #rotationAnimation} to define the animation used to
   1587          * specify that this window will immediately disappear or appear following
   1588          * a rotation.
   1589          */
   1590         public static final int ROTATION_ANIMATION_JUMPCUT = 2;
   1591 
   1592         /**
   1593          * Value for {@link #rotationAnimation} to specify seamless rotation mode.
   1594          * This works like JUMPCUT but will fall back to CROSSFADE if rotation
   1595          * can't be applied without pausing the screen.
   1596          *
   1597          * @hide
   1598          */
   1599         public static final int ROTATION_ANIMATION_SEAMLESS = 3;
   1600 
   1601         /**
   1602          * Define the exit and entry animations used on this window when the device is rotated.
   1603          * This only has an affect if the incoming and outgoing topmost
   1604          * opaque windows have the #FLAG_FULLSCREEN bit set and are not covered
   1605          * by other windows. All other situations default to the
   1606          * {@link #ROTATION_ANIMATION_ROTATE} behavior.
   1607          *
   1608          * @see #ROTATION_ANIMATION_ROTATE
   1609          * @see #ROTATION_ANIMATION_CROSSFADE
   1610          * @see #ROTATION_ANIMATION_JUMPCUT
   1611          */
   1612         public int rotationAnimation = ROTATION_ANIMATION_ROTATE;
   1613 
   1614         /**
   1615          * Identifier for this window.  This will usually be filled in for
   1616          * you.
   1617          */
   1618         public IBinder token = null;
   1619 
   1620         /**
   1621          * Name of the package owning this window.
   1622          */
   1623         public String packageName = null;
   1624 
   1625         /**
   1626          * Specific orientation value for a window.
   1627          * May be any of the same values allowed
   1628          * for {@link android.content.pm.ActivityInfo#screenOrientation}.
   1629          * If not set, a default value of
   1630          * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
   1631          * will be used.
   1632          */
   1633         public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
   1634 
   1635         /**
   1636          * The preferred refresh rate for the window.
   1637          *
   1638          * This must be one of the supported refresh rates obtained for the display(s) the window
   1639          * is on. The selected refresh rate will be applied to the display's default mode.
   1640          *
   1641          * This value is ignored if {@link #preferredDisplayModeId} is set.
   1642          *
   1643          * @see Display#getSupportedRefreshRates()
   1644          * @deprecated use {@link #preferredDisplayModeId} instead
   1645          */
   1646         @Deprecated
   1647         public float preferredRefreshRate;
   1648 
   1649         /**
   1650          * Id of the preferred display mode for the window.
   1651          * <p>
   1652          * This must be one of the supported modes obtained for the display(s) the window is on.
   1653          * A value of {@code 0} means no preference.
   1654          *
   1655          * @see Display#getSupportedModes()
   1656          * @see Display.Mode#getModeId()
   1657          */
   1658         public int preferredDisplayModeId;
   1659 
   1660         /**
   1661          * Control the visibility of the status bar.
   1662          *
   1663          * @see View#STATUS_BAR_VISIBLE
   1664          * @see View#STATUS_BAR_HIDDEN
   1665          */
   1666         public int systemUiVisibility;
   1667 
   1668         /**
   1669          * @hide
   1670          * The ui visibility as requested by the views in this hierarchy.
   1671          * the combined value should be systemUiVisibility | subtreeSystemUiVisibility.
   1672          */
   1673         public int subtreeSystemUiVisibility;
   1674 
   1675         /**
   1676          * Get callbacks about the system ui visibility changing.
   1677          *
   1678          * TODO: Maybe there should be a bitfield of optional callbacks that we need.
   1679          *
   1680          * @hide
   1681          */
   1682         public boolean hasSystemUiListeners;
   1683 
   1684         /**
   1685          * When this window has focus, disable touch pad pointer gesture processing.
   1686          * The window will receive raw position updates from the touch pad instead
   1687          * of pointer movements and synthetic touch events.
   1688          *
   1689          * @hide
   1690          */
   1691         public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001;
   1692 
   1693         /**
   1694          * Does not construct an input channel for this window.  The channel will therefore
   1695          * be incapable of receiving input.
   1696          *
   1697          * @hide
   1698          */
   1699         public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002;
   1700 
   1701         /**
   1702          * When this window has focus, does not call user activity for all input events so
   1703          * the application will have to do it itself.  Should only be used by
   1704          * the keyguard and phone app.
   1705          * <p>
   1706          * Should only be used by the keyguard and phone app.
   1707          * </p>
   1708          *
   1709          * @hide
   1710          */
   1711         public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004;
   1712 
   1713         /**
   1714          * Control special features of the input subsystem.
   1715          *
   1716          * @see #INPUT_FEATURE_DISABLE_POINTER_GESTURES
   1717          * @see #INPUT_FEATURE_NO_INPUT_CHANNEL
   1718          * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY
   1719          * @hide
   1720          */
   1721         public int inputFeatures;
   1722 
   1723         /**
   1724          * Sets the number of milliseconds before the user activity timeout occurs
   1725          * when this window has focus.  A value of -1 uses the standard timeout.
   1726          * A value of 0 uses the minimum support display timeout.
   1727          * <p>
   1728          * This property can only be used to reduce the user specified display timeout;
   1729          * it can never make the timeout longer than it normally would be.
   1730          * </p><p>
   1731          * Should only be used by the keyguard and phone app.
   1732          * </p>
   1733          *
   1734          * @hide
   1735          */
   1736         public long userActivityTimeout = -1;
   1737 
   1738         /**
   1739          * For windows with an anchor (e.g. PopupWindow), keeps track of the View that anchors the
   1740          * window.
   1741          *
   1742          * @hide
   1743          */
   1744         public int accessibilityIdOfAnchor = -1;
   1745 
   1746         /**
   1747          * The window title isn't kept in sync with what is displayed in the title bar, so we
   1748          * separately track the currently shown title to provide to accessibility.
   1749          *
   1750          * @hide
   1751          */
   1752         public CharSequence accessibilityTitle;
   1753 
   1754         /**
   1755          * Sets a timeout in milliseconds before which the window will be removed
   1756          * by the window manager. Useful for transient notifications like toasts
   1757          * so we don't have to rely on client cooperation to ensure the window
   1758          * is removed. Must be specified at window creation time.
   1759          *
   1760          * @hide
   1761          */
   1762         public long removeTimeoutMilliseconds = -1;
   1763 
   1764         public LayoutParams() {
   1765             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
   1766             type = TYPE_APPLICATION;
   1767             format = PixelFormat.OPAQUE;
   1768         }
   1769 
   1770         public LayoutParams(int _type) {
   1771             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
   1772             type = _type;
   1773             format = PixelFormat.OPAQUE;
   1774         }
   1775 
   1776         public LayoutParams(int _type, int _flags) {
   1777             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
   1778             type = _type;
   1779             flags = _flags;
   1780             format = PixelFormat.OPAQUE;
   1781         }
   1782 
   1783         public LayoutParams(int _type, int _flags, int _format) {
   1784             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
   1785             type = _type;
   1786             flags = _flags;
   1787             format = _format;
   1788         }
   1789 
   1790         public LayoutParams(int w, int h, int _type, int _flags, int _format) {
   1791             super(w, h);
   1792             type = _type;
   1793             flags = _flags;
   1794             format = _format;
   1795         }
   1796 
   1797         public LayoutParams(int w, int h, int xpos, int ypos, int _type,
   1798                 int _flags, int _format) {
   1799             super(w, h);
   1800             x = xpos;
   1801             y = ypos;
   1802             type = _type;
   1803             flags = _flags;
   1804             format = _format;
   1805         }
   1806 
   1807         public final void setTitle(CharSequence title) {
   1808             if (null == title)
   1809                 title = "";
   1810 
   1811             mTitle = TextUtils.stringOrSpannedString(title);
   1812         }
   1813 
   1814         public final CharSequence getTitle() {
   1815             return mTitle != null ? mTitle : "";
   1816         }
   1817 
   1818         /**
   1819          * Sets the surface insets based on the elevation (visual z position) of the input view.
   1820          * @hide
   1821          */
   1822         public final void setSurfaceInsets(View view, boolean manual, boolean preservePrevious) {
   1823             final int surfaceInset = (int) Math.ceil(view.getZ() * 2);
   1824             // Partial workaround for b/28318973. Every inset change causes a freeform window
   1825             // to jump a little for a few frames. If we never allow surface insets to decrease,
   1826             // they will stabilize quickly (often from the very beginning, as most windows start
   1827             // as focused).
   1828             // TODO(b/22668382) to fix this properly.
   1829             if (surfaceInset == 0) {
   1830                 // OK to have 0 (this is the case for non-freeform windows).
   1831                 surfaceInsets.set(0, 0, 0, 0);
   1832             } else {
   1833                 surfaceInsets.set(
   1834                         Math.max(surfaceInset, surfaceInsets.left),
   1835                         Math.max(surfaceInset, surfaceInsets.top),
   1836                         Math.max(surfaceInset, surfaceInsets.right),
   1837                         Math.max(surfaceInset, surfaceInsets.bottom));
   1838             }
   1839             hasManualSurfaceInsets = manual;
   1840             preservePreviousSurfaceInsets = preservePrevious;
   1841         }
   1842 
   1843         /** @hide */
   1844         @SystemApi
   1845         public final void setUserActivityTimeout(long timeout) {
   1846             userActivityTimeout = timeout;
   1847         }
   1848 
   1849         /** @hide */
   1850         @SystemApi
   1851         public final long getUserActivityTimeout() {
   1852             return userActivityTimeout;
   1853         }
   1854 
   1855         public int describeContents() {
   1856             return 0;
   1857         }
   1858 
   1859         public void writeToParcel(Parcel out, int parcelableFlags) {
   1860             out.writeInt(width);
   1861             out.writeInt(height);
   1862             out.writeInt(x);
   1863             out.writeInt(y);
   1864             out.writeInt(type);
   1865             out.writeInt(flags);
   1866             out.writeInt(privateFlags);
   1867             out.writeInt(softInputMode);
   1868             out.writeInt(gravity);
   1869             out.writeFloat(horizontalMargin);
   1870             out.writeFloat(verticalMargin);
   1871             out.writeInt(format);
   1872             out.writeInt(windowAnimations);
   1873             out.writeFloat(alpha);
   1874             out.writeFloat(dimAmount);
   1875             out.writeFloat(screenBrightness);
   1876             out.writeFloat(buttonBrightness);
   1877             out.writeInt(rotationAnimation);
   1878             out.writeStrongBinder(token);
   1879             out.writeString(packageName);
   1880             TextUtils.writeToParcel(mTitle, out, parcelableFlags);
   1881             out.writeInt(screenOrientation);
   1882             out.writeFloat(preferredRefreshRate);
   1883             out.writeInt(preferredDisplayModeId);
   1884             out.writeInt(systemUiVisibility);
   1885             out.writeInt(subtreeSystemUiVisibility);
   1886             out.writeInt(hasSystemUiListeners ? 1 : 0);
   1887             out.writeInt(inputFeatures);
   1888             out.writeLong(userActivityTimeout);
   1889             out.writeInt(surfaceInsets.left);
   1890             out.writeInt(surfaceInsets.top);
   1891             out.writeInt(surfaceInsets.right);
   1892             out.writeInt(surfaceInsets.bottom);
   1893             out.writeInt(hasManualSurfaceInsets ? 1 : 0);
   1894             out.writeInt(preservePreviousSurfaceInsets ? 1 : 0);
   1895             out.writeInt(needsMenuKey);
   1896             out.writeInt(accessibilityIdOfAnchor);
   1897             TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags);
   1898             out.writeLong(removeTimeoutMilliseconds);
   1899         }
   1900 
   1901         public static final Parcelable.Creator<LayoutParams> CREATOR
   1902                     = new Parcelable.Creator<LayoutParams>() {
   1903             public LayoutParams createFromParcel(Parcel in) {
   1904                 return new LayoutParams(in);
   1905             }
   1906 
   1907             public LayoutParams[] newArray(int size) {
   1908                 return new LayoutParams[size];
   1909             }
   1910         };
   1911 
   1912 
   1913         public LayoutParams(Parcel in) {
   1914             width = in.readInt();
   1915             height = in.readInt();
   1916             x = in.readInt();
   1917             y = in.readInt();
   1918             type = in.readInt();
   1919             flags = in.readInt();
   1920             privateFlags = in.readInt();
   1921             softInputMode = in.readInt();
   1922             gravity = in.readInt();
   1923             horizontalMargin = in.readFloat();
   1924             verticalMargin = in.readFloat();
   1925             format = in.readInt();
   1926             windowAnimations = in.readInt();
   1927             alpha = in.readFloat();
   1928             dimAmount = in.readFloat();
   1929             screenBrightness = in.readFloat();
   1930             buttonBrightness = in.readFloat();
   1931             rotationAnimation = in.readInt();
   1932             token = in.readStrongBinder();
   1933             packageName = in.readString();
   1934             mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
   1935             screenOrientation = in.readInt();
   1936             preferredRefreshRate = in.readFloat();
   1937             preferredDisplayModeId = in.readInt();
   1938             systemUiVisibility = in.readInt();
   1939             subtreeSystemUiVisibility = in.readInt();
   1940             hasSystemUiListeners = in.readInt() != 0;
   1941             inputFeatures = in.readInt();
   1942             userActivityTimeout = in.readLong();
   1943             surfaceInsets.left = in.readInt();
   1944             surfaceInsets.top = in.readInt();
   1945             surfaceInsets.right = in.readInt();
   1946             surfaceInsets.bottom = in.readInt();
   1947             hasManualSurfaceInsets = in.readInt() != 0;
   1948             preservePreviousSurfaceInsets = in.readInt() != 0;
   1949             needsMenuKey = in.readInt();
   1950             accessibilityIdOfAnchor = in.readInt();
   1951             accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
   1952             removeTimeoutMilliseconds = in.readLong();
   1953         }
   1954 
   1955         @SuppressWarnings({"PointlessBitwiseExpression"})
   1956         public static final int LAYOUT_CHANGED = 1<<0;
   1957         public static final int TYPE_CHANGED = 1<<1;
   1958         public static final int FLAGS_CHANGED = 1<<2;
   1959         public static final int FORMAT_CHANGED = 1<<3;
   1960         public static final int ANIMATION_CHANGED = 1<<4;
   1961         public static final int DIM_AMOUNT_CHANGED = 1<<5;
   1962         public static final int TITLE_CHANGED = 1<<6;
   1963         public static final int ALPHA_CHANGED = 1<<7;
   1964         public static final int MEMORY_TYPE_CHANGED = 1<<8;
   1965         public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
   1966         public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
   1967         public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
   1968         public static final int ROTATION_ANIMATION_CHANGED = 1<<12;
   1969         /** {@hide} */
   1970         public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<13;
   1971         /** {@hide} */
   1972         public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<14;
   1973         /** {@hide} */
   1974         public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<15;
   1975         /** {@hide} */
   1976         public static final int INPUT_FEATURES_CHANGED = 1<<16;
   1977         /** {@hide} */
   1978         public static final int PRIVATE_FLAGS_CHANGED = 1<<17;
   1979         /** {@hide} */
   1980         public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<18;
   1981         /** {@hide} */
   1982         public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19;
   1983         /** {@hide} */
   1984         public static final int SURFACE_INSETS_CHANGED = 1<<20;
   1985         /** {@hide} */
   1986         public static final int PREFERRED_REFRESH_RATE_CHANGED = 1 << 21;
   1987         /** {@hide} */
   1988         public static final int NEEDS_MENU_KEY_CHANGED = 1 << 22;
   1989         /** {@hide} */
   1990         public static final int PREFERRED_DISPLAY_MODE_ID = 1 << 23;
   1991         /** {@hide} */
   1992         public static final int ACCESSIBILITY_ANCHOR_CHANGED = 1 << 24;
   1993         /** {@hide} */
   1994         public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25;
   1995         /** {@hide} */
   1996         public static final int EVERYTHING_CHANGED = 0xffffffff;
   1997 
   1998         // internal buffer to backup/restore parameters under compatibility mode.
   1999         private int[] mCompatibilityParamsBackup = null;
   2000 
   2001         public final int copyFrom(LayoutParams o) {
   2002             int changes = 0;
   2003 
   2004             if (width != o.width) {
   2005                 width = o.width;
   2006                 changes |= LAYOUT_CHANGED;
   2007             }
   2008             if (height != o.height) {
   2009                 height = o.height;
   2010                 changes |= LAYOUT_CHANGED;
   2011             }
   2012             if (x != o.x) {
   2013                 x = o.x;
   2014                 changes |= LAYOUT_CHANGED;
   2015             }
   2016             if (y != o.y) {
   2017                 y = o.y;
   2018                 changes |= LAYOUT_CHANGED;
   2019             }
   2020             if (horizontalWeight != o.horizontalWeight) {
   2021                 horizontalWeight = o.horizontalWeight;
   2022                 changes |= LAYOUT_CHANGED;
   2023             }
   2024             if (verticalWeight != o.verticalWeight) {
   2025                 verticalWeight = o.verticalWeight;
   2026                 changes |= LAYOUT_CHANGED;
   2027             }
   2028             if (horizontalMargin != o.horizontalMargin) {
   2029                 horizontalMargin = o.horizontalMargin;
   2030                 changes |= LAYOUT_CHANGED;
   2031             }
   2032             if (verticalMargin != o.verticalMargin) {
   2033                 verticalMargin = o.verticalMargin;
   2034                 changes |= LAYOUT_CHANGED;
   2035             }
   2036             if (type != o.type) {
   2037                 type = o.type;
   2038                 changes |= TYPE_CHANGED;
   2039             }
   2040             if (flags != o.flags) {
   2041                 final int diff = flags ^ o.flags;
   2042                 if ((diff & (FLAG_TRANSLUCENT_STATUS | FLAG_TRANSLUCENT_NAVIGATION)) != 0) {
   2043                     changes |= TRANSLUCENT_FLAGS_CHANGED;
   2044                 }
   2045                 flags = o.flags;
   2046                 changes |= FLAGS_CHANGED;
   2047             }
   2048             if (privateFlags != o.privateFlags) {
   2049                 privateFlags = o.privateFlags;
   2050                 changes |= PRIVATE_FLAGS_CHANGED;
   2051             }
   2052             if (softInputMode != o.softInputMode) {
   2053                 softInputMode = o.softInputMode;
   2054                 changes |= SOFT_INPUT_MODE_CHANGED;
   2055             }
   2056             if (gravity != o.gravity) {
   2057                 gravity = o.gravity;
   2058                 changes |= LAYOUT_CHANGED;
   2059             }
   2060             if (format != o.format) {
   2061                 format = o.format;
   2062                 changes |= FORMAT_CHANGED;
   2063             }
   2064             if (windowAnimations != o.windowAnimations) {
   2065                 windowAnimations = o.windowAnimations;
   2066                 changes |= ANIMATION_CHANGED;
   2067             }
   2068             if (token == null) {
   2069                 // NOTE: token only copied if the recipient doesn't
   2070                 // already have one.
   2071                 token = o.token;
   2072             }
   2073             if (packageName == null) {
   2074                 // NOTE: packageName only copied if the recipient doesn't
   2075                 // already have one.
   2076                 packageName = o.packageName;
   2077             }
   2078             if (!Objects.equals(mTitle, o.mTitle) && o.mTitle != null) {
   2079                 // NOTE: mTitle only copied if the originator set one.
   2080                 mTitle = o.mTitle;
   2081                 changes |= TITLE_CHANGED;
   2082             }
   2083             if (alpha != o.alpha) {
   2084                 alpha = o.alpha;
   2085                 changes |= ALPHA_CHANGED;
   2086             }
   2087             if (dimAmount != o.dimAmount) {
   2088                 dimAmount = o.dimAmount;
   2089                 changes |= DIM_AMOUNT_CHANGED;
   2090             }
   2091             if (screenBrightness != o.screenBrightness) {
   2092                 screenBrightness = o.screenBrightness;
   2093                 changes |= SCREEN_BRIGHTNESS_CHANGED;
   2094             }
   2095             if (buttonBrightness != o.buttonBrightness) {
   2096                 buttonBrightness = o.buttonBrightness;
   2097                 changes |= BUTTON_BRIGHTNESS_CHANGED;
   2098             }
   2099             if (rotationAnimation != o.rotationAnimation) {
   2100                 rotationAnimation = o.rotationAnimation;
   2101                 changes |= ROTATION_ANIMATION_CHANGED;
   2102             }
   2103 
   2104             if (screenOrientation != o.screenOrientation) {
   2105                 screenOrientation = o.screenOrientation;
   2106                 changes |= SCREEN_ORIENTATION_CHANGED;
   2107             }
   2108 
   2109             if (preferredRefreshRate != o.preferredRefreshRate) {
   2110                 preferredRefreshRate = o.preferredRefreshRate;
   2111                 changes |= PREFERRED_REFRESH_RATE_CHANGED;
   2112             }
   2113 
   2114             if (preferredDisplayModeId != o.preferredDisplayModeId) {
   2115                 preferredDisplayModeId = o.preferredDisplayModeId;
   2116                 changes |= PREFERRED_DISPLAY_MODE_ID;
   2117             }
   2118 
   2119             if (systemUiVisibility != o.systemUiVisibility
   2120                     || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
   2121                 systemUiVisibility = o.systemUiVisibility;
   2122                 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility;
   2123                 changes |= SYSTEM_UI_VISIBILITY_CHANGED;
   2124             }
   2125 
   2126             if (hasSystemUiListeners != o.hasSystemUiListeners) {
   2127                 hasSystemUiListeners = o.hasSystemUiListeners;
   2128                 changes |= SYSTEM_UI_LISTENER_CHANGED;
   2129             }
   2130 
   2131             if (inputFeatures != o.inputFeatures) {
   2132                 inputFeatures = o.inputFeatures;
   2133                 changes |= INPUT_FEATURES_CHANGED;
   2134             }
   2135 
   2136             if (userActivityTimeout != o.userActivityTimeout) {
   2137                 userActivityTimeout = o.userActivityTimeout;
   2138                 changes |= USER_ACTIVITY_TIMEOUT_CHANGED;
   2139             }
   2140 
   2141             if (!surfaceInsets.equals(o.surfaceInsets)) {
   2142                 surfaceInsets.set(o.surfaceInsets);
   2143                 changes |= SURFACE_INSETS_CHANGED;
   2144             }
   2145 
   2146             if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) {
   2147                 hasManualSurfaceInsets = o.hasManualSurfaceInsets;
   2148                 changes |= SURFACE_INSETS_CHANGED;
   2149             }
   2150 
   2151             if (preservePreviousSurfaceInsets != o.preservePreviousSurfaceInsets) {
   2152                 preservePreviousSurfaceInsets = o.preservePreviousSurfaceInsets;
   2153                 changes |= SURFACE_INSETS_CHANGED;
   2154             }
   2155 
   2156             if (needsMenuKey != o.needsMenuKey) {
   2157                 needsMenuKey = o.needsMenuKey;
   2158                 changes |= NEEDS_MENU_KEY_CHANGED;
   2159             }
   2160 
   2161             if (accessibilityIdOfAnchor != o.accessibilityIdOfAnchor) {
   2162                 accessibilityIdOfAnchor = o.accessibilityIdOfAnchor;
   2163                 changes |= ACCESSIBILITY_ANCHOR_CHANGED;
   2164             }
   2165 
   2166             if (!Objects.equals(accessibilityTitle, o.accessibilityTitle)
   2167                     && o.accessibilityTitle != null) {
   2168                 // NOTE: accessibilityTitle only copied if the originator set one.
   2169                 accessibilityTitle = o.accessibilityTitle;
   2170                 changes |= ACCESSIBILITY_TITLE_CHANGED;
   2171             }
   2172 
   2173             // This can't change, it's only set at window creation time.
   2174             removeTimeoutMilliseconds = o.removeTimeoutMilliseconds;
   2175 
   2176             return changes;
   2177         }
   2178 
   2179         @Override
   2180         public String debug(String output) {
   2181             output += "Contents of " + this + ":";
   2182             Log.d("Debug", output);
   2183             output = super.debug("");
   2184             Log.d("Debug", output);
   2185             Log.d("Debug", "");
   2186             Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
   2187             return "";
   2188         }
   2189 
   2190         @Override
   2191         public String toString() {
   2192             StringBuilder sb = new StringBuilder(256);
   2193             sb.append("WM.LayoutParams{");
   2194             sb.append("(");
   2195             sb.append(x);
   2196             sb.append(',');
   2197             sb.append(y);
   2198             sb.append(")(");
   2199             sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width)));
   2200             sb.append('x');
   2201             sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height)));
   2202             sb.append(")");
   2203             if (horizontalMargin != 0) {
   2204                 sb.append(" hm=");
   2205                 sb.append(horizontalMargin);
   2206             }
   2207             if (verticalMargin != 0) {
   2208                 sb.append(" vm=");
   2209                 sb.append(verticalMargin);
   2210             }
   2211             if (gravity != 0) {
   2212                 sb.append(" gr=#");
   2213                 sb.append(Integer.toHexString(gravity));
   2214             }
   2215             if (softInputMode != 0) {
   2216                 sb.append(" sim=#");
   2217                 sb.append(Integer.toHexString(softInputMode));
   2218             }
   2219             sb.append(" ty=");
   2220             sb.append(type);
   2221             sb.append(" fl=#");
   2222             sb.append(Integer.toHexString(flags));
   2223             if (privateFlags != 0) {
   2224                 if ((privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0) {
   2225                     sb.append(" compatible=true");
   2226                 }
   2227                 sb.append(" pfl=0x").append(Integer.toHexString(privateFlags));
   2228             }
   2229             if (format != PixelFormat.OPAQUE) {
   2230                 sb.append(" fmt=");
   2231                 sb.append(format);
   2232             }
   2233             if (windowAnimations != 0) {
   2234                 sb.append(" wanim=0x");
   2235                 sb.append(Integer.toHexString(windowAnimations));
   2236             }
   2237             if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
   2238                 sb.append(" or=");
   2239                 sb.append(screenOrientation);
   2240             }
   2241             if (alpha != 1.0f) {
   2242                 sb.append(" alpha=");
   2243                 sb.append(alpha);
   2244             }
   2245             if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) {
   2246                 sb.append(" sbrt=");
   2247                 sb.append(screenBrightness);
   2248             }
   2249             if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) {
   2250                 sb.append(" bbrt=");
   2251                 sb.append(buttonBrightness);
   2252             }
   2253             if (rotationAnimation != ROTATION_ANIMATION_ROTATE) {
   2254                 sb.append(" rotAnim=");
   2255                 sb.append(rotationAnimation);
   2256             }
   2257             if (preferredRefreshRate != 0) {
   2258                 sb.append(" preferredRefreshRate=");
   2259                 sb.append(preferredRefreshRate);
   2260             }
   2261             if (preferredDisplayModeId != 0) {
   2262                 sb.append(" preferredDisplayMode=");
   2263                 sb.append(preferredDisplayModeId);
   2264             }
   2265             if (systemUiVisibility != 0) {
   2266                 sb.append(" sysui=0x");
   2267                 sb.append(Integer.toHexString(systemUiVisibility));
   2268             }
   2269             if (subtreeSystemUiVisibility != 0) {
   2270                 sb.append(" vsysui=0x");
   2271                 sb.append(Integer.toHexString(subtreeSystemUiVisibility));
   2272             }
   2273             if (hasSystemUiListeners) {
   2274                 sb.append(" sysuil=");
   2275                 sb.append(hasSystemUiListeners);
   2276             }
   2277             if (inputFeatures != 0) {
   2278                 sb.append(" if=0x").append(Integer.toHexString(inputFeatures));
   2279             }
   2280             if (userActivityTimeout >= 0) {
   2281                 sb.append(" userActivityTimeout=").append(userActivityTimeout);
   2282             }
   2283             if (surfaceInsets.left != 0 || surfaceInsets.top != 0 || surfaceInsets.right != 0 ||
   2284                     surfaceInsets.bottom != 0 || hasManualSurfaceInsets
   2285                     || !preservePreviousSurfaceInsets) {
   2286                 sb.append(" surfaceInsets=").append(surfaceInsets);
   2287                 if (hasManualSurfaceInsets) {
   2288                     sb.append(" (manual)");
   2289                 }
   2290                 if (!preservePreviousSurfaceInsets) {
   2291                     sb.append(" (!preservePreviousSurfaceInsets)");
   2292                 }
   2293             }
   2294             if (needsMenuKey != NEEDS_MENU_UNSET) {
   2295                 sb.append(" needsMenuKey=");
   2296                 sb.append(needsMenuKey);
   2297             }
   2298             sb.append('}');
   2299             return sb.toString();
   2300         }
   2301 
   2302         /**
   2303          * Scale the layout params' coordinates and size.
   2304          * @hide
   2305          */
   2306         public void scale(float scale) {
   2307             x = (int) (x * scale + 0.5f);
   2308             y = (int) (y * scale + 0.5f);
   2309             if (width > 0) {
   2310                 width = (int) (width * scale + 0.5f);
   2311             }
   2312             if (height > 0) {
   2313                 height = (int) (height * scale + 0.5f);
   2314             }
   2315         }
   2316 
   2317         /**
   2318          * Backup the layout parameters used in compatibility mode.
   2319          * @see LayoutParams#restore()
   2320          */
   2321         void backup() {
   2322             int[] backup = mCompatibilityParamsBackup;
   2323             if (backup == null) {
   2324                 // we backup 4 elements, x, y, width, height
   2325                 backup = mCompatibilityParamsBackup = new int[4];
   2326             }
   2327             backup[0] = x;
   2328             backup[1] = y;
   2329             backup[2] = width;
   2330             backup[3] = height;
   2331         }
   2332 
   2333         /**
   2334          * Restore the layout params' coordinates, size and gravity
   2335          * @see LayoutParams#backup()
   2336          */
   2337         void restore() {
   2338             int[] backup = mCompatibilityParamsBackup;
   2339             if (backup != null) {
   2340                 x = backup[0];
   2341                 y = backup[1];
   2342                 width = backup[2];
   2343                 height = backup[3];
   2344             }
   2345         }
   2346 
   2347         private CharSequence mTitle = null;
   2348 
   2349         /** @hide */
   2350         @Override
   2351         protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) {
   2352             super.encodeProperties(encoder);
   2353 
   2354             encoder.addProperty("x", x);
   2355             encoder.addProperty("y", y);
   2356             encoder.addProperty("horizontalWeight", horizontalWeight);
   2357             encoder.addProperty("verticalWeight", verticalWeight);
   2358             encoder.addProperty("type", type);
   2359             encoder.addProperty("flags", flags);
   2360         }
   2361     }
   2362 }
   2363