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