Debian Codegraph @

core/java/android/view/WindowManager.java

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