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