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