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