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.WindowLayoutParamsProto.ALPHA;
21 import static android.view.WindowLayoutParamsProto.BUTTON_BRIGHTNESS;
22 import static android.view.WindowLayoutParamsProto.COLOR_MODE;
23 import static android.view.WindowLayoutParamsProto.FLAGS;
24 import static android.view.WindowLayoutParamsProto.FORMAT;
25 import static android.view.WindowLayoutParamsProto.GRAVITY;
26 import static android.view.WindowLayoutParamsProto.HAS_SYSTEM_UI_LISTENERS;
27 import static android.view.WindowLayoutParamsProto.HEIGHT;
28 import static android.view.WindowLayoutParamsProto.HORIZONTAL_MARGIN;
29 import static android.view.WindowLayoutParamsProto.INPUT_FEATURE_FLAGS;
30 import static android.view.WindowLayoutParamsProto.NEEDS_MENU_KEY;
31 import static android.view.WindowLayoutParamsProto.PREFERRED_REFRESH_RATE;
32 import static android.view.WindowLayoutParamsProto.PRIVATE_FLAGS;
33 import static android.view.WindowLayoutParamsProto.ROTATION_ANIMATION;
34 import static android.view.WindowLayoutParamsProto.SCREEN_BRIGHTNESS;
35 import static android.view.WindowLayoutParamsProto.SOFT_INPUT_MODE;
36 import static android.view.WindowLayoutParamsProto.SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS;
37 import static android.view.WindowLayoutParamsProto.SYSTEM_UI_VISIBILITY_FLAGS;
38 import static android.view.WindowLayoutParamsProto.TYPE;
39 import static android.view.WindowLayoutParamsProto.USER_ACTIVITY_TIMEOUT;
40 import static android.view.WindowLayoutParamsProto.VERTICAL_MARGIN;
41 import static android.view.WindowLayoutParamsProto.WIDTH;
42 import static android.view.WindowLayoutParamsProto.WINDOW_ANIMATIONS;
43 import static android.view.WindowLayoutParamsProto.X;
44 import static android.view.WindowLayoutParamsProto.Y;
45 
46 import android.Manifest.permission;
47 import android.annotation.IntDef;
48 import android.annotation.NonNull;
49 import android.annotation.RequiresPermission;
50 import android.annotation.SystemApi;
51 import android.annotation.SystemService;
52 import android.annotation.TestApi;
53 import android.app.KeyguardManager;
54 import android.app.Presentation;
55 import android.compat.annotation.UnsupportedAppUsage;
56 import android.content.Context;
57 import android.content.pm.ActivityInfo;
58 import android.graphics.PixelFormat;
59 import android.graphics.Rect;
60 import android.graphics.Region;
61 import android.os.IBinder;
62 import android.os.Parcel;
63 import android.os.Parcelable;
64 import android.text.TextUtils;
65 import android.util.Log;
66 import android.util.proto.ProtoOutputStream;
67 import android.view.accessibility.AccessibilityNodeInfo;
68 
69 import java.lang.annotation.Retention;
70 import java.lang.annotation.RetentionPolicy;
71 import java.util.List;
72 import java.util.Objects;
73 
74 /**
75  * The interface that apps use to talk to the window manager.
76  * </p><p>
77  * Each window manager instance is bound to a particular {@link Display}.
78  * To obtain a {@link WindowManager} for a different display, use
79  * {@link Context#createDisplayContext} to obtain a {@link Context} for that
80  * display, then use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code>
81  * to get the WindowManager.
82  * </p><p>
83  * The simplest way to show a window on another display is to create a
84  * {@link Presentation}.  The presentation will automatically obtain a
85  * {@link WindowManager} and {@link Context} for that display.
86  * </p>
87  */
88 @SystemService(Context.WINDOW_SERVICE)
89 public interface WindowManager extends ViewManager {
90 
91     /** @hide */
92     int DOCKED_INVALID = -1;
93     /** @hide */
94     int DOCKED_LEFT = 1;
95     /** @hide */
96     int DOCKED_TOP = 2;
97     /** @hide */
98     int DOCKED_RIGHT = 3;
99     /** @hide */
100     int DOCKED_BOTTOM = 4;
101 
102     /** @hide */
103     String INPUT_CONSUMER_PIP = "pip_input_consumer";
104     /** @hide */
105     String INPUT_CONSUMER_NAVIGATION = "nav_input_consumer";
106     /** @hide */
107     String INPUT_CONSUMER_WALLPAPER = "wallpaper_input_consumer";
108     /** @hide */
109     String INPUT_CONSUMER_RECENTS_ANIMATION = "recents_animation_input_consumer";
110 
111     /**
112      * Not set up for a transition.
113      * @hide
114      */
115     int TRANSIT_UNSET = -1;
116 
117     /**
118      * No animation for transition.
119      * @hide
120      */
121     int TRANSIT_NONE = 0;
122 
123     /**
124      * A window in a new activity is being opened on top of an existing one in the same task.
125      * @hide
126      */
127     int TRANSIT_ACTIVITY_OPEN = 6;
128 
129     /**
130      * The window in the top-most activity is being closed to reveal the previous activity in the
131      * same task.
132      * @hide
133      */
134     int TRANSIT_ACTIVITY_CLOSE = 7;
135 
136     /**
137      * A window in a new task is being opened on top of an existing one in another activity's task.
138      * @hide
139      */
140     int TRANSIT_TASK_OPEN = 8;
141 
142     /**
143      * A window in the top-most activity is being closed to reveal the previous activity in a
144      * different task.
145      * @hide
146      */
147     int TRANSIT_TASK_CLOSE = 9;
148 
149     /**
150      * A window in an existing task is being displayed on top of an existing one in another
151      * activity's task.
152      * @hide
153      */
154     int TRANSIT_TASK_TO_FRONT = 10;
155 
156     /**
157      * A window in an existing task is being put below all other tasks.
158      * @hide
159      */
160     int TRANSIT_TASK_TO_BACK = 11;
161 
162     /**
163      * A window in a new activity that doesn't have a wallpaper is being opened on top of one that
164      * does, effectively closing the wallpaper.
165      * @hide
166      */
167     int TRANSIT_WALLPAPER_CLOSE = 12;
168 
169     /**
170      * A window in a new activity that does have a wallpaper is being opened on one that didn't,
171      * effectively opening the wallpaper.
172      * @hide
173      */
174     int TRANSIT_WALLPAPER_OPEN = 13;
175 
176     /**
177      * A window in a new activity is being opened on top of an existing one, and both are on top
178      * of the wallpaper.
179      * @hide
180      */
181     int TRANSIT_WALLPAPER_INTRA_OPEN = 14;
182 
183     /**
184      * The window in the top-most activity is being closed to reveal the previous activity, and
185      * both are on top of the wallpaper.
186      * @hide
187      */
188     int TRANSIT_WALLPAPER_INTRA_CLOSE = 15;
189 
190     /**
191      * A window in a new task is being opened behind an existing one in another activity's task.
192      * The new window will show briefly and then be gone.
193      * @hide
194      */
195     int TRANSIT_TASK_OPEN_BEHIND = 16;
196 
197     /**
198      * A window in a task is being animated in-place.
199      * @hide
200      */
201     int TRANSIT_TASK_IN_PLACE = 17;
202 
203     /**
204      * An activity is being relaunched (e.g. due to configuration change).
205      * @hide
206      */
207     int TRANSIT_ACTIVITY_RELAUNCH = 18;
208 
209     /**
210      * A task is being docked from recents.
211      * @hide
212      */
213     int TRANSIT_DOCK_TASK_FROM_RECENTS = 19;
214 
215     /**
216      * Keyguard is going away.
217      * @hide
218      */
219     int TRANSIT_KEYGUARD_GOING_AWAY = 20;
220 
221     /**
222      * Keyguard is going away with showing an activity behind that requests wallpaper.
223      * @hide
224      */
225     int TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER = 21;
226 
227     /**
228      * Keyguard is being occluded.
229      * @hide
230      */
231     int TRANSIT_KEYGUARD_OCCLUDE = 22;
232 
233     /**
234      * Keyguard is being unoccluded.
235      * @hide
236      */
237     int TRANSIT_KEYGUARD_UNOCCLUDE = 23;
238 
239     /**
240      * A translucent activity is being opened.
241      * @hide
242      */
243     int TRANSIT_TRANSLUCENT_ACTIVITY_OPEN = 24;
244 
245     /**
246      * A translucent activity is being closed.
247      * @hide
248      */
249     int TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE = 25;
250 
251     /**
252      * A crashing activity is being closed.
253      * @hide
254      */
255     int TRANSIT_CRASHING_ACTIVITY_CLOSE = 26;
256 
257     /**
258      * A task is changing windowing modes
259      * @hide
260      */
261     int TRANSIT_TASK_CHANGE_WINDOWING_MODE = 27;
262 
263     /**
264      * A display which can only contain one task is being shown because the first activity is
265      * started or it's being turned on.
266      * @hide
267      */
268     int TRANSIT_SHOW_SINGLE_TASK_DISPLAY = 28;
269 
270     /**
271      * @hide
272      */
273     @IntDef(prefix = { "TRANSIT_" }, value = {
274             TRANSIT_UNSET,
275             TRANSIT_NONE,
276             TRANSIT_ACTIVITY_OPEN,
277             TRANSIT_ACTIVITY_CLOSE,
278             TRANSIT_TASK_OPEN,
279             TRANSIT_TASK_CLOSE,
280             TRANSIT_TASK_TO_FRONT,
281             TRANSIT_TASK_TO_BACK,
282             TRANSIT_WALLPAPER_CLOSE,
283             TRANSIT_WALLPAPER_OPEN,
284             TRANSIT_WALLPAPER_INTRA_OPEN,
285             TRANSIT_WALLPAPER_INTRA_CLOSE,
286             TRANSIT_TASK_OPEN_BEHIND,
287             TRANSIT_TASK_IN_PLACE,
288             TRANSIT_ACTIVITY_RELAUNCH,
289             TRANSIT_DOCK_TASK_FROM_RECENTS,
290             TRANSIT_KEYGUARD_GOING_AWAY,
291             TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER,
292             TRANSIT_KEYGUARD_OCCLUDE,
293             TRANSIT_KEYGUARD_UNOCCLUDE,
294             TRANSIT_TRANSLUCENT_ACTIVITY_OPEN,
295             TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE,
296             TRANSIT_CRASHING_ACTIVITY_CLOSE,
297             TRANSIT_TASK_CHANGE_WINDOWING_MODE,
298             TRANSIT_SHOW_SINGLE_TASK_DISPLAY
299     })
300     @Retention(RetentionPolicy.SOURCE)
301     @interface TransitionType {}
302 
303     /**
304      * Transition flag: Keyguard is going away, but keeping the notification shade open
305      * @hide
306      */
307     int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE = 0x1;
308 
309     /**
310      * Transition flag: Keyguard is going away, but doesn't want an animation for it
311      * @hide
312      */
313     int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION = 0x2;
314 
315     /**
316      * Transition flag: Keyguard is going away while it was showing the system wallpaper.
317      * @hide
318      */
319     int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER = 0x4;
320 
321     /**
322      * Transition flag: Keyguard is going away with subtle animation.
323      * @hide
324      */
325     int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION = 0x8;
326 
327     /**
328      * @hide
329      */
330     @IntDef(flag = true, prefix = { "TRANSIT_FLAG_" }, value = {
331             TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE,
332             TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION,
333             TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER,
334     })
335     @Retention(RetentionPolicy.SOURCE)
336     @interface TransitionFlags {}
337 
338     /**
339      * Remove content mode: Indicates remove content mode is currently not defined.
340      * @hide
341      */
342     int REMOVE_CONTENT_MODE_UNDEFINED = 0;
343 
344     /**
345      * Remove content mode: Indicates that when display is removed, all its activities will be moved
346      * to the primary display and the topmost activity should become focused.
347      * @hide
348      */
349     int REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY = 1;
350 
351     /**
352      * Remove content mode: Indicates that when display is removed, all its stacks and tasks will be
353      * removed, all activities will be destroyed according to the usual lifecycle.
354      * @hide
355      */
356     int REMOVE_CONTENT_MODE_DESTROY = 2;
357 
358     /**
359      * @hide
360      */
361     @IntDef(prefix = { "REMOVE_CONTENT_MODE_" }, value = {
362             REMOVE_CONTENT_MODE_UNDEFINED,
363             REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY,
364             REMOVE_CONTENT_MODE_DESTROY,
365     })
366     @interface RemoveContentMode {}
367 
368     /**
369      * Exception that is thrown when trying to add view whose
370      * {@link LayoutParams} {@link LayoutParams#token}
371      * is invalid.
372      */
373     public static class BadTokenException extends RuntimeException {
BadTokenException()374         public BadTokenException() {
375         }
376 
BadTokenException(String name)377         public BadTokenException(String name) {
378             super(name);
379         }
380     }
381 
382     /**
383      * Exception that is thrown when calling {@link #addView} to a secondary display that cannot
384      * be found. See {@link android.app.Presentation} for more information on secondary displays.
385      */
386     public static class InvalidDisplayException extends RuntimeException {
InvalidDisplayException()387         public InvalidDisplayException() {
388         }
389 
InvalidDisplayException(String name)390         public InvalidDisplayException(String name) {
391             super(name);
392         }
393     }
394 
395     /**
396      * Returns the {@link Display} upon which this {@link WindowManager} instance
397      * will create new windows.
398      * <p>
399      * Despite the name of this method, the display that is returned is not
400      * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}).
401      * The returned display could instead be a secondary display that this
402      * window manager instance is managing.  Think of it as the display that
403      * this {@link WindowManager} instance uses by default.
404      * </p><p>
405      * To create windows on a different display, you need to obtain a
406      * {@link WindowManager} for that {@link Display}.  (See the {@link WindowManager}
407      * class documentation for more information.)
408      * </p>
409      *
410      * @return The display that this window manager is managing.
411      */
getDefaultDisplay()412     public Display getDefaultDisplay();
413 
414     /**
415      * Special variation of {@link #removeView} that immediately invokes
416      * the given view hierarchy's {@link View#onDetachedFromWindow()
417      * View.onDetachedFromWindow()} methods before returning.  This is not
418      * for normal applications; using it correctly requires great care.
419      *
420      * @param view The view to be removed.
421      */
removeViewImmediate(View view)422     public void removeViewImmediate(View view);
423 
424     /**
425      * Used to asynchronously request Keyboard Shortcuts from the focused window.
426      *
427      * @hide
428      */
429     public interface KeyboardShortcutsReceiver {
430         /**
431          * Callback used when the focused window keyboard shortcuts are ready to be displayed.
432          *
433          * @param result The keyboard shortcuts to be displayed.
434          */
onKeyboardShortcutsReceived(List<KeyboardShortcutGroup> result)435         void onKeyboardShortcutsReceived(List<KeyboardShortcutGroup> result);
436     }
437 
438     /**
439      * Message for taking fullscreen screenshot
440      * @hide
441      */
442     final int TAKE_SCREENSHOT_FULLSCREEN = 1;
443 
444     /**
445      * Message for taking screenshot of selected region.
446      * @hide
447      */
448     final int TAKE_SCREENSHOT_SELECTED_REGION = 2;
449 
450     /**
451      * @hide
452      */
453     public static final String PARCEL_KEY_SHORTCUTS_ARRAY = "shortcuts_array";
454 
455     /**
456      * Request for keyboard shortcuts to be retrieved asynchronously.
457      *
458      * @param receiver The callback to be triggered when the result is ready.
459      *
460      * @hide
461      */
requestAppKeyboardShortcuts(final KeyboardShortcutsReceiver receiver, int deviceId)462     public void requestAppKeyboardShortcuts(final KeyboardShortcutsReceiver receiver, int deviceId);
463 
464     /**
465      * Return the touch region for the current IME window, or an empty region if there is none.
466      *
467      * @return The region of the IME that is accepting touch inputs, or null if there is no IME, no
468      *         region or there was an error.
469      *
470      * @hide
471      */
472     @SystemApi
473     @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS)
getCurrentImeTouchRegion()474     public Region getCurrentImeTouchRegion();
475 
476     /**
477      * Sets that the display should show its content when non-secure keyguard is shown.
478      *
479      * @param displayId Display ID.
480      * @param shouldShow Indicates that the display should show its content when non-secure keyguard
481      *                  is shown.
482      * @see KeyguardManager#isDeviceSecure()
483      * @see KeyguardManager#isDeviceLocked()
484      * @hide
485      */
486     @TestApi
setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow)487     default void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow) {
488     }
489 
490     /**
491      * Sets that the display should show system decors.
492      * <p>
493      * System decors include status bar, navigation bar, launcher.
494      * </p>
495      *
496      * @param displayId The id of the display.
497      * @param shouldShow Indicates that the display should show system decors.
498      * @see #shouldShowSystemDecors(int)
499      * @hide
500      */
501     @TestApi
setShouldShowSystemDecors(int displayId, boolean shouldShow)502     default void setShouldShowSystemDecors(int displayId, boolean shouldShow) {
503     }
504 
505     /**
506      * Checks if the display supports showing system decors.
507      * <p>
508      * System decors include status bar, navigation bar, launcher.
509      * </p>
510      *
511      * @param displayId The id of the display.
512      * @see #setShouldShowSystemDecors(int, boolean)
513      * @hide
514      */
515     @TestApi
shouldShowSystemDecors(int displayId)516     default boolean shouldShowSystemDecors(int displayId) {
517         return false;
518     }
519 
520     /**
521      * Sets that the display should show IME.
522      *
523      * @param displayId Display ID.
524      * @param shouldShow Indicates that the display should show IME.
525      * @hide
526      */
527     @TestApi
setShouldShowIme(int displayId, boolean shouldShow)528     default void setShouldShowIme(int displayId, boolean shouldShow) {
529     }
530 
531     /**
532      * Indicates that the display should show IME.
533      *
534      * @param displayId The id of the display.
535      * @return {@code true} if the display should show IME when an input field becomes
536      * focused on it.
537      * @hide
538      */
539     @TestApi
shouldShowIme(int displayId)540     default boolean shouldShowIme(int displayId) {
541         return false;
542     }
543 
544     public static class LayoutParams extends ViewGroup.LayoutParams implements Parcelable {
545         /**
546          * X position for this window.  With the default gravity it is ignored.
547          * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or
548          * {@link Gravity#END} it provides an offset from the given edge.
549          */
550         @ViewDebug.ExportedProperty
551         public int x;
552 
553         /**
554          * Y position for this window.  With the default gravity it is ignored.
555          * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides
556          * an offset from the given edge.
557          */
558         @ViewDebug.ExportedProperty
559         public int y;
560 
561         /**
562          * Indicates how much of the extra space will be allocated horizontally
563          * to the view associated with these LayoutParams. Specify 0 if the view
564          * should not be stretched. Otherwise the extra pixels will be pro-rated
565          * among all views whose weight is greater than 0.
566          */
567         @ViewDebug.ExportedProperty
568         public float horizontalWeight;
569 
570         /**
571          * Indicates how much of the extra space will be allocated vertically
572          * to the view associated with these LayoutParams. Specify 0 if the view
573          * should not be stretched. Otherwise the extra pixels will be pro-rated
574          * among all views whose weight is greater than 0.
575          */
576         @ViewDebug.ExportedProperty
577         public float verticalWeight;
578 
579         /**
580          * The general type of window.  There are three main classes of
581          * window types:
582          * <ul>
583          * <li> <strong>Application windows</strong> (ranging from
584          * {@link #FIRST_APPLICATION_WINDOW} to
585          * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application
586          * windows.  For these types of windows, the {@link #token} must be
587          * set to the token of the activity they are a part of (this will
588          * normally be done for you if {@link #token} is null).
589          * <li> <strong>Sub-windows</strong> (ranging from
590          * {@link #FIRST_SUB_WINDOW} to
591          * {@link #LAST_SUB_WINDOW}) are associated with another top-level
592          * window.  For these types of windows, the {@link #token} must be
593          * the token of the window it is attached to.
594          * <li> <strong>System windows</strong> (ranging from
595          * {@link #FIRST_SYSTEM_WINDOW} to
596          * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for
597          * use by the system for specific purposes.  They should not normally
598          * be used by applications, and a special permission is required
599          * to use them.
600          * </ul>
601          *
602          * @see #TYPE_BASE_APPLICATION
603          * @see #TYPE_APPLICATION
604          * @see #TYPE_APPLICATION_STARTING
605          * @see #TYPE_DRAWN_APPLICATION
606          * @see #TYPE_APPLICATION_PANEL
607          * @see #TYPE_APPLICATION_MEDIA
608          * @see #TYPE_APPLICATION_SUB_PANEL
609          * @see #TYPE_APPLICATION_ATTACHED_DIALOG
610          * @see #TYPE_STATUS_BAR
611          * @see #TYPE_SEARCH_BAR
612          * @see #TYPE_PHONE
613          * @see #TYPE_SYSTEM_ALERT
614          * @see #TYPE_TOAST
615          * @see #TYPE_SYSTEM_OVERLAY
616          * @see #TYPE_PRIORITY_PHONE
617          * @see #TYPE_SYSTEM_DIALOG
618          * @see #TYPE_KEYGUARD_DIALOG
619          * @see #TYPE_SYSTEM_ERROR
620          * @see #TYPE_INPUT_METHOD
621          * @see #TYPE_INPUT_METHOD_DIALOG
622          */
623         @ViewDebug.ExportedProperty(mapping = {
624                 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION,
625                         to = "BASE_APPLICATION"),
626                 @ViewDebug.IntToString(from = TYPE_APPLICATION,
627                         to = "APPLICATION"),
628                 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING,
629                         to = "APPLICATION_STARTING"),
630                 @ViewDebug.IntToString(from = TYPE_DRAWN_APPLICATION,
631                         to = "DRAWN_APPLICATION"),
632                 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL,
633                         to = "APPLICATION_PANEL"),
634                 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA,
635                         to = "APPLICATION_MEDIA"),
636                 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL,
637                         to = "APPLICATION_SUB_PANEL"),
638                 @ViewDebug.IntToString(from = TYPE_APPLICATION_ABOVE_SUB_PANEL,
639                         to = "APPLICATION_ABOVE_SUB_PANEL"),
640                 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG,
641                         to = "APPLICATION_ATTACHED_DIALOG"),
642                 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY,
643                         to = "APPLICATION_MEDIA_OVERLAY"),
644                 @ViewDebug.IntToString(from = TYPE_STATUS_BAR,
645                         to = "STATUS_BAR"),
646                 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR,
647                         to = "SEARCH_BAR"),
648                 @ViewDebug.IntToString(from = TYPE_PHONE,
649                         to = "PHONE"),
650                 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT,
651                         to = "SYSTEM_ALERT"),
652                 @ViewDebug.IntToString(from = TYPE_TOAST,
653                         to = "TOAST"),
654                 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY,
655                         to = "SYSTEM_OVERLAY"),
656                 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE,
657                         to = "PRIORITY_PHONE"),
658                 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG,
659                         to = "SYSTEM_DIALOG"),
660                 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG,
661                         to = "KEYGUARD_DIALOG"),
662                 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR,
663                         to = "SYSTEM_ERROR"),
664                 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD,
665                         to = "INPUT_METHOD"),
666                 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG,
667                         to = "INPUT_METHOD_DIALOG"),
668                 @ViewDebug.IntToString(from = TYPE_WALLPAPER,
669                         to = "WALLPAPER"),
670                 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL,
671                         to = "STATUS_BAR_PANEL"),
672                 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY,
673                         to = "SECURE_SYSTEM_OVERLAY"),
674                 @ViewDebug.IntToString(from = TYPE_DRAG,
675                         to = "DRAG"),
676                 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL,
677                         to = "STATUS_BAR_SUB_PANEL"),
678                 @ViewDebug.IntToString(from = TYPE_POINTER,
679                         to = "POINTER"),
680                 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR,
681                         to = "NAVIGATION_BAR"),
682                 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY,
683                         to = "VOLUME_OVERLAY"),
684                 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS,
685                         to = "BOOT_PROGRESS"),
686                 @ViewDebug.IntToString(from = TYPE_INPUT_CONSUMER,
687                         to = "INPUT_CONSUMER"),
688                 @ViewDebug.IntToString(from = TYPE_DREAM,
689                         to = "DREAM"),
690                 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL,
691                         to = "NAVIGATION_BAR_PANEL"),
692                 @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY,
693                         to = "DISPLAY_OVERLAY"),
694                 @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY,
695                         to = "MAGNIFICATION_OVERLAY"),
696                 @ViewDebug.IntToString(from = TYPE_PRESENTATION,
697                         to = "PRESENTATION"),
698                 @ViewDebug.IntToString(from = TYPE_PRIVATE_PRESENTATION,
699                         to = "PRIVATE_PRESENTATION"),
700                 @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION,
701                         to = "VOICE_INTERACTION"),
702                 @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION_STARTING,
703                         to = "VOICE_INTERACTION_STARTING"),
704                 @ViewDebug.IntToString(from = TYPE_DOCK_DIVIDER,
705                         to = "DOCK_DIVIDER"),
706                 @ViewDebug.IntToString(from = TYPE_QS_DIALOG,
707                         to = "QS_DIALOG"),
708                 @ViewDebug.IntToString(from = TYPE_SCREENSHOT,
709                         to = "SCREENSHOT"),
710                 @ViewDebug.IntToString(from = TYPE_APPLICATION_OVERLAY,
711                         to = "APPLICATION_OVERLAY")
712         })
713         public int type;
714 
715         /**
716          * Start of window types that represent normal application windows.
717          */
718         public static final int FIRST_APPLICATION_WINDOW = 1;
719 
720         /**
721          * Window type: an application window that serves as the "base" window
722          * of the overall application; all other application windows will
723          * appear on top of it.
724          * In multiuser systems shows only on the owning user's window.
725          */
726         public static final int TYPE_BASE_APPLICATION   = 1;
727 
728         /**
729          * Window type: a normal application window.  The {@link #token} must be
730          * an Activity token identifying who the window belongs to.
731          * In multiuser systems shows only on the owning user's window.
732          */
733         public static final int TYPE_APPLICATION        = 2;
734 
735         /**
736          * Window type: special application window that is displayed while the
737          * application is starting.  Not for use by applications themselves;
738          * this is used by the system to display something until the
739          * application can show its own windows.
740          * In multiuser systems shows on all users' windows.
741          */
742         public static final int TYPE_APPLICATION_STARTING = 3;
743 
744         /**
745          * Window type: a variation on TYPE_APPLICATION that ensures the window
746          * manager will wait for this window to be drawn before the app is shown.
747          * In multiuser systems shows only on the owning user's window.
748          */
749         public static final int TYPE_DRAWN_APPLICATION = 4;
750 
751         /**
752          * End of types of application windows.
753          */
754         public static final int LAST_APPLICATION_WINDOW = 99;
755 
756         /**
757          * Start of types of sub-windows.  The {@link #token} of these windows
758          * must be set to the window they are attached to.  These types of
759          * windows are kept next to their attached window in Z-order, and their
760          * coordinate space is relative to their attached window.
761          */
762         public static final int FIRST_SUB_WINDOW = 1000;
763 
764         /**
765          * Window type: a panel on top of an application window.  These windows
766          * appear on top of their attached window.
767          */
768         public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW;
769 
770         /**
771          * Window type: window for showing media (such as video).  These windows
772          * are displayed behind their attached window.
773          */
774         public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1;
775 
776         /**
777          * Window type: a sub-panel on top of an application window.  These
778          * windows are displayed on top their attached window and any
779          * {@link #TYPE_APPLICATION_PANEL} panels.
780          */
781         public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2;
782 
783         /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout
784          * of the window happens as that of a top-level window, <em>not</em>
785          * as a child of its container.
786          */
787         public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3;
788 
789         /**
790          * Window type: window for showing overlays on top of media windows.
791          * These windows are displayed between TYPE_APPLICATION_MEDIA and the
792          * application window.  They should be translucent to be useful.  This
793          * is a big ugly hack so:
794          * @hide
795          */
796         @UnsupportedAppUsage
797         public static final int TYPE_APPLICATION_MEDIA_OVERLAY  = FIRST_SUB_WINDOW + 4;
798 
799         /**
800          * Window type: a above sub-panel on top of an application window and it's
801          * sub-panel windows. These windows are displayed on top of their attached window
802          * and any {@link #TYPE_APPLICATION_SUB_PANEL} panels.
803          * @hide
804          */
805         public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5;
806 
807         /**
808          * End of types of sub-windows.
809          */
810         public static final int LAST_SUB_WINDOW = 1999;
811 
812         /**
813          * Start of system-specific window types.  These are not normally
814          * created by applications.
815          */
816         public static final int FIRST_SYSTEM_WINDOW     = 2000;
817 
818         /**
819          * Window type: the status bar.  There can be only one status bar
820          * window; it is placed at the top of the screen, and all other
821          * windows are shifted down so they are below it.
822          * In multiuser systems shows on all users' windows.
823          */
824         public static final int TYPE_STATUS_BAR         = FIRST_SYSTEM_WINDOW;
825 
826         /**
827          * Window type: the search bar.  There can be only one search bar
828          * window; it is placed at the top of the screen.
829          * In multiuser systems shows on all users' windows.
830          */
831         public static final int TYPE_SEARCH_BAR         = FIRST_SYSTEM_WINDOW+1;
832 
833         /**
834          * Window type: phone.  These are non-application windows providing
835          * user interaction with the phone (in particular incoming calls).
836          * These windows are normally placed above all applications, but behind
837          * the status bar.
838          * In multiuser systems shows on all users' windows.
839          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
840          */
841         @Deprecated
842         public static final int TYPE_PHONE              = FIRST_SYSTEM_WINDOW+2;
843 
844         /**
845          * Window type: system window, such as low power alert. These windows
846          * are always on top of application windows.
847          * In multiuser systems shows only on the owning user's window.
848          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
849          */
850         @Deprecated
851         public static final int TYPE_SYSTEM_ALERT       = FIRST_SYSTEM_WINDOW+3;
852 
853         /**
854          * Window type: keyguard window.
855          * In multiuser systems shows on all users' windows.
856          * @removed
857          */
858         public static final int TYPE_KEYGUARD           = FIRST_SYSTEM_WINDOW+4;
859 
860         /**
861          * Window type: transient notifications.
862          * In multiuser systems shows only on the owning user's window.
863          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
864          */
865         @Deprecated
866         public static final int TYPE_TOAST              = FIRST_SYSTEM_WINDOW+5;
867 
868         /**
869          * Window type: system overlay windows, which need to be displayed
870          * on top of everything else.  These windows must not take input
871          * focus, or they will interfere with the keyguard.
872          * In multiuser systems shows only on the owning user's window.
873          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
874          */
875         @Deprecated
876         public static final int TYPE_SYSTEM_OVERLAY     = FIRST_SYSTEM_WINDOW+6;
877 
878         /**
879          * Window type: priority phone UI, which needs to be displayed even if
880          * the keyguard is active.  These windows must not take input
881          * focus, or they will interfere with the keyguard.
882          * In multiuser systems shows on all users' windows.
883          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
884          */
885         @Deprecated
886         public static final int TYPE_PRIORITY_PHONE     = FIRST_SYSTEM_WINDOW+7;
887 
888         /**
889          * Window type: panel that slides out from the status bar
890          * In multiuser systems shows on all users' windows.
891          */
892         public static final int TYPE_SYSTEM_DIALOG      = FIRST_SYSTEM_WINDOW+8;
893 
894         /**
895          * Window type: dialogs that the keyguard shows
896          * In multiuser systems shows on all users' windows.
897          */
898         public static final int TYPE_KEYGUARD_DIALOG    = FIRST_SYSTEM_WINDOW+9;
899 
900         /**
901          * Window type: internal system error windows, appear on top of
902          * everything they can.
903          * In multiuser systems shows only on the owning user's window.
904          * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead.
905          */
906         @Deprecated
907         public static final int TYPE_SYSTEM_ERROR       = FIRST_SYSTEM_WINDOW+10;
908 
909         /**
910          * Window type: internal input methods windows, which appear above
911          * the normal UI.  Application windows may be resized or panned to keep
912          * the input focus visible while this window is displayed.
913          * In multiuser systems shows only on the owning user's window.
914          */
915         public static final int TYPE_INPUT_METHOD       = FIRST_SYSTEM_WINDOW+11;
916 
917         /**
918          * Window type: internal input methods dialog windows, which appear above
919          * the current input method window.
920          * In multiuser systems shows only on the owning user's window.
921          */
922         public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12;
923 
924         /**
925          * Window type: wallpaper window, placed behind any window that wants
926          * to sit on top of the wallpaper.
927          * In multiuser systems shows only on the owning user's window.
928          */
929         public static final int TYPE_WALLPAPER          = FIRST_SYSTEM_WINDOW+13;
930 
931         /**
932          * Window type: panel that slides out from over the status bar
933          * In multiuser systems shows on all users' windows.
934          */
935         public static final int TYPE_STATUS_BAR_PANEL   = FIRST_SYSTEM_WINDOW+14;
936 
937         /**
938          * Window type: secure system overlay windows, which need to be displayed
939          * on top of everything else.  These windows must not take input
940          * focus, or they will interfere with the keyguard.
941          *
942          * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the
943          * system itself is allowed to create these overlays.  Applications cannot
944          * obtain permission to create secure system overlays.
945          *
946          * In multiuser systems shows only on the owning user's window.
947          * @hide
948          */
949         @UnsupportedAppUsage
950         public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
951 
952         /**
953          * Window type: the drag-and-drop pseudowindow.  There is only one
954          * drag layer (at most), and it is placed on top of all other windows.
955          * In multiuser systems shows only on the owning user's window.
956          * @hide
957          */
958         public static final int TYPE_DRAG               = FIRST_SYSTEM_WINDOW+16;
959 
960         /**
961          * Window type: panel that slides out from over the status bar
962          * In multiuser systems shows on all users' windows. These windows
963          * are displayed on top of the stauts bar and any {@link #TYPE_STATUS_BAR_PANEL}
964          * windows.
965          * @hide
966          */
967         public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17;
968 
969         /**
970          * Window type: (mouse) pointer
971          * In multiuser systems shows on all users' windows.
972          * @hide
973          */
974         public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18;
975 
976         /**
977          * Window type: Navigation bar (when distinct from status bar)
978          * In multiuser systems shows on all users' windows.
979          * @hide
980          */
981         public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19;
982 
983         /**
984          * Window type: The volume level overlay/dialog shown when the user
985          * changes the system volume.
986          * In multiuser systems shows on all users' windows.
987          * @hide
988          */
989         public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20;
990 
991         /**
992          * Window type: The boot progress dialog, goes on top of everything
993          * in the world.
994          * In multiuser systems shows on all users' windows.
995          * @hide
996          */
997         public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21;
998 
999         /**
1000          * Window type to consume input events when the systemUI bars are hidden.
1001          * In multiuser systems shows on all users' windows.
1002          * @hide
1003          */
1004         public static final int TYPE_INPUT_CONSUMER = FIRST_SYSTEM_WINDOW+22;
1005 
1006         /**
1007          * Window type: Dreams (screen saver) window, just above keyguard.
1008          * In multiuser systems shows only on the owning user's window.
1009          * @hide
1010          */
1011         public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23;
1012 
1013         /**
1014          * Window type: Navigation bar panel (when navigation bar is distinct from status bar)
1015          * In multiuser systems shows on all users' windows.
1016          * @hide
1017          */
1018         public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24;
1019 
1020         /**
1021          * Window type: Display overlay window.  Used to simulate secondary display devices.
1022          * In multiuser systems shows on all users' windows.
1023          * @hide
1024          */
1025         @UnsupportedAppUsage
1026         public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26;
1027 
1028         /**
1029          * Window type: Magnification overlay window. Used to highlight the magnified
1030          * portion of a display when accessibility magnification is enabled.
1031          * In multiuser systems shows on all users' windows.
1032          * @hide
1033          */
1034         public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27;
1035 
1036         /**
1037          * Window type: Window for Presentation on top of private
1038          * virtual display.
1039          */
1040         public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30;
1041 
1042         /**
1043          * Window type: Windows in the voice interaction layer.
1044          * @hide
1045          */
1046         public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31;
1047 
1048         /**
1049          * Window type: Windows that are overlaid <em>only</em> by a connected {@link
1050          * android.accessibilityservice.AccessibilityService} for interception of
1051          * user interactions without changing the windows an accessibility service
1052          * can introspect. In particular, an accessibility service can introspect
1053          * only windows that a sighted user can interact with which is they can touch
1054          * these windows or can type into these windows. For example, if there
1055          * is a full screen accessibility overlay that is touchable, the windows
1056          * below it will be introspectable by an accessibility service even though
1057          * they are covered by a touchable window.
1058          */
1059         public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32;
1060 
1061         /**
1062          * Window type: Starting window for voice interaction layer.
1063          * @hide
1064          */
1065         public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33;
1066 
1067         /**
1068          * Window for displaying a handle used for resizing docked stacks. This window is owned
1069          * by the system process.
1070          * @hide
1071          */
1072         public static final int TYPE_DOCK_DIVIDER = FIRST_SYSTEM_WINDOW+34;
1073 
1074         /**
1075          * Window type: like {@link #TYPE_APPLICATION_ATTACHED_DIALOG}, but used
1076          * by Quick Settings Tiles.
1077          * @hide
1078          */
1079         public static final int TYPE_QS_DIALOG = FIRST_SYSTEM_WINDOW+35;
1080 
1081         /**
1082          * Window type: shares similar characteristics with {@link #TYPE_DREAM}. The layer is
1083          * reserved for screenshot region selection. These windows must not take input focus.
1084          * @hide
1085          */
1086         public static final int TYPE_SCREENSHOT = FIRST_SYSTEM_WINDOW + 36;
1087 
1088         /**
1089          * Window type: Window for Presentation on an external display.
1090          * @see android.app.Presentation
1091          * @hide
1092          */
1093         public static final int TYPE_PRESENTATION = FIRST_SYSTEM_WINDOW + 37;
1094 
1095         /**
1096          * Window type: Application overlay windows are displayed above all activity windows
1097          * (types between {@link #FIRST_APPLICATION_WINDOW} and {@link #LAST_APPLICATION_WINDOW})
1098          * but below critical system windows like the status bar or IME.
1099          * <p>
1100          * The system may change the position, size, or visibility of these windows at anytime
1101          * to reduce visual clutter to the user and also manage resources.
1102          * <p>
1103          * Requires {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} permission.
1104          * <p>
1105          * The system will adjust the importance of processes with this window type to reduce the
1106          * chance of the low-memory-killer killing them.
1107          * <p>
1108          * In multi-user systems shows only on the owning user's screen.
1109          */
1110         public static final int TYPE_APPLICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 38;
1111 
1112         /**
1113          * End of types of system windows.
1114          */
1115         public static final int LAST_SYSTEM_WINDOW      = 2999;
1116 
1117         /**
1118          * @hide
1119          * Used internally when there is no suitable type available.
1120          */
1121         public static final int INVALID_WINDOW_TYPE = -1;
1122 
1123         /**
1124          * Return true if the window type is an alert window.
1125          *
1126          * @param type The window type.
1127          * @return If the window type is an alert window.
1128          * @hide
1129          */
isSystemAlertWindowType(int type)1130         public static boolean isSystemAlertWindowType(int type) {
1131             switch (type) {
1132                 case TYPE_PHONE:
1133                 case TYPE_PRIORITY_PHONE:
1134                 case TYPE_SYSTEM_ALERT:
1135                 case TYPE_SYSTEM_ERROR:
1136                 case TYPE_SYSTEM_OVERLAY:
1137                 case TYPE_APPLICATION_OVERLAY:
1138                     return true;
1139             }
1140             return false;
1141         }
1142 
1143         /** @deprecated this is ignored, this value is set automatically when needed. */
1144         @Deprecated
1145         public static final int MEMORY_TYPE_NORMAL = 0;
1146         /** @deprecated this is ignored, this value is set automatically when needed. */
1147         @Deprecated
1148         public static final int MEMORY_TYPE_HARDWARE = 1;
1149         /** @deprecated this is ignored, this value is set automatically when needed. */
1150         @Deprecated
1151         public static final int MEMORY_TYPE_GPU = 2;
1152         /** @deprecated this is ignored, this value is set automatically when needed. */
1153         @Deprecated
1154         public static final int MEMORY_TYPE_PUSH_BUFFERS = 3;
1155 
1156         /**
1157          * @deprecated this is ignored
1158          */
1159         @Deprecated
1160         public int memoryType;
1161 
1162         /** Window flag: as long as this window is visible to the user, allow
1163          *  the lock screen to activate while the screen is on.
1164          *  This can be used independently, or in combination with
1165          *  {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */
1166         public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON     = 0x00000001;
1167 
1168         /** Window flag: everything behind this window will be dimmed.
1169          *  Use {@link #dimAmount} to control the amount of dim. */
1170         public static final int FLAG_DIM_BEHIND        = 0x00000002;
1171 
1172         /** Window flag: blur everything behind this window.
1173          * @deprecated Blurring is no longer supported. */
1174         @Deprecated
1175         public static final int FLAG_BLUR_BEHIND        = 0x00000004;
1176 
1177         /** Window flag: this window won't ever get key input focus, so the
1178          * user can not send key or other button events to it.  Those will
1179          * instead go to whatever focusable window is behind it.  This flag
1180          * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that
1181          * is explicitly set.
1182          *
1183          * <p>Setting this flag also implies that the window will not need to
1184          * interact with
1185          * a soft input method, so it will be Z-ordered and positioned
1186          * independently of any active input method (typically this means it
1187          * gets Z-ordered on top of the input method, so it can use the full
1188          * screen for its content and cover the input method if needed.  You
1189          * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */
1190         public static final int FLAG_NOT_FOCUSABLE      = 0x00000008;
1191 
1192         /** Window flag: this window can never receive touch events. */
1193         public static final int FLAG_NOT_TOUCHABLE      = 0x00000010;
1194 
1195         /** Window flag: even when this window is focusable (its
1196          * {@link #FLAG_NOT_FOCUSABLE} is not set), allow any pointer events
1197          * outside of the window to be sent to the windows behind it.  Otherwise
1198          * it will consume all pointer events itself, regardless of whether they
1199          * are inside of the window. */
1200         public static final int FLAG_NOT_TOUCH_MODAL    = 0x00000020;
1201 
1202         /** Window flag: when set, if the device is asleep when the touch
1203          * screen is pressed, you will receive this first touch event.  Usually
1204          * the first touch event is consumed by the system since the user can
1205          * not see what they are pressing on.
1206          *
1207          * @deprecated This flag has no effect.
1208          */
1209         @Deprecated
1210         public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040;
1211 
1212         /** Window flag: as long as this window is visible to the user, keep
1213          *  the device's screen turned on and bright. */
1214         public static final int FLAG_KEEP_SCREEN_ON     = 0x00000080;
1215 
1216         /** Window flag: place the window within the entire screen, ignoring
1217          *  decorations around the border (such as the status bar).  The
1218          *  window must correctly position its contents to take the screen
1219          *  decoration into account.  This flag is normally set for you
1220          *  by Window as described in {@link Window#setFlags}.
1221          *
1222          *  <p>Note: on displays that have a {@link DisplayCutout}, the window may be placed
1223          *  such that it avoids the {@link DisplayCutout} area if necessary according to the
1224          *  {@link #layoutInDisplayCutoutMode}.
1225          */
1226         public static final int FLAG_LAYOUT_IN_SCREEN   = 0x00000100;
1227 
1228         /** Window flag: allow window to extend outside of the screen. */
1229         public static final int FLAG_LAYOUT_NO_LIMITS   = 0x00000200;
1230 
1231         /**
1232          * Window flag: hide all screen decorations (such as the status bar) while
1233          * this window is displayed.  This allows the window to use the entire
1234          * display space for itself -- the status bar will be hidden when
1235          * an app window with this flag set is on the top layer. A fullscreen window
1236          * will ignore a value of {@link #SOFT_INPUT_ADJUST_RESIZE} for the window's
1237          * {@link #softInputMode} field; the window will stay fullscreen
1238          * and will not resize.
1239          *
1240          * <p>This flag can be controlled in your theme through the
1241          * {@link android.R.attr#windowFullscreen} attribute; this attribute
1242          * is automatically set for you in the standard fullscreen themes
1243          * such as {@link android.R.style#Theme_NoTitleBar_Fullscreen},
1244          * {@link android.R.style#Theme_Black_NoTitleBar_Fullscreen},
1245          * {@link android.R.style#Theme_Light_NoTitleBar_Fullscreen},
1246          * {@link android.R.style#Theme_Holo_NoActionBar_Fullscreen},
1247          * {@link android.R.style#Theme_Holo_Light_NoActionBar_Fullscreen},
1248          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Fullscreen}, and
1249          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Fullscreen}.</p>
1250          */
1251         public static final int FLAG_FULLSCREEN      = 0x00000400;
1252 
1253         /** Window flag: override {@link #FLAG_FULLSCREEN} and force the
1254          *  screen decorations (such as the status bar) to be shown. */
1255         public static final int FLAG_FORCE_NOT_FULLSCREEN   = 0x00000800;
1256 
1257         /** Window flag: turn on dithering when compositing this window to
1258          *  the screen.
1259          * @deprecated This flag is no longer used. */
1260         @Deprecated
1261         public static final int FLAG_DITHER             = 0x00001000;
1262 
1263         /** Window flag: treat the content of the window as secure, preventing
1264          * it from appearing in screenshots or from being viewed on non-secure
1265          * displays.
1266          *
1267          * <p>See {@link android.view.Display#FLAG_SECURE} for more details about
1268          * secure surfaces and secure displays.
1269          */
1270         public static final int FLAG_SECURE             = 0x00002000;
1271 
1272         /** Window flag: a special mode where the layout parameters are used
1273          * to perform scaling of the surface when it is composited to the
1274          * screen. */
1275         public static final int FLAG_SCALED             = 0x00004000;
1276 
1277         /** Window flag: intended for windows that will often be used when the user is
1278          * holding the screen against their face, it will aggressively filter the event
1279          * stream to prevent unintended presses in this situation that may not be
1280          * desired for a particular window, when such an event stream is detected, the
1281          * application will receive a CANCEL motion event to indicate this so applications
1282          * can handle this accordingly by taking no action on the event
1283          * until the finger is released. */
1284         public static final int FLAG_IGNORE_CHEEK_PRESSES    = 0x00008000;
1285 
1286         /** Window flag: a special option only for use in combination with
1287          * {@link #FLAG_LAYOUT_IN_SCREEN}.  When requesting layout in the
1288          * screen your window may appear on top of or behind screen decorations
1289          * such as the status bar.  By also including this flag, the window
1290          * manager will report the inset rectangle needed to ensure your
1291          * content is not covered by screen decorations.  This flag is normally
1292          * set for you by Window as described in {@link Window#setFlags}.*/
1293         public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000;
1294 
1295         /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with
1296          * respect to how this window interacts with the current method.  That
1297          * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the
1298          * window will behave as if it needs to interact with the input method
1299          * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is
1300          * not set and this flag is set, then the window will behave as if it
1301          * doesn't need to interact with the input method and can be placed
1302          * to use more space and cover the input method.
1303          */
1304         public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000;
1305 
1306         /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you
1307          * can set this flag to receive a single special MotionEvent with
1308          * the action
1309          * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for
1310          * touches that occur outside of your window.  Note that you will not
1311          * receive the full down/move/up gesture, only the location of the
1312          * first down as an ACTION_OUTSIDE.
1313          */
1314         public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000;
1315 
1316         /** Window flag: special flag to let windows be shown when the screen
1317          * is locked. This will let application windows take precedence over
1318          * key guard or any other lock screens. Can be used with
1319          * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows
1320          * directly before showing the key guard window.  Can be used with
1321          * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss
1322          * non-secure keyguards.  This flag only applies to the top-most
1323          * full-screen window.
1324          * @deprecated Use {@link android.R.attr#showWhenLocked} or
1325          * {@link android.app.Activity#setShowWhenLocked(boolean)} instead to prevent an
1326          * unintentional double life-cycle event.
1327          */
1328         @Deprecated
1329         public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000;
1330 
1331         /** Window flag: ask that the system wallpaper be shown behind
1332          * your window.  The window surface must be translucent to be able
1333          * to actually see the wallpaper behind it; this flag just ensures
1334          * that the wallpaper surface will be there if this window actually
1335          * has translucent regions.
1336          *
1337          * <p>This flag can be controlled in your theme through the
1338          * {@link android.R.attr#windowShowWallpaper} attribute; this attribute
1339          * is automatically set for you in the standard wallpaper themes
1340          * such as {@link android.R.style#Theme_Wallpaper},
1341          * {@link android.R.style#Theme_Wallpaper_NoTitleBar},
1342          * {@link android.R.style#Theme_Wallpaper_NoTitleBar_Fullscreen},
1343          * {@link android.R.style#Theme_Holo_Wallpaper},
1344          * {@link android.R.style#Theme_Holo_Wallpaper_NoTitleBar},
1345          * {@link android.R.style#Theme_DeviceDefault_Wallpaper}, and
1346          * {@link android.R.style#Theme_DeviceDefault_Wallpaper_NoTitleBar}.</p>
1347          */
1348         public static final int FLAG_SHOW_WALLPAPER = 0x00100000;
1349 
1350         /** Window flag: when set as a window is being added or made
1351          * visible, once the window has been shown then the system will
1352          * poke the power manager's user activity (as if the user had woken
1353          * up the device) to turn the screen on.
1354          * @deprecated Use {@link android.R.attr#turnScreenOn} or
1355          * {@link android.app.Activity#setTurnScreenOn(boolean)} instead to prevent an
1356          * unintentional double life-cycle event.
1357          */
1358         @Deprecated
1359         public static final int FLAG_TURN_SCREEN_ON = 0x00200000;
1360 
1361         /**
1362          * Window flag: when set the window will cause the keyguard to be
1363          * dismissed, only if it is not a secure lock keyguard. Because such a
1364          * keyguard is not needed for security, it will never re-appear if the
1365          * user navigates to another window (in contrast to
1366          * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily hide both
1367          * secure and non-secure keyguards but ensure they reappear when the
1368          * user moves to another UI that doesn't hide them). If the keyguard is
1369          * currently active and is secure (requires an unlock credential) than
1370          * the user will still need to confirm it before seeing this window,
1371          * unless {@link #FLAG_SHOW_WHEN_LOCKED} has also been set.
1372          *
1373          * @deprecated Use {@link #FLAG_SHOW_WHEN_LOCKED} or
1374          *             {@link KeyguardManager#requestDismissKeyguard} instead.
1375          *             Since keyguard was dismissed all the time as long as an
1376          *             activity with this flag on its window was focused,
1377          *             keyguard couldn't guard against unintentional touches on
1378          *             the screen, which isn't desired.
1379          */
1380         @Deprecated
1381         public static final int FLAG_DISMISS_KEYGUARD = 0x00400000;
1382 
1383         /** Window flag: when set the window will accept for touch events
1384          * outside of its bounds to be sent to other windows that also
1385          * support split touch.  When this flag is not set, the first pointer
1386          * that goes down determines the window to which all subsequent touches
1387          * go until all pointers go up.  When this flag is set, each pointer
1388          * (not necessarily the first) that goes down determines the window
1389          * to which all subsequent touches of that pointer will go until that
1390          * pointer goes up thereby enabling touches with multiple pointers
1391          * to be split across multiple windows.
1392          */
1393         public static final int FLAG_SPLIT_TOUCH = 0x00800000;
1394 
1395         /**
1396          * <p>Indicates whether this window should be hardware accelerated.
1397          * Requesting hardware acceleration does not guarantee it will happen.</p>
1398          *
1399          * <p>This flag can be controlled programmatically <em>only</em> to enable
1400          * hardware acceleration. To enable hardware acceleration for a given
1401          * window programmatically, do the following:</p>
1402          *
1403          * <pre>
1404          * Window w = activity.getWindow(); // in Activity's onCreate() for instance
1405          * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
1406          *         WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
1407          * </pre>
1408          *
1409          * <p>It is important to remember that this flag <strong>must</strong>
1410          * be set before setting the content view of your activity or dialog.</p>
1411          *
1412          * <p>This flag cannot be used to disable hardware acceleration after it
1413          * was enabled in your manifest using
1414          * {@link android.R.attr#hardwareAccelerated}. If you need to selectively
1415          * and programmatically disable hardware acceleration (for automated testing
1416          * for instance), make sure it is turned off in your manifest and enable it
1417          * on your activity or dialog when you need it instead, using the method
1418          * described above.</p>
1419          *
1420          * <p>This flag is automatically set by the system if the
1421          * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated}
1422          * XML attribute is set to true on an activity or on the application.</p>
1423          */
1424         public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000;
1425 
1426         /**
1427          * Window flag: allow window contents to extend in to the screen's
1428          * overscan area, if there is one.  The window should still correctly
1429          * position its contents to take the overscan area into account.
1430          *
1431          * <p>This flag can be controlled in your theme through the
1432          * {@link android.R.attr#windowOverscan} attribute; this attribute
1433          * is automatically set for you in the standard overscan themes
1434          * such as
1435          * {@link android.R.style#Theme_Holo_NoActionBar_Overscan},
1436          * {@link android.R.style#Theme_Holo_Light_NoActionBar_Overscan},
1437          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Overscan}, and
1438          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Overscan}.</p>
1439          *
1440          * <p>When this flag is enabled for a window, its normal content may be obscured
1441          * to some degree by the overscan region of the display.  To ensure key parts of
1442          * that content are visible to the user, you can use
1443          * {@link View#setFitsSystemWindows(boolean) View.setFitsSystemWindows(boolean)}
1444          * to set the point in the view hierarchy where the appropriate offsets should
1445          * be applied.  (This can be done either by directly calling this function, using
1446          * the {@link android.R.attr#fitsSystemWindows} attribute in your view hierarchy,
1447          * or implementing you own {@link View#fitSystemWindows(android.graphics.Rect)
1448          * View.fitSystemWindows(Rect)} method).</p>
1449          *
1450          * <p>This mechanism for positioning content elements is identical to its equivalent
1451          * use with layout and {@link View#setSystemUiVisibility(int)
1452          * View.setSystemUiVisibility(int)}; here is an example layout that will correctly
1453          * position its UI elements with this overscan flag is set:</p>
1454          *
1455          * {@sample development/samples/ApiDemos/res/layout/overscan_activity.xml complete}
1456          */
1457         public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000;
1458 
1459         /**
1460          * Window flag: request a translucent status bar with minimal system-provided
1461          * background protection.
1462          *
1463          * <p>This flag can be controlled in your theme through the
1464          * {@link android.R.attr#windowTranslucentStatus} attribute; this attribute
1465          * is automatically set for you in the standard translucent decor themes
1466          * such as
1467          * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor},
1468          * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor},
1469          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and
1470          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p>
1471          *
1472          * <p>When this flag is enabled for a window, it automatically sets
1473          * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
1474          * {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p>
1475          *
1476          * <p>Note: For devices that support
1477          * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE} this flag may be ignored.
1478          */
1479         public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000;
1480 
1481         /**
1482          * Window flag: request a translucent navigation bar with minimal system-provided
1483          * background protection.
1484          *
1485          * <p>This flag can be controlled in your theme through the
1486          * {@link android.R.attr#windowTranslucentNavigation} attribute; this attribute
1487          * is automatically set for you in the standard translucent decor themes
1488          * such as
1489          * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor},
1490          * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor},
1491          * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and
1492          * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p>
1493          *
1494          * <p>When this flag is enabled for a window, it automatically sets
1495          * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and
1496          * {@link View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.</p>
1497          *
1498          * <p>Note: For devices that support
1499          * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE} this flag can be disabled
1500          * by the car manufacturers.
1501          */
1502         public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000;
1503 
1504         /**
1505          * Flag for a window in local focus mode.
1506          * Window in local focus mode can control focus independent of window manager using
1507          * {@link Window#setLocalFocus(boolean, boolean)}.
1508          * Usually window in this mode will not get touch/key events from window manager, but will
1509          * get events only via local injection using {@link Window#injectInputEvent(InputEvent)}.
1510          */
1511         public static final int FLAG_LOCAL_FOCUS_MODE = 0x10000000;
1512 
1513         /** Window flag: Enable touches to slide out of a window into neighboring
1514          * windows in mid-gesture instead of being captured for the duration of
1515          * the gesture.
1516          *
1517          * This flag changes the behavior of touch focus for this window only.
1518          * Touches can slide out of the window but they cannot necessarily slide
1519          * back in (unless the other window with touch focus permits it).
1520          *
1521          * {@hide}
1522          */
1523         @UnsupportedAppUsage
1524         public static final int FLAG_SLIPPERY = 0x20000000;
1525 
1526         /**
1527          * Window flag: When requesting layout with an attached window, the attached window may
1528          * overlap with the screen decorations of the parent window such as the navigation bar. By
1529          * including this flag, the window manager will layout the attached window within the decor
1530          * frame of the parent window such that it doesn't overlap with screen decorations.
1531          */
1532         public static final int FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000;
1533 
1534         /**
1535          * Flag indicating that this Window is responsible for drawing the background for the
1536          * system bars. If set, the system bars are drawn with a transparent background and the
1537          * corresponding areas in this window are filled with the colors specified in
1538          * {@link Window#getStatusBarColor()} and {@link Window#getNavigationBarColor()}.
1539          */
1540         public static final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000;
1541 
1542         /**
1543          * Various behavioral options/flags.  Default is none.
1544          *
1545          * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
1546          * @see #FLAG_DIM_BEHIND
1547          * @see #FLAG_NOT_FOCUSABLE
1548          * @see #FLAG_NOT_TOUCHABLE
1549          * @see #FLAG_NOT_TOUCH_MODAL
1550          * @see #FLAG_TOUCHABLE_WHEN_WAKING
1551          * @see #FLAG_KEEP_SCREEN_ON
1552          * @see #FLAG_LAYOUT_IN_SCREEN
1553          * @see #FLAG_LAYOUT_NO_LIMITS
1554          * @see #FLAG_FULLSCREEN
1555          * @see #FLAG_FORCE_NOT_FULLSCREEN
1556          * @see #FLAG_SECURE
1557          * @see #FLAG_SCALED
1558          * @see #FLAG_IGNORE_CHEEK_PRESSES
1559          * @see #FLAG_LAYOUT_INSET_DECOR
1560          * @see #FLAG_ALT_FOCUSABLE_IM
1561          * @see #FLAG_WATCH_OUTSIDE_TOUCH
1562          * @see #FLAG_SHOW_WHEN_LOCKED
1563          * @see #FLAG_SHOW_WALLPAPER
1564          * @see #FLAG_TURN_SCREEN_ON
1565          * @see #FLAG_DISMISS_KEYGUARD
1566          * @see #FLAG_SPLIT_TOUCH
1567          * @see #FLAG_HARDWARE_ACCELERATED
1568          * @see #FLAG_LOCAL_FOCUS_MODE
1569          * @see #FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS
1570          */
1571         @ViewDebug.ExportedProperty(flagMapping = {
1572             @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON,
1573                     name = "ALLOW_LOCK_WHILE_SCREEN_ON"),
1574             @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND,
1575                     name = "DIM_BEHIND"),
1576             @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND,
1577                     name = "BLUR_BEHIND"),
1578             @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE,
1579                     name = "NOT_FOCUSABLE"),
1580             @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE,
1581                     name = "NOT_TOUCHABLE"),
1582             @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL,
1583                     name = "NOT_TOUCH_MODAL"),
1584             @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING,
1585                     name = "TOUCHABLE_WHEN_WAKING"),
1586             @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON,
1587                     name = "KEEP_SCREEN_ON"),
1588             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN,
1589                     name = "LAYOUT_IN_SCREEN"),
1590             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS,
1591                     name = "LAYOUT_NO_LIMITS"),
1592             @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN,
1593                     name = "FULLSCREEN"),
1594             @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN,
1595                     name = "FORCE_NOT_FULLSCREEN"),
1596             @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER,
1597                     name = "DITHER"),
1598             @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE,
1599                     name = "SECURE"),
1600             @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED,
1601                     name = "SCALED"),
1602             @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES,
1603                     name = "IGNORE_CHEEK_PRESSES"),
1604             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR,
1605                     name = "LAYOUT_INSET_DECOR"),
1606             @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM,
1607                     name = "ALT_FOCUSABLE_IM"),
1608             @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH,
1609                     name = "WATCH_OUTSIDE_TOUCH"),
1610             @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED,
1611                     name = "SHOW_WHEN_LOCKED"),
1612             @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER,
1613                     name = "SHOW_WALLPAPER"),
1614             @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON,
1615                     name = "TURN_SCREEN_ON"),
1616             @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD,
1617                     name = "DISMISS_KEYGUARD"),
1618             @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH,
1619                     name = "SPLIT_TOUCH"),
1620             @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED,
1621                     name = "HARDWARE_ACCELERATED"),
1622             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_OVERSCAN, equals = FLAG_LAYOUT_IN_OVERSCAN,
1623                     name = "LOCAL_FOCUS_MODE"),
1624             @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_STATUS, equals = FLAG_TRANSLUCENT_STATUS,
1625                     name = "TRANSLUCENT_STATUS"),
1626             @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_NAVIGATION, equals = FLAG_TRANSLUCENT_NAVIGATION,
1627                     name = "TRANSLUCENT_NAVIGATION"),
1628             @ViewDebug.FlagToString(mask = FLAG_LOCAL_FOCUS_MODE, equals = FLAG_LOCAL_FOCUS_MODE,
1629                     name = "LOCAL_FOCUS_MODE"),
1630             @ViewDebug.FlagToString(mask = FLAG_SLIPPERY, equals = FLAG_SLIPPERY,
1631                     name = "FLAG_SLIPPERY"),
1632             @ViewDebug.FlagToString(mask = FLAG_LAYOUT_ATTACHED_IN_DECOR, equals = FLAG_LAYOUT_ATTACHED_IN_DECOR,
1633                     name = "FLAG_LAYOUT_ATTACHED_IN_DECOR"),
1634             @ViewDebug.FlagToString(mask = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, equals = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
1635                     name = "DRAWS_SYSTEM_BAR_BACKGROUNDS")
1636         }, formatToHexString = true)
1637         public int flags;
1638 
1639         /**
1640          * If the window has requested hardware acceleration, but this is not
1641          * allowed in the process it is in, then still render it as if it is
1642          * hardware accelerated.  This is used for the starting preview windows
1643          * in the system process, which don't need to have the overhead of
1644          * hardware acceleration (they are just a static rendering), but should
1645          * be rendered as such to match the actual window of the app even if it
1646          * is hardware accelerated.
1647          * Even if the window isn't hardware accelerated, still do its rendering
1648          * as if it was.
1649          * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows
1650          * that need hardware acceleration (e.g. LockScreen), where hardware acceleration
1651          * is generally disabled. This flag must be specified in addition to
1652          * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system
1653          * windows.
1654          *
1655          * @hide
1656          */
1657         public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001;
1658 
1659         /**
1660          * In the system process, we globally do not use hardware acceleration
1661          * because there are many threads doing UI there and they conflict.
1662          * If certain parts of the UI that really do want to use hardware
1663          * acceleration, this flag can be set to force it.  This is basically
1664          * for the lock screen.  Anyone else using it, you are probably wrong.
1665          *
1666          * @hide
1667          */
1668         public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002;
1669 
1670         /**
1671          * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers
1672          * may elect to skip these notifications if they are not doing anything productive with
1673          * them (they do not affect the wallpaper scrolling operation) by calling
1674          * {@link
1675          * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}.
1676          *
1677          * @hide
1678          */
1679         public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004;
1680 
1681         /** In a multiuser system if this flag is set and the owner is a system process then this
1682          * window will appear on all user screens. This overrides the default behavior of window
1683          * types that normally only appear on the owning user's screen. Refer to each window type
1684          * to determine its default behavior.
1685          *
1686          * {@hide} */
1687         @UnsupportedAppUsage
1688         public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010;
1689 
1690         /**
1691          * Never animate position changes of the window.
1692          *
1693          * {@hide}
1694          */
1695         @UnsupportedAppUsage
1696         @TestApi
1697         public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 0x00000040;
1698 
1699         /** Window flag: special flag to limit the size of the window to be
1700          * original size ([320x480] x density). Used to create window for applications
1701          * running under compatibility mode.
1702          *
1703          * {@hide} */
1704         public static final int PRIVATE_FLAG_COMPATIBLE_WINDOW = 0x00000080;
1705 
1706         /** Window flag: a special option intended for system dialogs.  When
1707          * this flag is set, the window will demand focus unconditionally when
1708          * it is created.
1709          * {@hide} */
1710         public static final int PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100;
1711 
1712         /** Window flag: maintain the previous translucent decor state when this window
1713          * becomes top-most.
1714          * {@hide} */
1715         public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200;
1716 
1717         /**
1718          * Flag whether the current window is a keyguard window, meaning that it will hide all other
1719          * windows behind it except for windows with flag {@link #FLAG_SHOW_WHEN_LOCKED} set.
1720          * Further, this can only be set by {@link LayoutParams#TYPE_STATUS_BAR}.
1721          * {@hide}
1722          */
1723         public static final int PRIVATE_FLAG_KEYGUARD = 0x00000400;
1724 
1725         /**
1726          * Flag that prevents the wallpaper behind the current window from receiving touch events.
1727          *
1728          * {@hide}
1729          */
1730         public static final int PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS = 0x00000800;
1731 
1732         /**
1733          * Flag to force the status bar window to be visible all the time. If the bar is hidden when
1734          * this flag is set it will be shown again and the bar will have a transparent background.
1735          * This can only be set by {@link LayoutParams#TYPE_STATUS_BAR}.
1736          *
1737          * {@hide}
1738          */
1739         public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000;
1740 
1741         /**
1742          * Flag indicating that the x, y, width, and height members should be
1743          * ignored (and thus their previous value preserved). For example
1744          * because they are being managed externally through repositionChild.
1745          *
1746          * {@hide}
1747          */
1748         public static final int PRIVATE_FLAG_PRESERVE_GEOMETRY = 0x00002000;
1749 
1750         /**
1751          * Flag that will make window ignore app visibility and instead depend purely on the decor
1752          * view visibility for determining window visibility. This is used by recents to keep
1753          * drawing after it launches an app.
1754          * @hide
1755          */
1756         public static final int PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY = 0x00004000;
1757 
1758         /**
1759          * Flag to indicate that this window is not expected to be replaced across
1760          * configuration change triggered activity relaunches. In general the WindowManager
1761          * expects Windows to be replaced after relaunch, and thus it will preserve their surfaces
1762          * until the replacement is ready to show in order to prevent visual glitch. However
1763          * some windows, such as PopupWindows expect to be cleared across configuration change,
1764          * and thus should hint to the WindowManager that it should not wait for a replacement.
1765          * @hide
1766          */
1767         public static final int PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH = 0x00008000;
1768 
1769         /**
1770          * Flag to indicate that this child window should always be laid-out in the parent
1771          * frame regardless of the current windowing mode configuration.
1772          * @hide
1773          */
1774         public static final int PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME = 0x00010000;
1775 
1776         /**
1777          * Flag to indicate that this window is always drawing the status bar background, no matter
1778          * what the other flags are.
1779          * @hide
1780          */
1781         public static final int PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS = 0x00020000;
1782 
1783         /**
1784          * Flag to indicate that this window needs Sustained Performance Mode if
1785          * the device supports it.
1786          * @hide
1787          */
1788         public static final int PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE = 0x00040000;
1789 
1790         /**
1791          * Flag to indicate that any window added by an application process that is of type
1792          * {@link #TYPE_TOAST} or that requires
1793          * {@link android.app.AppOpsManager#OP_SYSTEM_ALERT_WINDOW} permission should be hidden when
1794          * this window is visible.
1795          * @hide
1796          */
1797         @SystemApi
1798         @RequiresPermission(permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS)
1799         public static final int SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 0x00080000;
1800 
1801         /**
1802          * Indicates that this window is the rounded corners overlay present on some
1803          * devices this means that it will be excluded from: screenshots,
1804          * screen magnification, and mirroring.
1805          * @hide
1806          */
1807         public static final int PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY = 0x00100000;
1808 
1809         /**
1810          * Flag to indicate that this window should be considered a screen decoration similar to the
1811          * nav bar and status bar. This will cause this window to affect the window insets reported
1812          * to other windows when it is visible.
1813          * @hide
1814          */
1815         @RequiresPermission(permission.STATUS_BAR_SERVICE)
1816         public static final int PRIVATE_FLAG_IS_SCREEN_DECOR = 0x00400000;
1817 
1818         /**
1819          * Flag to indicate that the status bar window is in a state such that it forces showing
1820          * the navigation bar unless the navigation bar window is explicitly set to
1821          * {@link View#GONE}.
1822          * It only takes effects if this is set by {@link LayoutParams#TYPE_STATUS_BAR}.
1823          * @hide
1824          */
1825         public static final int PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION = 0x00800000;
1826 
1827         /**
1828          * Flag to indicate that the window is color space agnostic, and the color can be
1829          * interpreted to any color space.
1830          * @hide
1831          */
1832         public static final int PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC = 0x01000000;
1833 
1834         /**
1835          * An internal annotation for flags that can be specified to {@link #softInputMode}.
1836          *
1837          * @hide
1838          */
1839         @SystemApi
1840         @Retention(RetentionPolicy.SOURCE)
1841         @IntDef(flag = true, prefix = { "SYSTEM_FLAG_" }, value = {
1842                 SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS,
1843         })
1844         public @interface SystemFlags {}
1845 
1846         /**
1847          * Control flags that are private to the platform.
1848          * @hide
1849          */
1850         @ViewDebug.ExportedProperty(flagMapping = {
1851                 @ViewDebug.FlagToString(
1852                         mask = PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED,
1853                         equals = PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED,
1854                         name = "FAKE_HARDWARE_ACCELERATED"),
1855                 @ViewDebug.FlagToString(
1856                         mask = PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED,
1857                         equals = PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED,
1858                         name = "FORCE_HARDWARE_ACCELERATED"),
1859                 @ViewDebug.FlagToString(
1860                         mask = PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS,
1861                         equals = PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS,
1862                         name = "WANTS_OFFSET_NOTIFICATIONS"),
1863                 @ViewDebug.FlagToString(
1864                         mask = PRIVATE_FLAG_SHOW_FOR_ALL_USERS,
1865                         equals = PRIVATE_FLAG_SHOW_FOR_ALL_USERS,
1866                         name = "SHOW_FOR_ALL_USERS"),
1867                 @ViewDebug.FlagToString(
1868                         mask = PRIVATE_FLAG_NO_MOVE_ANIMATION,
1869                         equals = PRIVATE_FLAG_NO_MOVE_ANIMATION,
1870                         name = "NO_MOVE_ANIMATION"),
1871                 @ViewDebug.FlagToString(
1872                         mask = PRIVATE_FLAG_COMPATIBLE_WINDOW,
1873                         equals = PRIVATE_FLAG_COMPATIBLE_WINDOW,
1874                         name = "COMPATIBLE_WINDOW"),
1875                 @ViewDebug.FlagToString(
1876                         mask = PRIVATE_FLAG_SYSTEM_ERROR,
1877                         equals = PRIVATE_FLAG_SYSTEM_ERROR,
1878                         name = "SYSTEM_ERROR"),
1879                 @ViewDebug.FlagToString(
1880                         mask = PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR,
1881                         equals = PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR,
1882                         name = "INHERIT_TRANSLUCENT_DECOR"),
1883                 @ViewDebug.FlagToString(
1884                         mask = PRIVATE_FLAG_KEYGUARD,
1885                         equals = PRIVATE_FLAG_KEYGUARD,
1886                         name = "KEYGUARD"),
1887                 @ViewDebug.FlagToString(
1888                         mask = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS,
1889                         equals = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS,
1890                         name = "DISABLE_WALLPAPER_TOUCH_EVENTS"),
1891                 @ViewDebug.FlagToString(
1892                         mask = PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT,
1893                         equals = PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT,
1894                         name = "FORCE_STATUS_BAR_VISIBLE_TRANSPARENT"),
1895                 @ViewDebug.FlagToString(
1896                         mask = PRIVATE_FLAG_PRESERVE_GEOMETRY,
1897                         equals = PRIVATE_FLAG_PRESERVE_GEOMETRY,
1898                         name = "PRESERVE_GEOMETRY"),
1899                 @ViewDebug.FlagToString(
1900                         mask = PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY,
1901                         equals = PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY,
1902                         name = "FORCE_DECOR_VIEW_VISIBILITY"),
1903                 @ViewDebug.FlagToString(
1904                         mask = PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH,
1905                         equals = PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH,
1906                         name = "WILL_NOT_REPLACE_ON_RELAUNCH"),
1907                 @ViewDebug.FlagToString(
1908                         mask = PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME,
1909                         equals = PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME,
1910                         name = "LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME"),
1911                 @ViewDebug.FlagToString(
1912                         mask = PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS,
1913                         equals = PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS,
1914                         name = "FORCE_DRAW_STATUS_BAR_BACKGROUND"),
1915                 @ViewDebug.FlagToString(
1916                         mask = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE,
1917                         equals = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE,
1918                         name = "SUSTAINED_PERFORMANCE_MODE"),
1919                 @ViewDebug.FlagToString(
1920                         mask = SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS,
1921                         equals = SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS,
1922                         name = "HIDE_NON_SYSTEM_OVERLAY_WINDOWS"),
1923                 @ViewDebug.FlagToString(
1924                         mask = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY,
1925                         equals = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY,
1926                         name = "IS_ROUNDED_CORNERS_OVERLAY"),
1927                 @ViewDebug.FlagToString(
1928                         mask = PRIVATE_FLAG_IS_SCREEN_DECOR,
1929                         equals = PRIVATE_FLAG_IS_SCREEN_DECOR,
1930                         name = "IS_SCREEN_DECOR"),
1931                 @ViewDebug.FlagToString(
1932                         mask = PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION,
1933                         equals = PRIVATE_FLAG_STATUS_FORCE_SHOW_NAVIGATION,
1934                         name = "STATUS_FORCE_SHOW_NAVIGATION"),
1935                 @ViewDebug.FlagToString(
1936                         mask = PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
1937                         equals = PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC,
1938                         name = "COLOR_SPACE_AGNOSTIC")
1939         })
1940         @UnsupportedAppUsage
1941         @TestApi
1942         public int privateFlags;
1943 
1944         /**
1945          * Value for {@link #needsMenuKey} for a window that has not explicitly specified if it
1946          * needs {@link #NEEDS_MENU_SET_TRUE} or doesn't need {@link #NEEDS_MENU_SET_FALSE} a menu
1947          * key. For this case, we should look at windows behind it to determine the appropriate
1948          * value.
1949          *
1950          * @hide
1951          */
1952         public static final int NEEDS_MENU_UNSET = 0;
1953 
1954         /**
1955          * Value for {@link #needsMenuKey} for a window that has explicitly specified it needs a
1956          * menu key.
1957          *
1958          * @hide
1959          */
1960         @UnsupportedAppUsage
1961         public static final int NEEDS_MENU_SET_TRUE = 1;
1962 
1963         /**
1964          * Value for {@link #needsMenuKey} for a window that has explicitly specified it doesn't
1965          * needs a menu key.
1966          *
1967          * @hide
1968          */
1969         @UnsupportedAppUsage
1970         public static final int NEEDS_MENU_SET_FALSE = 2;
1971 
1972         /**
1973          * State variable for a window belonging to an activity that responds to
1974          * {@link KeyEvent#KEYCODE_MENU} and therefore needs a Menu key. For devices where Menu is a
1975          * physical button this variable is ignored, but on devices where the Menu key is drawn in
1976          * software it may be hidden unless this variable is set to {@link #NEEDS_MENU_SET_TRUE}.
1977          *
1978          *  (Note that Action Bars, when available, are the preferred way to offer additional
1979          * functions otherwise accessed via an options menu.)
1980          *
1981          * {@hide}
1982          */
1983         @UnsupportedAppUsage
1984         public int needsMenuKey = NEEDS_MENU_UNSET;
1985 
1986         /**
1987          * Given a particular set of window manager flags, determine whether
1988          * such a window may be a target for an input method when it has
1989          * focus.  In particular, this checks the
1990          * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM}
1991          * flags and returns true if the combination of the two corresponds
1992          * to a window that needs to be behind the input method so that the
1993          * user can type into it.
1994          *
1995          * @param flags The current window manager flags.
1996          *
1997          * @return Returns true if such a window should be behind/interact
1998          * with an input method, false if not.
1999          */
mayUseInputMethod(int flags)2000         public static boolean mayUseInputMethod(int flags) {
2001             switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) {
2002                 case 0:
2003                 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM:
2004                     return true;
2005             }
2006             return false;
2007         }
2008 
2009         /**
2010          * Mask for {@link #softInputMode} of the bits that determine the
2011          * desired visibility state of the soft input area for this window.
2012          */
2013         public static final int SOFT_INPUT_MASK_STATE = 0x0f;
2014 
2015         /**
2016          * Visibility state for {@link #softInputMode}: no state has been specified. The system may
2017          * show or hide the software keyboard for better user experience when the window gains
2018          * focus.
2019          */
2020         public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0;
2021 
2022         /**
2023          * Visibility state for {@link #softInputMode}: please don't change the state of
2024          * the soft input area.
2025          */
2026         public static final int SOFT_INPUT_STATE_UNCHANGED = 1;
2027 
2028         /**
2029          * Visibility state for {@link #softInputMode}: please hide any soft input
2030          * area when normally appropriate (when the user is navigating
2031          * forward to your window).
2032          */
2033         public static final int SOFT_INPUT_STATE_HIDDEN = 2;
2034 
2035         /**
2036          * Visibility state for {@link #softInputMode}: please always hide any
2037          * soft input area when this window receives focus.
2038          */
2039         public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3;
2040 
2041         /**
2042          * Visibility state for {@link #softInputMode}: please show the soft
2043          * input area when normally appropriate (when the user is navigating
2044          * forward to your window).
2045          *
2046          * <p>Applications that target {@link android.os.Build.VERSION_CODES#P} and later, this flag
2047          * is ignored unless there is a focused view that returns {@code true} from
2048          * {@link View#isInEditMode()} when the window is focused.</p>
2049          */
2050         public static final int SOFT_INPUT_STATE_VISIBLE = 4;
2051 
2052         /**
2053          * Visibility state for {@link #softInputMode}: please always make the
2054          * soft input area visible when this window receives input focus.
2055          *
2056          * <p>Applications that target {@link android.os.Build.VERSION_CODES#P} and later, this flag
2057          * is ignored unless there is a focused view that returns {@code true} from
2058          * {@link View#isInEditMode()} when the window is focused.</p>
2059          */
2060         public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5;
2061 
2062         /**
2063          * Mask for {@link #softInputMode} of the bits that determine the
2064          * way that the window should be adjusted to accommodate the soft
2065          * input window.
2066          */
2067         public static final int SOFT_INPUT_MASK_ADJUST = 0xf0;
2068 
2069         /** Adjustment option for {@link #softInputMode}: nothing specified.
2070          * The system will try to pick one or
2071          * the other depending on the contents of the window.
2072          */
2073         public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00;
2074 
2075         /** Adjustment option for {@link #softInputMode}: set to allow the
2076          * window to be resized when an input
2077          * method is shown, so that its contents are not covered by the input
2078          * method.  This can <em>not</em> be combined with
2079          * {@link #SOFT_INPUT_ADJUST_PAN}; if
2080          * neither of these are set, then the system will try to pick one or
2081          * the other depending on the contents of the window. If the window's
2082          * layout parameter flags include {@link #FLAG_FULLSCREEN}, this
2083          * value for {@link #softInputMode} will be ignored; the window will
2084          * not resize, but will stay fullscreen.
2085          */
2086         public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10;
2087 
2088         /** Adjustment option for {@link #softInputMode}: set to have a window
2089          * pan when an input method is
2090          * shown, so it doesn't need to deal with resizing but just panned
2091          * by the framework to ensure the current input focus is visible.  This
2092          * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if
2093          * neither of these are set, then the system will try to pick one or
2094          * the other depending on the contents of the window.
2095          */
2096         public static final int SOFT_INPUT_ADJUST_PAN = 0x20;
2097 
2098         /** Adjustment option for {@link #softInputMode}: set to have a window
2099          * not adjust for a shown input method.  The window will not be resized,
2100          * and it will not be panned to make its focus visible.
2101          */
2102         public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30;
2103 
2104         /**
2105          * Bit for {@link #softInputMode}: set when the user has navigated
2106          * forward to the window.  This is normally set automatically for
2107          * you by the system, though you may want to set it in certain cases
2108          * when you are displaying a window yourself.  This flag will always
2109          * be cleared automatically after the window is displayed.
2110          */
2111         public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100;
2112 
2113         /**
2114          * An internal annotation for flags that can be specified to {@link #softInputMode}.
2115          *
2116          * @hide
2117          */
2118         @Retention(RetentionPolicy.SOURCE)
2119         @IntDef(flag = true, prefix = { "SOFT_INPUT_" }, value = {
2120                 SOFT_INPUT_STATE_UNSPECIFIED,
2121                 SOFT_INPUT_STATE_UNCHANGED,
2122                 SOFT_INPUT_STATE_HIDDEN,
2123                 SOFT_INPUT_STATE_ALWAYS_HIDDEN,
2124                 SOFT_INPUT_STATE_VISIBLE,
2125                 SOFT_INPUT_STATE_ALWAYS_VISIBLE,
2126                 SOFT_INPUT_ADJUST_UNSPECIFIED,
2127                 SOFT_INPUT_ADJUST_RESIZE,
2128                 SOFT_INPUT_ADJUST_PAN,
2129                 SOFT_INPUT_ADJUST_NOTHING,
2130                 SOFT_INPUT_IS_FORWARD_NAVIGATION,
2131         })
2132         public @interface SoftInputModeFlags {}
2133 
2134         /**
2135          * Desired operating mode for any soft input area.  May be any combination
2136          * of:
2137          *
2138          * <ul>
2139          * <li> One of the visibility states
2140          * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED},
2141          * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_HIDDEN},
2142          * {@link #SOFT_INPUT_STATE_VISIBLE}, or {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}.
2143          * <li> One of the adjustment options
2144          * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, {@link #SOFT_INPUT_ADJUST_RESIZE},
2145          * {@link #SOFT_INPUT_ADJUST_PAN}, or {@link #SOFT_INPUT_ADJUST_NOTHING}.
2146          * </ul>
2147          *
2148          *
2149          * <p>This flag can be controlled in your theme through the
2150          * {@link android.R.attr#windowSoftInputMode} attribute.</p>
2151          */
2152         @SoftInputModeFlags
2153         public int softInputMode;
2154 
2155         /**
2156          * Placement of window within the screen as per {@link Gravity}.  Both
2157          * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
2158          * android.graphics.Rect) Gravity.apply} and
2159          * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
2160          * Gravity.applyDisplay} are used during window layout, with this value
2161          * given as the desired gravity.  For example you can specify
2162          * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and
2163          * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here
2164          * to control the behavior of
2165          * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect)
2166          * Gravity.applyDisplay}.
2167          *
2168          * @see Gravity
2169          */
2170         public int gravity;
2171 
2172         /**
2173          * The horizontal margin, as a percentage of the container's width,
2174          * between the container and the widget.  See
2175          * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
2176          * android.graphics.Rect) Gravity.apply} for how this is used.  This
2177          * field is added with {@link #x} to supply the <var>xAdj</var> parameter.
2178          */
2179         public float horizontalMargin;
2180 
2181         /**
2182          * The vertical margin, as a percentage of the container's height,
2183          * between the container and the widget.  See
2184          * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int,
2185          * android.graphics.Rect) Gravity.apply} for how this is used.  This
2186          * field is added with {@link #y} to supply the <var>yAdj</var> parameter.
2187          */
2188         public float verticalMargin;
2189 
2190         /**
2191          * Positive insets between the drawing surface and window content.
2192          *
2193          * @hide
2194          */
2195         public final Rect surfaceInsets = new Rect();
2196 
2197         /**
2198          * Whether the surface insets have been manually set. When set to
2199          * {@code false}, the view root will automatically determine the
2200          * appropriate surface insets.
2201          *
2202          * @see #surfaceInsets
2203          * @hide
2204          */
2205         public boolean hasManualSurfaceInsets;
2206 
2207         /**
2208          * Whether the previous surface insets should be used vs. what is currently set. When set
2209          * to {@code true}, the view root will ignore surfaces insets in this object and use what
2210          * it currently has.
2211          *
2212          * @see #surfaceInsets
2213          * @hide
2214          */
2215         public boolean preservePreviousSurfaceInsets = true;
2216 
2217         /**
2218          * The desired bitmap format.  May be one of the constants in
2219          * {@link android.graphics.PixelFormat}. The choice of format
2220          * might be overridden by {@link #setColorMode(int)}. Default is OPAQUE.
2221          */
2222         public int format;
2223 
2224         /**
2225          * A style resource defining the animations to use for this window.
2226          * This must be a system resource; it can not be an application resource
2227          * because the window manager does not have access to applications.
2228          */
2229         public int windowAnimations;
2230 
2231         /**
2232          * An alpha value to apply to this entire window.
2233          * An alpha of 1.0 means fully opaque and 0.0 means fully transparent
2234          */
2235         public float alpha = 1.0f;
2236 
2237         /**
2238          * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming
2239          * to apply.  Range is from 1.0 for completely opaque to 0.0 for no
2240          * dim.
2241          */
2242         public float dimAmount = 1.0f;
2243 
2244         /**
2245          * Default value for {@link #screenBrightness} and {@link #buttonBrightness}
2246          * indicating that the brightness value is not overridden for this window
2247          * and normal brightness policy should be used.
2248          */
2249         public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f;
2250 
2251         /**
2252          * Value for {@link #screenBrightness} and {@link #buttonBrightness}
2253          * indicating that the screen or button backlight brightness should be set
2254          * to the lowest value when this window is in front.
2255          */
2256         public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f;
2257 
2258         /**
2259          * Value for {@link #screenBrightness} and {@link #buttonBrightness}
2260          * indicating that the screen or button backlight brightness should be set
2261          * to the hightest value when this window is in front.
2262          */
2263         public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f;
2264 
2265         /**
2266          * This can be used to override the user's preferred brightness of
2267          * the screen.  A value of less than 0, the default, means to use the
2268          * preferred screen brightness.  0 to 1 adjusts the brightness from
2269          * dark to full bright.
2270          */
2271         public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE;
2272 
2273         /**
2274          * This can be used to override the standard behavior of the button and
2275          * keyboard backlights.  A value of less than 0, the default, means to
2276          * use the standard backlight behavior.  0 to 1 adjusts the brightness
2277          * from dark to full bright.
2278          */
2279         public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE;
2280 
2281         /**
2282          * Unspecified value for {@link #rotationAnimation} indicating
2283          * a lack of preference.
2284          * @hide
2285          */
2286         public static final int ROTATION_ANIMATION_UNSPECIFIED = -1;
2287 
2288         /**
2289          * Value for {@link #rotationAnimation} which specifies that this
2290          * window will visually rotate in or out following a rotation.
2291          */
2292         public static final int ROTATION_ANIMATION_ROTATE = 0;
2293 
2294         /**
2295          * Value for {@link #rotationAnimation} which specifies that this
2296          * window will fade in or out following a rotation.
2297          */
2298         public static final int ROTATION_ANIMATION_CROSSFADE = 1;
2299 
2300         /**
2301          * Value for {@link #rotationAnimation} which specifies that this window
2302          * will immediately disappear or appear following a rotation.
2303          */
2304         public static final int ROTATION_ANIMATION_JUMPCUT = 2;
2305 
2306         /**
2307          * Value for {@link #rotationAnimation} to specify seamless rotation mode.
2308          * This works like JUMPCUT but will fall back to CROSSFADE if rotation
2309          * can't be applied without pausing the screen. For example, this is ideal
2310          * for Camera apps which don't want the viewfinder contents to ever rotate
2311          * or fade (and rather to be seamless) but also don't want ROTATION_ANIMATION_JUMPCUT
2312          * during app transition scenarios where seamless rotation can't be applied.
2313          */
2314         public static final int ROTATION_ANIMATION_SEAMLESS = 3;
2315 
2316         /**
2317          * Define the exit and entry animations used on this window when the device is rotated.
2318          * This only has an affect if the incoming and outgoing topmost
2319          * opaque windows have the #FLAG_FULLSCREEN bit set and are not covered
2320          * by other windows. All other situations default to the
2321          * {@link #ROTATION_ANIMATION_ROTATE} behavior.
2322          *
2323          * @see #ROTATION_ANIMATION_ROTATE
2324          * @see #ROTATION_ANIMATION_CROSSFADE
2325          * @see #ROTATION_ANIMATION_JUMPCUT
2326          */
2327         public int rotationAnimation = ROTATION_ANIMATION_ROTATE;
2328 
2329         /**
2330          * Identifier for this window.  This will usually be filled in for
2331          * you.
2332          */
2333         public IBinder token = null;
2334 
2335         /**
2336          * Name of the package owning this window.
2337          */
2338         public String packageName = null;
2339 
2340         /**
2341          * Specific orientation value for a window.
2342          * May be any of the same values allowed
2343          * for {@link android.content.pm.ActivityInfo#screenOrientation}.
2344          * If not set, a default value of
2345          * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}
2346          * will be used.
2347          */
2348         public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
2349 
2350         /**
2351          * The preferred refresh rate for the window.
2352          *
2353          * This must be one of the supported refresh rates obtained for the display(s) the window
2354          * is on. The selected refresh rate will be applied to the display's default mode.
2355          *
2356          * This value is ignored if {@link #preferredDisplayModeId} is set.
2357          *
2358          * @see Display#getSupportedRefreshRates()
2359          * @deprecated use {@link #preferredDisplayModeId} instead
2360          */
2361         @Deprecated
2362         public float preferredRefreshRate;
2363 
2364         /**
2365          * Id of the preferred display mode for the window.
2366          * <p>
2367          * This must be one of the supported modes obtained for the display(s) the window is on.
2368          * A value of {@code 0} means no preference.
2369          *
2370          * @see Display#getSupportedModes()
2371          * @see Display.Mode#getModeId()
2372          */
2373         public int preferredDisplayModeId;
2374 
2375         /**
2376          * Control the visibility of the status bar.
2377          *
2378          * @see View#STATUS_BAR_VISIBLE
2379          * @see View#STATUS_BAR_HIDDEN
2380          */
2381         public int systemUiVisibility;
2382 
2383         /**
2384          * @hide
2385          * The ui visibility as requested by the views in this hierarchy.
2386          * the combined value should be systemUiVisibility | subtreeSystemUiVisibility.
2387          */
2388         @UnsupportedAppUsage
2389         public int subtreeSystemUiVisibility;
2390 
2391         /**
2392          * Get callbacks about the system ui visibility changing.
2393          *
2394          * TODO: Maybe there should be a bitfield of optional callbacks that we need.
2395          *
2396          * @hide
2397          */
2398         @UnsupportedAppUsage
2399         public boolean hasSystemUiListeners;
2400 
2401 
2402         /** @hide */
2403         @Retention(RetentionPolicy.SOURCE)
2404         @IntDef(
2405                 flag = true,
2406                 value = {LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT,
2407                         LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES,
2408                         LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER})
2409         @interface LayoutInDisplayCutoutMode {}
2410 
2411         /**
2412          * Controls how the window is laid out if there is a {@link DisplayCutout}.
2413          *
2414          * <p>
2415          * Defaults to {@link #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT}.
2416          *
2417          * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT
2418          * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
2419          * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
2420          * @see DisplayCutout
2421          * @see android.R.attr#windowLayoutInDisplayCutoutMode
2422          *         android:windowLayoutInDisplayCutoutMode
2423          */
2424         @LayoutInDisplayCutoutMode
2425         public int layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT;
2426 
2427         /**
2428          * The window is allowed to extend into the {@link DisplayCutout} area, only if the
2429          * {@link DisplayCutout} is fully contained within a system bar. Otherwise, the window is
2430          * laid out such that it does not overlap with the {@link DisplayCutout} area.
2431          *
2432          * <p>
2433          * In practice, this means that if the window did not set {@link #FLAG_FULLSCREEN} or
2434          * {@link View#SYSTEM_UI_FLAG_FULLSCREEN}, it can extend into the cutout area in portrait
2435          * if the cutout is at the top edge. Similarly for
2436          * {@link View#SYSTEM_UI_FLAG_HIDE_NAVIGATION} and a cutout at the bottom of the screen.
2437          * Otherwise (i.e. fullscreen or landscape) it is laid out such that it does not overlap the
2438          * cutout area.
2439          *
2440          * <p>
2441          * The usual precautions for not overlapping with the status and navigation bar are
2442          * sufficient for ensuring that no important content overlaps with the DisplayCutout.
2443          *
2444          * @see DisplayCutout
2445          * @see WindowInsets
2446          * @see #layoutInDisplayCutoutMode
2447          * @see android.R.attr#windowLayoutInDisplayCutoutMode
2448          *         android:windowLayoutInDisplayCutoutMode
2449          */
2450         public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT = 0;
2451 
2452         /**
2453          * @deprecated use {@link #LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES}
2454          * @hide
2455          */
2456         @Deprecated
2457         public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS = 1;
2458 
2459         /**
2460          * The window is always allowed to extend into the {@link DisplayCutout} areas on the short
2461          * edges of the screen.
2462          *
2463          * The window will never extend into a {@link DisplayCutout} area on the long edges of the
2464          * screen.
2465          *
2466          * <p>
2467          * The window must make sure that no important content overlaps with the
2468          * {@link DisplayCutout}.
2469          *
2470          * <p>
2471          * In this mode, the window extends under cutouts on the short edge of the display in both
2472          * portrait and landscape, regardless of whether the window is hiding the system bars:<br/>
2473          * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/fullscreen_top_no_letterbox.png"
2474          * height="720"
2475          * alt="Screenshot of a fullscreen activity on a display with a cutout at the top edge in
2476          *         portrait, no letterbox is applied."/>
2477          *
2478          * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/landscape_top_no_letterbox.png"
2479          * width="720"
2480          * alt="Screenshot of an activity on a display with a cutout at the top edge in landscape,
2481          *         no letterbox is applied."/>
2482          *
2483          * <p>
2484          * A cutout in the corner is considered to be on the short edge: <br/>
2485          * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/fullscreen_corner_no_letterbox.png"
2486          * height="720"
2487          * alt="Screenshot of a fullscreen activity on a display with a cutout in the corner in
2488          *         portrait, no letterbox is applied."/>
2489          *
2490          * <p>
2491          * On the other hand, should the cutout be on the long edge of the display, a letterbox will
2492          * be applied such that the window does not extend into the cutout on either long edge:
2493          * <br/>
2494          * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/portrait_side_letterbox.png"
2495          * height="720"
2496          * alt="Screenshot of an activity on a display with a cutout on the long edge in portrait,
2497          *         letterbox is applied."/>
2498          *
2499          * @see DisplayCutout
2500          * @see WindowInsets#getDisplayCutout()
2501          * @see #layoutInDisplayCutoutMode
2502          * @see android.R.attr#windowLayoutInDisplayCutoutMode
2503          *         android:windowLayoutInDisplayCutoutMode
2504          */
2505         public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES = 1;
2506 
2507         /**
2508          * The window is never allowed to overlap with the DisplayCutout area.
2509          *
2510          * <p>
2511          * This should be used with windows that transiently set
2512          * {@link View#SYSTEM_UI_FLAG_FULLSCREEN} or {@link View#SYSTEM_UI_FLAG_HIDE_NAVIGATION}
2513          * to avoid a relayout of the window when the respective flag is set or cleared.
2514          *
2515          * @see DisplayCutout
2516          * @see #layoutInDisplayCutoutMode
2517          * @see android.R.attr#windowLayoutInDisplayCutoutMode
2518          *         android:windowLayoutInDisplayCutoutMode
2519          */
2520         public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER = 2;
2521 
2522 
2523         /**
2524          * When this window has focus, disable touch pad pointer gesture processing.
2525          * The window will receive raw position updates from the touch pad instead
2526          * of pointer movements and synthetic touch events.
2527          *
2528          * @hide
2529          */
2530         public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001;
2531 
2532         /**
2533          * Does not construct an input channel for this window.  The channel will therefore
2534          * be incapable of receiving input.
2535          *
2536          * @hide
2537          */
2538         public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002;
2539 
2540         /**
2541          * When this window has focus, does not call user activity for all input events so
2542          * the application will have to do it itself.  Should only be used by
2543          * the keyguard and phone app.
2544          * <p>
2545          * Should only be used by the keyguard and phone app.
2546          * </p>
2547          *
2548          * @hide
2549          */
2550         @UnsupportedAppUsage
2551         public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004;
2552 
2553         /**
2554          * Control special features of the input subsystem.
2555          *
2556          * @see #INPUT_FEATURE_DISABLE_POINTER_GESTURES
2557          * @see #INPUT_FEATURE_NO_INPUT_CHANNEL
2558          * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY
2559          * @hide
2560          */
2561         @UnsupportedAppUsage
2562         public int inputFeatures;
2563 
2564         /**
2565          * Sets the number of milliseconds before the user activity timeout occurs
2566          * when this window has focus.  A value of -1 uses the standard timeout.
2567          * A value of 0 uses the minimum support display timeout.
2568          * <p>
2569          * This property can only be used to reduce the user specified display timeout;
2570          * it can never make the timeout longer than it normally would be.
2571          * </p><p>
2572          * Should only be used by the keyguard and phone app.
2573          * </p>
2574          *
2575          * @hide
2576          */
2577         @UnsupportedAppUsage
2578         public long userActivityTimeout = -1;
2579 
2580         /**
2581          * For windows with an anchor (e.g. PopupWindow), keeps track of the View that anchors the
2582          * window.
2583          *
2584          * @hide
2585          */
2586         public long accessibilityIdOfAnchor = AccessibilityNodeInfo.UNDEFINED_NODE_ID;
2587 
2588         /**
2589          * The window title isn't kept in sync with what is displayed in the title bar, so we
2590          * separately track the currently shown title to provide to accessibility.
2591          *
2592          * @hide
2593          */
2594         @TestApi
2595         public CharSequence accessibilityTitle;
2596 
2597         /**
2598          * Sets a timeout in milliseconds before which the window will be hidden
2599          * by the window manager. Useful for transient notifications like toasts
2600          * so we don't have to rely on client cooperation to ensure the window
2601          * is hidden. Must be specified at window creation time. Note that apps
2602          * are not prepared to handle their windows being removed without their
2603          * explicit request and may try to interact with the removed window
2604          * resulting in undefined behavior and crashes. Therefore, we do hide
2605          * such windows to prevent them from overlaying other apps.
2606          *
2607          * @hide
2608          */
2609         @UnsupportedAppUsage
2610         public long hideTimeoutMilliseconds = -1;
2611 
2612         /**
2613          * The color mode requested by this window. The target display may
2614          * not be able to honor the request. When the color mode is not set
2615          * to {@link ActivityInfo#COLOR_MODE_DEFAULT}, it might override the
2616          * pixel format specified in {@link #format}.
2617          *
2618          * @hide
2619          */
2620         @ActivityInfo.ColorMode
2621         private int mColorMode = COLOR_MODE_DEFAULT;
2622 
LayoutParams()2623         public LayoutParams() {
2624             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
2625             type = TYPE_APPLICATION;
2626             format = PixelFormat.OPAQUE;
2627         }
2628 
LayoutParams(int _type)2629         public LayoutParams(int _type) {
2630             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
2631             type = _type;
2632             format = PixelFormat.OPAQUE;
2633         }
2634 
LayoutParams(int _type, int _flags)2635         public LayoutParams(int _type, int _flags) {
2636             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
2637             type = _type;
2638             flags = _flags;
2639             format = PixelFormat.OPAQUE;
2640         }
2641 
LayoutParams(int _type, int _flags, int _format)2642         public LayoutParams(int _type, int _flags, int _format) {
2643             super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
2644             type = _type;
2645             flags = _flags;
2646             format = _format;
2647         }
2648 
LayoutParams(int w, int h, int _type, int _flags, int _format)2649         public LayoutParams(int w, int h, int _type, int _flags, int _format) {
2650             super(w, h);
2651             type = _type;
2652             flags = _flags;
2653             format = _format;
2654         }
2655 
LayoutParams(int w, int h, int xpos, int ypos, int _type, int _flags, int _format)2656         public LayoutParams(int w, int h, int xpos, int ypos, int _type,
2657                 int _flags, int _format) {
2658             super(w, h);
2659             x = xpos;
2660             y = ypos;
2661             type = _type;
2662             flags = _flags;
2663             format = _format;
2664         }
2665 
setTitle(CharSequence title)2666         public final void setTitle(CharSequence title) {
2667             if (null == title)
2668                 title = "";
2669 
2670             mTitle = TextUtils.stringOrSpannedString(title);
2671         }
2672 
getTitle()2673         public final CharSequence getTitle() {
2674             return mTitle != null ? mTitle : "";
2675         }
2676 
2677         /**
2678          * Sets the surface insets based on the elevation (visual z position) of the input view.
2679          * @hide
2680          */
setSurfaceInsets(View view, boolean manual, boolean preservePrevious)2681         public final void setSurfaceInsets(View view, boolean manual, boolean preservePrevious) {
2682             final int surfaceInset = (int) Math.ceil(view.getZ() * 2);
2683             // Partial workaround for b/28318973. Every inset change causes a freeform window
2684             // to jump a little for a few frames. If we never allow surface insets to decrease,
2685             // they will stabilize quickly (often from the very beginning, as most windows start
2686             // as focused).
2687             // TODO(b/22668382) to fix this properly.
2688             if (surfaceInset == 0) {
2689                 // OK to have 0 (this is the case for non-freeform windows).
2690                 surfaceInsets.set(0, 0, 0, 0);
2691             } else {
2692                 surfaceInsets.set(
2693                         Math.max(surfaceInset, surfaceInsets.left),
2694                         Math.max(surfaceInset, surfaceInsets.top),
2695                         Math.max(surfaceInset, surfaceInsets.right),
2696                         Math.max(surfaceInset, surfaceInsets.bottom));
2697             }
2698             hasManualSurfaceInsets = manual;
2699             preservePreviousSurfaceInsets = preservePrevious;
2700         }
2701 
2702         /**
2703          * <p>Set the color mode of the window. Setting the color mode might
2704          * override the window's pixel {@link WindowManager.LayoutParams#format format}.</p>
2705          *
2706          * <p>The color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
2707          * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or
2708          * {@link ActivityInfo#COLOR_MODE_HDR}.</p>
2709          *
2710          * @see #getColorMode()
2711          */
setColorMode(@ctivityInfo.ColorMode int colorMode)2712         public void setColorMode(@ActivityInfo.ColorMode int colorMode) {
2713             mColorMode = colorMode;
2714         }
2715 
2716         /**
2717          * Returns the color mode of the window, one of {@link ActivityInfo#COLOR_MODE_DEFAULT},
2718          * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}.
2719          *
2720          * @see #setColorMode(int)
2721          */
2722         @ActivityInfo.ColorMode
getColorMode()2723         public int getColorMode() {
2724             return mColorMode;
2725         }
2726 
2727         /** @hide */
2728         @SystemApi
setUserActivityTimeout(long timeout)2729         public final void setUserActivityTimeout(long timeout) {
2730             userActivityTimeout = timeout;
2731         }
2732 
2733         /** @hide */
2734         @SystemApi
getUserActivityTimeout()2735         public final long getUserActivityTimeout() {
2736             return userActivityTimeout;
2737         }
2738 
describeContents()2739         public int describeContents() {
2740             return 0;
2741         }
2742 
writeToParcel(Parcel out, int parcelableFlags)2743         public void writeToParcel(Parcel out, int parcelableFlags) {
2744             out.writeInt(width);
2745             out.writeInt(height);
2746             out.writeInt(x);
2747             out.writeInt(y);
2748             out.writeInt(type);
2749             out.writeInt(flags);
2750             out.writeInt(privateFlags);
2751             out.writeInt(softInputMode);
2752             out.writeInt(layoutInDisplayCutoutMode);
2753             out.writeInt(gravity);
2754             out.writeFloat(horizontalMargin);
2755             out.writeFloat(verticalMargin);
2756             out.writeInt(format);
2757             out.writeInt(windowAnimations);
2758             out.writeFloat(alpha);
2759             out.writeFloat(dimAmount);
2760             out.writeFloat(screenBrightness);
2761             out.writeFloat(buttonBrightness);
2762             out.writeInt(rotationAnimation);
2763             out.writeStrongBinder(token);
2764             out.writeString(packageName);
2765             TextUtils.writeToParcel(mTitle, out, parcelableFlags);
2766             out.writeInt(screenOrientation);
2767             out.writeFloat(preferredRefreshRate);
2768             out.writeInt(preferredDisplayModeId);
2769             out.writeInt(systemUiVisibility);
2770             out.writeInt(subtreeSystemUiVisibility);
2771             out.writeInt(hasSystemUiListeners ? 1 : 0);
2772             out.writeInt(inputFeatures);
2773             out.writeLong(userActivityTimeout);
2774             out.writeInt(surfaceInsets.left);
2775             out.writeInt(surfaceInsets.top);
2776             out.writeInt(surfaceInsets.right);
2777             out.writeInt(surfaceInsets.bottom);
2778             out.writeInt(hasManualSurfaceInsets ? 1 : 0);
2779             out.writeInt(preservePreviousSurfaceInsets ? 1 : 0);
2780             out.writeInt(needsMenuKey);
2781             out.writeLong(accessibilityIdOfAnchor);
2782             TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags);
2783             out.writeInt(mColorMode);
2784             out.writeLong(hideTimeoutMilliseconds);
2785         }
2786 
2787         public static final @android.annotation.NonNull Parcelable.Creator<LayoutParams> CREATOR
2788                     = new Parcelable.Creator<LayoutParams>() {
2789             public LayoutParams createFromParcel(Parcel in) {
2790                 return new LayoutParams(in);
2791             }
2792 
2793             public LayoutParams[] newArray(int size) {
2794                 return new LayoutParams[size];
2795             }
2796         };
2797 
2798 
LayoutParams(Parcel in)2799         public LayoutParams(Parcel in) {
2800             width = in.readInt();
2801             height = in.readInt();
2802             x = in.readInt();
2803             y = in.readInt();
2804             type = in.readInt();
2805             flags = in.readInt();
2806             privateFlags = in.readInt();
2807             softInputMode = in.readInt();
2808             layoutInDisplayCutoutMode = in.readInt();
2809             gravity = in.readInt();
2810             horizontalMargin = in.readFloat();
2811             verticalMargin = in.readFloat();
2812             format = in.readInt();
2813             windowAnimations = in.readInt();
2814             alpha = in.readFloat();
2815             dimAmount = in.readFloat();
2816             screenBrightness = in.readFloat();
2817             buttonBrightness = in.readFloat();
2818             rotationAnimation = in.readInt();
2819             token = in.readStrongBinder();
2820             packageName = in.readString();
2821             mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
2822             screenOrientation = in.readInt();
2823             preferredRefreshRate = in.readFloat();
2824             preferredDisplayModeId = in.readInt();
2825             systemUiVisibility = in.readInt();
2826             subtreeSystemUiVisibility = in.readInt();
2827             hasSystemUiListeners = in.readInt() != 0;
2828             inputFeatures = in.readInt();
2829             userActivityTimeout = in.readLong();
2830             surfaceInsets.left = in.readInt();
2831             surfaceInsets.top = in.readInt();
2832             surfaceInsets.right = in.readInt();
2833             surfaceInsets.bottom = in.readInt();
2834             hasManualSurfaceInsets = in.readInt() != 0;
2835             preservePreviousSurfaceInsets = in.readInt() != 0;
2836             needsMenuKey = in.readInt();
2837             accessibilityIdOfAnchor = in.readLong();
2838             accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
2839             mColorMode = in.readInt();
2840             hideTimeoutMilliseconds = in.readLong();
2841         }
2842 
2843         @SuppressWarnings({"PointlessBitwiseExpression"})
2844         public static final int LAYOUT_CHANGED = 1<<0;
2845         public static final int TYPE_CHANGED = 1<<1;
2846         public static final int FLAGS_CHANGED = 1<<2;
2847         public static final int FORMAT_CHANGED = 1<<3;
2848         public static final int ANIMATION_CHANGED = 1<<4;
2849         public static final int DIM_AMOUNT_CHANGED = 1<<5;
2850         public static final int TITLE_CHANGED = 1<<6;
2851         public static final int ALPHA_CHANGED = 1<<7;
2852         public static final int MEMORY_TYPE_CHANGED = 1<<8;
2853         public static final int SOFT_INPUT_MODE_CHANGED = 1<<9;
2854         public static final int SCREEN_ORIENTATION_CHANGED = 1<<10;
2855         public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11;
2856         public static final int ROTATION_ANIMATION_CHANGED = 1<<12;
2857         /** {@hide} */
2858         public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<13;
2859         /** {@hide} */
2860         public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<14;
2861         /** {@hide} */
2862         public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<15;
2863         /** {@hide} */
2864         public static final int INPUT_FEATURES_CHANGED = 1<<16;
2865         /** {@hide} */
2866         public static final int PRIVATE_FLAGS_CHANGED = 1<<17;
2867         /** {@hide} */
2868         public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<18;
2869         /** {@hide} */
2870         public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19;
2871         /** {@hide} */
2872         public static final int SURFACE_INSETS_CHANGED = 1<<20;
2873         /** {@hide} */
2874         public static final int PREFERRED_REFRESH_RATE_CHANGED = 1 << 21;
2875         /** {@hide} */
2876         public static final int NEEDS_MENU_KEY_CHANGED = 1 << 22;
2877         /** {@hide} */
2878         public static final int PREFERRED_DISPLAY_MODE_ID = 1 << 23;
2879         /** {@hide} */
2880         public static final int ACCESSIBILITY_ANCHOR_CHANGED = 1 << 24;
2881         /** {@hide} */
2882         @TestApi
2883         public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25;
2884         /** {@hide} */
2885         public static final int COLOR_MODE_CHANGED = 1 << 26;
2886         /** {@hide} */
2887         public static final int EVERYTHING_CHANGED = 0xffffffff;
2888 
2889         // internal buffer to backup/restore parameters under compatibility mode.
2890         private int[] mCompatibilityParamsBackup = null;
2891 
copyFrom(LayoutParams o)2892         public final int copyFrom(LayoutParams o) {
2893             int changes = 0;
2894 
2895             if (width != o.width) {
2896                 width = o.width;
2897                 changes |= LAYOUT_CHANGED;
2898             }
2899             if (height != o.height) {
2900                 height = o.height;
2901                 changes |= LAYOUT_CHANGED;
2902             }
2903             if (x != o.x) {
2904                 x = o.x;
2905                 changes |= LAYOUT_CHANGED;
2906             }
2907             if (y != o.y) {
2908                 y = o.y;
2909                 changes |= LAYOUT_CHANGED;
2910             }
2911             if (horizontalWeight != o.horizontalWeight) {
2912                 horizontalWeight = o.horizontalWeight;
2913                 changes |= LAYOUT_CHANGED;
2914             }
2915             if (verticalWeight != o.verticalWeight) {
2916                 verticalWeight = o.verticalWeight;
2917                 changes |= LAYOUT_CHANGED;
2918             }
2919             if (horizontalMargin != o.horizontalMargin) {
2920                 horizontalMargin = o.horizontalMargin;
2921                 changes |= LAYOUT_CHANGED;
2922             }
2923             if (verticalMargin != o.verticalMargin) {
2924                 verticalMargin = o.verticalMargin;
2925                 changes |= LAYOUT_CHANGED;
2926             }
2927             if (type != o.type) {
2928                 type = o.type;
2929                 changes |= TYPE_CHANGED;
2930             }
2931             if (flags != o.flags) {
2932                 final int diff = flags ^ o.flags;
2933                 if ((diff & (FLAG_TRANSLUCENT_STATUS | FLAG_TRANSLUCENT_NAVIGATION)) != 0) {
2934                     changes |= TRANSLUCENT_FLAGS_CHANGED;
2935                 }
2936                 flags = o.flags;
2937                 changes |= FLAGS_CHANGED;
2938             }
2939             if (privateFlags != o.privateFlags) {
2940                 privateFlags = o.privateFlags;
2941                 changes |= PRIVATE_FLAGS_CHANGED;
2942             }
2943             if (softInputMode != o.softInputMode) {
2944                 softInputMode = o.softInputMode;
2945                 changes |= SOFT_INPUT_MODE_CHANGED;
2946             }
2947             if (layoutInDisplayCutoutMode != o.layoutInDisplayCutoutMode) {
2948                 layoutInDisplayCutoutMode = o.layoutInDisplayCutoutMode;
2949                 changes |= LAYOUT_CHANGED;
2950             }
2951             if (gravity != o.gravity) {
2952                 gravity = o.gravity;
2953                 changes |= LAYOUT_CHANGED;
2954             }
2955             if (format != o.format) {
2956                 format = o.format;
2957                 changes |= FORMAT_CHANGED;
2958             }
2959             if (windowAnimations != o.windowAnimations) {
2960                 windowAnimations = o.windowAnimations;
2961                 changes |= ANIMATION_CHANGED;
2962             }
2963             if (token == null) {
2964                 // NOTE: token only copied if the recipient doesn't
2965                 // already have one.
2966                 token = o.token;
2967             }
2968             if (packageName == null) {
2969                 // NOTE: packageName only copied if the recipient doesn't
2970                 // already have one.
2971                 packageName = o.packageName;
2972             }
2973             if (!Objects.equals(mTitle, o.mTitle) && o.mTitle != null) {
2974                 // NOTE: mTitle only copied if the originator set one.
2975                 mTitle = o.mTitle;
2976                 changes |= TITLE_CHANGED;
2977             }
2978             if (alpha != o.alpha) {
2979                 alpha = o.alpha;
2980                 changes |= ALPHA_CHANGED;
2981             }
2982             if (dimAmount != o.dimAmount) {
2983                 dimAmount = o.dimAmount;
2984                 changes |= DIM_AMOUNT_CHANGED;
2985             }
2986             if (screenBrightness != o.screenBrightness) {
2987                 screenBrightness = o.screenBrightness;
2988                 changes |= SCREEN_BRIGHTNESS_CHANGED;
2989             }
2990             if (buttonBrightness != o.buttonBrightness) {
2991                 buttonBrightness = o.buttonBrightness;
2992                 changes |= BUTTON_BRIGHTNESS_CHANGED;
2993             }
2994             if (rotationAnimation != o.rotationAnimation) {
2995                 rotationAnimation = o.rotationAnimation;
2996                 changes |= ROTATION_ANIMATION_CHANGED;
2997             }
2998 
2999             if (screenOrientation != o.screenOrientation) {
3000                 screenOrientation = o.screenOrientation;
3001                 changes |= SCREEN_ORIENTATION_CHANGED;
3002             }
3003 
3004             if (preferredRefreshRate != o.preferredRefreshRate) {
3005                 preferredRefreshRate = o.preferredRefreshRate;
3006                 changes |= PREFERRED_REFRESH_RATE_CHANGED;
3007             }
3008 
3009             if (preferredDisplayModeId != o.preferredDisplayModeId) {
3010                 preferredDisplayModeId = o.preferredDisplayModeId;
3011                 changes |= PREFERRED_DISPLAY_MODE_ID;
3012             }
3013 
3014             if (systemUiVisibility != o.systemUiVisibility
3015                     || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) {
3016                 systemUiVisibility = o.systemUiVisibility;
3017                 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility;
3018                 changes |= SYSTEM_UI_VISIBILITY_CHANGED;
3019             }
3020 
3021             if (hasSystemUiListeners != o.hasSystemUiListeners) {
3022                 hasSystemUiListeners = o.hasSystemUiListeners;
3023                 changes |= SYSTEM_UI_LISTENER_CHANGED;
3024             }
3025 
3026             if (inputFeatures != o.inputFeatures) {
3027                 inputFeatures = o.inputFeatures;
3028                 changes |= INPUT_FEATURES_CHANGED;
3029             }
3030 
3031             if (userActivityTimeout != o.userActivityTimeout) {
3032                 userActivityTimeout = o.userActivityTimeout;
3033                 changes |= USER_ACTIVITY_TIMEOUT_CHANGED;
3034             }
3035 
3036             if (!surfaceInsets.equals(o.surfaceInsets)) {
3037                 surfaceInsets.set(o.surfaceInsets);
3038                 changes |= SURFACE_INSETS_CHANGED;
3039             }
3040 
3041             if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) {
3042                 hasManualSurfaceInsets = o.hasManualSurfaceInsets;
3043                 changes |= SURFACE_INSETS_CHANGED;
3044             }
3045 
3046             if (preservePreviousSurfaceInsets != o.preservePreviousSurfaceInsets) {
3047                 preservePreviousSurfaceInsets = o.preservePreviousSurfaceInsets;
3048                 changes |= SURFACE_INSETS_CHANGED;
3049             }
3050 
3051             if (needsMenuKey != o.needsMenuKey) {
3052                 needsMenuKey = o.needsMenuKey;
3053                 changes |= NEEDS_MENU_KEY_CHANGED;
3054             }
3055 
3056             if (accessibilityIdOfAnchor != o.accessibilityIdOfAnchor) {
3057                 accessibilityIdOfAnchor = o.accessibilityIdOfAnchor;
3058                 changes |= ACCESSIBILITY_ANCHOR_CHANGED;
3059             }
3060 
3061             if (!Objects.equals(accessibilityTitle, o.accessibilityTitle)
3062                     && o.accessibilityTitle != null) {
3063                 // NOTE: accessibilityTitle only copied if the originator set one.
3064                 accessibilityTitle = o.accessibilityTitle;
3065                 changes |= ACCESSIBILITY_TITLE_CHANGED;
3066             }
3067 
3068             if (mColorMode != o.mColorMode) {
3069                 mColorMode = o.mColorMode;
3070                 changes |= COLOR_MODE_CHANGED;
3071             }
3072 
3073             // This can't change, it's only set at window creation time.
3074             hideTimeoutMilliseconds = o.hideTimeoutMilliseconds;
3075 
3076             return changes;
3077         }
3078 
3079         @Override
debug(String output)3080         public String debug(String output) {
3081             output += "Contents of " + this + ":";
3082             Log.d("Debug", output);
3083             output = super.debug("");
3084             Log.d("Debug", output);
3085             Log.d("Debug", "");
3086             Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}");
3087             return "";
3088         }
3089 
3090         @Override
toString()3091         public String toString() {
3092             return toString("");
3093         }
3094 
3095         /**
3096          * @hide
3097          */
dumpDimensions(StringBuilder sb)3098         public void dumpDimensions(StringBuilder sb) {
3099             sb.append('(');
3100             sb.append(x);
3101             sb.append(',');
3102             sb.append(y);
3103             sb.append(")(");
3104             sb.append((width == MATCH_PARENT ? "fill" : (width == WRAP_CONTENT
3105                     ? "wrap" : String.valueOf(width))));
3106             sb.append('x');
3107             sb.append((height == MATCH_PARENT ? "fill" : (height == WRAP_CONTENT
3108                     ? "wrap" : String.valueOf(height))));
3109             sb.append(")");
3110         }
3111 
3112         /**
3113          * @hide
3114          */
toString(String prefix)3115         public String toString(String prefix) {
3116             StringBuilder sb = new StringBuilder(256);
3117             sb.append('{');
3118             dumpDimensions(sb);
3119             if (horizontalMargin != 0) {
3120                 sb.append(" hm=");
3121                 sb.append(horizontalMargin);
3122             }
3123             if (verticalMargin != 0) {
3124                 sb.append(" vm=");
3125                 sb.append(verticalMargin);
3126             }
3127             if (gravity != 0) {
3128                 sb.append(" gr=");
3129                 sb.append(Gravity.toString(gravity));
3130             }
3131             if (softInputMode != 0) {
3132                 sb.append(" sim={");
3133                 sb.append(softInputModeToString(softInputMode));
3134                 sb.append('}');
3135             }
3136             if (layoutInDisplayCutoutMode != 0) {
3137                 sb.append(" layoutInDisplayCutoutMode=");
3138                 sb.append(layoutInDisplayCutoutModeToString(layoutInDisplayCutoutMode));
3139             }
3140             sb.append(" ty=");
3141             sb.append(ViewDebug.intToString(LayoutParams.class, "type", type));
3142             if (format != PixelFormat.OPAQUE) {
3143                 sb.append(" fmt=");
3144                 sb.append(PixelFormat.formatToString(format));
3145             }
3146             if (windowAnimations != 0) {
3147                 sb.append(" wanim=0x");
3148                 sb.append(Integer.toHexString(windowAnimations));
3149             }
3150             if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
3151                 sb.append(" or=");
3152                 sb.append(ActivityInfo.screenOrientationToString(screenOrientation));
3153             }
3154             if (alpha != 1.0f) {
3155                 sb.append(" alpha=");
3156                 sb.append(alpha);
3157             }
3158             if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) {
3159                 sb.append(" sbrt=");
3160                 sb.append(screenBrightness);
3161             }
3162             if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) {
3163                 sb.append(" bbrt=");
3164                 sb.append(buttonBrightness);
3165             }
3166             if (rotationAnimation != ROTATION_ANIMATION_ROTATE) {
3167                 sb.append(" rotAnim=");
3168                 sb.append(rotationAnimationToString(rotationAnimation));
3169             }
3170             if (preferredRefreshRate != 0) {
3171                 sb.append(" preferredRefreshRate=");
3172                 sb.append(preferredRefreshRate);
3173             }
3174             if (preferredDisplayModeId != 0) {
3175                 sb.append(" preferredDisplayMode=");
3176                 sb.append(preferredDisplayModeId);
3177             }
3178             if (hasSystemUiListeners) {
3179                 sb.append(" sysuil=");
3180                 sb.append(hasSystemUiListeners);
3181             }
3182             if (inputFeatures != 0) {
3183                 sb.append(" if=").append(inputFeatureToString(inputFeatures));
3184             }
3185             if (userActivityTimeout >= 0) {
3186                 sb.append(" userActivityTimeout=").append(userActivityTimeout);
3187             }
3188             if (surfaceInsets.left != 0 || surfaceInsets.top != 0 || surfaceInsets.right != 0 ||
3189                     surfaceInsets.bottom != 0 || hasManualSurfaceInsets
3190                     || !preservePreviousSurfaceInsets) {
3191                 sb.append(" surfaceInsets=").append(surfaceInsets);
3192                 if (hasManualSurfaceInsets) {
3193                     sb.append(" (manual)");
3194                 }
3195                 if (!preservePreviousSurfaceInsets) {
3196                     sb.append(" (!preservePreviousSurfaceInsets)");
3197                 }
3198             }
3199             if (needsMenuKey == NEEDS_MENU_SET_TRUE) {
3200                 sb.append(" needsMenuKey");
3201             }
3202             if (mColorMode != COLOR_MODE_DEFAULT) {
3203                 sb.append(" colorMode=").append(ActivityInfo.colorModeToString(mColorMode));
3204             }
3205             sb.append(System.lineSeparator());
3206             sb.append(prefix).append("  fl=").append(
3207                     ViewDebug.flagsToString(LayoutParams.class, "flags", flags));
3208             if (privateFlags != 0) {
3209                 sb.append(System.lineSeparator());
3210                 sb.append(prefix).append("  pfl=").append(ViewDebug.flagsToString(
3211                         LayoutParams.class, "privateFlags", privateFlags));
3212             }
3213             if (systemUiVisibility != 0) {
3214                 sb.append(System.lineSeparator());
3215                 sb.append(prefix).append("  sysui=").append(ViewDebug.flagsToString(
3216                         View.class, "mSystemUiVisibility", systemUiVisibility));
3217             }
3218             if (subtreeSystemUiVisibility != 0) {
3219                 sb.append(System.lineSeparator());
3220                 sb.append(prefix).append("  vsysui=").append(ViewDebug.flagsToString(
3221                         View.class, "mSystemUiVisibility", subtreeSystemUiVisibility));
3222             }
3223             sb.append('}');
3224             return sb.toString();
3225         }
3226 
3227         /**
3228          * @hide
3229          */
writeToProto(ProtoOutputStream proto, long fieldId)3230         public void writeToProto(ProtoOutputStream proto, long fieldId) {
3231             final long token = proto.start(fieldId);
3232             proto.write(TYPE, type);
3233             proto.write(X, x);
3234             proto.write(Y, y);
3235             proto.write(WIDTH, width);
3236             proto.write(HEIGHT, height);
3237             proto.write(HORIZONTAL_MARGIN, horizontalMargin);
3238             proto.write(VERTICAL_MARGIN, verticalMargin);
3239             proto.write(GRAVITY, gravity);
3240             proto.write(SOFT_INPUT_MODE, softInputMode);
3241             proto.write(FORMAT, format);
3242             proto.write(WINDOW_ANIMATIONS, windowAnimations);
3243             proto.write(ALPHA, alpha);
3244             proto.write(SCREEN_BRIGHTNESS, screenBrightness);
3245             proto.write(BUTTON_BRIGHTNESS, buttonBrightness);
3246             proto.write(ROTATION_ANIMATION, rotationAnimation);
3247             proto.write(PREFERRED_REFRESH_RATE, preferredRefreshRate);
3248             proto.write(WindowLayoutParamsProto.PREFERRED_DISPLAY_MODE_ID, preferredDisplayModeId);
3249             proto.write(HAS_SYSTEM_UI_LISTENERS, hasSystemUiListeners);
3250             proto.write(INPUT_FEATURE_FLAGS, inputFeatures);
3251             proto.write(USER_ACTIVITY_TIMEOUT, userActivityTimeout);
3252             proto.write(NEEDS_MENU_KEY, needsMenuKey);
3253             proto.write(COLOR_MODE, mColorMode);
3254             proto.write(FLAGS, flags);
3255             proto.write(PRIVATE_FLAGS, privateFlags);
3256             proto.write(SYSTEM_UI_VISIBILITY_FLAGS, systemUiVisibility);
3257             proto.write(SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS, subtreeSystemUiVisibility);
3258             proto.end(token);
3259         }
3260 
3261         /**
3262          * Scale the layout params' coordinates and size.
3263          * @hide
3264          */
scale(float scale)3265         public void scale(float scale) {
3266             x = (int) (x * scale + 0.5f);
3267             y = (int) (y * scale + 0.5f);
3268             if (width > 0) {
3269                 width = (int) (width * scale + 0.5f);
3270             }
3271             if (height > 0) {
3272                 height = (int) (height * scale + 0.5f);
3273             }
3274         }
3275 
3276         /**
3277          * Backup the layout parameters used in compatibility mode.
3278          * @see LayoutParams#restore()
3279          */
3280         @UnsupportedAppUsage
backup()3281         void backup() {
3282             int[] backup = mCompatibilityParamsBackup;
3283             if (backup == null) {
3284                 // we backup 4 elements, x, y, width, height
3285                 backup = mCompatibilityParamsBackup = new int[4];
3286             }
3287             backup[0] = x;
3288             backup[1] = y;
3289             backup[2] = width;
3290             backup[3] = height;
3291         }
3292 
3293         /**
3294          * Restore the layout params' coordinates, size and gravity
3295          * @see LayoutParams#backup()
3296          */
3297         @UnsupportedAppUsage
restore()3298         void restore() {
3299             int[] backup = mCompatibilityParamsBackup;
3300             if (backup != null) {
3301                 x = backup[0];
3302                 y = backup[1];
3303                 width = backup[2];
3304                 height = backup[3];
3305             }
3306         }
3307 
3308         private CharSequence mTitle = null;
3309 
3310         /** @hide */
3311         @Override
encodeProperties(@onNull ViewHierarchyEncoder encoder)3312         protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) {
3313             super.encodeProperties(encoder);
3314 
3315             encoder.addProperty("x", x);
3316             encoder.addProperty("y", y);
3317             encoder.addProperty("horizontalWeight", horizontalWeight);
3318             encoder.addProperty("verticalWeight", verticalWeight);
3319             encoder.addProperty("type", type);
3320             encoder.addProperty("flags", flags);
3321         }
3322 
3323         /**
3324          * @hide
3325          * @return True if the layout parameters will cause the window to cover the full screen;
3326          *         false otherwise.
3327          */
isFullscreen()3328         public boolean isFullscreen() {
3329             return x == 0 && y == 0
3330                     && width == WindowManager.LayoutParams.MATCH_PARENT
3331                     && height == WindowManager.LayoutParams.MATCH_PARENT;
3332         }
3333 
layoutInDisplayCutoutModeToString( @ayoutInDisplayCutoutMode int mode)3334         private static String layoutInDisplayCutoutModeToString(
3335                 @LayoutInDisplayCutoutMode int mode) {
3336             switch (mode) {
3337                 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT:
3338                     return "default";
3339                 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS:
3340                     return "always";
3341                 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER:
3342                     return "never";
3343                 default:
3344                     return "unknown(" + mode + ")";
3345             }
3346         }
3347 
softInputModeToString(@oftInputModeFlags int softInputMode)3348         private static String softInputModeToString(@SoftInputModeFlags int softInputMode) {
3349             final StringBuilder result = new StringBuilder();
3350             final int state = softInputMode & SOFT_INPUT_MASK_STATE;
3351             if (state != 0) {
3352                 result.append("state=");
3353                 switch (state) {
3354                     case SOFT_INPUT_STATE_UNCHANGED:
3355                         result.append("unchanged");
3356                         break;
3357                     case SOFT_INPUT_STATE_HIDDEN:
3358                         result.append("hidden");
3359                         break;
3360                     case SOFT_INPUT_STATE_ALWAYS_HIDDEN:
3361                         result.append("always_hidden");
3362                         break;
3363                     case SOFT_INPUT_STATE_VISIBLE:
3364                         result.append("visible");
3365                         break;
3366                     case SOFT_INPUT_STATE_ALWAYS_VISIBLE:
3367                         result.append("always_visible");
3368                         break;
3369                     default:
3370                         result.append(state);
3371                         break;
3372                 }
3373                 result.append(' ');
3374             }
3375             final int adjust = softInputMode & SOFT_INPUT_MASK_ADJUST;
3376             if (adjust != 0) {
3377                 result.append("adjust=");
3378                 switch (adjust) {
3379                     case SOFT_INPUT_ADJUST_RESIZE:
3380                         result.append("resize");
3381                         break;
3382                     case SOFT_INPUT_ADJUST_PAN:
3383                         result.append("pan");
3384                         break;
3385                     case SOFT_INPUT_ADJUST_NOTHING:
3386                         result.append("nothing");
3387                         break;
3388                     default:
3389                         result.append(adjust);
3390                         break;
3391                 }
3392                 result.append(' ');
3393             }
3394             if ((softInputMode & SOFT_INPUT_IS_FORWARD_NAVIGATION) != 0) {
3395                 result.append("forwardNavigation").append(' ');
3396             }
3397             result.deleteCharAt(result.length() - 1);
3398             return result.toString();
3399         }
3400 
rotationAnimationToString(int rotationAnimation)3401         private static String rotationAnimationToString(int rotationAnimation) {
3402             switch (rotationAnimation) {
3403                 case ROTATION_ANIMATION_UNSPECIFIED:
3404                     return "UNSPECIFIED";
3405                 case ROTATION_ANIMATION_ROTATE:
3406                     return "ROTATE";
3407                 case ROTATION_ANIMATION_CROSSFADE:
3408                     return "CROSSFADE";
3409                 case ROTATION_ANIMATION_JUMPCUT:
3410                     return "JUMPCUT";
3411                 case ROTATION_ANIMATION_SEAMLESS:
3412                     return "SEAMLESS";
3413                 default:
3414                     return Integer.toString(rotationAnimation);
3415             }
3416         }
3417 
inputFeatureToString(int inputFeature)3418         private static String inputFeatureToString(int inputFeature) {
3419             switch (inputFeature) {
3420                 case INPUT_FEATURE_DISABLE_POINTER_GESTURES:
3421                     return "DISABLE_POINTER_GESTURES";
3422                 case INPUT_FEATURE_NO_INPUT_CHANNEL:
3423                     return "NO_INPUT_CHANNEL";
3424                 case INPUT_FEATURE_DISABLE_USER_ACTIVITY:
3425                     return "DISABLE_USER_ACTIVITY";
3426                 default:
3427                     return Integer.toString(inputFeature);
3428             }
3429         }
3430     }
3431 }
3432