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