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