WindowManager.java revision a754785cf949113a7ae09893c101558f4737f3cd
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 static android.content.pm.ActivityInfo.COLOR_MODE_DEFAULT;
20import static android.view.WindowLayoutParamsProto.ALPHA;
21import static android.view.WindowLayoutParamsProto.BUTTON_BRIGHTNESS;
22import static android.view.WindowLayoutParamsProto.COLOR_MODE;
23import static android.view.WindowLayoutParamsProto.FLAGS;
24import static android.view.WindowLayoutParamsProto.FORMAT;
25import static android.view.WindowLayoutParamsProto.GRAVITY;
26import static android.view.WindowLayoutParamsProto.HAS_SYSTEM_UI_LISTENERS;
27import static android.view.WindowLayoutParamsProto.HEIGHT;
28import static android.view.WindowLayoutParamsProto.HORIZONTAL_MARGIN;
29import static android.view.WindowLayoutParamsProto.INPUT_FEATURE_FLAGS;
30import static android.view.WindowLayoutParamsProto.NEEDS_MENU_KEY;
31import static android.view.WindowLayoutParamsProto.PREFERRED_REFRESH_RATE;
32import static android.view.WindowLayoutParamsProto.PRIVATE_FLAGS;
33import static android.view.WindowLayoutParamsProto.ROTATION_ANIMATION;
34import static android.view.WindowLayoutParamsProto.SCREEN_BRIGHTNESS;
35import static android.view.WindowLayoutParamsProto.SOFT_INPUT_MODE;
36import static android.view.WindowLayoutParamsProto.SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS;
37import static android.view.WindowLayoutParamsProto.SYSTEM_UI_VISIBILITY_FLAGS;
38import static android.view.WindowLayoutParamsProto.TYPE;
39import static android.view.WindowLayoutParamsProto.USER_ACTIVITY_TIMEOUT;
40import static android.view.WindowLayoutParamsProto.VERTICAL_MARGIN;
41import static android.view.WindowLayoutParamsProto.WIDTH;
42import static android.view.WindowLayoutParamsProto.WINDOW_ANIMATIONS;
43import static android.view.WindowLayoutParamsProto.X;
44import static android.view.WindowLayoutParamsProto.Y;
45
46import android.Manifest.permission;
47import android.annotation.IntDef;
48import android.annotation.NonNull;
49import android.annotation.RequiresPermission;
50import android.annotation.SystemApi;
51import android.annotation.SystemService;
52import android.annotation.TestApi;
53import android.app.KeyguardManager;
54import android.app.Presentation;
55import android.content.Context;
56import android.content.pm.ActivityInfo;
57import android.graphics.PixelFormat;
58import android.graphics.Rect;
59import android.graphics.Region;
60import android.os.IBinder;
61import android.os.Parcel;
62import android.os.Parcelable;
63import android.text.TextUtils;
64import android.util.Log;
65import android.util.proto.ProtoOutputStream;
66import android.view.accessibility.AccessibilityNodeInfo;
67
68import java.lang.annotation.Retention;
69import java.lang.annotation.RetentionPolicy;
70import java.util.List;
71import java.util.Objects;
72
73/**
74 * The interface that apps use to talk to the window manager.
75 * </p><p>
76 * Each window manager instance is bound to a particular {@link Display}.
77 * To obtain a {@link WindowManager} for a different display, use
78 * {@link Context#createDisplayContext} to obtain a {@link Context} for that
79 * display, then use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code>
80 * to get the WindowManager.
81 * </p><p>
82 * The simplest way to show a window on another display is to create a
83 * {@link Presentation}.  The presentation will automatically obtain a
84 * {@link WindowManager} and {@link Context} for that display.
85 * </p>
86 */
87@SystemService(Context.WINDOW_SERVICE)
88public interface WindowManager extends ViewManager {
89
90    /** @hide */
91    int DOCKED_INVALID = -1;
92    /** @hide */
93    int DOCKED_LEFT = 1;
94    /** @hide */
95    int DOCKED_TOP = 2;
96    /** @hide */
97    int DOCKED_RIGHT = 3;
98    /** @hide */
99    int DOCKED_BOTTOM = 4;
100
101    /** @hide */
102    String INPUT_CONSUMER_PIP = "pip_input_consumer";
103    /** @hide */
104    String INPUT_CONSUMER_NAVIGATION = "nav_input_consumer";
105    /** @hide */
106    String INPUT_CONSUMER_WALLPAPER = "wallpaper_input_consumer";
107    /** @hide */
108    String INPUT_CONSUMER_RECENTS_ANIMATION = "recents_animation_input_consumer";
109
110    /**
111     * Not set up for a transition.
112     * @hide
113     */
114    int TRANSIT_UNSET = -1;
115
116    /**
117     * No animation for transition.
118     * @hide
119     */
120    int TRANSIT_NONE = 0;
121
122    /**
123     * A window in a new activity is being opened on top of an existing one in the same task.
124     * @hide
125     */
126    int TRANSIT_ACTIVITY_OPEN = 6;
127
128    /**
129     * The window in the top-most activity is being closed to reveal the previous activity in the
130     * same task.
131     * @hide
132     */
133    int TRANSIT_ACTIVITY_CLOSE = 7;
134
135    /**
136     * A window in a new task is being opened on top of an existing one in another activity's task.
137     * @hide
138     */
139    int TRANSIT_TASK_OPEN = 8;
140
141    /**
142     * A window in the top-most activity is being closed to reveal the previous activity in a
143     * different task.
144     * @hide
145     */
146    int TRANSIT_TASK_CLOSE = 9;
147
148    /**
149     * A window in an existing task is being displayed on top of an existing one in another
150     * activity's task.
151     * @hide
152     */
153    int TRANSIT_TASK_TO_FRONT = 10;
154
155    /**
156     * A window in an existing task is being put below all other tasks.
157     * @hide
158     */
159    int TRANSIT_TASK_TO_BACK = 11;
160
161    /**
162     * A window in a new activity that doesn't have a wallpaper is being opened on top of one that
163     * does, effectively closing the wallpaper.
164     * @hide
165     */
166    int TRANSIT_WALLPAPER_CLOSE = 12;
167
168    /**
169     * A window in a new activity that does have a wallpaper is being opened on one that didn't,
170     * effectively opening the wallpaper.
171     * @hide
172     */
173    int TRANSIT_WALLPAPER_OPEN = 13;
174
175    /**
176     * A window in a new activity is being opened on top of an existing one, and both are on top
177     * of the wallpaper.
178     * @hide
179     */
180    int TRANSIT_WALLPAPER_INTRA_OPEN = 14;
181
182    /**
183     * The window in the top-most activity is being closed to reveal the previous activity, and
184     * both are on top of the wallpaper.
185     * @hide
186     */
187    int TRANSIT_WALLPAPER_INTRA_CLOSE = 15;
188
189    /**
190     * A window in a new task is being opened behind an existing one in another activity's task.
191     * The new window will show briefly and then be gone.
192     * @hide
193     */
194    int TRANSIT_TASK_OPEN_BEHIND = 16;
195
196    /**
197     * A window in a task is being animated in-place.
198     * @hide
199     */
200    int TRANSIT_TASK_IN_PLACE = 17;
201
202    /**
203     * An activity is being relaunched (e.g. due to configuration change).
204     * @hide
205     */
206    int TRANSIT_ACTIVITY_RELAUNCH = 18;
207
208    /**
209     * A task is being docked from recents.
210     * @hide
211     */
212    int TRANSIT_DOCK_TASK_FROM_RECENTS = 19;
213
214    /**
215     * Keyguard is going away.
216     * @hide
217     */
218    int TRANSIT_KEYGUARD_GOING_AWAY = 20;
219
220    /**
221     * Keyguard is going away with showing an activity behind that requests wallpaper.
222     * @hide
223     */
224    int TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER = 21;
225
226    /**
227     * Keyguard is being occluded.
228     * @hide
229     */
230    int TRANSIT_KEYGUARD_OCCLUDE = 22;
231
232    /**
233     * Keyguard is being unoccluded.
234     * @hide
235     */
236    int TRANSIT_KEYGUARD_UNOCCLUDE = 23;
237
238    /**
239     * @hide
240     */
241    @IntDef(prefix = { "TRANSIT_" }, value = {
242            TRANSIT_UNSET,
243            TRANSIT_NONE,
244            TRANSIT_ACTIVITY_OPEN,
245            TRANSIT_ACTIVITY_CLOSE,
246            TRANSIT_TASK_OPEN,
247            TRANSIT_TASK_CLOSE,
248            TRANSIT_TASK_TO_FRONT,
249            TRANSIT_TASK_TO_BACK,
250            TRANSIT_WALLPAPER_CLOSE,
251            TRANSIT_WALLPAPER_OPEN,
252            TRANSIT_WALLPAPER_INTRA_OPEN,
253            TRANSIT_WALLPAPER_INTRA_CLOSE,
254            TRANSIT_TASK_OPEN_BEHIND,
255            TRANSIT_TASK_IN_PLACE,
256            TRANSIT_ACTIVITY_RELAUNCH,
257            TRANSIT_DOCK_TASK_FROM_RECENTS,
258            TRANSIT_KEYGUARD_GOING_AWAY,
259            TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER,
260            TRANSIT_KEYGUARD_OCCLUDE,
261            TRANSIT_KEYGUARD_UNOCCLUDE
262    })
263    @Retention(RetentionPolicy.SOURCE)
264    @interface TransitionType {}
265
266    /**
267     * Transition flag: Keyguard is going away, but keeping the notification shade open
268     * @hide
269     */
270    int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE = 0x1;
271
272    /**
273     * Transition flag: Keyguard is going away, but doesn't want an animation for it
274     * @hide
275     */
276    int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION = 0x2;
277
278    /**
279     * Transition flag: Keyguard is going away while it was showing the system wallpaper.
280     * @hide
281     */
282    int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER = 0x4;
283
284    /**
285     * @hide
286     */
287    @IntDef(flag = true, prefix = { "TRANSIT_FLAG_" }, value = {
288            TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE,
289            TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION,
290            TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER,
291    })
292    @Retention(RetentionPolicy.SOURCE)
293    @interface TransitionFlags {}
294
295    /**
296     * Exception that is thrown when trying to add view whose
297     * {@link LayoutParams} {@link LayoutParams#token}
298     * is invalid.
299     */
300    public static class BadTokenException extends RuntimeException {
301        public BadTokenException() {
302        }
303
304        public BadTokenException(String name) {
305            super(name);
306        }
307    }
308
309    /**
310     * Exception that is thrown when calling {@link #addView} to a secondary display that cannot
311     * be found. See {@link android.app.Presentation} for more information on secondary displays.
312     */
313    public static class InvalidDisplayException extends RuntimeException {
314        public InvalidDisplayException() {
315        }
316
317        public InvalidDisplayException(String name) {
318            super(name);
319        }
320    }
321
322    /**
323     * Returns the {@link Display} upon which this {@link WindowManager} instance
324     * will create new windows.
325     * <p>
326     * Despite the name of this method, the display that is returned is not
327     * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}).
328     * The returned display could instead be a secondary display that this
329     * window manager instance is managing.  Think of it as the display that
330     * this {@link WindowManager} instance uses by default.
331     * </p><p>
332     * To create windows on a different display, you need to obtain a
333     * {@link WindowManager} for that {@link Display}.  (See the {@link WindowManager}
334     * class documentation for more information.)
335     * </p>
336     *
337     * @return The display that this window manager is managing.
338     */
339    public Display getDefaultDisplay();
340
341    /**
342     * Special variation of {@link #removeView} that immediately invokes
343     * the given view hierarchy's {@link View#onDetachedFromWindow()
344     * View.onDetachedFromWindow()} methods before returning.  This is not
345     * for normal applications; using it correctly requires great care.
346     *
347     * @param view The view to be removed.
348     */
349    public void removeViewImmediate(View view);
350
351    /**
352     * Used to asynchronously request Keyboard Shortcuts from the focused window.
353     *
354     * @hide
355     */
356    public interface KeyboardShortcutsReceiver {
357        /**
358         * Callback used when the focused window keyboard shortcuts are ready to be displayed.
359         *
360         * @param result The keyboard shortcuts to be displayed.
361         */
362        void onKeyboardShortcutsReceived(List<KeyboardShortcutGroup> result);
363    }
364
365    /**
366     * Message for taking fullscreen screenshot
367     * @hide
368     */
369    final int TAKE_SCREENSHOT_FULLSCREEN = 1;
370
371    /**
372     * Message for taking screenshot of selected region.
373     * @hide
374     */
375    final int TAKE_SCREENSHOT_SELECTED_REGION = 2;
376
377    /**
378     * @hide
379     */
380    public static final String PARCEL_KEY_SHORTCUTS_ARRAY = "shortcuts_array";
381
382    /**
383     * Request for keyboard shortcuts to be retrieved asynchronously.
384     *
385     * @param receiver The callback to be triggered when the result is ready.
386     *
387     * @hide
388     */
389    public void requestAppKeyboardShortcuts(final KeyboardShortcutsReceiver receiver, int deviceId);
390
391    /**
392     * Return the touch region for the current IME window, or an empty region if there is none.
393     *
394     * @return The region of the IME that is accepting touch inputs, or null if there is no IME, no
395     *         region or there was an error.
396     *
397     * @hide
398     */
399    @SystemApi
400    @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS)
401    public Region getCurrentImeTouchRegion();
402
403    public static class LayoutParams extends ViewGroup.LayoutParams implements Parcelable {
404        /**
405         * X position for this window.  With the default gravity it is ignored.
406         * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or
407         * {@link Gravity#END} it provides an offset from the given edge.
408         */
409        @ViewDebug.ExportedProperty
410        public int x;
411
412        /**
413         * Y position for this window.  With the default gravity it is ignored.
414         * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
415         * an offset from the given edge.
416         */
417        @ViewDebug.ExportedProperty
418        public int y;
419
420        /**
421         * Indicates how much of the extra space will be allocated horizontally
422         * to the view associated with these LayoutParams. Specify 0 if the view
423         * should not be stretched. Otherwise the extra pixels will be pro-rated
424         * among all views whose weight is greater than 0.
425         */
426        @ViewDebug.ExportedProperty
427        public float horizontalWeight;
428
429        /**
430         * Indicates how much of the extra space will be allocated vertically
431         * to the view associated with these LayoutParams. Specify 0 if the view
432         * should not be stretched. Otherwise the extra pixels will be pro-rated
433         * among all views whose weight is greater than 0.
434         */
435        @ViewDebug.ExportedProperty
436        public float verticalWeight;
437
438        /**
439         * The general type of window.  There are three main classes of
440         * window types:
441         * <ul>
442         * <li> <strong>Application windows</strong> (ranging from
443         * {@link #FIRST_APPLICATION_WINDOW} to
444         * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application
445         * windows.  For these types of windows, the {@link #token} must be
446         * set to the token of the activity they are a part of (this will
447         * normally be done for you if {@link #token} is null).
448         * <li> <strong>Sub-windows</strong> (ranging from
449         * {@link #FIRST_SUB_WINDOW} to
450         * {@link #LAST_SUB_WINDOW}) are associated with another top-level
451         * window.  For these types of windows, the {@link #token} must be
452         * the token of the window it is attached to.
453         * <li> <strong>System windows</strong> (ranging from
454         * {@link #FIRST_SYSTEM_WINDOW} to
455         * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for
456         * use by the system for specific purposes.  They should not normally
457         * be used by applications, and a special permission is required
458         * to use them.
459         * </ul>
460         *
461         * @see #TYPE_BASE_APPLICATION
462         * @see #TYPE_APPLICATION
463         * @see #TYPE_APPLICATION_STARTING
464         * @see #TYPE_DRAWN_APPLICATION
465         * @see #TYPE_APPLICATION_PANEL
466         * @see #TYPE_APPLICATION_MEDIA
467         * @see #TYPE_APPLICATION_SUB_PANEL
468         * @see #TYPE_APPLICATION_ABOVE_SUB_PANEL
469         * @see #TYPE_APPLICATION_ATTACHED_DIALOG
470         * @see #TYPE_STATUS_BAR
471         * @see #TYPE_SEARCH_BAR
472         * @see #TYPE_PHONE
473         * @see #TYPE_SYSTEM_ALERT
474         * @see #TYPE_TOAST
475         * @see #TYPE_SYSTEM_OVERLAY
476         * @see #TYPE_PRIORITY_PHONE
477         * @see #TYPE_STATUS_BAR_PANEL
478         * @see #TYPE_SYSTEM_DIALOG
479         * @see #TYPE_KEYGUARD_DIALOG
480         * @see #TYPE_SYSTEM_ERROR
481         * @see #TYPE_INPUT_METHOD
482         * @see #TYPE_INPUT_METHOD_DIALOG
483         */
484        @ViewDebug.ExportedProperty(mapping = {
485                @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION,
486                        to = "BASE_APPLICATION"),
487                @ViewDebug.IntToString(from = TYPE_APPLICATION,
488                        to = "APPLICATION"),
489                @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING,
490                        to = "APPLICATION_STARTING"),
491                @ViewDebug.IntToString(from = TYPE_DRAWN_APPLICATION,
492                        to = "DRAWN_APPLICATION"),
493                @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL,
494                        to = "APPLICATION_PANEL"),
495                @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA,
496                        to = "APPLICATION_MEDIA"),
497                @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL,
498                        to = "APPLICATION_SUB_PANEL"),
499                @ViewDebug.IntToString(from = TYPE_APPLICATION_ABOVE_SUB_PANEL,
500                        to = "APPLICATION_ABOVE_SUB_PANEL"),
501                @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG,
502                        to = "APPLICATION_ATTACHED_DIALOG"),
503                @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY,
504                        to = "APPLICATION_MEDIA_OVERLAY"),
505                @ViewDebug.IntToString(from = TYPE_STATUS_BAR,
506                        to = "STATUS_BAR"),
507                @ViewDebug.IntToString(from = TYPE_SEARCH_BAR,
508                        to = "SEARCH_BAR"),
509                @ViewDebug.IntToString(from = TYPE_PHONE,
510                        to = "PHONE"),
511                @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT,
512                        to = "SYSTEM_ALERT"),
513                @ViewDebug.IntToString(from = TYPE_TOAST,
514                        to = "TOAST"),
515                @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY,
516                        to = "SYSTEM_OVERLAY"),
517                @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE,
518                        to = "PRIORITY_PHONE"),
519                @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG,
520                        to = "SYSTEM_DIALOG"),
521                @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG,
522                        to = "KEYGUARD_DIALOG"),
523                @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR,
524                        to = "SYSTEM_ERROR"),
525                @ViewDebug.IntToString(from = TYPE_INPUT_METHOD,
526                        to = "INPUT_METHOD"),
527                @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG,
528                        to = "INPUT_METHOD_DIALOG"),
529                @ViewDebug.IntToString(from = TYPE_WALLPAPER,
530                        to = "WALLPAPER"),
531                @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL,
532                        to = "STATUS_BAR_PANEL"),
533                @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY,
534                        to = "SECURE_SYSTEM_OVERLAY"),
535                @ViewDebug.IntToString(from = TYPE_DRAG,
536                        to = "DRAG"),
537                @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL,
538                        to = "STATUS_BAR_SUB_PANEL"),
539                @ViewDebug.IntToString(from = TYPE_POINTER,
540                        to = "POINTER"),
541                @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR,
542                        to = "NAVIGATION_BAR"),
543                @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY,
544                        to = "VOLUME_OVERLAY"),
545                @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS,
546                        to = "BOOT_PROGRESS"),
547                @ViewDebug.IntToString(from = TYPE_INPUT_CONSUMER,
548                        to = "INPUT_CONSUMER"),
549                @ViewDebug.IntToString(from = TYPE_DREAM,
550                        to = "DREAM"),
551                @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL,
552                        to = "NAVIGATION_BAR_PANEL"),
553                @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY,
554                        to = "DISPLAY_OVERLAY"),
555                @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY,
556                        to = "MAGNIFICATION_OVERLAY"),
557                @ViewDebug.IntToString(from = TYPE_PRESENTATION,
558                        to = "PRESENTATION"),
559                @ViewDebug.IntToString(from = TYPE_PRIVATE_PRESENTATION,
560                        to = "PRIVATE_PRESENTATION"),
561                @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION,
562                        to = "VOICE_INTERACTION"),
563                @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION_STARTING,
564                        to = "VOICE_INTERACTION_STARTING"),
565                @ViewDebug.IntToString(from = TYPE_DOCK_DIVIDER,
566                        to = "DOCK_DIVIDER"),
567                @ViewDebug.IntToString(from = TYPE_QS_DIALOG,
568                        to = "QS_DIALOG"),
569                @ViewDebug.IntToString(from = TYPE_SCREENSHOT,
570                        to = "SCREENSHOT"),
571                @ViewDebug.IntToString(from = TYPE_APPLICATION_OVERLAY,
572                        to = "APPLICATION_OVERLAY")
573        })
574        public int type;
575
576        /**
577         * Start of window types that represent normal application windows.
578         */
579        public static final int FIRST_APPLICATION_WINDOW = 1;
580
581        /**
582         * Window type: an application window that serves as the "base" window
583         * of the overall application; all other application windows will
584         * appear on top of it.
585         * In multiuser systems shows only on the owning user's window.
586         */
587        public static final int TYPE_BASE_APPLICATION   = 1;
588
589        /**
590         * Window type: a normal application window.  The {@link #token} must be
591         * an Activity token identifying who the window belongs to.
592         * In multiuser systems shows only on the owning user's window.
593         */
594        public static final int TYPE_APPLICATION        = 2;
595
596        /**
597         * Window type: special application window that is displayed while the
598         * application is starting.  Not for use by applications themselves;
599         * this is used by the system to display something until the
600         * application can show its own windows.
601         * In multiuser systems shows on all users' windows.
602         */
603        public static final int TYPE_APPLICATION_STARTING = 3;
604
605        /**
606         * Window type: a variation on TYPE_APPLICATION that ensures the window
607         * manager will wait for this window to be drawn before the app is shown.
608         * In multiuser systems shows only on the owning user's window.
609         */
610        public static final int TYPE_DRAWN_APPLICATION = 4;
611
612        /**
613         * End of types of application windows.
614         */
615        public static final int LAST_APPLICATION_WINDOW = 99;
616
617        /**
618         * Start of types of sub-windows.  The {@link #token} of these windows
619         * must be set to the window they are attached to.  These types of
620         * windows are kept next to their attached window in Z-order, and their
621         * coordinate space is relative to their attached window.
622         */
623        public static final int FIRST_SUB_WINDOW = 1000;
624
625        /**
626         * Window type: a panel on top of an application window.  These windows
627         * appear on top of their attached window.
628         */
629        public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
630
631        /**
632         * Window type: window for showing media (such as video).  These windows
633         * are displayed behind their attached window.
634         */
635        public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1;
636
637        /**
638         * Window type: a sub-panel on top of an application window.  These
639         * windows are displayed on top their attached window and any
640         * {@link #TYPE_APPLICATION_PANEL} panels.
641         */
642        public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2;
643
644        /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
645         * of the window happens as that of a top-level window, <em>not</em>
646         * as a child of its container.
647         */
648        public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3;
649
650        /**
651         * Window type: window for showing overlays on top of media windows.
652         * These windows are displayed between TYPE_APPLICATION_MEDIA and the
653         * application window.  They should be translucent to be useful.  This
654         * is a big ugly hack so:
655         * @hide
656         */
657        public static final int TYPE_APPLICATION_MEDIA_OVERLAY  = FIRST_SUB_WINDOW + 4;
658
659        /**
660         * Window type: a above sub-panel on top of an application window and it's
661         * sub-panel windows. These windows are displayed on top of their attached window
662         * and any {@link #TYPE_APPLICATION_SUB_PANEL} panels.
663         * @hide
664         */
665        public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5;
666
667        /**
668         * End of types of sub-windows.
669         */
670        public static final int LAST_SUB_WINDOW = 1999;
671
672        /**
673         * Start of system-specific window types.  These are not normally
674         * created by applications.
675         */
676        public static final int FIRST_SYSTEM_WINDOW     = 2000;
677
678        /**
679         * Window type: the status bar.  There can be only one status bar
680         * window; it is placed at the top of the screen, and all other
681         * windows are shifted down so they are below it.
682         * In multiuser systems shows on all users' windows.
683         */
684        public static final int TYPE_STATUS_BAR         = FIRST_SYSTEM_WINDOW;
685
686        /**
687         * Window type: the search bar.  There can be only one search bar
688         * window; it is placed at the top of the screen.
689         * In multiuser systems shows on all users' windows.
690         */
691        public static final int TYPE_SEARCH_BAR         = FIRST_SYSTEM_WINDOW+1;
692
693        /**
694         * Window type: phone.  These are non-application windows providing
695         * user interaction with the phone (in particular incoming calls).
696         * These windows are normally placed above all applications, but behind
697         * the status bar.
698         * In multiuser systems shows on all users' windows.
699         * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
700         */
701        @Deprecated
702        public static final int TYPE_PHONE              = FIRST_SYSTEM_WINDOW+2;
703
704        /**
705         * Window type: system window, such as low power alert. These windows
706         * are always on top of application windows.
707         * In multiuser systems shows only on the owning user's window.
708         * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
709         */
710        @Deprecated
711        public static final int TYPE_SYSTEM_ALERT       = FIRST_SYSTEM_WINDOW+3;
712
713        /**
714         * Window type: keyguard window.
715         * In multiuser systems shows on all users' windows.
716         * @removed
717         */
718        public static final int TYPE_KEYGUARD           = FIRST_SYSTEM_WINDOW+4;
719
720        /**
721         * Window type: transient notifications.
722         * In multiuser systems shows only on the owning user's window.
723         * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
724         */
725        @Deprecated
726        public static final int TYPE_TOAST              = FIRST_SYSTEM_WINDOW+5;
727
728        /**
729         * Window type: system overlay windows, which need to be displayed
730         * on top of everything else.  These windows must not take input
731         * focus, or they will interfere with the keyguard.
732         * In multiuser systems shows only on the owning user's window.
733         * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
734         */
735        @Deprecated
736        public static final int TYPE_SYSTEM_OVERLAY     = FIRST_SYSTEM_WINDOW+6;
737
738        /**
739         * Window type: priority phone UI, which needs to be displayed even if
740         * the keyguard is active.  These windows must not take input
741         * focus, or they will interfere with the keyguard.
742         * In multiuser systems shows on all users' windows.
743         * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
744         */
745        @Deprecated
746        public static final int TYPE_PRIORITY_PHONE     = FIRST_SYSTEM_WINDOW+7;
747
748        /**
749         * Window type: panel that slides out from the status bar
750         * In multiuser systems shows on all users' windows.
751         */
752        public static final int TYPE_SYSTEM_DIALOG      = FIRST_SYSTEM_WINDOW+8;
753
754        /**
755         * Window type: dialogs that the keyguard shows
756         * In multiuser systems shows on all users' windows.
757         */
758        public static final int TYPE_KEYGUARD_DIALOG    = FIRST_SYSTEM_WINDOW+9;
759
760        /**
761         * Window type: internal system error windows, appear on top of
762         * everything they can.
763         * In multiuser systems shows only on the owning user's window.
764         * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
765         */
766        @Deprecated
767        public static final int TYPE_SYSTEM_ERROR       = FIRST_SYSTEM_WINDOW+10;
768
769        /**
770         * Window type: internal input methods windows, which appear above
771         * the normal UI.  Application windows may be resized or panned to keep
772         * the input focus visible while this window is displayed.
773         * In multiuser systems shows only on the owning user's window.
774         */
775        public static final int TYPE_INPUT_METHOD       = FIRST_SYSTEM_WINDOW+11;
776
777        /**
778         * Window type: internal input methods dialog windows, which appear above
779         * the current input method window.
780         * In multiuser systems shows only on the owning user's window.
781         */
782        public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
783
784        /**
785         * Window type: wallpaper window, placed behind any window that wants
786         * to sit on top of the wallpaper.
787         * In multiuser systems shows only on the owning user's window.
788         */
789        public static final int TYPE_WALLPAPER          = FIRST_SYSTEM_WINDOW+13;
790
791        /**
792         * Window type: panel that slides out from over the status bar
793         * In multiuser systems shows on all users' windows.
794         */
795        public static final int TYPE_STATUS_BAR_PANEL   = FIRST_SYSTEM_WINDOW+14;
796
797        /**
798         * Window type: secure system overlay windows, which need to be displayed
799         * on top of everything else.  These windows must not take input
800         * focus, or they will interfere with the keyguard.
801         *
802         * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
803         * system itself is allowed to create these overlays.  Applications cannot
804         * obtain permission to create secure system overlays.
805         *
806         * In multiuser systems shows only on the owning user's window.
807         * @hide
808         */
809        public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
810
811        /**
812         * Window type: the drag-and-drop pseudowindow.  There is only one
813         * drag layer (at most), and it is placed on top of all other windows.
814         * In multiuser systems shows only on the owning user's window.
815         * @hide
816         */
817        public static final int TYPE_DRAG               = FIRST_SYSTEM_WINDOW+16;
818
819        /**
820         * Window type: panel that slides out from over the status bar
821         * In multiuser systems shows on all users' windows. These windows
822         * are displayed on top of the stauts bar and any {@link #TYPE_STATUS_BAR_PANEL}
823         * windows.
824         * @hide
825         */
826        public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
827
828        /**
829         * Window type: (mouse) pointer
830         * In multiuser systems shows on all users' windows.
831         * @hide
832         */
833        public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
834
835        /**
836         * Window type: Navigation bar (when distinct from status bar)
837         * In multiuser systems shows on all users' windows.
838         * @hide
839         */
840        public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
841
842        /**
843         * Window type: The volume level overlay/dialog shown when the user
844         * changes the system volume.
845         * In multiuser systems shows on all users' windows.
846         * @hide
847         */
848        public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
849
850        /**
851         * Window type: The boot progress dialog, goes on top of everything
852         * in the world.
853         * In multiuser systems shows on all users' windows.
854         * @hide
855         */
856        public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
857
858        /**
859         * Window type to consume input events when the systemUI bars are hidden.
860         * In multiuser systems shows on all users' windows.
861         * @hide
862         */
863        public static final int TYPE_INPUT_CONSUMER = FIRST_SYSTEM_WINDOW+22;
864
865        /**
866         * Window type: Dreams (screen saver) window, just above keyguard.
867         * In multiuser systems shows only on the owning user's window.
868         * @hide
869         */
870        public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23;
871
872        /**
873         * Window type: Navigation bar panel (when navigation bar is distinct from status bar)
874         * In multiuser systems shows on all users' windows.
875         * @hide
876         */
877        public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24;
878
879        /**
880         * Window type: Display overlay window.  Used to simulate secondary display devices.
881         * In multiuser systems shows on all users' windows.
882         * @hide
883         */
884        public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26;
885
886        /**
887         * Window type: Magnification overlay window. Used to highlight the magnified
888         * portion of a display when accessibility magnification is enabled.
889         * In multiuser systems shows on all users' windows.
890         * @hide
891         */
892        public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27;
893
894        /**
895         * Window type: Window for Presentation on top of private
896         * virtual display.
897         */
898        public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30;
899
900        /**
901         * Window type: Windows in the voice interaction layer.
902         * @hide
903         */
904        public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31;
905
906        /**
907         * Window type: Windows that are overlaid <em>only</em> by a connected {@link
908         * android.accessibilityservice.AccessibilityService} for interception of
909         * user interactions without changing the windows an accessibility service
910         * can introspect. In particular, an accessibility service can introspect
911         * only windows that a sighted user can interact with which is they can touch
912         * these windows or can type into these windows. For example, if there
913         * is a full screen accessibility overlay that is touchable, the windows
914         * below it will be introspectable by an accessibility service even though
915         * they are covered by a touchable window.
916         */
917        public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32;
918
919        /**
920         * Window type: Starting window for voice interaction layer.
921         * @hide
922         */
923        public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33;
924
925        /**
926         * Window for displaying a handle used for resizing docked stacks. This window is owned
927         * by the system process.
928         * @hide
929         */
930        public static final int TYPE_DOCK_DIVIDER = FIRST_SYSTEM_WINDOW+34;
931
932        /**
933         * Window type: like {@link #TYPE_APPLICATION_ATTACHED_DIALOG}, but used
934         * by Quick Settings Tiles.
935         * @hide
936         */
937        public static final int TYPE_QS_DIALOG = FIRST_SYSTEM_WINDOW+35;
938
939        /**
940         * Window type: shares similar characteristics with {@link #TYPE_DREAM}. The layer is
941         * reserved for screenshot region selection. These windows must not take input focus.
942         * @hide
943         */
944        public static final int TYPE_SCREENSHOT = FIRST_SYSTEM_WINDOW + 36;
945
946        /**
947         * Window type: Window for Presentation on an external display.
948         * @see android.app.Presentation
949         * @hide
950         */
951        public static final int TYPE_PRESENTATION = FIRST_SYSTEM_WINDOW + 37;
952
953        /**
954         * Window type: Application overlay windows are displayed above all activity windows
955         * (types between {@link #FIRST_APPLICATION_WINDOW} and {@link #LAST_APPLICATION_WINDOW})
956         * but below critical system windows like the status bar or IME.
957         * <p>
958         * The system may change the position, size, or visibility of these windows at anytime
959         * to reduce visual clutter to the user and also manage resources.
960         * <p>
961         * Requires {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} permission.
962         * <p>
963         * The system will adjust the importance of processes with this window type to reduce the
964         * chance of the low-memory-killer killing them.
965         * <p>
966         * In multi-user systems shows only on the owning user's screen.
967         */
968        public static final int TYPE_APPLICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 38;
969
970        /**
971         * End of types of system windows.
972         */
973        public static final int LAST_SYSTEM_WINDOW      = 2999;
974
975        /**
976         * @hide
977         * Used internally when there is no suitable type available.
978         */
979        public static final int INVALID_WINDOW_TYPE = -1;
980
981        /**
982         * Return true if the window type is an alert window.
983         *
984         * @param type The window type.
985         * @return If the window type is an alert window.
986         * @hide
987         */
988        public static boolean isSystemAlertWindowType(int type) {
989            switch (type) {
990                case TYPE_PHONE:
991                case TYPE_PRIORITY_PHONE:
992                case TYPE_SYSTEM_ALERT:
993                case TYPE_SYSTEM_ERROR:
994                case TYPE_SYSTEM_OVERLAY:
995                case TYPE_APPLICATION_OVERLAY:
996                    return true;
997            }
998            return false;
999        }
1000
1001        /** @deprecated this is ignored, this value is set automatically when needed. */
1002        @Deprecated
1003        public static final int MEMORY_TYPE_NORMAL = 0;
1004        /** @deprecated this is ignored, this value is set automatically when needed. */
1005        @Deprecated
1006        public static final int MEMORY_TYPE_HARDWARE = 1;
1007        /** @deprecated this is ignored, this value is set automatically when needed. */
1008        @Deprecated
1009        public static final int MEMORY_TYPE_GPU = 2;
1010        /** @deprecated this is ignored, this value is set automatically when needed. */
1011        @Deprecated
1012        public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
1013
1014        /**
1015         * @deprecated this is ignored
1016         */
1017        @Deprecated
1018        public int memoryType;
1019
1020        /** Window flag: as long as this window is visible to the user, allow
1021         *  the lock screen to activate while the screen is on.
1022         *  This can be used independently, or in combination with
1023         *  {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
1024        public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001;
1025
1026        /** Window flag: everything behind this window will be dimmed.
1027         *  Use {@link #dimAmount} to control the amount of dim. */
1028        public static final int FLAG_DIM_BEHIND        = 0x00000002;
1029
1030        /** Window flag: blur everything behind this window.
1031         * @deprecated Blurring is no longer supported. */
1032        @Deprecated
1033        public static final int FLAG_BLUR_BEHIND        = 0x00000004;
1034
1035        /** Window flag: this window won't ever get key input focus, so the
1036         * user can not send key or other button events to it.  Those will
1037         * instead go to whatever focusable window is behind it.  This flag
1038         * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
1039         * is explicitly set.
1040         *
1041         * <p>Setting this flag also implies that the window will not need to
1042         * interact with
1043         * a soft input method, so it will be Z-ordered and positioned
1044         * independently of any active input method (typically this means it
1045         * gets Z-ordered on top of the input method, so it can use the full
1046         * screen for its content and cover the input method if needed.  You
1047         * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
1048        public static final int FLAG_NOT_FOCUSABLE      = 0x00000008;
1049
1050        /** Window flag: this window can never receive touch events. */
1051        public static final int FLAG_NOT_TOUCHABLE      = 0x00000010;
1052
1053        /** Window flag: even when this window is focusable (its
1054         * {@link #FLAG_NOT_FOCUSABLE} is not set), allow any pointer events
1055         * outside of the window to be sent to the windows behind it.  Otherwise
1056         * it will consume all pointer events itself, regardless of whether they
1057         * are inside of the window. */
1058        public static final int FLAG_NOT_TOUCH_MODAL    = 0x00000020;
1059
1060        /** Window flag: when set, if the device is asleep when the touch
1061         * screen is pressed, you will receive this first touch event.  Usually
1062         * the first touch event is consumed by the system since the user can
1063         * not see what they are pressing on.
1064         *
1065         * @deprecated This flag has no effect.
1066         */
1067        @Deprecated
1068        public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
1069
1070        /** Window flag: as long as this window is visible to the user, keep
1071         *  the device's screen turned on and bright. */
1072        public static final int FLAG_KEEP_SCREEN_ON     = 0x00000080;
1073
1074        /** Window flag: place the window within the entire screen, ignoring
1075         *  decorations around the border (such as the status bar).  The
1076         *  window must correctly position its contents to take the screen
1077         *  decoration into account.  This flag is normally set for you
1078         *  by Window as described in {@link Window#setFlags}.
1079         *
1080         *  <p>Note: on displays that have a {@link DisplayCutout}, the window may be placed
1081         *  such that it avoids the {@link DisplayCutout} area if necessary according to the
1082         *  {@link #layoutInDisplayCutoutMode}.
1083         */
1084        public static final int FLAG_LAYOUT_IN_SCREEN   = 0x00000100;
1085
1086        /** Window flag: allow window to extend outside of the screen. */
1087        public static final int FLAG_LAYOUT_NO_LIMITS   = 0x00000200;
1088
1089        /**
1090         * Window flag: hide all screen decorations (such as the status bar) while
1091         * this window is displayed.  This allows the window to use the entire
1092         * display space for itself -- the status bar will be hidden when
1093         * an app window with this flag set is on the top layer. A fullscreen window
1094         * will ignore a value of {@link #SOFT_INPUT_ADJUST_RESIZE} for the window's
1095         * {@link #softInputMode} field; the window will stay fullscreen
1096         * and will not resize.
1097         *
1098         * <p>This flag can be controlled in your theme through the
1099         * {@link android.R.attr#windowFullscreen} attribute; this attribute
1100         * is automatically set for you in the standard fullscreen themes
1101         * such as {@link android.R.style#Theme_NoTitleBar_Fullscreen},
1102         * {@link android.R.style#Theme_Black_NoTitleBar_Fullscreen},
1103         * {@link android.R.style#Theme_Light_NoTitleBar_Fullscreen},
1104         * {@link android.R.style#Theme_Holo_NoActionBar_Fullscreen},
1105         * {@link android.R.style#Theme_Holo_Light_NoActionBar_Fullscreen},
1106         * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Fullscreen}, and
1107         * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Fullscreen}.</p>
1108         */
1109        public static final int FLAG_FULLSCREEN      = 0x00000400;
1110
1111        /** Window flag: override {@link #FLAG_FULLSCREEN} and force the
1112         *  screen decorations (such as the status bar) to be shown. */
1113        public static final int FLAG_FORCE_NOT_FULLSCREEN   = 0x00000800;
1114
1115        /** Window flag: turn on dithering when compositing this window to
1116         *  the screen.
1117         * @deprecated This flag is no longer used. */
1118        @Deprecated
1119        public static final int FLAG_DITHER             = 0x00001000;
1120
1121        /** Window flag: treat the content of the window as secure, preventing
1122         * it from appearing in screenshots or from being viewed on non-secure
1123         * displays.
1124         *
1125         * <p>See {@link android.view.Display#FLAG_SECURE} for more details about
1126         * secure surfaces and secure displays.
1127         */
1128        public static final int FLAG_SECURE             = 0x00002000;
1129
1130        /** Window flag: a special mode where the layout parameters are used
1131         * to perform scaling of the surface when it is composited to the
1132         * screen. */
1133        public static final int FLAG_SCALED             = 0x00004000;
1134
1135        /** Window flag: intended for windows that will often be used when the user is
1136         * holding the screen against their face, it will aggressively filter the event
1137         * stream to prevent unintended presses in this situation that may not be
1138         * desired for a particular window, when such an event stream is detected, the
1139         * application will receive a CANCEL motion event to indicate this so applications
1140         * can handle this accordingly by taking no action on the event
1141         * until the finger is released. */
1142        public static final int FLAG_IGNORE_CHEEK_PRESSES    = 0x00008000;
1143
1144        /** Window flag: a special option only for use in combination with
1145         * {@link #FLAG_LAYOUT_IN_SCREEN}.  When requesting layout in the
1146         * screen your window may appear on top of or behind screen decorations
1147         * such as the status bar.  By also including this flag, the window
1148         * manager will report the inset rectangle needed to ensure your
1149         * content is not covered by screen decorations.  This flag is normally
1150         * set for you by Window as described in {@link Window#setFlags}.*/
1151        public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
1152
1153        /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
1154         * respect to how this window interacts with the current method.  That
1155         * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
1156         * window will behave as if it needs to interact with the input method
1157         * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
1158         * not set and this flag is set, then the window will behave as if it
1159         * doesn't need to interact with the input method and can be placed
1160         * to use more space and cover the input method.
1161         */
1162        public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
1163
1164        /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
1165         * can set this flag to receive a single special MotionEvent with
1166         * the action
1167         * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
1168         * touches that occur outside of your window.  Note that you will not
1169         * receive the full down/move/up gesture, only the location of the
1170         * first down as an ACTION_OUTSIDE.
1171         */
1172        public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
1173
1174        /** Window flag: special flag to let windows be shown when the screen
1175         * is locked. This will let application windows take precedence over
1176         * key guard or any other lock screens. Can be used with
1177         * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
1178         * directly before showing the key guard window.  Can be used with
1179         * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
1180         * non-secure keyguards.  This flag only applies to the top-most
1181         * full-screen window.
1182         * @deprecated Use {@link android.R.attr#showWhenLocked} or
1183         * {@link android.app.Activity#setShowWhenLocked(boolean)} instead to prevent an
1184         * unintentional double life-cycle event.
1185         */
1186        @Deprecated
1187        public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
1188
1189        /** Window flag: ask that the system wallpaper be shown behind
1190         * your window.  The window surface must be translucent to be able
1191         * to actually see the wallpaper behind it; this flag just ensures
1192         * that the wallpaper surface will be there if this window actually
1193         * has translucent regions.
1194         *
1195         * <p>This flag can be controlled in your theme through the
1196         * {@link android.R.attr#windowShowWallpaper} attribute; this attribute
1197         * is automatically set for you in the standard wallpaper themes
1198         * such as {@link android.R.style#Theme_Wallpaper},
1199         * {@link android.R.style#Theme_Wallpaper_NoTitleBar},
1200         * {@link android.R.style#Theme_Wallpaper_NoTitleBar_Fullscreen},
1201         * {@link android.R.style#Theme_Holo_Wallpaper},
1202         * {@link android.R.style#Theme_Holo_Wallpaper_NoTitleBar},
1203         * {@link android.R.style#Theme_DeviceDefault_Wallpaper}, and
1204         * {@link android.R.style#Theme_DeviceDefault_Wallpaper_NoTitleBar}.</p>
1205         */
1206        public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
1207
1208        /** Window flag: when set as a window is being added or made
1209         * visible, once the window has been shown then the system will
1210         * poke the power manager's user activity (as if the user had woken
1211         * up the device) to turn the screen on.
1212         * @deprecated Use {@link android.R.attr#turnScreenOn} or
1213         * {@link android.app.Activity#setTurnScreenOn(boolean)} instead to prevent an
1214         * unintentional double life-cycle event.
1215         */
1216        @Deprecated
1217        public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
1218
1219        /**
1220         * Window flag: when set the window will cause the keyguard to be
1221         * dismissed, only if it is not a secure lock keyguard. Because such a
1222         * keyguard is not needed for security, it will never re-appear if the
1223         * user navigates to another window (in contrast to
1224         * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily hide both
1225         * secure and non-secure keyguards but ensure they reappear when the
1226         * user moves to another UI that doesn't hide them). If the keyguard is
1227         * currently active and is secure (requires an unlock credential) than
1228         * the user will still need to confirm it before seeing this window,
1229         * unless {@link #FLAG_SHOW_WHEN_LOCKED} has also been set.
1230         *
1231         * @deprecated Use {@link #FLAG_SHOW_WHEN_LOCKED} or
1232         *             {@link KeyguardManager#requestDismissKeyguard} instead.
1233         *             Since keyguard was dismissed all the time as long as an
1234         *             activity with this flag on its window was focused,
1235         *             keyguard couldn't guard against unintentional touches on
1236         *             the screen, which isn't desired.
1237         */
1238        @Deprecated
1239        public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
1240
1241        /** Window flag: when set the window will accept for touch events
1242         * outside of its bounds to be sent to other windows that also
1243         * support split touch.  When this flag is not set, the first pointer
1244         * that goes down determines the window to which all subsequent touches
1245         * go until all pointers go up.  When this flag is set, each pointer
1246         * (not necessarily the first) that goes down determines the window
1247         * to which all subsequent touches of that pointer will go until that
1248         * pointer goes up thereby enabling touches with multiple pointers
1249         * to be split across multiple windows.
1250         */
1251        public static final int FLAG_SPLIT_TOUCH = 0x00800000;
1252
1253        /**
1254         * <p>Indicates whether this window should be hardware accelerated.
1255         * Requesting hardware acceleration does not guarantee it will happen.</p>
1256         *
1257         * <p>This flag can be controlled programmatically <em>only</em> to enable
1258         * hardware acceleration. To enable hardware acceleration for a given
1259         * window programmatically, do the following:</p>
1260         *
1261         * <pre>
1262         * Window w = activity.getWindow(); // in Activity's onCreate() for instance
1263         * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
1264         *         WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
1265         * </pre>
1266         *
1267         * <p>It is important to remember that this flag <strong>must</strong>
1268         * be set before setting the content view of your activity or dialog.</p>
1269         *
1270         * <p>This flag cannot be used to disable hardware acceleration after it
1271         * was enabled in your manifest using
1272         * {@link android.R.attr#hardwareAccelerated}. If you need to selectively
1273         * and programmatically disable hardware acceleration (for automated testing
1274         * for instance), make sure it is turned off in your manifest and enable it
1275         * on your activity or dialog when you need it instead, using the method
1276         * described above.</p>
1277         *
1278         * <p>This flag is automatically set by the system if the
1279         * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
1280         * XML attribute is set to true on an activity or on the application.</p>
1281         */
1282        public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
1283
1284        /**
1285         * Window flag: allow window contents to extend in to the screen's
1286         * overscan area, if there is one.  The window should still correctly
1287         * position its contents to take the overscan area into account.
1288         *
1289         * <p>This flag can be controlled in your theme through the
1290         * {@link android.R.attr#windowOverscan} attribute; this attribute
1291         * is automatically set for you in the standard overscan themes
1292         * such as
1293         * {@link android.R.style#Theme_Holo_NoActionBar_Overscan},
1294         * {@link android.R.style#Theme_Holo_Light_NoActionBar_Overscan},
1295         * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Overscan}, and
1296         * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Overscan}.</p>
1297         *
1298         * <p>When this flag is enabled for a window, its normal content may be obscured
1299         * to some degree by the overscan region of the display.  To ensure key parts of
1300         * that content are visible to the user, you can use
1301         * {@link View#setFitsSystemWindows(boolean) View.setFitsSystemWindows(boolean)}
1302         * to set the point in the view hierarchy where the appropriate offsets should
1303         * be applied.  (This can be done either by directly calling this function, using
1304         * the {@link android.R.attr#fitsSystemWindows} attribute in your view hierarchy,
1305         * or implementing you own {@link View#fitSystemWindows(android.graphics.Rect)
1306         * View.fitSystemWindows(Rect)} method).</p>
1307         *
1308         * <p>This mechanism for positioning content elements is identical to its equivalent
1309         * use with layout and {@link View#setSystemUiVisibility(int)
1310         * View.setSystemUiVisibility(int)}; here is an example layout that will correctly
1311         * position its UI elements with this overscan flag is set:</p>
1312         *
1313         * {@sample development/samples/ApiDemos/res/layout/overscan_activity.xml complete}
1314         */
1315        public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000;
1316
1317        /**
1318         * Window flag: request a translucent status bar with minimal system-provided
1319         * background protection.
1320         *
1321         * <p>This flag can be controlled in your theme through the
1322         * {@link android.R.attr#windowTranslucentStatus} attribute; this attribute
1323         * is automatically set for you in the standard translucent decor themes
1324         * such as
1325         * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor},
1326         * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor},
1327         * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and
1328         * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p>
1329         *
1330         * <p>When this flag is enabled for a window, it automatically sets
1331         * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
1332         * {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p>
1333         */
1334        public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000;
1335
1336        /**
1337         * Window flag: request a translucent navigation bar with minimal system-provided
1338         * background protection.
1339         *
1340         * <p>This flag can be controlled in your theme through the
1341         * {@link android.R.attr#windowTranslucentNavigation} attribute; this attribute
1342         * is automatically set for you in the standard translucent decor themes
1343         * such as
1344         * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor},
1345         * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor},
1346         * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and
1347         * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p>
1348         *
1349         * <p>When this flag is enabled for a window, it automatically sets
1350         * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
1351         * {@link View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.</p>
1352         */
1353        public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000;
1354
1355        /**
1356         * Flag for a window in local focus mode.
1357         * Window in local focus mode can control focus independent of window manager using
1358         * {@link Window#setLocalFocus(boolean, boolean)}.
1359         * Usually window in this mode will not get touch/key events from window manager, but will
1360         * get events only via local injection using {@link Window#injectInputEvent(InputEvent)}.
1361         */
1362        public static final int FLAG_LOCAL_FOCUS_MODE = 0x10000000;
1363
1364        /** Window flag: Enable touches to slide out of a window into neighboring
1365         * windows in mid-gesture instead of being captured for the duration of
1366         * the gesture.
1367         *
1368         * This flag changes the behavior of touch focus for this window only.
1369         * Touches can slide out of the window but they cannot necessarily slide
1370         * back in (unless the other window with touch focus permits it).
1371         *
1372         * {@hide}
1373         */
1374        public static final int FLAG_SLIPPERY = 0x20000000;
1375
1376        /**
1377         * Window flag: When requesting layout with an attached window, the attached window may
1378         * overlap with the screen decorations of the parent window such as the navigation bar. By
1379         * including this flag, the window manager will layout the attached window within the decor
1380         * frame of the parent window such that it doesn't overlap with screen decorations.
1381         */
1382        public static final int FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000;
1383
1384        /**
1385         * Flag indicating that this Window is responsible for drawing the background for the
1386         * system bars. If set, the system bars are drawn with a transparent background and the
1387         * corresponding areas in this window are filled with the colors specified in
1388         * {@link Window#getStatusBarColor()} and {@link Window#getNavigationBarColor()}.
1389         */
1390        public static final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000;
1391
1392        /**
1393         * Various behavioral options/flags.  Default is none.
1394         *
1395         * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
1396         * @see #FLAG_DIM_BEHIND
1397         * @see #FLAG_NOT_FOCUSABLE
1398         * @see #FLAG_NOT_TOUCHABLE
1399         * @see #FLAG_NOT_TOUCH_MODAL
1400         * @see #FLAG_TOUCHABLE_WHEN_WAKING
1401         * @see #FLAG_KEEP_SCREEN_ON
1402         * @see #FLAG_LAYOUT_IN_SCREEN
1403         * @see #FLAG_LAYOUT_NO_LIMITS
1404         * @see #FLAG_FULLSCREEN
1405         * @see #FLAG_FORCE_NOT_FULLSCREEN
1406         * @see #FLAG_SECURE
1407         * @see #FLAG_SCALED
1408         * @see #FLAG_IGNORE_CHEEK_PRESSES
1409         * @see #FLAG_LAYOUT_INSET_DECOR
1410         * @see #FLAG_ALT_FOCUSABLE_IM
1411         * @see #FLAG_WATCH_OUTSIDE_TOUCH
1412         * @see #FLAG_SHOW_WHEN_LOCKED
1413         * @see #FLAG_SHOW_WALLPAPER
1414         * @see #FLAG_TURN_SCREEN_ON
1415         * @see #FLAG_DISMISS_KEYGUARD
1416         * @see #FLAG_SPLIT_TOUCH
1417         * @see #FLAG_HARDWARE_ACCELERATED
1418         * @see #FLAG_LOCAL_FOCUS_MODE
1419         * @see #FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
1420         */
1421        @ViewDebug.ExportedProperty(flagMapping = {
1422            @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
1423                    name = "ALLOW_LOCK_WHILE_SCREEN_ON"),
1424            @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
1425                    name = "DIM_BEHIND"),
1426            @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
1427                    name = "BLUR_BEHIND"),
1428            @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
1429                    name = "NOT_FOCUSABLE"),
1430            @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
1431                    name = "NOT_TOUCHABLE"),
1432            @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
1433                    name = "NOT_TOUCH_MODAL"),
1434            @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING,
1435                    name = "TOUCHABLE_WHEN_WAKING"),
1436            @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
1437                    name = "KEEP_SCREEN_ON"),
1438            @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
1439                    name = "LAYOUT_IN_SCREEN"),
1440            @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS,
1441                    name = "LAYOUT_NO_LIMITS"),
1442            @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
1443                    name = "FULLSCREEN"),
1444            @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN,
1445                    name = "FORCE_NOT_FULLSCREEN"),
1446            @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
1447                    name = "DITHER"),
1448            @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE,
1449                    name = "SECURE"),
1450            @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED,
1451                    name = "SCALED"),
1452            @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES,
1453                    name = "IGNORE_CHEEK_PRESSES"),
1454            @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR,
1455                    name = "LAYOUT_INSET_DECOR"),
1456            @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM,
1457                    name = "ALT_FOCUSABLE_IM"),
1458            @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH,
1459                    name = "WATCH_OUTSIDE_TOUCH"),
1460            @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
1461                    name = "SHOW_WHEN_LOCKED"),
1462            @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER,
1463                    name = "SHOW_WALLPAPER"),
1464            @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
1465                    name = "TURN_SCREEN_ON"),
1466            @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
1467                    name = "DISMISS_KEYGUARD"),
1468            @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH,
1469                    name = "SPLIT_TOUCH"),
1470            @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
1471                    name = "HARDWARE_ACCELERATED"),
1472            @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_OVERSCAN, equals = FLAG_LAYOUT_IN_OVERSCAN,
1473                    name = "LOCAL_FOCUS_MODE"),
1474            @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_STATUS, equals = FLAG_TRANSLUCENT_STATUS,
1475                    name = "TRANSLUCENT_STATUS"),
1476            @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_NAVIGATION, equals = FLAG_TRANSLUCENT_NAVIGATION,
1477                    name = "TRANSLUCENT_NAVIGATION"),
1478            @ViewDebug.FlagToString(mask = FLAG_LOCAL_FOCUS_MODE, equals = FLAG_LOCAL_FOCUS_MODE,
1479                    name = "LOCAL_FOCUS_MODE"),
1480            @ViewDebug.FlagToString(mask = FLAG_SLIPPERY, equals = FLAG_SLIPPERY,
1481                    name = "FLAG_SLIPPERY"),
1482            @ViewDebug.FlagToString(mask = FLAG_LAYOUT_ATTACHED_IN_DECOR, equals = FLAG_LAYOUT_ATTACHED_IN_DECOR,
1483                    name = "FLAG_LAYOUT_ATTACHED_IN_DECOR"),
1484            @ViewDebug.FlagToString(mask = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, equals = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
1485                    name = "DRAWS_SYSTEM_BAR_BACKGROUNDS")
1486        }, formatToHexString = true)
1487        public int flags;
1488
1489        /**
1490         * If the window has requested hardware acceleration, but this is not
1491         * allowed in the process it is in, then still render it as if it is
1492         * hardware accelerated.  This is used for the starting preview windows
1493         * in the system process, which don't need to have the overhead of
1494         * hardware acceleration (they are just a static rendering), but should
1495         * be rendered as such to match the actual window of the app even if it
1496         * is hardware accelerated.
1497         * Even if the window isn't hardware accelerated, still do its rendering
1498         * as if it was.
1499         * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
1500         * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
1501         * is generally disabled. This flag must be specified in addition to
1502         * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
1503         * windows.
1504         *
1505         * @hide
1506         */
1507        public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
1508
1509        /**
1510         * In the system process, we globally do not use hardware acceleration
1511         * because there are many threads doing UI there and they conflict.
1512         * If certain parts of the UI that really do want to use hardware
1513         * acceleration, this flag can be set to force it.  This is basically
1514         * for the lock screen.  Anyone else using it, you are probably wrong.
1515         *
1516         * @hide
1517         */
1518        public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002;
1519
1520        /**
1521         * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers
1522         * may elect to skip these notifications if they are not doing anything productive with
1523         * them (they do not affect the wallpaper scrolling operation) by calling
1524         * {@link
1525         * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}.
1526         *
1527         * @hide
1528         */
1529        public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004;
1530
1531        /** In a multiuser system if this flag is set and the owner is a system process then this
1532         * window will appear on all user screens. This overrides the default behavior of window
1533         * types that normally only appear on the owning user's screen. Refer to each window type
1534         * to determine its default behavior.
1535         *
1536         * {@hide} */
1537        public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010;
1538
1539        /**
1540         * Never animate position changes of the window.
1541         *
1542         * {@hide}
1543         */
1544        @TestApi
1545        public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 0x00000040;
1546
1547        /** Window flag: special flag to limit the size of the window to be
1548         * original size ([320x480] x density). Used to create window for applications
1549         * running under compatibility mode.
1550         *
1551         * {@hide} */
1552        public static final int PRIVATE_FLAG_COMPATIBLE_WINDOW = 0x00000080;
1553
1554        /** Window flag: a special option intended for system dialogs.  When
1555         * this flag is set, the window will demand focus unconditionally when
1556         * it is created.
1557         * {@hide} */
1558        public static final int PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100;
1559
1560        /** Window flag: maintain the previous translucent decor state when this window
1561         * becomes top-most.
1562         * {@hide} */
1563        public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200;
1564
1565        /**
1566         * Flag whether the current window is a keyguard window, meaning that it will hide all other
1567         * windows behind it except for windows with flag {@link #FLAG_SHOW_WHEN_LOCKED} set.
1568         * Further, this can only be set by {@link LayoutParams#TYPE_STATUS_BAR}.
1569         * {@hide}
1570         */
1571        public static final int PRIVATE_FLAG_KEYGUARD = 0x00000400;
1572
1573        /**
1574         * Flag that prevents the wallpaper behind the current window from receiving touch events.
1575         *
1576         * {@hide}
1577         */
1578        public static final int PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS = 0x00000800;
1579
1580        /**
1581         * Flag to force the status bar window to be visible all the time. If the bar is hidden when
1582         * this flag is set it will be shown again and the bar will have a transparent background.
1583         * This can only be set by {@link LayoutParams#TYPE_STATUS_BAR}.
1584         *
1585         * {@hide}
1586         */
1587        public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000;
1588
1589        /**
1590         * Flag indicating that the x, y, width, and height members should be
1591         * ignored (and thus their previous value preserved). For example
1592         * because they are being managed externally through repositionChild.
1593         *
1594         * {@hide}
1595         */
1596        public static final int PRIVATE_FLAG_PRESERVE_GEOMETRY = 0x00002000;
1597
1598        /**
1599         * Flag that will make window ignore app visibility and instead depend purely on the decor
1600         * view visibility for determining window visibility. This is used by recents to keep
1601         * drawing after it launches an app.
1602         * @hide
1603         */
1604        public static final int PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY = 0x00004000;
1605
1606        /**
1607         * Flag to indicate that this window is not expected to be replaced across
1608         * configuration change triggered activity relaunches. In general the WindowManager
1609         * expects Windows to be replaced after relaunch, and thus it will preserve their surfaces
1610         * until the replacement is ready to show in order to prevent visual glitch. However
1611         * some windows, such as PopupWindows expect to be cleared across configuration change,
1612         * and thus should hint to the WindowManager that it should not wait for a replacement.
1613         * @hide
1614         */
1615        public static final int PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH = 0x00008000;
1616
1617        /**
1618         * Flag to indicate that this child window should always be laid-out in the parent
1619         * frame regardless of the current windowing mode configuration.
1620         * @hide
1621         */
1622        public static final int PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME = 0x00010000;
1623
1624        /**
1625         * Flag to indicate that this window is always drawing the status bar background, no matter
1626         * what the other flags are.
1627         * @hide
1628         */
1629        public static final int PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND = 0x00020000;
1630
1631        /**
1632         * Flag to indicate that this window needs Sustained Performance Mode if
1633         * the device supports it.
1634         * @hide
1635         */
1636        public static final int PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE = 0x00040000;
1637
1638        /**
1639         * Flag to indicate that any window added by an application process that is of type
1640         * {@link #TYPE_TOAST} or that requires
1641         * {@link android.app.AppOpsManager#OP_SYSTEM_ALERT_WINDOW} permission should be hidden when
1642         * this window is visible.
1643         * @hide
1644         */
1645        @RequiresPermission(permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS)
1646        public static final int PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 0x00080000;
1647
1648        /**
1649         * Indicates that this window is the rounded corners overlay present on some
1650         * devices this means that it will be excluded from: screenshots,
1651         * screen magnification, and mirroring.
1652         * @hide
1653         */
1654        public static final int PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY = 0x00100000;
1655
1656        /**
1657         * If this flag is set on the window, window manager will acquire a sleep token that puts
1658         * all activities to sleep as long as this window is visible. When this flag is set, the
1659         * window needs to occlude all activity windows.
1660         * @hide
1661         */
1662        @RequiresPermission(permission.DEVICE_POWER)
1663        public static final int PRIVATE_FLAG_ACQUIRES_SLEEP_TOKEN = 0x00200000;
1664
1665        /**
1666         * Flag to indicate that this window should be considered a screen decoration similar to the
1667         * nav bar and status bar. This will cause this window to affect the window insets reported
1668         * to other windows when it is visible.
1669         * @hide
1670         */
1671        @RequiresPermission(permission.STATUS_BAR_SERVICE)
1672        public static final int PRIVATE_FLAG_IS_SCREEN_DECOR = 0x00400000;
1673
1674        /**
1675         * Control flags that are private to the platform.
1676         * @hide
1677         */
1678        @ViewDebug.ExportedProperty(flagMapping = {
1679                @ViewDebug.FlagToString(
1680                        mask = PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED,
1681                        equals = PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED,
1682                        name = "FAKE_HARDWARE_ACCELERATED"),
1683                @ViewDebug.FlagToString(
1684                        mask = PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED,
1685                        equals = PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED,
1686                        name = "FORCE_HARDWARE_ACCELERATED"),
1687                @ViewDebug.FlagToString(
1688                        mask = PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS,
1689                        equals = PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS,
1690                        name = "WANTS_OFFSET_NOTIFICATIONS"),
1691                @ViewDebug.FlagToString(
1692                        mask = PRIVATE_FLAG_SHOW_FOR_ALL_USERS,
1693                        equals = PRIVATE_FLAG_SHOW_FOR_ALL_USERS,
1694                        name = "SHOW_FOR_ALL_USERS"),
1695                @ViewDebug.FlagToString(
1696                        mask = PRIVATE_FLAG_NO_MOVE_ANIMATION,
1697                        equals = PRIVATE_FLAG_NO_MOVE_ANIMATION,
1698                        name = "NO_MOVE_ANIMATION"),
1699                @ViewDebug.FlagToString(
1700                        mask = PRIVATE_FLAG_COMPATIBLE_WINDOW,
1701                        equals = PRIVATE_FLAG_COMPATIBLE_WINDOW,
1702                        name = "COMPATIBLE_WINDOW"),
1703                @ViewDebug.FlagToString(
1704                        mask = PRIVATE_FLAG_SYSTEM_ERROR,
1705                        equals = PRIVATE_FLAG_SYSTEM_ERROR,
1706                        name = "SYSTEM_ERROR"),
1707                @ViewDebug.FlagToString(
1708                        mask = PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR,
1709                        equals = PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR,
1710                        name = "INHERIT_TRANSLUCENT_DECOR"),
1711                @ViewDebug.FlagToString(
1712                        mask = PRIVATE_FLAG_KEYGUARD,
1713                        equals = PRIVATE_FLAG_KEYGUARD,
1714                        name = "KEYGUARD"),
1715                @ViewDebug.FlagToString(
1716                        mask = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS,
1717                        equals = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS,
1718                        name = "DISABLE_WALLPAPER_TOUCH_EVENTS"),
1719                @ViewDebug.FlagToString(
1720                        mask = PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT,
1721                        equals = PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT,
1722                        name = "FORCE_STATUS_BAR_VISIBLE_TRANSPARENT"),
1723                @ViewDebug.FlagToString(
1724                        mask = PRIVATE_FLAG_PRESERVE_GEOMETRY,
1725                        equals = PRIVATE_FLAG_PRESERVE_GEOMETRY,
1726                        name = "PRESERVE_GEOMETRY"),
1727                @ViewDebug.FlagToString(
1728                        mask = PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY,
1729                        equals = PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY,
1730                        name = "FORCE_DECOR_VIEW_VISIBILITY"),
1731                @ViewDebug.FlagToString(
1732                        mask = PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH,
1733                        equals = PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH,
1734                        name = "WILL_NOT_REPLACE_ON_RELAUNCH"),
1735                @ViewDebug.FlagToString(
1736                        mask = PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME,
1737                        equals = PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME,
1738                        name = "LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME"),
1739                @ViewDebug.FlagToString(
1740                        mask = PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND,
1741                        equals = PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND,
1742                        name = "FORCE_DRAW_STATUS_BAR_BACKGROUND"),
1743                @ViewDebug.FlagToString(
1744                        mask = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE,
1745                        equals = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE,
1746                        name = "SUSTAINED_PERFORMANCE_MODE"),
1747                @ViewDebug.FlagToString(
1748                        mask = PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS,
1749                        equals = PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS,
1750                        name = "HIDE_NON_SYSTEM_OVERLAY_WINDOWS"),
1751                @ViewDebug.FlagToString(
1752                        mask = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY,
1753                        equals = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY,
1754                        name = "IS_ROUNDED_CORNERS_OVERLAY"),
1755                @ViewDebug.FlagToString(
1756                        mask = PRIVATE_FLAG_ACQUIRES_SLEEP_TOKEN,
1757                        equals = PRIVATE_FLAG_ACQUIRES_SLEEP_TOKEN,
1758                        name = "ACQUIRES_SLEEP_TOKEN"),
1759                @ViewDebug.FlagToString(
1760                        mask = PRIVATE_FLAG_IS_SCREEN_DECOR,
1761                        equals = PRIVATE_FLAG_IS_SCREEN_DECOR,
1762                        name = "IS_SCREEN_DECOR")
1763        })
1764        @TestApi
1765        public int privateFlags;
1766
1767        /**
1768         * Value for {@link #needsMenuKey} for a window that has not explicitly specified if it
1769         * needs {@link #NEEDS_MENU_SET_TRUE} or doesn't need {@link #NEEDS_MENU_SET_FALSE} a menu
1770         * key. For this case, we should look at windows behind it to determine the appropriate
1771         * value.
1772         *
1773         * @hide
1774         */
1775        public static final int NEEDS_MENU_UNSET = 0;
1776
1777        /**
1778         * Value for {@link #needsMenuKey} for a window that has explicitly specified it needs a
1779         * menu key.
1780         *
1781         * @hide
1782         */
1783        public static final int NEEDS_MENU_SET_TRUE = 1;
1784
1785        /**
1786         * Value for {@link #needsMenuKey} for a window that has explicitly specified it doesn't
1787         * needs a menu key.
1788         *
1789         * @hide
1790         */
1791        public static final int NEEDS_MENU_SET_FALSE = 2;
1792
1793        /**
1794         * State variable for a window belonging to an activity that responds to
1795         * {@link KeyEvent#KEYCODE_MENU} and therefore needs a Menu key. For devices where Menu is a
1796         * physical button this variable is ignored, but on devices where the Menu key is drawn in
1797         * software it may be hidden unless this variable is set to {@link #NEEDS_MENU_SET_TRUE}.
1798         *
1799         *  (Note that Action Bars, when available, are the preferred way to offer additional
1800         * functions otherwise accessed via an options menu.)
1801         *
1802         * {@hide}
1803         */
1804        public int needsMenuKey = NEEDS_MENU_UNSET;
1805
1806        /**
1807         * Given a particular set of window manager flags, determine whether
1808         * such a window may be a target for an input method when it has
1809         * focus.  In particular, this checks the
1810         * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
1811         * flags and returns true if the combination of the two corresponds
1812         * to a window that needs to be behind the input method so that the
1813         * user can type into it.
1814         *
1815         * @param flags The current window manager flags.
1816         *
1817         * @return Returns true if such a window should be behind/interact
1818         * with an input method, false if not.
1819         */
1820        public static boolean mayUseInputMethod(int flags) {
1821            switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
1822                case 0:
1823                case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
1824                    return true;
1825            }
1826            return false;
1827        }
1828
1829        /**
1830         * Mask for {@link #softInputMode} of the bits that determine the
1831         * desired visibility state of the soft input area for this window.
1832         */
1833        public static final int SOFT_INPUT_MASK_STATE = 0x0f;
1834
1835        /**
1836         * Visibility state for {@link #softInputMode}: no state has been specified. The system may
1837         * show or hide the software keyboard for better user experience when the window gains
1838         * focus.
1839         */
1840        public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
1841
1842        /**
1843         * Visibility state for {@link #softInputMode}: please don't change the state of
1844         * the soft input area.
1845         */
1846        public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
1847
1848        /**
1849         * Visibility state for {@link #softInputMode}: please hide any soft input
1850         * area when normally appropriate (when the user is navigating
1851         * forward to your window).
1852         */
1853        public static final int SOFT_INPUT_STATE_HIDDEN = 2;
1854
1855        /**
1856         * Visibility state for {@link #softInputMode}: please always hide any
1857         * soft input area when this window receives focus.
1858         */
1859        public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
1860
1861        /**
1862         * Visibility state for {@link #softInputMode}: please show the soft
1863         * input area when normally appropriate (when the user is navigating
1864         * forward to your window).
1865         *
1866         * <p>Applications that target {@link android.os.Build.VERSION_CODES#P} and later, this flag
1867         * is ignored unless there is a focused view that returns {@code true} from
1868         * {@link View#isInEditMode()} when the window is focused.</p>
1869         */
1870        public static final int SOFT_INPUT_STATE_VISIBLE = 4;
1871
1872        /**
1873         * Visibility state for {@link #softInputMode}: please always make the
1874         * soft input area visible when this window receives input focus.
1875         *
1876         * <p>Applications that target {@link android.os.Build.VERSION_CODES#P} and later, this flag
1877         * is ignored unless there is a focused view that returns {@code true} from
1878         * {@link View#isInEditMode()} when the window is focused.</p>
1879         */
1880        public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
1881
1882        /**
1883         * Mask for {@link #softInputMode} of the bits that determine the
1884         * way that the window should be adjusted to accommodate the soft
1885         * input window.
1886         */
1887        public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
1888
1889        /** Adjustment option for {@link #softInputMode}: nothing specified.
1890         * The system will try to pick one or
1891         * the other depending on the contents of the window.
1892         */
1893        public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
1894
1895        /** Adjustment option for {@link #softInputMode}: set to allow the
1896         * window to be resized when an input
1897         * method is shown, so that its contents are not covered by the input
1898         * method.  This can <em>not</em> be combined with
1899         * {@link #SOFT_INPUT_ADJUST_PAN}; if
1900         * neither of these are set, then the system will try to pick one or
1901         * the other depending on the contents of the window. If the window's
1902         * layout parameter flags include {@link #FLAG_FULLSCREEN}, this
1903         * value for {@link #softInputMode} will be ignored; the window will
1904         * not resize, but will stay fullscreen.
1905         */
1906        public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
1907
1908        /** Adjustment option for {@link #softInputMode}: set to have a window
1909         * pan when an input method is
1910         * shown, so it doesn't need to deal with resizing but just panned
1911         * by the framework to ensure the current input focus is visible.  This
1912         * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
1913         * neither of these are set, then the system will try to pick one or
1914         * the other depending on the contents of the window.
1915         */
1916        public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
1917
1918        /** Adjustment option for {@link #softInputMode}: set to have a window
1919         * not adjust for a shown input method.  The window will not be resized,
1920         * and it will not be panned to make its focus visible.
1921         */
1922        public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30;
1923
1924        /**
1925         * Bit for {@link #softInputMode}: set when the user has navigated
1926         * forward to the window.  This is normally set automatically for
1927         * you by the system, though you may want to set it in certain cases
1928         * when you are displaying a window yourself.  This flag will always
1929         * be cleared automatically after the window is displayed.
1930         */
1931        public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
1932
1933        /**
1934         * An internal annotation for flags that can be specified to {@link #softInputMode}.
1935         *
1936         * @hide
1937         */
1938        @Retention(RetentionPolicy.SOURCE)
1939        @IntDef(flag = true, prefix = { "SOFT_INPUT_" }, value = {
1940                SOFT_INPUT_STATE_UNSPECIFIED,
1941                SOFT_INPUT_STATE_UNCHANGED,
1942                SOFT_INPUT_STATE_HIDDEN,
1943                SOFT_INPUT_STATE_ALWAYS_HIDDEN,
1944                SOFT_INPUT_STATE_VISIBLE,
1945                SOFT_INPUT_STATE_ALWAYS_VISIBLE,
1946                SOFT_INPUT_ADJUST_UNSPECIFIED,
1947                SOFT_INPUT_ADJUST_RESIZE,
1948                SOFT_INPUT_ADJUST_PAN,
1949                SOFT_INPUT_ADJUST_NOTHING,
1950                SOFT_INPUT_IS_FORWARD_NAVIGATION,
1951        })
1952        public @interface SoftInputModeFlags {}
1953
1954        /**
1955         * Desired operating mode for any soft input area.  May be any combination
1956         * of:
1957         *
1958         * <ul>
1959         * <li> One of the visibility states
1960         * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
1961         * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_HIDDEN},
1962         * {@link #SOFT_INPUT_STATE_VISIBLE}, or {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}.
1963         * <li> One of the adjustment options
1964         * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, {@link #SOFT_INPUT_ADJUST_RESIZE},
1965         * {@link #SOFT_INPUT_ADJUST_PAN}, or {@link #SOFT_INPUT_ADJUST_NOTHING}.
1966         * </ul>
1967         *
1968         *
1969         * <p>This flag can be controlled in your theme through the
1970         * {@link android.R.attr#windowSoftInputMode} attribute.</p>
1971         */
1972        @SoftInputModeFlags
1973        public int softInputMode;
1974
1975        /**
1976         * Placement of window within the screen as per {@link Gravity}.  Both
1977         * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
1978         * android.graphics.Rect) Gravity.apply} and
1979         * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
1980         * Gravity.applyDisplay} are used during window layout, with this value
1981         * given as the desired gravity.  For example you can specify
1982         * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and
1983         * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here
1984         * to control the behavior of
1985         * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
1986         * Gravity.applyDisplay}.
1987         *
1988         * @see Gravity
1989         */
1990        public int gravity;
1991
1992        /**
1993         * The horizontal margin, as a percentage of the container's width,
1994         * between the container and the widget.  See
1995         * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
1996         * android.graphics.Rect) Gravity.apply} for how this is used.  This
1997         * field is added with {@link #x} to supply the <var>xAdj</var> parameter.
1998         */
1999        public float horizontalMargin;
2000
2001        /**
2002         * The vertical margin, as a percentage of the container's height,
2003         * between the container and the widget.  See
2004         * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
2005         * android.graphics.Rect) Gravity.apply} for how this is used.  This
2006         * field is added with {@link #y} to supply the <var>yAdj</var> parameter.
2007         */
2008        public float verticalMargin;
2009
2010        /**
2011         * Positive insets between the drawing surface and window content.
2012         *
2013         * @hide
2014         */
2015        public final Rect surfaceInsets = new Rect();
2016
2017        /**
2018         * Whether the surface insets have been manually set. When set to
2019         * {@code false}, the view root will automatically determine the
2020         * appropriate surface insets.
2021         *
2022         * @see #surfaceInsets
2023         * @hide
2024         */
2025        public boolean hasManualSurfaceInsets;
2026
2027        /**
2028         * Whether the previous surface insets should be used vs. what is currently set. When set
2029         * to {@code true}, the view root will ignore surfaces insets in this object and use what
2030         * it currently has.
2031         *
2032         * @see #surfaceInsets
2033         * @hide
2034         */
2035        public boolean preservePreviousSurfaceInsets = true;
2036
2037        /**
2038         * The desired bitmap format.  May be one of the constants in
2039         * {@link android.graphics.PixelFormat}. The choice of format
2040         * might be overridden by {@link #setColorMode(int)}. Default is OPAQUE.
2041         */
2042        public int format;
2043
2044        /**
2045         * A style resource defining the animations to use for this window.
2046         * This must be a system resource; it can not be an application resource
2047         * because the window manager does not have access to applications.
2048         */
2049        public int windowAnimations;
2050
2051        /**
2052         * An alpha value to apply to this entire window.
2053         * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
2054         */
2055        public float alpha = 1.0f;
2056
2057        /**
2058         * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
2059         * to apply.  Range is from 1.0 for completely opaque to 0.0 for no
2060         * dim.
2061         */
2062        public float dimAmount = 1.0f;
2063
2064        /**
2065         * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
2066         * indicating that the brightness value is not overridden for this window
2067         * and normal brightness policy should be used.
2068         */
2069        public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
2070
2071        /**
2072         * Value for {@link #screenBrightness} and {@link #buttonBrightness}
2073         * indicating that the screen or button backlight brightness should be set
2074         * to the lowest value when this window is in front.
2075         */
2076        public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
2077
2078        /**
2079         * Value for {@link #screenBrightness} and {@link #buttonBrightness}
2080         * indicating that the screen or button backlight brightness should be set
2081         * to the hightest value when this window is in front.
2082         */
2083        public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
2084
2085        /**
2086         * This can be used to override the user's preferred brightness of
2087         * the screen.  A value of less than 0, the default, means to use the
2088         * preferred screen brightness.  0 to 1 adjusts the brightness from
2089         * dark to full bright.
2090         */
2091        public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
2092
2093        /**
2094         * This can be used to override the standard behavior of the button and
2095         * keyboard backlights.  A value of less than 0, the default, means to
2096         * use the standard backlight behavior.  0 to 1 adjusts the brightness
2097         * from dark to full bright.
2098         */
2099        public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
2100
2101        /**
2102         * Unspecified value for {@link #rotationAnimation} indicating
2103         * a lack of preference.
2104         * @hide
2105         */
2106        public static final int ROTATION_ANIMATION_UNSPECIFIED = -1;
2107
2108        /**
2109         * Value for {@link #rotationAnimation} which specifies that this
2110         * window will visually rotate in or out following a rotation.
2111         */
2112        public static final int ROTATION_ANIMATION_ROTATE = 0;
2113
2114        /**
2115         * Value for {@link #rotationAnimation} which specifies that this
2116         * window will fade in or out following a rotation.
2117         */
2118        public static final int ROTATION_ANIMATION_CROSSFADE = 1;
2119
2120        /**
2121         * Value for {@link #rotationAnimation} which specifies that this window
2122         * will immediately disappear or appear following a rotation.
2123         */
2124        public static final int ROTATION_ANIMATION_JUMPCUT = 2;
2125
2126        /**
2127         * Value for {@link #rotationAnimation} to specify seamless rotation mode.
2128         * This works like JUMPCUT but will fall back to CROSSFADE if rotation
2129         * can't be applied without pausing the screen. For example, this is ideal
2130         * for Camera apps which don't want the viewfinder contents to ever rotate
2131         * or fade (and rather to be seamless) but also don't want ROTATION_ANIMATION_JUMPCUT
2132         * during app transition scenarios where seamless rotation can't be applied.
2133         */
2134        public static final int ROTATION_ANIMATION_SEAMLESS = 3;
2135
2136        /**
2137         * Define the exit and entry animations used on this window when the device is rotated.
2138         * This only has an affect if the incoming and outgoing topmost
2139         * opaque windows have the #FLAG_FULLSCREEN bit set and are not covered
2140         * by other windows. All other situations default to the
2141         * {@link #ROTATION_ANIMATION_ROTATE} behavior.
2142         *
2143         * @see #ROTATION_ANIMATION_ROTATE
2144         * @see #ROTATION_ANIMATION_CROSSFADE
2145         * @see #ROTATION_ANIMATION_JUMPCUT
2146         */
2147        public int rotationAnimation = ROTATION_ANIMATION_ROTATE;
2148
2149        /**
2150         * Identifier for this window.  This will usually be filled in for
2151         * you.
2152         */
2153        public IBinder token = null;
2154
2155        /**
2156         * Name of the package owning this window.
2157         */
2158        public String packageName = null;
2159
2160        /**
2161         * Specific orientation value for a window.
2162         * May be any of the same values allowed
2163         * for {@link android.content.pm.ActivityInfo#screenOrientation}.
2164         * If not set, a default value of
2165         * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
2166         * will be used.
2167         */
2168        public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
2169
2170        /**
2171         * The preferred refresh rate for the window.
2172         *
2173         * This must be one of the supported refresh rates obtained for the display(s) the window
2174         * is on. The selected refresh rate will be applied to the display's default mode.
2175         *
2176         * This value is ignored if {@link #preferredDisplayModeId} is set.
2177         *
2178         * @see Display#getSupportedRefreshRates()
2179         * @deprecated use {@link #preferredDisplayModeId} instead
2180         */
2181        @Deprecated
2182        public float preferredRefreshRate;
2183
2184        /**
2185         * Id of the preferred display mode for the window.
2186         * <p>
2187         * This must be one of the supported modes obtained for the display(s) the window is on.
2188         * A value of {@code 0} means no preference.
2189         *
2190         * @see Display#getSupportedModes()
2191         * @see Display.Mode#getModeId()
2192         */
2193        public int preferredDisplayModeId;
2194
2195        /**
2196         * Control the visibility of the status bar.
2197         *
2198         * @see View#STATUS_BAR_VISIBLE
2199         * @see View#STATUS_BAR_HIDDEN
2200         */
2201        public int systemUiVisibility;
2202
2203        /**
2204         * @hide
2205         * The ui visibility as requested by the views in this hierarchy.
2206         * the combined value should be systemUiVisibility | subtreeSystemUiVisibility.
2207         */
2208        public int subtreeSystemUiVisibility;
2209
2210        /**
2211         * Get callbacks about the system ui visibility changing.
2212         *
2213         * TODO: Maybe there should be a bitfield of optional callbacks that we need.
2214         *
2215         * @hide
2216         */
2217        public boolean hasSystemUiListeners;
2218
2219
2220        /** @hide */
2221        @Retention(RetentionPolicy.SOURCE)
2222        @IntDef(
2223                flag = true,
2224                value = {LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT,
2225                        LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS,
2226                        LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER})
2227        @interface LayoutInDisplayCutoutMode {}
2228
2229        /**
2230         * Controls how the window is laid out if there is a {@link DisplayCutout}.
2231         *
2232         * <p>
2233         * Defaults to {@link #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT}.
2234         *
2235         * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
2236         * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
2237         * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
2238         * @see DisplayCutout
2239         * @see android.R.attr#layoutInDisplayCutoutMode
2240         */
2241        @LayoutInDisplayCutoutMode
2242        public int layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
2243
2244        /**
2245         * The window is allowed to extend into the {@link DisplayCutout} area, only if the
2246         * {@link DisplayCutout} is fully contained within a system bar. Otherwise, the window is
2247         * laid out such that it does not overlap with the {@link DisplayCutout} area.
2248         *
2249         * <p>
2250         * In practice, this means that if the window did not set FLAG_FULLSCREEN or
2251         * SYSTEM_UI_FLAG_FULLSCREEN, it can extend into the cutout area in portrait if the cutout
2252         * is at the top edge. Similarly for SYSTEM_UI_FLAG_HIDE_NAVIGATION and a cutout at the
2253         * bottom of the screen.
2254         * Otherwise (i.e. fullscreen or landscape) it is laid out such that it does not overlap the
2255         * cutout area.
2256         *
2257         * <p>
2258         * The usual precautions for not overlapping with the status and navigation bar are
2259         * sufficient for ensuring that no important content overlaps with the DisplayCutout.
2260         *
2261         * @see DisplayCutout
2262         * @see WindowInsets
2263         */
2264        public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT = 0;
2265
2266        /**
2267         * @deprecated use {@link #LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES}
2268         * @hide
2269         */
2270        @Deprecated
2271        public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS = 1;
2272
2273        /**
2274         * The window is always allowed to extend into the {@link DisplayCutout} areas on the short
2275         * edges of the screen.
2276         *
2277         * The window will never extend into a {@link DisplayCutout} area on the long edges of the
2278         * screen.
2279         *
2280         * <p>
2281         * The window must make sure that no important content overlaps with the
2282         * {@link DisplayCutout}.
2283         *
2284         * @see DisplayCutout
2285         * @see WindowInsets#getDisplayCutout()
2286         */
2287        public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES = 1;
2288
2289        /**
2290         * The window is never allowed to overlap with the DisplayCutout area.
2291         *
2292         * <p>
2293         * This should be used with windows that transiently set SYSTEM_UI_FLAG_FULLSCREEN to
2294         * avoid a relayout of the window when the flag is set or cleared.
2295         *
2296         * @see DisplayCutout
2297         * @see View#SYSTEM_UI_FLAG_FULLSCREEN SYSTEM_UI_FLAG_FULLSCREEN
2298         * @see View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
2299         */
2300        public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER = 2;
2301
2302
2303        /**
2304         * When this window has focus, disable touch pad pointer gesture processing.
2305         * The window will receive raw position updates from the touch pad instead
2306         * of pointer movements and synthetic touch events.
2307         *
2308         * @hide
2309         */
2310        public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001;
2311
2312        /**
2313         * Does not construct an input channel for this window.  The channel will therefore
2314         * be incapable of receiving input.
2315         *
2316         * @hide
2317         */
2318        public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002;
2319
2320        /**
2321         * When this window has focus, does not call user activity for all input events so
2322         * the application will have to do it itself.  Should only be used by
2323         * the keyguard and phone app.
2324         * <p>
2325         * Should only be used by the keyguard and phone app.
2326         * </p>
2327         *
2328         * @hide
2329         */
2330        public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004;
2331
2332        /**
2333         * Control special features of the input subsystem.
2334         *
2335         * @see #INPUT_FEATURE_DISABLE_POINTER_GESTURES
2336         * @see #INPUT_FEATURE_NO_INPUT_CHANNEL
2337         * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY
2338         * @hide
2339         */
2340        public int inputFeatures;
2341
2342        /**
2343         * Sets the number of milliseconds before the user activity timeout occurs
2344         * when this window has focus.  A value of -1 uses the standard timeout.
2345         * A value of 0 uses the minimum support display timeout.
2346         * <p>
2347         * This property can only be used to reduce the user specified display timeout;
2348         * it can never make the timeout longer than it normally would be.
2349         * </p><p>
2350         * Should only be used by the keyguard and phone app.
2351         * </p>
2352         *
2353         * @hide
2354         */
2355        public long userActivityTimeout = -1;
2356
2357        /**
2358         * For windows with an anchor (e.g. PopupWindow), keeps track of the View that anchors the
2359         * window.
2360         *
2361         * @hide
2362         */
2363        public long accessibilityIdOfAnchor = AccessibilityNodeInfo.UNDEFINED_NODE_ID;
2364
2365        /**
2366         * The window title isn't kept in sync with what is displayed in the title bar, so we
2367         * separately track the currently shown title to provide to accessibility.
2368         *
2369         * @hide
2370         */
2371        @TestApi
2372        public CharSequence accessibilityTitle;
2373
2374        /**
2375         * Sets a timeout in milliseconds before which the window will be hidden
2376         * by the window manager. Useful for transient notifications like toasts
2377         * so we don't have to rely on client cooperation to ensure the window
2378         * is hidden. Must be specified at window creation time. Note that apps
2379         * are not prepared to handle their windows being removed without their
2380         * explicit request and may try to interact with the removed window
2381         * resulting in undefined behavior and crashes. Therefore, we do hide
2382         * such windows to prevent them from overlaying other apps.
2383         *
2384         * @hide
2385         */
2386        public long hideTimeoutMilliseconds = -1;
2387
2388        /**
2389         * A frame number in which changes requested in this layout will be rendered.
2390         *
2391         * @hide
2392         */
2393        public long frameNumber = -1;
2394
2395        /**
2396         * The color mode requested by this window. The target display may
2397         * not be able to honor the request. When the color mode is not set
2398         * to {@link ActivityInfo#COLOR_MODE_DEFAULT}, it might override the
2399         * pixel format specified in {@link #format}.
2400         *
2401         * @hide
2402         */
2403        @ActivityInfo.ColorMode
2404        private int mColorMode = COLOR_MODE_DEFAULT;
2405
2406        public LayoutParams() {
2407            super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
2408            type = TYPE_APPLICATION;
2409            format = PixelFormat.OPAQUE;
2410        }
2411
2412        public LayoutParams(int _type) {
2413            super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
2414            type = _type;
2415            format = PixelFormat.OPAQUE;
2416        }
2417
2418        public LayoutParams(int _type, int _flags) {
2419            super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
2420            type = _type;
2421            flags = _flags;
2422            format = PixelFormat.OPAQUE;
2423        }
2424
2425        public LayoutParams(int _type, int _flags, int _format) {
2426            super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
2427            type = _type;
2428            flags = _flags;
2429            format = _format;
2430        }
2431
2432        public LayoutParams(int w, int h, int _type, int _flags, int _format) {
2433            super(w, h);
2434            type = _type;
2435            flags = _flags;
2436            format = _format;
2437        }
2438
2439        public LayoutParams(int w, int h, int xpos, int ypos, int _type,
2440                int _flags, int _format) {
2441            super(w, h);
2442            x = xpos;
2443            y = ypos;
2444            type = _type;
2445            flags = _flags;
2446            format = _format;
2447        }
2448
2449        public final void setTitle(CharSequence title) {
2450            if (null == title)
2451                title = "";
2452
2453            mTitle = TextUtils.stringOrSpannedString(title);
2454        }
2455
2456        public final CharSequence getTitle() {
2457            return mTitle != null ? mTitle : "";
2458        }
2459
2460        /**
2461         * Sets the surface insets based on the elevation (visual z position) of the input view.
2462         * @hide
2463         */
2464        public final void setSurfaceInsets(View view, boolean manual, boolean preservePrevious) {
2465            final int surfaceInset = (int) Math.ceil(view.getZ() * 2);
2466            // Partial workaround for b/28318973. Every inset change causes a freeform window
2467            // to jump a little for a few frames. If we never allow surface insets to decrease,
2468            // they will stabilize quickly (often from the very beginning, as most windows start
2469            // as focused).
2470            // TODO(b/22668382) to fix this properly.
2471            if (surfaceInset == 0) {
2472                // OK to have 0 (this is the case for non-freeform windows).
2473                surfaceInsets.set(0, 0, 0, 0);
2474            } else {
2475                surfaceInsets.set(
2476                        Math.max(surfaceInset, surfaceInsets.left),
2477                        Math.max(surfaceInset, surfaceInsets.top),
2478                        Math.max(surfaceInset, surfaceInsets.right),
2479                        Math.max(surfaceInset, surfaceInsets.bottom));
2480            }
2481            hasManualSurfaceInsets = manual;
2482            preservePreviousSurfaceInsets = preservePrevious;
2483        }
2484
2485        /**
2486         * <p>Set the color mode of the window. Setting the color mode might
2487         * override the window's pixel {@link WindowManager.LayoutParams#format format}.</p>
2488         *
2489         * <p>The color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
2490         * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or
2491         * {@link ActivityInfo#COLOR_MODE_HDR}.</p>
2492         *
2493         * @see #getColorMode()
2494         */
2495        public void setColorMode(@ActivityInfo.ColorMode int colorMode) {
2496            mColorMode = colorMode;
2497        }
2498
2499        /**
2500         * Returns the color mode of the window, one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
2501         * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}.
2502         *
2503         * @see #setColorMode(int)
2504         */
2505        @ActivityInfo.ColorMode
2506        public int getColorMode() {
2507            return mColorMode;
2508        }
2509
2510        /** @hide */
2511        @SystemApi
2512        public final void setUserActivityTimeout(long timeout) {
2513            userActivityTimeout = timeout;
2514        }
2515
2516        /** @hide */
2517        @SystemApi
2518        public final long getUserActivityTimeout() {
2519            return userActivityTimeout;
2520        }
2521
2522        public int describeContents() {
2523            return 0;
2524        }
2525
2526        public void writeToParcel(Parcel out, int parcelableFlags) {
2527            out.writeInt(width);
2528            out.writeInt(height);
2529            out.writeInt(x);
2530            out.writeInt(y);
2531            out.writeInt(type);
2532            out.writeInt(flags);
2533            out.writeInt(privateFlags);
2534            out.writeInt(softInputMode);
2535            out.writeInt(layoutInDisplayCutoutMode);
2536            out.writeInt(gravity);
2537            out.writeFloat(horizontalMargin);
2538            out.writeFloat(verticalMargin);
2539            out.writeInt(format);
2540            out.writeInt(windowAnimations);
2541            out.writeFloat(alpha);
2542            out.writeFloat(dimAmount);
2543            out.writeFloat(screenBrightness);
2544            out.writeFloat(buttonBrightness);
2545            out.writeInt(rotationAnimation);
2546            out.writeStrongBinder(token);
2547            out.writeString(packageName);
2548            TextUtils.writeToParcel(mTitle, out, parcelableFlags);
2549            out.writeInt(screenOrientation);
2550            out.writeFloat(preferredRefreshRate);
2551            out.writeInt(preferredDisplayModeId);
2552            out.writeInt(systemUiVisibility);
2553            out.writeInt(subtreeSystemUiVisibility);
2554            out.writeInt(hasSystemUiListeners ? 1 : 0);
2555            out.writeInt(inputFeatures);
2556            out.writeLong(userActivityTimeout);
2557            out.writeInt(surfaceInsets.left);
2558            out.writeInt(surfaceInsets.top);
2559            out.writeInt(surfaceInsets.right);
2560            out.writeInt(surfaceInsets.bottom);
2561            out.writeInt(hasManualSurfaceInsets ? 1 : 0);
2562            out.writeInt(preservePreviousSurfaceInsets ? 1 : 0);
2563            out.writeInt(needsMenuKey);
2564            out.writeLong(accessibilityIdOfAnchor);
2565            TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags);
2566            out.writeInt(mColorMode);
2567            out.writeLong(hideTimeoutMilliseconds);
2568            out.writeLong(frameNumber);
2569        }
2570
2571        public static final Parcelable.Creator<LayoutParams> CREATOR
2572                    = new Parcelable.Creator<LayoutParams>() {
2573            public LayoutParams createFromParcel(Parcel in) {
2574                return new LayoutParams(in);
2575            }
2576
2577            public LayoutParams[] newArray(int size) {
2578                return new LayoutParams[size];
2579            }
2580        };
2581
2582
2583        public LayoutParams(Parcel in) {
2584            width = in.readInt();
2585            height = in.readInt();
2586            x = in.readInt();
2587            y = in.readInt();
2588            type = in.readInt();
2589            flags = in.readInt();
2590            privateFlags = in.readInt();
2591            softInputMode = in.readInt();
2592            layoutInDisplayCutoutMode = in.readInt();
2593            gravity = in.readInt();
2594            horizontalMargin = in.readFloat();
2595            verticalMargin = in.readFloat();
2596            format = in.readInt();
2597            windowAnimations = in.readInt();
2598            alpha = in.readFloat();
2599            dimAmount = in.readFloat();
2600            screenBrightness = in.readFloat();
2601            buttonBrightness = in.readFloat();
2602            rotationAnimation = in.readInt();
2603            token = in.readStrongBinder();
2604            packageName = in.readString();
2605            mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
2606            screenOrientation = in.readInt();
2607            preferredRefreshRate = in.readFloat();
2608            preferredDisplayModeId = in.readInt();
2609            systemUiVisibility = in.readInt();
2610            subtreeSystemUiVisibility = in.readInt();
2611            hasSystemUiListeners = in.readInt() != 0;
2612            inputFeatures = in.readInt();
2613            userActivityTimeout = in.readLong();
2614            surfaceInsets.left = in.readInt();
2615            surfaceInsets.top = in.readInt();
2616            surfaceInsets.right = in.readInt();
2617            surfaceInsets.bottom = in.readInt();
2618            hasManualSurfaceInsets = in.readInt() != 0;
2619            preservePreviousSurfaceInsets = in.readInt() != 0;
2620            needsMenuKey = in.readInt();
2621            accessibilityIdOfAnchor = in.readLong();
2622            accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
2623            mColorMode = in.readInt();
2624            hideTimeoutMilliseconds = in.readLong();
2625            frameNumber = in.readLong();
2626        }
2627
2628        @SuppressWarnings({"PointlessBitwiseExpression"})
2629        public static final int LAYOUT_CHANGED = 1<<0;
2630        public static final int TYPE_CHANGED = 1<<1;
2631        public static final int FLAGS_CHANGED = 1<<2;
2632        public static final int FORMAT_CHANGED = 1<<3;
2633        public static final int ANIMATION_CHANGED = 1<<4;
2634        public static final int DIM_AMOUNT_CHANGED = 1<<5;
2635        public static final int TITLE_CHANGED = 1<<6;
2636        public static final int ALPHA_CHANGED = 1<<7;
2637        public static final int MEMORY_TYPE_CHANGED = 1<<8;
2638        public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
2639        public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
2640        public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
2641        public static final int ROTATION_ANIMATION_CHANGED = 1<<12;
2642        /** {@hide} */
2643        public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<13;
2644        /** {@hide} */
2645        public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<14;
2646        /** {@hide} */
2647        public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<15;
2648        /** {@hide} */
2649        public static final int INPUT_FEATURES_CHANGED = 1<<16;
2650        /** {@hide} */
2651        public static final int PRIVATE_FLAGS_CHANGED = 1<<17;
2652        /** {@hide} */
2653        public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<18;
2654        /** {@hide} */
2655        public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19;
2656        /** {@hide} */
2657        public static final int SURFACE_INSETS_CHANGED = 1<<20;
2658        /** {@hide} */
2659        public static final int PREFERRED_REFRESH_RATE_CHANGED = 1 << 21;
2660        /** {@hide} */
2661        public static final int NEEDS_MENU_KEY_CHANGED = 1 << 22;
2662        /** {@hide} */
2663        public static final int PREFERRED_DISPLAY_MODE_ID = 1 << 23;
2664        /** {@hide} */
2665        public static final int ACCESSIBILITY_ANCHOR_CHANGED = 1 << 24;
2666        /** {@hide} */
2667        @TestApi
2668        public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25;
2669        /** {@hide} */
2670        public static final int COLOR_MODE_CHANGED = 1 << 26;
2671        /** {@hide} */
2672        public static final int EVERYTHING_CHANGED = 0xffffffff;
2673
2674        // internal buffer to backup/restore parameters under compatibility mode.
2675        private int[] mCompatibilityParamsBackup = null;
2676
2677        public final int copyFrom(LayoutParams o) {
2678            int changes = 0;
2679
2680            if (width != o.width) {
2681                width = o.width;
2682                changes |= LAYOUT_CHANGED;
2683            }
2684            if (height != o.height) {
2685                height = o.height;
2686                changes |= LAYOUT_CHANGED;
2687            }
2688            if (x != o.x) {
2689                x = o.x;
2690                changes |= LAYOUT_CHANGED;
2691            }
2692            if (y != o.y) {
2693                y = o.y;
2694                changes |= LAYOUT_CHANGED;
2695            }
2696            if (horizontalWeight != o.horizontalWeight) {
2697                horizontalWeight = o.horizontalWeight;
2698                changes |= LAYOUT_CHANGED;
2699            }
2700            if (verticalWeight != o.verticalWeight) {
2701                verticalWeight = o.verticalWeight;
2702                changes |= LAYOUT_CHANGED;
2703            }
2704            if (horizontalMargin != o.horizontalMargin) {
2705                horizontalMargin = o.horizontalMargin;
2706                changes |= LAYOUT_CHANGED;
2707            }
2708            if (verticalMargin != o.verticalMargin) {
2709                verticalMargin = o.verticalMargin;
2710                changes |= LAYOUT_CHANGED;
2711            }
2712            if (type != o.type) {
2713                type = o.type;
2714                changes |= TYPE_CHANGED;
2715            }
2716            if (flags != o.flags) {
2717                final int diff = flags ^ o.flags;
2718                if ((diff & (FLAG_TRANSLUCENT_STATUS | FLAG_TRANSLUCENT_NAVIGATION)) != 0) {
2719                    changes |= TRANSLUCENT_FLAGS_CHANGED;
2720                }
2721                flags = o.flags;
2722                changes |= FLAGS_CHANGED;
2723            }
2724            if (privateFlags != o.privateFlags) {
2725                privateFlags = o.privateFlags;
2726                changes |= PRIVATE_FLAGS_CHANGED;
2727            }
2728            if (softInputMode != o.softInputMode) {
2729                softInputMode = o.softInputMode;
2730                changes |= SOFT_INPUT_MODE_CHANGED;
2731            }
2732            if (layoutInDisplayCutoutMode != o.layoutInDisplayCutoutMode) {
2733                layoutInDisplayCutoutMode = o.layoutInDisplayCutoutMode;
2734                changes |= LAYOUT_CHANGED;
2735            }
2736            if (gravity != o.gravity) {
2737                gravity = o.gravity;
2738                changes |= LAYOUT_CHANGED;
2739            }
2740            if (format != o.format) {
2741                format = o.format;
2742                changes |= FORMAT_CHANGED;
2743            }
2744            if (windowAnimations != o.windowAnimations) {
2745                windowAnimations = o.windowAnimations;
2746                changes |= ANIMATION_CHANGED;
2747            }
2748            if (token == null) {
2749                // NOTE: token only copied if the recipient doesn't
2750                // already have one.
2751                token = o.token;
2752            }
2753            if (packageName == null) {
2754                // NOTE: packageName only copied if the recipient doesn't
2755                // already have one.
2756                packageName = o.packageName;
2757            }
2758            if (!Objects.equals(mTitle, o.mTitle) && o.mTitle != null) {
2759                // NOTE: mTitle only copied if the originator set one.
2760                mTitle = o.mTitle;
2761                changes |= TITLE_CHANGED;
2762            }
2763            if (alpha != o.alpha) {
2764                alpha = o.alpha;
2765                changes |= ALPHA_CHANGED;
2766            }
2767            if (dimAmount != o.dimAmount) {
2768                dimAmount = o.dimAmount;
2769                changes |= DIM_AMOUNT_CHANGED;
2770            }
2771            if (screenBrightness != o.screenBrightness) {
2772                screenBrightness = o.screenBrightness;
2773                changes |= SCREEN_BRIGHTNESS_CHANGED;
2774            }
2775            if (buttonBrightness != o.buttonBrightness) {
2776                buttonBrightness = o.buttonBrightness;
2777                changes |= BUTTON_BRIGHTNESS_CHANGED;
2778            }
2779            if (rotationAnimation != o.rotationAnimation) {
2780                rotationAnimation = o.rotationAnimation;
2781                changes |= ROTATION_ANIMATION_CHANGED;
2782            }
2783
2784            if (screenOrientation != o.screenOrientation) {
2785                screenOrientation = o.screenOrientation;
2786                changes |= SCREEN_ORIENTATION_CHANGED;
2787            }
2788
2789            if (preferredRefreshRate != o.preferredRefreshRate) {
2790                preferredRefreshRate = o.preferredRefreshRate;
2791                changes |= PREFERRED_REFRESH_RATE_CHANGED;
2792            }
2793
2794            if (preferredDisplayModeId != o.preferredDisplayModeId) {
2795                preferredDisplayModeId = o.preferredDisplayModeId;
2796                changes |= PREFERRED_DISPLAY_MODE_ID;
2797            }
2798
2799            if (systemUiVisibility != o.systemUiVisibility
2800                    || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
2801                systemUiVisibility = o.systemUiVisibility;
2802                subtreeSystemUiVisibility = o.subtreeSystemUiVisibility;
2803                changes |= SYSTEM_UI_VISIBILITY_CHANGED;
2804            }
2805
2806            if (hasSystemUiListeners != o.hasSystemUiListeners) {
2807                hasSystemUiListeners = o.hasSystemUiListeners;
2808                changes |= SYSTEM_UI_LISTENER_CHANGED;
2809            }
2810
2811            if (inputFeatures != o.inputFeatures) {
2812                inputFeatures = o.inputFeatures;
2813                changes |= INPUT_FEATURES_CHANGED;
2814            }
2815
2816            if (userActivityTimeout != o.userActivityTimeout) {
2817                userActivityTimeout = o.userActivityTimeout;
2818                changes |= USER_ACTIVITY_TIMEOUT_CHANGED;
2819            }
2820
2821            if (!surfaceInsets.equals(o.surfaceInsets)) {
2822                surfaceInsets.set(o.surfaceInsets);
2823                changes |= SURFACE_INSETS_CHANGED;
2824            }
2825
2826            // The frame number changing is only relevant in the context of other
2827            // changes, and so we don't need to track it with a flag.
2828            frameNumber = o.frameNumber;
2829
2830            if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) {
2831                hasManualSurfaceInsets = o.hasManualSurfaceInsets;
2832                changes |= SURFACE_INSETS_CHANGED;
2833            }
2834
2835            if (preservePreviousSurfaceInsets != o.preservePreviousSurfaceInsets) {
2836                preservePreviousSurfaceInsets = o.preservePreviousSurfaceInsets;
2837                changes |= SURFACE_INSETS_CHANGED;
2838            }
2839
2840            if (needsMenuKey != o.needsMenuKey) {
2841                needsMenuKey = o.needsMenuKey;
2842                changes |= NEEDS_MENU_KEY_CHANGED;
2843            }
2844
2845            if (accessibilityIdOfAnchor != o.accessibilityIdOfAnchor) {
2846                accessibilityIdOfAnchor = o.accessibilityIdOfAnchor;
2847                changes |= ACCESSIBILITY_ANCHOR_CHANGED;
2848            }
2849
2850            if (!Objects.equals(accessibilityTitle, o.accessibilityTitle)
2851                    && o.accessibilityTitle != null) {
2852                // NOTE: accessibilityTitle only copied if the originator set one.
2853                accessibilityTitle = o.accessibilityTitle;
2854                changes |= ACCESSIBILITY_TITLE_CHANGED;
2855            }
2856
2857            if (mColorMode != o.mColorMode) {
2858                mColorMode = o.mColorMode;
2859                changes |= COLOR_MODE_CHANGED;
2860            }
2861
2862            // This can't change, it's only set at window creation time.
2863            hideTimeoutMilliseconds = o.hideTimeoutMilliseconds;
2864
2865            return changes;
2866        }
2867
2868        @Override
2869        public String debug(String output) {
2870            output += "Contents of " + this + ":";
2871            Log.d("Debug", output);
2872            output = super.debug("");
2873            Log.d("Debug", output);
2874            Log.d("Debug", "");
2875            Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
2876            return "";
2877        }
2878
2879        @Override
2880        public String toString() {
2881            return toString("");
2882        }
2883
2884        /**
2885         * @hide
2886         */
2887        public void dumpDimensions(StringBuilder sb) {
2888            sb.append('(');
2889            sb.append(x);
2890            sb.append(',');
2891            sb.append(y);
2892            sb.append(")(");
2893            sb.append((width == MATCH_PARENT ? "fill" : (width == WRAP_CONTENT
2894                    ? "wrap" : String.valueOf(width))));
2895            sb.append('x');
2896            sb.append((height == MATCH_PARENT ? "fill" : (height == WRAP_CONTENT
2897                    ? "wrap" : String.valueOf(height))));
2898            sb.append(")");
2899        }
2900
2901        /**
2902         * @hide
2903         */
2904        public String toString(String prefix) {
2905            StringBuilder sb = new StringBuilder(256);
2906            sb.append('{');
2907            dumpDimensions(sb);
2908            if (horizontalMargin != 0) {
2909                sb.append(" hm=");
2910                sb.append(horizontalMargin);
2911            }
2912            if (verticalMargin != 0) {
2913                sb.append(" vm=");
2914                sb.append(verticalMargin);
2915            }
2916            if (gravity != 0) {
2917                sb.append(" gr=");
2918                sb.append(Gravity.toString(gravity));
2919            }
2920            if (softInputMode != 0) {
2921                sb.append(" sim={");
2922                sb.append(softInputModeToString(softInputMode));
2923                sb.append('}');
2924            }
2925            if (layoutInDisplayCutoutMode != 0) {
2926                sb.append(" layoutInDisplayCutoutMode=");
2927                sb.append(layoutInDisplayCutoutModeToString(layoutInDisplayCutoutMode));
2928            }
2929            sb.append(" ty=");
2930            sb.append(ViewDebug.intToString(LayoutParams.class, "type", type));
2931            if (format != PixelFormat.OPAQUE) {
2932                sb.append(" fmt=");
2933                sb.append(PixelFormat.formatToString(format));
2934            }
2935            if (windowAnimations != 0) {
2936                sb.append(" wanim=0x");
2937                sb.append(Integer.toHexString(windowAnimations));
2938            }
2939            if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
2940                sb.append(" or=");
2941                sb.append(ActivityInfo.screenOrientationToString(screenOrientation));
2942            }
2943            if (alpha != 1.0f) {
2944                sb.append(" alpha=");
2945                sb.append(alpha);
2946            }
2947            if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) {
2948                sb.append(" sbrt=");
2949                sb.append(screenBrightness);
2950            }
2951            if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) {
2952                sb.append(" bbrt=");
2953                sb.append(buttonBrightness);
2954            }
2955            if (rotationAnimation != ROTATION_ANIMATION_ROTATE) {
2956                sb.append(" rotAnim=");
2957                sb.append(rotationAnimationToString(rotationAnimation));
2958            }
2959            if (preferredRefreshRate != 0) {
2960                sb.append(" preferredRefreshRate=");
2961                sb.append(preferredRefreshRate);
2962            }
2963            if (preferredDisplayModeId != 0) {
2964                sb.append(" preferredDisplayMode=");
2965                sb.append(preferredDisplayModeId);
2966            }
2967            if (hasSystemUiListeners) {
2968                sb.append(" sysuil=");
2969                sb.append(hasSystemUiListeners);
2970            }
2971            if (inputFeatures != 0) {
2972                sb.append(" if=").append(inputFeatureToString(inputFeatures));
2973            }
2974            if (userActivityTimeout >= 0) {
2975                sb.append(" userActivityTimeout=").append(userActivityTimeout);
2976            }
2977            if (surfaceInsets.left != 0 || surfaceInsets.top != 0 || surfaceInsets.right != 0 ||
2978                    surfaceInsets.bottom != 0 || hasManualSurfaceInsets
2979                    || !preservePreviousSurfaceInsets) {
2980                sb.append(" surfaceInsets=").append(surfaceInsets);
2981                if (hasManualSurfaceInsets) {
2982                    sb.append(" (manual)");
2983                }
2984                if (!preservePreviousSurfaceInsets) {
2985                    sb.append(" (!preservePreviousSurfaceInsets)");
2986                }
2987            }
2988            if (needsMenuKey == NEEDS_MENU_SET_TRUE) {
2989                sb.append(" needsMenuKey");
2990            }
2991            if (mColorMode != COLOR_MODE_DEFAULT) {
2992                sb.append(" colorMode=").append(ActivityInfo.colorModeToString(mColorMode));
2993            }
2994            sb.append(System.lineSeparator());
2995            sb.append(prefix).append("  fl=").append(
2996                    ViewDebug.flagsToString(LayoutParams.class, "flags", flags));
2997            if (privateFlags != 0) {
2998                sb.append(System.lineSeparator());
2999                sb.append(prefix).append("  pfl=").append(ViewDebug.flagsToString(
3000                        LayoutParams.class, "privateFlags", privateFlags));
3001            }
3002            if (systemUiVisibility != 0) {
3003                sb.append(System.lineSeparator());
3004                sb.append(prefix).append("  sysui=").append(ViewDebug.flagsToString(
3005                        View.class, "mSystemUiVisibility", systemUiVisibility));
3006            }
3007            if (subtreeSystemUiVisibility != 0) {
3008                sb.append(System.lineSeparator());
3009                sb.append(prefix).append("  vsysui=").append(ViewDebug.flagsToString(
3010                        View.class, "mSystemUiVisibility", subtreeSystemUiVisibility));
3011            }
3012            sb.append('}');
3013            return sb.toString();
3014        }
3015
3016        /**
3017         * @hide
3018         */
3019        public void writeToProto(ProtoOutputStream proto, long fieldId) {
3020            final long token = proto.start(fieldId);
3021            proto.write(TYPE, type);
3022            proto.write(X, x);
3023            proto.write(Y, y);
3024            proto.write(WIDTH, width);
3025            proto.write(HEIGHT, height);
3026            proto.write(HORIZONTAL_MARGIN, horizontalMargin);
3027            proto.write(VERTICAL_MARGIN, verticalMargin);
3028            proto.write(GRAVITY, gravity);
3029            proto.write(SOFT_INPUT_MODE, softInputMode);
3030            proto.write(FORMAT, format);
3031            proto.write(WINDOW_ANIMATIONS, windowAnimations);
3032            proto.write(ALPHA, alpha);
3033            proto.write(SCREEN_BRIGHTNESS, screenBrightness);
3034            proto.write(BUTTON_BRIGHTNESS, buttonBrightness);
3035            proto.write(ROTATION_ANIMATION, rotationAnimation);
3036            proto.write(PREFERRED_REFRESH_RATE, preferredRefreshRate);
3037            proto.write(WindowLayoutParamsProto.PREFERRED_DISPLAY_MODE_ID, preferredDisplayModeId);
3038            proto.write(HAS_SYSTEM_UI_LISTENERS, hasSystemUiListeners);
3039            proto.write(INPUT_FEATURE_FLAGS, inputFeatures);
3040            proto.write(USER_ACTIVITY_TIMEOUT, userActivityTimeout);
3041            proto.write(NEEDS_MENU_KEY, needsMenuKey);
3042            proto.write(COLOR_MODE, mColorMode);
3043            proto.write(FLAGS, flags);
3044            proto.write(PRIVATE_FLAGS, privateFlags);
3045            proto.write(SYSTEM_UI_VISIBILITY_FLAGS, systemUiVisibility);
3046            proto.write(SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS, subtreeSystemUiVisibility);
3047            proto.end(token);
3048        }
3049
3050        /**
3051         * Scale the layout params' coordinates and size.
3052         * @hide
3053         */
3054        public void scale(float scale) {
3055            x = (int) (x * scale + 0.5f);
3056            y = (int) (y * scale + 0.5f);
3057            if (width > 0) {
3058                width = (int) (width * scale + 0.5f);
3059            }
3060            if (height > 0) {
3061                height = (int) (height * scale + 0.5f);
3062            }
3063        }
3064
3065        /**
3066         * Backup the layout parameters used in compatibility mode.
3067         * @see LayoutParams#restore()
3068         */
3069        void backup() {
3070            int[] backup = mCompatibilityParamsBackup;
3071            if (backup == null) {
3072                // we backup 4 elements, x, y, width, height
3073                backup = mCompatibilityParamsBackup = new int[4];
3074            }
3075            backup[0] = x;
3076            backup[1] = y;
3077            backup[2] = width;
3078            backup[3] = height;
3079        }
3080
3081        /**
3082         * Restore the layout params' coordinates, size and gravity
3083         * @see LayoutParams#backup()
3084         */
3085        void restore() {
3086            int[] backup = mCompatibilityParamsBackup;
3087            if (backup != null) {
3088                x = backup[0];
3089                y = backup[1];
3090                width = backup[2];
3091                height = backup[3];
3092            }
3093        }
3094
3095        private CharSequence mTitle = null;
3096
3097        /** @hide */
3098        @Override
3099        protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) {
3100            super.encodeProperties(encoder);
3101
3102            encoder.addProperty("x", x);
3103            encoder.addProperty("y", y);
3104            encoder.addProperty("horizontalWeight", horizontalWeight);
3105            encoder.addProperty("verticalWeight", verticalWeight);
3106            encoder.addProperty("type", type);
3107            encoder.addProperty("flags", flags);
3108        }
3109
3110        /**
3111         * @hide
3112         * @return True if the layout parameters will cause the window to cover the full screen;
3113         *         false otherwise.
3114         */
3115        public boolean isFullscreen() {
3116            return x == 0 && y == 0
3117                    && width == WindowManager.LayoutParams.MATCH_PARENT
3118                    && height == WindowManager.LayoutParams.MATCH_PARENT;
3119        }
3120
3121        private static String layoutInDisplayCutoutModeToString(
3122                @LayoutInDisplayCutoutMode int mode) {
3123            switch (mode) {
3124                case LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT:
3125                    return "default";
3126                case LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS:
3127                    return "always";
3128                case LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER:
3129                    return "never";
3130                default:
3131                    return "unknown(" + mode + ")";
3132            }
3133        }
3134
3135        private static String softInputModeToString(@SoftInputModeFlags int softInputMode) {
3136            final StringBuilder result = new StringBuilder();
3137            final int state = softInputMode & SOFT_INPUT_MASK_STATE;
3138            if (state != 0) {
3139                result.append("state=");
3140                switch (state) {
3141                    case SOFT_INPUT_STATE_UNCHANGED:
3142                        result.append("unchanged");
3143                        break;
3144                    case SOFT_INPUT_STATE_HIDDEN:
3145                        result.append("hidden");
3146                        break;
3147                    case SOFT_INPUT_STATE_ALWAYS_HIDDEN:
3148                        result.append("always_hidden");
3149                        break;
3150                    case SOFT_INPUT_STATE_VISIBLE:
3151                        result.append("visible");
3152                        break;
3153                    case SOFT_INPUT_STATE_ALWAYS_VISIBLE:
3154                        result.append("always_visible");
3155                        break;
3156                    default:
3157                        result.append(state);
3158                        break;
3159                }
3160                result.append(' ');
3161            }
3162            final int adjust = softInputMode & SOFT_INPUT_MASK_ADJUST;
3163            if (adjust != 0) {
3164                result.append("adjust=");
3165                switch (adjust) {
3166                    case SOFT_INPUT_ADJUST_RESIZE:
3167                        result.append("resize");
3168                        break;
3169                    case SOFT_INPUT_ADJUST_PAN:
3170                        result.append("pan");
3171                        break;
3172                    case SOFT_INPUT_ADJUST_NOTHING:
3173                        result.append("nothing");
3174                        break;
3175                    default:
3176                        result.append(adjust);
3177                        break;
3178                }
3179                result.append(' ');
3180            }
3181            if ((softInputMode & SOFT_INPUT_IS_FORWARD_NAVIGATION) != 0) {
3182                result.append("forwardNavigation").append(' ');
3183            }
3184            result.deleteCharAt(result.length() - 1);
3185            return result.toString();
3186        }
3187
3188        private static String rotationAnimationToString(int rotationAnimation) {
3189            switch (rotationAnimation) {
3190                case ROTATION_ANIMATION_UNSPECIFIED:
3191                    return "UNSPECIFIED";
3192                case ROTATION_ANIMATION_ROTATE:
3193                    return "ROTATE";
3194                case ROTATION_ANIMATION_CROSSFADE:
3195                    return "CROSSFADE";
3196                case ROTATION_ANIMATION_JUMPCUT:
3197                    return "JUMPCUT";
3198                case ROTATION_ANIMATION_SEAMLESS:
3199                    return "SEAMLESS";
3200                default:
3201                    return Integer.toString(rotationAnimation);
3202            }
3203        }
3204
3205        private static String inputFeatureToString(int inputFeature) {
3206            switch (inputFeature) {
3207                case INPUT_FEATURE_DISABLE_POINTER_GESTURES:
3208                    return "DISABLE_POINTER_GESTURES";
3209                case INPUT_FEATURE_NO_INPUT_CHANNEL:
3210                    return "NO_INPUT_CHANNEL";
3211                case INPUT_FEATURE_DISABLE_USER_ACTIVITY:
3212                    return "DISABLE_USER_ACTIVITY";
3213                default:
3214                    return Integer.toString(inputFeature);
3215            }
3216        }
3217    }
3218}
3219