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.content.pm.ActivityInfo;
     20 import android.graphics.PixelFormat;
     21 import android.os.IBinder;
     22 import android.os.Parcel;
     23 import android.os.Parcelable;
     24 import android.text.TextUtils;
     25 import android.util.Log;
     26 
     27 
     28 /**
     29  * The interface that apps use to talk to the window manager.
     30  * <p>
     31  * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these.
     32  *
     33  * @see android.content.Context#getSystemService
     34  * @see android.content.Context#WINDOW_SERVICE
     35  */
     36 public interface WindowManager extends ViewManager {
     37     /**
     38      * Exception that is thrown when trying to add view whose
     39      * {@link WindowManager.LayoutParams} {@link WindowManager.LayoutParams#token}
     40      * is invalid.
     41      */
     42     public static class BadTokenException extends RuntimeException {
     43         public BadTokenException() {
     44         }
     45 
     46         public BadTokenException(String name) {
     47             super(name);
     48         }
     49     }
     50 
     51     /**
     52      * Use this method to get the default Display object.
     53      *
     54      * @return default Display object
     55      */
     56     public Display getDefaultDisplay();
     57 
     58     /**
     59      * Special variation of {@link #removeView} that immediately invokes
     60      * the given view hierarchy's {@link View#onDetachedFromWindow()
     61      * View.onDetachedFromWindow()} methods before returning.  This is not
     62      * for normal applications; using it correctly requires great care.
     63      *
     64      * @param view The view to be removed.
     65      */
     66     public void removeViewImmediate(View view);
     67 
     68     public static class LayoutParams extends ViewGroup.LayoutParams
     69             implements Parcelable {
     70         /**
     71          * X position for this window.  With the default gravity it is ignored.
     72          * When using {@link Gravity#LEFT} or {@link Gravity#RIGHT} it provides
     73          * an offset from the given edge.
     74          */
     75         public int x;
     76 
     77         /**
     78          * Y position for this window.  With the default gravity it is ignored.
     79          * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
     80          * an offset from the given edge.
     81          */
     82         public int y;
     83 
     84         /**
     85          * Indicates how much of the extra space will be allocated horizontally
     86          * to the view associated with these LayoutParams. Specify 0 if the view
     87          * should not be stretched. Otherwise the extra pixels will be pro-rated
     88          * among all views whose weight is greater than 0.
     89          */
     90         public float horizontalWeight;
     91 
     92         /**
     93          * Indicates how much of the extra space will be allocated vertically
     94          * to the view associated with these LayoutParams. Specify 0 if the view
     95          * should not be stretched. Otherwise the extra pixels will be pro-rated
     96          * among all views whose weight is greater than 0.
     97          */
     98         public float verticalWeight;
     99 
    100         /**
    101          * The general type of window.  There are three main classes of
    102          * window types:
    103          * <ul>
    104          * <li> <strong>Application windows</strong> (ranging from
    105          * {@link #FIRST_APPLICATION_WINDOW} to
    106          * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application
    107          * windows.  For these types of windows, the {@link #token} must be
    108          * set to the token of the activity they are a part of (this will
    109          * normally be done for you if {@link #token} is null).
    110          * <li> <strong>Sub-windows</strong> (ranging from
    111          * {@link #FIRST_SUB_WINDOW} to
    112          * {@link #LAST_SUB_WINDOW}) are associated with another top-level
    113          * window.  For these types of windows, the {@link #token} must be
    114          * the token of the window it is attached to.
    115          * <li> <strong>System windows</strong> (ranging from
    116          * {@link #FIRST_SYSTEM_WINDOW} to
    117          * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for
    118          * use by the system for specific purposes.  They should not normally
    119          * be used by applications, and a special permission is required
    120          * to use them.
    121          * </ul>
    122          *
    123          * @see #TYPE_BASE_APPLICATION
    124          * @see #TYPE_APPLICATION
    125          * @see #TYPE_APPLICATION_STARTING
    126          * @see #TYPE_APPLICATION_PANEL
    127          * @see #TYPE_APPLICATION_MEDIA
    128          * @see #TYPE_APPLICATION_SUB_PANEL
    129          * @see #TYPE_APPLICATION_ATTACHED_DIALOG
    130          * @see #TYPE_STATUS_BAR
    131          * @see #TYPE_SEARCH_BAR
    132          * @see #TYPE_PHONE
    133          * @see #TYPE_SYSTEM_ALERT
    134          * @see #TYPE_KEYGUARD
    135          * @see #TYPE_TOAST
    136          * @see #TYPE_SYSTEM_OVERLAY
    137          * @see #TYPE_PRIORITY_PHONE
    138          * @see #TYPE_STATUS_BAR_PANEL
    139          * @see #TYPE_SYSTEM_DIALOG
    140          * @see #TYPE_KEYGUARD_DIALOG
    141          * @see #TYPE_SYSTEM_ERROR
    142          * @see #TYPE_INPUT_METHOD
    143          * @see #TYPE_INPUT_METHOD_DIALOG
    144          */
    145         @ViewDebug.ExportedProperty(mapping = {
    146             @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"),
    147             @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"),
    148             @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"),
    149             @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"),
    150             @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"),
    151             @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"),
    152             @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"),
    153             @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"),
    154             @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"),
    155             @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"),
    156             @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"),
    157             @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"),
    158             @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"),
    159             @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"),
    160             @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"),
    161             @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"),
    162             @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"),
    163             @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"),
    164             @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"),
    165             @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"),
    166             @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG")
    167         })
    168         public int type;
    169 
    170         /**
    171          * Start of window types that represent normal application windows.
    172          */
    173         public static final int FIRST_APPLICATION_WINDOW = 1;
    174 
    175         /**
    176          * Window type: an application window that serves as the "base" window
    177          * of the overall application; all other application windows will
    178          * appear on top of it.
    179          */
    180         public static final int TYPE_BASE_APPLICATION   = 1;
    181 
    182         /**
    183          * Window type: a normal application window.  The {@link #token} must be
    184          * an Activity token identifying who the window belongs to.
    185          */
    186         public static final int TYPE_APPLICATION        = 2;
    187 
    188         /**
    189          * Window type: special application window that is displayed while the
    190          * application is starting.  Not for use by applications themselves;
    191          * this is used by the system to display something until the
    192          * application can show its own windows.
    193          */
    194         public static final int TYPE_APPLICATION_STARTING = 3;
    195 
    196         /**
    197          * End of types of application windows.
    198          */
    199         public static final int LAST_APPLICATION_WINDOW = 99;
    200 
    201         /**
    202          * Start of types of sub-windows.  The {@link #token} of these windows
    203          * must be set to the window they are attached to.  These types of
    204          * windows are kept next to their attached window in Z-order, and their
    205          * coordinate space is relative to their attached window.
    206          */
    207         public static final int FIRST_SUB_WINDOW        = 1000;
    208 
    209         /**
    210          * Window type: a panel on top of an application window.  These windows
    211          * appear on top of their attached window.
    212          */
    213         public static final int TYPE_APPLICATION_PANEL  = FIRST_SUB_WINDOW;
    214 
    215         /**
    216          * Window type: window for showing media (e.g. video).  These windows
    217          * are displayed behind their attached window.
    218          */
    219         public static final int TYPE_APPLICATION_MEDIA  = FIRST_SUB_WINDOW+1;
    220 
    221         /**
    222          * Window type: a sub-panel on top of an application window.  These
    223          * windows are displayed on top their attached window and any
    224          * {@link #TYPE_APPLICATION_PANEL} panels.
    225          */
    226         public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2;
    227 
    228         /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
    229          * of the window happens as that of a top-level window, <em>not</em>
    230          * as a child of its container.
    231          */
    232         public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3;
    233 
    234         /**
    235          * Window type: window for showing overlays on top of media windows.
    236          * These windows are displayed between TYPE_APPLICATION_MEDIA and the
    237          * application window.  They should be translucent to be useful.  This
    238          * is a big ugly hack so:
    239          * @hide
    240          */
    241         public static final int TYPE_APPLICATION_MEDIA_OVERLAY  = FIRST_SUB_WINDOW+4;
    242 
    243         /**
    244          * End of types of sub-windows.
    245          */
    246         public static final int LAST_SUB_WINDOW         = 1999;
    247 
    248         /**
    249          * Start of system-specific window types.  These are not normally
    250          * created by applications.
    251          */
    252         public static final int FIRST_SYSTEM_WINDOW     = 2000;
    253 
    254         /**
    255          * Window type: the status bar.  There can be only one status bar
    256          * window; it is placed at the top of the screen, and all other
    257          * windows are shifted down so they are below it.
    258          */
    259         public static final int TYPE_STATUS_BAR         = FIRST_SYSTEM_WINDOW;
    260 
    261         /**
    262          * Window type: the search bar.  There can be only one search bar
    263          * window; it is placed at the top of the screen.
    264          */
    265         public static final int TYPE_SEARCH_BAR         = FIRST_SYSTEM_WINDOW+1;
    266 
    267         /**
    268          * Window type: phone.  These are non-application windows providing
    269          * user interaction with the phone (in particular incoming calls).
    270          * These windows are normally placed above all applications, but behind
    271          * the status bar.
    272          */
    273         public static final int TYPE_PHONE              = FIRST_SYSTEM_WINDOW+2;
    274 
    275         /**
    276          * Window type: system window, such as low power alert. These windows
    277          * are always on top of application windows.
    278          */
    279         public static final int TYPE_SYSTEM_ALERT       = FIRST_SYSTEM_WINDOW+3;
    280 
    281         /**
    282          * Window type: keyguard window.
    283          */
    284         public static final int TYPE_KEYGUARD           = FIRST_SYSTEM_WINDOW+4;
    285 
    286         /**
    287          * Window type: transient notifications.
    288          */
    289         public static final int TYPE_TOAST              = FIRST_SYSTEM_WINDOW+5;
    290 
    291         /**
    292          * Window type: system overlay windows, which need to be displayed
    293          * on top of everything else.  These windows must not take input
    294          * focus, or they will interfere with the keyguard.
    295          */
    296         public static final int TYPE_SYSTEM_OVERLAY     = FIRST_SYSTEM_WINDOW+6;
    297 
    298         /**
    299          * Window type: priority phone UI, which needs to be displayed even if
    300          * the keyguard is active.  These windows must not take input
    301          * focus, or they will interfere with the keyguard.
    302          */
    303         public static final int TYPE_PRIORITY_PHONE     = FIRST_SYSTEM_WINDOW+7;
    304 
    305         /**
    306          * Window type: panel that slides out from the status bar
    307          */
    308         public static final int TYPE_SYSTEM_DIALOG      = FIRST_SYSTEM_WINDOW+8;
    309 
    310         /**
    311          * Window type: dialogs that the keyguard shows
    312          */
    313         public static final int TYPE_KEYGUARD_DIALOG    = FIRST_SYSTEM_WINDOW+9;
    314 
    315         /**
    316          * Window type: internal system error windows, appear on top of
    317          * everything they can.
    318          */
    319         public static final int TYPE_SYSTEM_ERROR       = FIRST_SYSTEM_WINDOW+10;
    320 
    321         /**
    322          * Window type: internal input methods windows, which appear above
    323          * the normal UI.  Application windows may be resized or panned to keep
    324          * the input focus visible while this window is displayed.
    325          */
    326         public static final int TYPE_INPUT_METHOD       = FIRST_SYSTEM_WINDOW+11;
    327 
    328         /**
    329          * Window type: internal input methods dialog windows, which appear above
    330          * the current input method window.
    331          */
    332         public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
    333 
    334         /**
    335          * Window type: wallpaper window, placed behind any window that wants
    336          * to sit on top of the wallpaper.
    337          */
    338         public static final int TYPE_WALLPAPER          = FIRST_SYSTEM_WINDOW+13;
    339 
    340         /**
    341          * Window type: panel that slides out from the status bar
    342          */
    343         public static final int TYPE_STATUS_BAR_PANEL   = FIRST_SYSTEM_WINDOW+14;
    344 
    345         /**
    346          * End of types of system windows.
    347          */
    348         public static final int LAST_SYSTEM_WINDOW      = 2999;
    349 
    350         /**
    351          * Specifies what type of memory buffers should be used by this window.
    352          * Default is normal.
    353          *
    354          * @see #MEMORY_TYPE_NORMAL
    355          * @see #MEMORY_TYPE_PUSH_BUFFERS
    356          */
    357         public int memoryType;
    358 
    359         /** Memory type: The window's surface is allocated in main memory. */
    360         public static final int MEMORY_TYPE_NORMAL = 0;
    361         /** Memory type: The window's surface is configured to be accessible
    362          * by DMA engines and hardware accelerators.
    363          * @deprecated this is ignored, this value is set automatically when needed.
    364          */
    365         @Deprecated
    366         public static final int MEMORY_TYPE_HARDWARE = 1;
    367         /** Memory type: The window's surface is configured to be accessible
    368          * by graphics accelerators.
    369          * @deprecated this is ignored, this value is set automatically when needed.
    370          */
    371         @Deprecated
    372         public static final int MEMORY_TYPE_GPU = 2;
    373         /** Memory type: The window's surface doesn't own its buffers and
    374          * therefore cannot be locked. Instead the buffers are pushed to
    375          * it through native binder calls. */
    376         public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
    377 
    378         /**
    379          * Various behavioral options/flags.  Default is none.
    380          *
    381          * @see #FLAG_BLUR_BEHIND
    382          * @see #FLAG_DIM_BEHIND
    383          * @see #FLAG_NOT_FOCUSABLE
    384          * @see #FLAG_NOT_TOUCHABLE
    385          * @see #FLAG_NOT_TOUCH_MODAL
    386          * @see #FLAG_LAYOUT_IN_SCREEN
    387          * @see #FLAG_DITHER
    388          * @see #FLAG_KEEP_SCREEN_ON
    389          * @see #FLAG_FULLSCREEN
    390          * @see #FLAG_FORCE_NOT_FULLSCREEN
    391          * @see #FLAG_IGNORE_CHEEK_PRESSES
    392          */
    393         @ViewDebug.ExportedProperty(flagMapping = {
    394             @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
    395                     name = "FLAG_BLUR_BEHIND"),
    396             @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
    397                     name = "FLAG_DIM_BEHIND"),
    398             @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
    399                     name = "FLAG_NOT_FOCUSABLE"),
    400             @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
    401                     name = "FLAG_NOT_TOUCHABLE"),
    402             @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
    403                     name = "FLAG_NOT_TOUCH_MODAL"),
    404             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
    405                     name = "FLAG_LAYOUT_IN_SCREEN"),
    406             @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
    407                     name = "FLAG_DITHER"),
    408             @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
    409                     name = "FLAG_TURN_SCREEN_ON"),
    410             @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
    411                     name = "FLAG_KEEP_SCREEN_ON"),
    412             @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
    413                     name = "FLAG_SHOW_WHEN_LOCKED"),
    414             @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
    415                     name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"),
    416             @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
    417                     name = "FLAG_DISMISS_KEYGUARD"),
    418             @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
    419                     name = "FLAG_FULLSCREEN"),
    420             @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN,
    421                     equals = FLAG_FORCE_NOT_FULLSCREEN, name = "FLAG_FORCE_NOT_FULLSCREEN"),
    422             @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES,
    423                     equals = FLAG_IGNORE_CHEEK_PRESSES, name = "FLAG_IGNORE_CHEEK_PRESSES")
    424         })
    425         public int flags;
    426 
    427         /** Window flag: as long as this window is visible to the user, allow
    428          *  the lock screen to activate while the screen is on.
    429          *  This can be used independently, or in combination with
    430          *  {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
    431         public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001;
    432 
    433         /** Window flag: everything behind this window will be dimmed.
    434          *  Use {@link #dimAmount} to control the amount of dim. */
    435         public static final int FLAG_DIM_BEHIND        = 0x00000002;
    436 
    437         /** Window flag: blur everything behind this window. */
    438         public static final int FLAG_BLUR_BEHIND        = 0x00000004;
    439 
    440         /** Window flag: this window won't ever get key input focus, so the
    441          * user can not send key or other button events to it.  Those will
    442          * instead go to whatever focusable window is behind it.  This flag
    443          * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
    444          * is explicitly set.
    445          *
    446          * <p>Setting this flag also implies that the window will not need to
    447          * interact with
    448          * a soft input method, so it will be Z-ordered and positioned
    449          * independently of any active input method (typically this means it
    450          * gets Z-ordered on top of the input method, so it can use the full
    451          * screen for its content and cover the input method if needed.  You
    452          * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
    453         public static final int FLAG_NOT_FOCUSABLE      = 0x00000008;
    454 
    455         /** Window flag: this window can never receive touch events. */
    456         public static final int FLAG_NOT_TOUCHABLE      = 0x00000010;
    457 
    458         /** Window flag: Even when this window is focusable (its
    459          * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events
    460          * outside of the window to be sent to the windows behind it.  Otherwise
    461          * it will consume all pointer events itself, regardless of whether they
    462          * are inside of the window. */
    463         public static final int FLAG_NOT_TOUCH_MODAL    = 0x00000020;
    464 
    465         /** Window flag: When set, if the device is asleep when the touch
    466          * screen is pressed, you will receive this first touch event.  Usually
    467          * the first touch event is consumed by the system since the user can
    468          * not see what they are pressing on.
    469          */
    470         public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
    471 
    472         /** Window flag: as long as this window is visible to the user, keep
    473          *  the device's screen turned on and bright. */
    474         public static final int FLAG_KEEP_SCREEN_ON     = 0x00000080;
    475 
    476         /** Window flag: place the window within the entire screen, ignoring
    477          *  decorations around the border (a.k.a. the status bar).  The
    478          *  window must correctly position its contents to take the screen
    479          *  decoration into account.  This flag is normally set for you
    480          *  by Window as described in {@link Window#setFlags}. */
    481         public static final int FLAG_LAYOUT_IN_SCREEN   = 0x00000100;
    482 
    483         /** Window flag: allow window to extend outside of the screen. */
    484         public static final int FLAG_LAYOUT_NO_LIMITS   = 0x00000200;
    485 
    486         /** Window flag: Hide all screen decorations (e.g. status bar) while
    487          * this window is displayed.  This allows the window to use the entire
    488          * display space for itself -- the status bar will be hidden when
    489          * an app window with this flag set is on the top layer. */
    490         public static final int FLAG_FULLSCREEN      = 0x00000400;
    491 
    492         /** Window flag: Override {@link #FLAG_FULLSCREEN and force the
    493          *  screen decorations (such as status bar) to be shown. */
    494         public static final int FLAG_FORCE_NOT_FULLSCREEN   = 0x00000800;
    495 
    496         /** Window flag: turn on dithering when compositing this window to
    497          *  the screen. */
    498         public static final int FLAG_DITHER             = 0x00001000;
    499 
    500         /** Window flag: don't allow screen shots while this window is
    501          * displayed. */
    502         public static final int FLAG_SECURE             = 0x00002000;
    503 
    504         /** Window flag: a special mode where the layout parameters are used
    505          * to perform scaling of the surface when it is composited to the
    506          * screen. */
    507         public static final int FLAG_SCALED             = 0x00004000;
    508 
    509         /** Window flag: intended for windows that will often be used when the user is
    510          * holding the screen against their face, it will aggressively filter the event
    511          * stream to prevent unintended presses in this situation that may not be
    512          * desired for a particular window, when such an event stream is detected, the
    513          * application will receive a CANCEL motion event to indicate this so applications
    514          * can handle this accordingly by taking no action on the event
    515          * until the finger is released. */
    516         public static final int FLAG_IGNORE_CHEEK_PRESSES    = 0x00008000;
    517 
    518         /** Window flag: a special option only for use in combination with
    519          * {@link #FLAG_LAYOUT_IN_SCREEN}.  When requesting layout in the
    520          * screen your window may appear on top of or behind screen decorations
    521          * such as the status bar.  By also including this flag, the window
    522          * manager will report the inset rectangle needed to ensure your
    523          * content is not covered by screen decorations.  This flag is normally
    524          * set for you by Window as described in {@link Window#setFlags}.*/
    525         public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
    526 
    527         /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
    528          * respect to how this window interacts with the current method.  That
    529          * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
    530          * window will behave as if it needs to interact with the input method
    531          * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
    532          * not set and this flag is set, then the window will behave as if it
    533          * doesn't need to interact with the input method and can be placed
    534          * to use more space and cover the input method.
    535          */
    536         public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
    537 
    538         /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
    539          * can set this flag to receive a single special MotionEvent with
    540          * the action
    541          * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
    542          * touches that occur outside of your window.  Note that you will not
    543          * receive the full down/move/up gesture, only the location of the
    544          * first down as an ACTION_OUTSIDE.
    545          */
    546         public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
    547 
    548         /** Window flag: special flag to let windows be shown when the screen
    549          * is locked. This will let application windows take precedence over
    550          * key guard or any other lock screens. Can be used with
    551          * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
    552          * directly before showing the key guard window.  Can be used with
    553          * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
    554          * non-secure keyguards.  This flag only applies to the top-most
    555          * full-screen window.
    556          */
    557         public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
    558 
    559         /** Window flag: ask that the system wallpaper be shown behind
    560          * your window.  The window surface must be translucent to be able
    561          * to actually see the wallpaper behind it; this flag just ensures
    562          * that the wallpaper surface will be there if this window actually
    563          * has translucent regions.
    564          */
    565         public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
    566 
    567         /** Window flag: when set as a window is being added or made
    568          * visible, once the window has been shown then the system will
    569          * poke the power manager's user activity (as if the user had woken
    570          * up the device) to turn the screen on. */
    571         public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
    572 
    573         /** Window flag: when set the window will cause the keyguard to
    574          * be dismissed, only if it is not a secure lock keyguard.  Because such
    575          * a keyguard is not needed for security, it will never re-appear if
    576          * the user navigates to another window (in contrast to
    577          * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily
    578          * hide both secure and non-secure keyguards but ensure they reappear
    579          * when the user moves to another UI that doesn't hide them).
    580          * If the keyguard is currently active and is secure (requires an
    581          * unlock pattern) than the user will still need to confirm it before
    582          * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has
    583          * also been set. */
    584         public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
    585 
    586         /** Window flag: *sigh* The lock screen wants to continue running its
    587          * animation while it is fading.  A kind-of hack to allow this.  Maybe
    588          * in the future we just make this the default behavior.
    589          *
    590          * {@hide} */
    591         public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000;
    592 
    593         /** Window flag: special flag to limit the size of the window to be
    594          * original size ([320x480] x density). Used to create window for applications
    595          * running under compatibility mode.
    596          *
    597          * {@hide} */
    598         public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000;
    599 
    600         /** Window flag: a special option intended for system dialogs.  When
    601          * this flag is set, the window will demand focus unconditionally when
    602          * it is created.
    603          * {@hide} */
    604         public static final int FLAG_SYSTEM_ERROR = 0x40000000;
    605 
    606         /**
    607          * Given a particular set of window manager flags, determine whether
    608          * such a window may be a target for an input method when it has
    609          * focus.  In particular, this checks the
    610          * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
    611          * flags and returns true if the combination of the two corresponds
    612          * to a window that needs to be behind the input method so that the
    613          * user can type into it.
    614          *
    615          * @param flags The current window manager flags.
    616          *
    617          * @return Returns true if such a window should be behind/interact
    618          * with an input method, false if not.
    619          */
    620         public static boolean mayUseInputMethod(int flags) {
    621             switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
    622                 case 0:
    623                 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
    624                     return true;
    625             }
    626             return false;
    627         }
    628 
    629         /**
    630          * Mask for {@link #softInputMode} of the bits that determine the
    631          * desired visibility state of the soft input area for this window.
    632          */
    633         public static final int SOFT_INPUT_MASK_STATE = 0x0f;
    634 
    635         /**
    636          * Visibility state for {@link #softInputMode}: no state has been specified.
    637          */
    638         public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
    639 
    640         /**
    641          * Visibility state for {@link #softInputMode}: please don't change the state of
    642          * the soft input area.
    643          */
    644         public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
    645 
    646         /**
    647          * Visibility state for {@link #softInputMode}: please hide any soft input
    648          * area when normally appropriate (when the user is navigating
    649          * forward to your window).
    650          */
    651         public static final int SOFT_INPUT_STATE_HIDDEN = 2;
    652 
    653         /**
    654          * Visibility state for {@link #softInputMode}: please always hide any
    655          * soft input area when this window receives focus.
    656          */
    657         public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
    658 
    659         /**
    660          * Visibility state for {@link #softInputMode}: please show the soft
    661          * input area when normally appropriate (when the user is navigating
    662          * forward to your window).
    663          */
    664         public static final int SOFT_INPUT_STATE_VISIBLE = 4;
    665 
    666         /**
    667          * Visibility state for {@link #softInputMode}: please always make the
    668          * soft input area visible when this window receives input focus.
    669          */
    670         public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
    671 
    672         /**
    673          * Mask for {@link #softInputMode} of the bits that determine the
    674          * way that the window should be adjusted to accommodate the soft
    675          * input window.
    676          */
    677         public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
    678 
    679         /** Adjustment option for {@link #softInputMode}: nothing specified.
    680          * The system will try to pick one or
    681          * the other depending on the contents of the window.
    682          */
    683         public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
    684 
    685         /** Adjustment option for {@link #softInputMode}: set to allow the
    686          * window to be resized when an input
    687          * method is shown, so that its contents are not covered by the input
    688          * method.  This can <em>not<em> be combined with
    689          * {@link #SOFT_INPUT_ADJUST_PAN}; if
    690          * neither of these are set, then the system will try to pick one or
    691          * the other depending on the contents of the window.
    692          */
    693         public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
    694 
    695         /** Adjustment option for {@link #softInputMode}: set to have a window
    696          * pan when an input method is
    697          * shown, so it doesn't need to deal with resizing but just panned
    698          * by the framework to ensure the current input focus is visible.  This
    699          * can <em>not<em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
    700          * neither of these are set, then the system will try to pick one or
    701          * the other depending on the contents of the window.
    702          */
    703         public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
    704 
    705         /**
    706          * Bit for {@link #softInputMode}: set when the user has navigated
    707          * forward to the window.  This is normally set automatically for
    708          * you by the system, though you may want to set it in certain cases
    709          * when you are displaying a window yourself.  This flag will always
    710          * be cleared automatically after the window is displayed.
    711          */
    712         public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
    713 
    714         /**
    715          * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
    716          * indicating that the brightness value is not overridden for this window
    717          * and normal brightness policy should be used.
    718          */
    719         public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
    720 
    721         /**
    722          * Value for {@link #screenBrightness} and {@link #buttonBrightness}
    723          * indicating that the screen or button backlight brightness should be set
    724          * to the lowest value when this window is in front.
    725          */
    726         public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
    727 
    728         /**
    729          * Value for {@link #screenBrightness} and {@link #buttonBrightness}
    730          * indicating that the screen or button backlight brightness should be set
    731          * to the hightest value when this window is in front.
    732          */
    733         public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
    734 
    735         /**
    736          * Desired operating mode for any soft input area.  May any combination
    737          * of:
    738          *
    739          * <ul>
    740          * <li> One of the visibility states
    741          * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
    742          * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or
    743          * {@link #SOFT_INPUT_STATE_VISIBLE}.
    744          * <li> One of the adjustment options
    745          * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED},
    746          * {@link #SOFT_INPUT_ADJUST_RESIZE}, or
    747          * {@link #SOFT_INPUT_ADJUST_PAN}.
    748          */
    749         public int softInputMode;
    750 
    751         /**
    752          * Placement of window within the screen as per {@link Gravity}
    753          *
    754          * @see Gravity
    755          */
    756         public int gravity;
    757 
    758         /**
    759          * The horizontal margin, as a percentage of the container's width,
    760          * between the container and the widget.
    761          */
    762         public float horizontalMargin;
    763 
    764         /**
    765          * The vertical margin, as a percentage of the container's height,
    766          * between the container and the widget.
    767          */
    768         public float verticalMargin;
    769 
    770         /**
    771          * The desired bitmap format.  May be one of the constants in
    772          * {@link android.graphics.PixelFormat}.  Default is OPAQUE.
    773          */
    774         public int format;
    775 
    776         /**
    777          * A style resource defining the animations to use for this window.
    778          * This must be a system resource; it can not be an application resource
    779          * because the window manager does not have access to applications.
    780          */
    781         public int windowAnimations;
    782 
    783         /**
    784          * An alpha value to apply to this entire window.
    785          * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
    786          */
    787         public float alpha = 1.0f;
    788 
    789         /**
    790          * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
    791          * to apply.  Range is from 1.0 for completely opaque to 0.0 for no
    792          * dim.
    793          */
    794         public float dimAmount = 1.0f;
    795 
    796         /**
    797          * This can be used to override the user's preferred brightness of
    798          * the screen.  A value of less than 0, the default, means to use the
    799          * preferred screen brightness.  0 to 1 adjusts the brightness from
    800          * dark to full bright.
    801          */
    802         public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
    803 
    804         /**
    805          * This can be used to override the standard behavior of the button and
    806          * keyboard backlights.  A value of less than 0, the default, means to
    807          * use the standard backlight behavior.  0 to 1 adjusts the brightness
    808          * from dark to full bright.
    809          */
    810         public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
    811 
    812         /**
    813          * Identifier for this window.  This will usually be filled in for
    814          * you.
    815          */
    816         public IBinder token = null;
    817 
    818         /**
    819          * Name of the package owning this window.
    820          */
    821         public String packageName = null;
    822 
    823         /**
    824          * Specific orientation value for a window.
    825          * May be any of the same values allowed
    826          * for {@link android.content.pm.ActivityInfo#screenOrientation}.
    827          * If not set, a default value of
    828          * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
    829          * will be used.
    830          */
    831         public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    832 
    833 
    834         public LayoutParams() {
    835             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    836             type = TYPE_APPLICATION;
    837             format = PixelFormat.OPAQUE;
    838         }
    839 
    840         public LayoutParams(int _type) {
    841             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    842             type = _type;
    843             format = PixelFormat.OPAQUE;
    844         }
    845 
    846         public LayoutParams(int _type, int _flags) {
    847             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    848             type = _type;
    849             flags = _flags;
    850             format = PixelFormat.OPAQUE;
    851         }
    852 
    853         public LayoutParams(int _type, int _flags, int _format) {
    854             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    855             type = _type;
    856             flags = _flags;
    857             format = _format;
    858         }
    859 
    860         public LayoutParams(int w, int h, int _type, int _flags, int _format) {
    861             super(w, h);
    862             type = _type;
    863             flags = _flags;
    864             format = _format;
    865         }
    866 
    867         public LayoutParams(int w, int h, int xpos, int ypos, int _type,
    868                 int _flags, int _format) {
    869             super(w, h);
    870             x = xpos;
    871             y = ypos;
    872             type = _type;
    873             flags = _flags;
    874             format = _format;
    875         }
    876 
    877         public final void setTitle(CharSequence title) {
    878             if (null == title)
    879                 title = "";
    880 
    881             mTitle = TextUtils.stringOrSpannedString(title);
    882         }
    883 
    884         public final CharSequence getTitle() {
    885             return mTitle;
    886         }
    887 
    888         public int describeContents() {
    889             return 0;
    890         }
    891 
    892         public void writeToParcel(Parcel out, int parcelableFlags) {
    893             out.writeInt(width);
    894             out.writeInt(height);
    895             out.writeInt(x);
    896             out.writeInt(y);
    897             out.writeInt(type);
    898             out.writeInt(memoryType);
    899             out.writeInt(flags);
    900             out.writeInt(softInputMode);
    901             out.writeInt(gravity);
    902             out.writeFloat(horizontalMargin);
    903             out.writeFloat(verticalMargin);
    904             out.writeInt(format);
    905             out.writeInt(windowAnimations);
    906             out.writeFloat(alpha);
    907             out.writeFloat(dimAmount);
    908             out.writeFloat(screenBrightness);
    909             out.writeFloat(buttonBrightness);
    910             out.writeStrongBinder(token);
    911             out.writeString(packageName);
    912             TextUtils.writeToParcel(mTitle, out, parcelableFlags);
    913             out.writeInt(screenOrientation);
    914         }
    915 
    916         public static final Parcelable.Creator<LayoutParams> CREATOR
    917                     = new Parcelable.Creator<LayoutParams>() {
    918             public LayoutParams createFromParcel(Parcel in) {
    919                 return new LayoutParams(in);
    920             }
    921 
    922             public LayoutParams[] newArray(int size) {
    923                 return new LayoutParams[size];
    924             }
    925         };
    926 
    927 
    928         public LayoutParams(Parcel in) {
    929             width = in.readInt();
    930             height = in.readInt();
    931             x = in.readInt();
    932             y = in.readInt();
    933             type = in.readInt();
    934             memoryType = in.readInt();
    935             flags = in.readInt();
    936             softInputMode = in.readInt();
    937             gravity = in.readInt();
    938             horizontalMargin = in.readFloat();
    939             verticalMargin = in.readFloat();
    940             format = in.readInt();
    941             windowAnimations = in.readInt();
    942             alpha = in.readFloat();
    943             dimAmount = in.readFloat();
    944             screenBrightness = in.readFloat();
    945             buttonBrightness = in.readFloat();
    946             token = in.readStrongBinder();
    947             packageName = in.readString();
    948             mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
    949             screenOrientation = in.readInt();
    950         }
    951 
    952         @SuppressWarnings({"PointlessBitwiseExpression"})
    953         public static final int LAYOUT_CHANGED = 1<<0;
    954         public static final int TYPE_CHANGED = 1<<1;
    955         public static final int FLAGS_CHANGED = 1<<2;
    956         public static final int FORMAT_CHANGED = 1<<3;
    957         public static final int ANIMATION_CHANGED = 1<<4;
    958         public static final int DIM_AMOUNT_CHANGED = 1<<5;
    959         public static final int TITLE_CHANGED = 1<<6;
    960         public static final int ALPHA_CHANGED = 1<<7;
    961         public static final int MEMORY_TYPE_CHANGED = 1<<8;
    962         public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
    963         public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
    964         public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
    965         /** {@hide} */
    966         public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12;
    967 
    968         // internal buffer to backup/restore parameters under compatibility mode.
    969         private int[] mCompatibilityParamsBackup = null;
    970 
    971         public final int copyFrom(LayoutParams o) {
    972             int changes = 0;
    973 
    974             if (width != o.width) {
    975                 width = o.width;
    976                 changes |= LAYOUT_CHANGED;
    977             }
    978             if (height != o.height) {
    979                 height = o.height;
    980                 changes |= LAYOUT_CHANGED;
    981             }
    982             if (x != o.x) {
    983                 x = o.x;
    984                 changes |= LAYOUT_CHANGED;
    985             }
    986             if (y != o.y) {
    987                 y = o.y;
    988                 changes |= LAYOUT_CHANGED;
    989             }
    990             if (horizontalWeight != o.horizontalWeight) {
    991                 horizontalWeight = o.horizontalWeight;
    992                 changes |= LAYOUT_CHANGED;
    993             }
    994             if (verticalWeight != o.verticalWeight) {
    995                 verticalWeight = o.verticalWeight;
    996                 changes |= LAYOUT_CHANGED;
    997             }
    998             if (horizontalMargin != o.horizontalMargin) {
    999                 horizontalMargin = o.horizontalMargin;
   1000                 changes |= LAYOUT_CHANGED;
   1001             }
   1002             if (verticalMargin != o.verticalMargin) {
   1003                 verticalMargin = o.verticalMargin;
   1004                 changes |= LAYOUT_CHANGED;
   1005             }
   1006             if (type != o.type) {
   1007                 type = o.type;
   1008                 changes |= TYPE_CHANGED;
   1009             }
   1010             if (memoryType != o.memoryType) {
   1011                 memoryType = o.memoryType;
   1012                 changes |= MEMORY_TYPE_CHANGED;
   1013             }
   1014             if (flags != o.flags) {
   1015                 flags = o.flags;
   1016                 changes |= FLAGS_CHANGED;
   1017             }
   1018             if (softInputMode != o.softInputMode) {
   1019                 softInputMode = o.softInputMode;
   1020                 changes |= SOFT_INPUT_MODE_CHANGED;
   1021             }
   1022             if (gravity != o.gravity) {
   1023                 gravity = o.gravity;
   1024                 changes |= LAYOUT_CHANGED;
   1025             }
   1026             if (horizontalMargin != o.horizontalMargin) {
   1027                 horizontalMargin = o.horizontalMargin;
   1028                 changes |= LAYOUT_CHANGED;
   1029             }
   1030             if (verticalMargin != o.verticalMargin) {
   1031                 verticalMargin = o.verticalMargin;
   1032                 changes |= LAYOUT_CHANGED;
   1033             }
   1034             if (format != o.format) {
   1035                 format = o.format;
   1036                 changes |= FORMAT_CHANGED;
   1037             }
   1038             if (windowAnimations != o.windowAnimations) {
   1039                 windowAnimations = o.windowAnimations;
   1040                 changes |= ANIMATION_CHANGED;
   1041             }
   1042             if (token == null) {
   1043                 // NOTE: token only copied if the recipient doesn't
   1044                 // already have one.
   1045                 token = o.token;
   1046             }
   1047             if (packageName == null) {
   1048                 // NOTE: packageName only copied if the recipient doesn't
   1049                 // already have one.
   1050                 packageName = o.packageName;
   1051             }
   1052             if (!mTitle.equals(o.mTitle)) {
   1053                 mTitle = o.mTitle;
   1054                 changes |= TITLE_CHANGED;
   1055             }
   1056             if (alpha != o.alpha) {
   1057                 alpha = o.alpha;
   1058                 changes |= ALPHA_CHANGED;
   1059             }
   1060             if (dimAmount != o.dimAmount) {
   1061                 dimAmount = o.dimAmount;
   1062                 changes |= DIM_AMOUNT_CHANGED;
   1063             }
   1064             if (screenBrightness != o.screenBrightness) {
   1065                 screenBrightness = o.screenBrightness;
   1066                 changes |= SCREEN_BRIGHTNESS_CHANGED;
   1067             }
   1068             if (buttonBrightness != o.buttonBrightness) {
   1069                 buttonBrightness = o.buttonBrightness;
   1070                 changes |= BUTTON_BRIGHTNESS_CHANGED;
   1071             }
   1072 
   1073             if (screenOrientation != o.screenOrientation) {
   1074                 screenOrientation = o.screenOrientation;
   1075                 changes |= SCREEN_ORIENTATION_CHANGED;
   1076             }
   1077             return changes;
   1078         }
   1079 
   1080         @Override
   1081         public String debug(String output) {
   1082             output += "Contents of " + this + ":";
   1083             Log.d("Debug", output);
   1084             output = super.debug("");
   1085             Log.d("Debug", output);
   1086             Log.d("Debug", "");
   1087             Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
   1088             return "";
   1089         }
   1090 
   1091         @Override
   1092         public String toString() {
   1093             StringBuilder sb = new StringBuilder(256);
   1094             sb.append("WM.LayoutParams{");
   1095             sb.append("(");
   1096             sb.append(x);
   1097             sb.append(',');
   1098             sb.append(y);
   1099             sb.append(")(");
   1100             sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width)));
   1101             sb.append('x');
   1102             sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height)));
   1103             sb.append(")");
   1104             if (softInputMode != 0) {
   1105                 sb.append(" sim=#");
   1106                 sb.append(Integer.toHexString(softInputMode));
   1107             }
   1108             if (gravity != 0) {
   1109                 sb.append(" gr=#");
   1110                 sb.append(Integer.toHexString(gravity));
   1111             }
   1112             sb.append(" ty=");
   1113             sb.append(type);
   1114             sb.append(" fl=#");
   1115             sb.append(Integer.toHexString(flags));
   1116             sb.append(" fmt=");
   1117             sb.append(format);
   1118             if (windowAnimations != 0) {
   1119                 sb.append(" wanim=0x");
   1120                 sb.append(Integer.toHexString(windowAnimations));
   1121             }
   1122             if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
   1123                 sb.append(" or=");
   1124                 sb.append(screenOrientation);
   1125             }
   1126             if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) {
   1127                 sb.append(" compatible=true");
   1128             }
   1129             sb.append('}');
   1130             return sb.toString();
   1131         }
   1132 
   1133         /**
   1134          * Scale the layout params' coordinates and size.
   1135          * @hide
   1136          */
   1137         public void scale(float scale) {
   1138             x = (int) (x * scale + 0.5f);
   1139             y = (int) (y * scale + 0.5f);
   1140             if (width > 0) {
   1141                 width = (int) (width * scale + 0.5f);
   1142             }
   1143             if (height > 0) {
   1144                 height = (int) (height * scale + 0.5f);
   1145             }
   1146         }
   1147 
   1148         /**
   1149          * Backup the layout parameters used in compatibility mode.
   1150          * @see LayoutParams#restore()
   1151          */
   1152         void backup() {
   1153             int[] backup = mCompatibilityParamsBackup;
   1154             if (backup == null) {
   1155                 // we backup 4 elements, x, y, width, height
   1156                 backup = mCompatibilityParamsBackup = new int[4];
   1157             }
   1158             backup[0] = x;
   1159             backup[1] = y;
   1160             backup[2] = width;
   1161             backup[3] = height;
   1162         }
   1163 
   1164         /**
   1165          * Restore the layout params' coordinates, size and gravity
   1166          * @see LayoutParams#backup()
   1167          */
   1168         void restore() {
   1169             int[] backup = mCompatibilityParamsBackup;
   1170             if (backup != null) {
   1171                 x = backup[0];
   1172                 y = backup[1];
   1173                 width = backup[2];
   1174                 height = backup[3];
   1175             }
   1176         }
   1177 
   1178         private CharSequence mTitle = "";
   1179     }
   1180 }
   1181