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