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