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