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