This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
/
WindowManager.java
4952 lines (4571 loc) · 208 KB
/
WindowManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.view;
import static android.content.pm.ActivityInfo.COLOR_MODE_DEFAULT;
import static android.view.View.STATUS_BAR_DISABLE_BACK;
import static android.view.View.STATUS_BAR_DISABLE_CLOCK;
import static android.view.View.STATUS_BAR_DISABLE_EXPAND;
import static android.view.View.STATUS_BAR_DISABLE_HOME;
import static android.view.View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS;
import static android.view.View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS;
import static android.view.View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER;
import static android.view.View.STATUS_BAR_DISABLE_RECENT;
import static android.view.View.STATUS_BAR_DISABLE_SEARCH;
import static android.view.View.STATUS_BAR_DISABLE_SYSTEM_INFO;
import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN;
import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE;
import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;
import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
import static android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
import static android.view.View.SYSTEM_UI_FLAG_LOW_PROFILE;
import static android.view.View.SYSTEM_UI_FLAG_VISIBLE;
import static android.view.WindowInsets.Side.BOTTOM;
import static android.view.WindowInsets.Side.LEFT;
import static android.view.WindowInsets.Side.RIGHT;
import static android.view.WindowInsets.Side.TOP;
import static android.view.WindowInsets.Type.CAPTION_BAR;
import static android.view.WindowInsets.Type.IME;
import static android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES;
import static android.view.WindowInsets.Type.NAVIGATION_BARS;
import static android.view.WindowInsets.Type.STATUS_BARS;
import static android.view.WindowInsets.Type.SYSTEM_GESTURES;
import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT;
import static android.view.WindowInsets.Type.WINDOW_DECOR;
import static android.view.WindowLayoutParamsProto.ALPHA;
import static android.view.WindowLayoutParamsProto.APPEARANCE;
import static android.view.WindowLayoutParamsProto.BEHAVIOR;
import static android.view.WindowLayoutParamsProto.BUTTON_BRIGHTNESS;
import static android.view.WindowLayoutParamsProto.COLOR_MODE;
import static android.view.WindowLayoutParamsProto.FIT_IGNORE_VISIBILITY;
import static android.view.WindowLayoutParamsProto.FIT_INSETS_SIDES;
import static android.view.WindowLayoutParamsProto.FIT_INSETS_TYPES;
import static android.view.WindowLayoutParamsProto.FLAGS;
import static android.view.WindowLayoutParamsProto.FORMAT;
import static android.view.WindowLayoutParamsProto.GRAVITY;
import static android.view.WindowLayoutParamsProto.HAS_SYSTEM_UI_LISTENERS;
import static android.view.WindowLayoutParamsProto.HEIGHT;
import static android.view.WindowLayoutParamsProto.HORIZONTAL_MARGIN;
import static android.view.WindowLayoutParamsProto.INPUT_FEATURE_FLAGS;
import static android.view.WindowLayoutParamsProto.PREFERRED_REFRESH_RATE;
import static android.view.WindowLayoutParamsProto.PRIVATE_FLAGS;
import static android.view.WindowLayoutParamsProto.ROTATION_ANIMATION;
import static android.view.WindowLayoutParamsProto.SCREEN_BRIGHTNESS;
import static android.view.WindowLayoutParamsProto.SOFT_INPUT_MODE;
import static android.view.WindowLayoutParamsProto.SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS;
import static android.view.WindowLayoutParamsProto.SYSTEM_UI_VISIBILITY_FLAGS;
import static android.view.WindowLayoutParamsProto.TYPE;
import static android.view.WindowLayoutParamsProto.USER_ACTIVITY_TIMEOUT;
import static android.view.WindowLayoutParamsProto.VERTICAL_MARGIN;
import static android.view.WindowLayoutParamsProto.WIDTH;
import static android.view.WindowLayoutParamsProto.WINDOW_ANIMATIONS;
import static android.view.WindowLayoutParamsProto.X;
import static android.view.WindowLayoutParamsProto.Y;
import android.Manifest.permission;
import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
import android.app.KeyguardManager;
import android.app.Presentation;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ClipData;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.Insets;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.Log;
import android.util.proto.ProtoOutputStream;
import android.view.Gravity.GravityFlags;
import android.view.View.OnApplyWindowInsetsListener;
import android.view.WindowInsets.Side;
import android.view.WindowInsets.Side.InsetsSide;
import android.view.WindowInsets.Type;
import android.view.WindowInsets.Type.InsetsType;
import android.view.accessibility.AccessibilityNodeInfo;
import android.window.TaskFpsCallback;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
/**
* The interface that apps use to talk to the window manager.
* <p>
* Each window manager instance is bound to a {@link Display}. To obtain the
* <code>WindowManager</code> associated with a display,
* call {@link Context#createWindowContext(Display, int, Bundle)} to get the display's UI context,
* then call {@link Context#getSystemService(String)} or {@link Context#getSystemService(Class)} on
* the UI context.
* <p>
* The simplest way to show a window on a particular display is to create a {@link Presentation},
* which automatically obtains a <code>WindowManager</code> and context for the display.
*/
@SystemService(Context.WINDOW_SERVICE)
public interface WindowManager extends ViewManager {
/** @hide */
int DOCKED_INVALID = -1;
/** @hide */
int DOCKED_LEFT = 1;
/** @hide */
int DOCKED_TOP = 2;
/** @hide */
int DOCKED_RIGHT = 3;
/** @hide */
int DOCKED_BOTTOM = 4;
/** @hide */
String INPUT_CONSUMER_PIP = "pip_input_consumer";
/** @hide */
String INPUT_CONSUMER_NAVIGATION = "nav_input_consumer";
/** @hide */
String INPUT_CONSUMER_WALLPAPER = "wallpaper_input_consumer";
/** @hide */
String INPUT_CONSUMER_RECENTS_ANIMATION = "recents_animation_input_consumer";
/** @hide */
int SHELL_ROOT_LAYER_DIVIDER = 0;
/** @hide */
int SHELL_ROOT_LAYER_PIP = 1;
/**
* Declares the layer the shell root will belong to. This is for z-ordering.
* @hide
*/
@IntDef(prefix = { "SHELL_ROOT_LAYER_" }, value = {
SHELL_ROOT_LAYER_DIVIDER,
SHELL_ROOT_LAYER_PIP
})
@Retention(RetentionPolicy.SOURCE)
@interface ShellRootLayer {}
/**
* Not set up for a transition.
* @hide
*/
int TRANSIT_OLD_UNSET = -1;
/**
* No animation for transition.
* @hide
*/
int TRANSIT_OLD_NONE = 0;
/**
* A window in a new activity is being opened on top of an existing one in the same task.
* @hide
*/
int TRANSIT_OLD_ACTIVITY_OPEN = 6;
/**
* The window in the top-most activity is being closed to reveal the previous activity in the
* same task.
* @hide
*/
int TRANSIT_OLD_ACTIVITY_CLOSE = 7;
/**
* A window in a new task is being opened on top of an existing one in another activity's task.
* @hide
*/
int TRANSIT_OLD_TASK_OPEN = 8;
/**
* A window in the top-most activity is being closed to reveal the previous activity in a
* different task.
* @hide
*/
int TRANSIT_OLD_TASK_CLOSE = 9;
/**
* A window in an existing task is being displayed on top of an existing one in another
* activity's task.
* @hide
*/
int TRANSIT_OLD_TASK_TO_FRONT = 10;
/**
* A window in an existing task is being put below all other tasks.
* @hide
*/
int TRANSIT_OLD_TASK_TO_BACK = 11;
/**
* A window in a new activity that doesn't have a wallpaper is being opened on top of one that
* does, effectively closing the wallpaper.
* @hide
*/
int TRANSIT_OLD_WALLPAPER_CLOSE = 12;
/**
* A window in a new activity that does have a wallpaper is being opened on one that didn't,
* effectively opening the wallpaper.
* @hide
*/
int TRANSIT_OLD_WALLPAPER_OPEN = 13;
/**
* A window in a new activity is being opened on top of an existing one, and both are on top
* of the wallpaper.
* @hide
*/
int TRANSIT_OLD_WALLPAPER_INTRA_OPEN = 14;
/**
* The window in the top-most activity is being closed to reveal the previous activity, and
* both are on top of the wallpaper.
* @hide
*/
int TRANSIT_OLD_WALLPAPER_INTRA_CLOSE = 15;
/**
* A window in a new task is being opened behind an existing one in another activity's task.
* The new window will show briefly and then be gone.
* @hide
*/
int TRANSIT_OLD_TASK_OPEN_BEHIND = 16;
/**
* An activity is being relaunched (e.g. due to configuration change).
* @hide
*/
int TRANSIT_OLD_ACTIVITY_RELAUNCH = 18;
/**
* Keyguard is going away.
* @hide
*/
int TRANSIT_OLD_KEYGUARD_GOING_AWAY = 20;
/**
* Keyguard is going away with showing an activity behind that requests wallpaper.
* @hide
*/
int TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER = 21;
/**
* Keyguard is being occluded.
* @hide
*/
int TRANSIT_OLD_KEYGUARD_OCCLUDE = 22;
/**
* Keyguard is being unoccluded.
* @hide
*/
int TRANSIT_OLD_KEYGUARD_UNOCCLUDE = 23;
/**
* A translucent activity is being opened.
* @hide
*/
int TRANSIT_OLD_TRANSLUCENT_ACTIVITY_OPEN = 24;
/**
* A translucent activity is being closed.
* @hide
*/
int TRANSIT_OLD_TRANSLUCENT_ACTIVITY_CLOSE = 25;
/**
* A crashing activity is being closed.
* @hide
*/
int TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE = 26;
/**
* A task is changing windowing modes
* @hide
*/
int TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE = 27;
/**
* A window in a new task fragment is being opened.
* @hide
*/
int TRANSIT_OLD_TASK_FRAGMENT_OPEN = 28;
/**
* A window in the top-most activity of task fragment is being closed to reveal the activity
* below.
* @hide
*/
int TRANSIT_OLD_TASK_FRAGMENT_CLOSE = 29;
/**
* A window of task fragment is changing bounds.
* @hide
*/
int TRANSIT_OLD_TASK_FRAGMENT_CHANGE = 30;
/**
* @hide
*/
@IntDef(prefix = { "TRANSIT_OLD_" }, value = {
TRANSIT_OLD_UNSET,
TRANSIT_OLD_NONE,
TRANSIT_OLD_ACTIVITY_OPEN,
TRANSIT_OLD_ACTIVITY_CLOSE,
TRANSIT_OLD_TASK_OPEN,
TRANSIT_OLD_TASK_CLOSE,
TRANSIT_OLD_TASK_TO_FRONT,
TRANSIT_OLD_TASK_TO_BACK,
TRANSIT_OLD_WALLPAPER_CLOSE,
TRANSIT_OLD_WALLPAPER_OPEN,
TRANSIT_OLD_WALLPAPER_INTRA_OPEN,
TRANSIT_OLD_WALLPAPER_INTRA_CLOSE,
TRANSIT_OLD_TASK_OPEN_BEHIND,
TRANSIT_OLD_ACTIVITY_RELAUNCH,
TRANSIT_OLD_KEYGUARD_GOING_AWAY,
TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER,
TRANSIT_OLD_KEYGUARD_OCCLUDE,
TRANSIT_OLD_KEYGUARD_UNOCCLUDE,
TRANSIT_OLD_TRANSLUCENT_ACTIVITY_OPEN,
TRANSIT_OLD_TRANSLUCENT_ACTIVITY_CLOSE,
TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE,
TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE,
TRANSIT_OLD_TASK_FRAGMENT_OPEN,
TRANSIT_OLD_TASK_FRAGMENT_CLOSE,
TRANSIT_OLD_TASK_FRAGMENT_CHANGE
})
@Retention(RetentionPolicy.SOURCE)
@interface TransitionOldType {}
/** @hide */
int TRANSIT_NONE = 0;
/**
* A window that didn't exist before has been created and made visible.
* @hide
*/
int TRANSIT_OPEN = 1;
/**
* A window that was visible no-longer exists (was finished or destroyed).
* @hide
*/
int TRANSIT_CLOSE = 2;
/**
* A window that already existed but was not visible is made visible.
* @hide
*/
int TRANSIT_TO_FRONT = 3;
/**
* A window that was visible is made invisible but still exists.
* @hide
*/
int TRANSIT_TO_BACK = 4;
/** @hide */
int TRANSIT_RELAUNCH = 5;
/**
* A window is visible before and after but changes in some way (eg. it resizes or changes
* windowing-mode).
* @hide
*/
int TRANSIT_CHANGE = 6;
/**
* The keyguard was visible and has been dismissed.
* @deprecated use {@link #TRANSIT_TO_BACK} + {@link #TRANSIT_FLAG_KEYGUARD_GOING_AWAY} for
* keyguard going away with Shell transition.
* @hide
*/
@Deprecated
int TRANSIT_KEYGUARD_GOING_AWAY = 7;
/**
* A window is appearing above a locked keyguard.
* @hide
*/
int TRANSIT_KEYGUARD_OCCLUDE = 8;
/**
* A window is made invisible revealing a locked keyguard.
* @hide
*/
int TRANSIT_KEYGUARD_UNOCCLUDE = 9;
/**
* A window is starting to enter PiP.
* @hide
*/
int TRANSIT_PIP = 10;
/**
* The screen is turning on.
* @hide
*/
int TRANSIT_WAKE = 11;
/**
* The first slot for custom transition types. Callers (like Shell) can make use of custom
* transition types for dealing with special cases. These types are effectively ignored by
* Core and will just be passed along as part of TransitionInfo objects. An example is
* split-screen using a custom type for it's snap-to-dismiss action. By using a custom type,
* Shell can properly dispatch the results of that transition to the split-screen
* implementation.
* @hide
*/
int TRANSIT_FIRST_CUSTOM = 12;
/**
* @hide
*/
@IntDef(prefix = { "TRANSIT_" }, value = {
TRANSIT_NONE,
TRANSIT_OPEN,
TRANSIT_CLOSE,
TRANSIT_TO_FRONT,
TRANSIT_TO_BACK,
TRANSIT_RELAUNCH,
TRANSIT_CHANGE,
TRANSIT_KEYGUARD_GOING_AWAY,
TRANSIT_KEYGUARD_OCCLUDE,
TRANSIT_KEYGUARD_UNOCCLUDE,
TRANSIT_PIP,
TRANSIT_WAKE,
TRANSIT_FIRST_CUSTOM
})
@Retention(RetentionPolicy.SOURCE)
@interface TransitionType {}
/**
* Transition flag: Keyguard is going away, but keeping the notification shade open
* @hide
*/
int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE = 0x1;
/**
* Transition flag: Keyguard is going away, but doesn't want an animation for it
* @hide
*/
int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION = 0x2;
/**
* Transition flag: Keyguard is going away while it was showing the system wallpaper.
* @hide
*/
int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER = 0x4;
/**
* Transition flag: Keyguard is going away with subtle animation.
* @hide
*/
int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION = 0x8;
/**
* Transition flag: Keyguard is going away to the launcher, and it needs us to clear the task
* snapshot of the launcher because it has changed something in the Launcher window.
* @hide
*/
int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_LAUNCHER_CLEAR_SNAPSHOT = 0x16;
/**
* Transition flag: App is crashed.
* @hide
*/
int TRANSIT_FLAG_APP_CRASHED = 0x10;
/**
* Transition flag: A window in a new task is being opened behind an existing one in another
* activity's task.
* @hide
*/
int TRANSIT_FLAG_OPEN_BEHIND = 0x20;
/**
* Transition flag: The keyguard is locked throughout the whole transition.
* @hide
*/
int TRANSIT_FLAG_KEYGUARD_LOCKED = 0x40;
/**
* Transition flag: Indicates that this transition is for recents animation.
* TODO(b/188669821): Remove once special-case logic moves to shell.
* @hide
*/
int TRANSIT_FLAG_IS_RECENTS = 0x80;
/**
* Transition flag: Indicates that keyguard should go away with this transition.
* @hide
*/
int TRANSIT_FLAG_KEYGUARD_GOING_AWAY = 0x100;
/**
* @hide
*/
@IntDef(flag = true, prefix = { "TRANSIT_FLAG_" }, value = {
TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE,
TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION,
TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER,
TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION,
TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_LAUNCHER_CLEAR_SNAPSHOT,
TRANSIT_FLAG_APP_CRASHED,
TRANSIT_FLAG_OPEN_BEHIND,
TRANSIT_FLAG_KEYGUARD_LOCKED,
TRANSIT_FLAG_IS_RECENTS,
TRANSIT_FLAG_KEYGUARD_GOING_AWAY
})
@Retention(RetentionPolicy.SOURCE)
@interface TransitionFlags {}
/**
* Remove content mode: Indicates remove content mode is currently not defined.
* @hide
*/
int REMOVE_CONTENT_MODE_UNDEFINED = 0;
/**
* Remove content mode: Indicates that when display is removed, all its activities will be moved
* to the primary display and the topmost activity should become focused.
* @hide
*/
int REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY = 1;
/**
* Remove content mode: Indicates that when display is removed, all its stacks and tasks will be
* removed, all activities will be destroyed according to the usual lifecycle.
* @hide
*/
int REMOVE_CONTENT_MODE_DESTROY = 2;
/**
* @hide
*/
@IntDef(prefix = { "REMOVE_CONTENT_MODE_" }, value = {
REMOVE_CONTENT_MODE_UNDEFINED,
REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY,
REMOVE_CONTENT_MODE_DESTROY,
})
@interface RemoveContentMode {}
/**
* Display IME Policy: The IME should appear on the local display.
* @hide
*/
@TestApi
int DISPLAY_IME_POLICY_LOCAL = 0;
/**
* Display IME Policy: The IME should appear on the fallback display.
* @hide
*/
@TestApi
int DISPLAY_IME_POLICY_FALLBACK_DISPLAY = 1;
/**
* Display IME Policy: The IME should be hidden.
*
* Setting this policy will prevent the IME from making a connection. This
* will prevent any IME from receiving metadata about input.
* @hide
*/
@TestApi
int DISPLAY_IME_POLICY_HIDE = 2;
/**
* @hide
*/
@IntDef({
DISPLAY_IME_POLICY_LOCAL,
DISPLAY_IME_POLICY_FALLBACK_DISPLAY,
DISPLAY_IME_POLICY_HIDE,
})
@interface DisplayImePolicy {}
/**
* Exception that is thrown when trying to add view whose
* {@link LayoutParams} {@link LayoutParams#token}
* is invalid.
*/
public static class BadTokenException extends RuntimeException {
public BadTokenException() {
}
public BadTokenException(String name) {
super(name);
}
}
/**
* Exception that is thrown when calling {@link #addView} to a secondary display that cannot
* be found. See {@link android.app.Presentation} for more information on secondary displays.
*/
public static class InvalidDisplayException extends RuntimeException {
public InvalidDisplayException() {
}
public InvalidDisplayException(String name) {
super(name);
}
}
/**
* Returns the {@link Display} upon which this {@link WindowManager} instance
* will create new windows.
* <p>
* Despite the name of this method, the display that is returned is not
* necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}).
* The returned display could instead be a secondary display that this
* window manager instance is managing. Think of it as the display that
* this {@link WindowManager} instance uses by default.
* </p><p>
* To create windows on a different display, you need to obtain a
* {@link WindowManager} for that {@link Display}. (See the {@link WindowManager}
* class documentation for more information.)
* </p>
*
* @return The display that this window manager is managing.
* @deprecated Use {@link Context#getDisplay()} instead.
*/
@Deprecated
public Display getDefaultDisplay();
/**
* Special variation of {@link #removeView} that immediately invokes
* the given view hierarchy's {@link View#onDetachedFromWindow()
* View.onDetachedFromWindow()} methods before returning. This is not
* for normal applications; using it correctly requires great care.
*
* @param view The view to be removed.
*/
public void removeViewImmediate(View view);
/**
* Returns the {@link WindowMetrics} according to the current system state.
* <p>
* The metrics describe the size of the area the window would occupy with
* {@link LayoutParams#MATCH_PARENT MATCH_PARENT} width and height, and the {@link WindowInsets}
* such a window would have.
* <p>
* The value of this is based on the <b>current</b> windowing state of the system.
*
* For example, for activities in multi-window mode, the metrics returned are based on the
* current bounds that the user has selected for the {@link android.app.Activity Activity}'s
* task.
* <p>
* In most scenarios, {@link #getCurrentWindowMetrics()} rather than
* {@link #getMaximumWindowMetrics()} is the correct API to use, since it ensures values reflect
* window size when the app is not fullscreen.
*
* @see #getMaximumWindowMetrics()
* @see WindowMetrics
*/
default @NonNull WindowMetrics getCurrentWindowMetrics() {
throw new UnsupportedOperationException();
}
/**
* Returns the largest {@link WindowMetrics} an app may expect in the current system state.
* <p>
* The value of this is based on the largest <b>potential</b> windowing state of the system.
*
* For example, for activities in multi-window mode, the metrics returned are based on the
* what the bounds would be if the user expanded the {@link android.app.Activity Activity}'s
* task to cover the entire screen.
* <p>
* The metrics describe the size of the largest potential area the window might occupy with
* {@link LayoutParams#MATCH_PARENT MATCH_PARENT} width and height, and the {@link WindowInsets}
* such a window would have.
* <p>
* Note that this might still be smaller than the size of the physical display if certain areas
* of the display are not available to windows created in this {@link Context}.
*
* For example, given that there's a device which have a multi-task mode to limit activities
* to a half screen. In this case, {@link #getMaximumWindowMetrics()} reports the bounds of
* the half screen which the activity is located.
* <p>
* <b>Generally {@link #getCurrentWindowMetrics()} is the correct API to use</b> for choosing
* UI layouts. {@link #getMaximumWindowMetrics()} are only appropriate when the application
* needs to know the largest possible size it can occupy if the user expands/maximizes it on the
* screen.
*
* @see #getCurrentWindowMetrics()
* @see WindowMetrics
* @see Display#getRealSize(Point)
*/
default @NonNull WindowMetrics getMaximumWindowMetrics() {
throw new UnsupportedOperationException();
}
/**
* Returns a set of {@link WindowMetrics} for the given display. Each WindowMetrics instance
* is the maximum WindowMetrics for a device state. This is not guaranteed to include all
* possible device states.
*
* This API can only be used by Launcher.
*
* @param displayId the id of the logical display
* @hide
*/
default @NonNull Set<WindowMetrics> getPossibleMaximumWindowMetrics(int displayId) {
throw new UnsupportedOperationException();
}
/**
* Used to asynchronously request Keyboard Shortcuts from the focused window.
*
* @hide
*/
public interface KeyboardShortcutsReceiver {
/**
* Callback used when the focused window keyboard shortcuts are ready to be displayed.
*
* @param result The keyboard shortcuts to be displayed.
*/
void onKeyboardShortcutsReceived(List<KeyboardShortcutGroup> result);
}
/**
* Invoke screenshot flow to capture a full-screen image.
* @hide
*/
int TAKE_SCREENSHOT_FULLSCREEN = 1;
/**
* Invoke screenshot flow allowing the user to select a region.
* @hide
*/
int TAKE_SCREENSHOT_SELECTED_REGION = 2;
/**
* Invoke screenshot flow with an image provided by the caller.
* @hide
*/
int TAKE_SCREENSHOT_PROVIDED_IMAGE = 3;
/**
* Enum listing the types of screenshot requests available.
*
* @hide
*/
@IntDef({TAKE_SCREENSHOT_FULLSCREEN,
TAKE_SCREENSHOT_SELECTED_REGION,
TAKE_SCREENSHOT_PROVIDED_IMAGE})
@interface ScreenshotType {}
/**
* Enum listing the possible sources from which a screenshot was originated. Used for logging.
*
* @hide
*/
@IntDef({ScreenshotSource.SCREENSHOT_GLOBAL_ACTIONS,
ScreenshotSource.SCREENSHOT_KEY_CHORD,
ScreenshotSource.SCREENSHOT_KEY_OTHER,
ScreenshotSource.SCREENSHOT_OVERVIEW,
ScreenshotSource.SCREENSHOT_ACCESSIBILITY_ACTIONS,
ScreenshotSource.SCREENSHOT_OTHER,
ScreenshotSource.SCREENSHOT_VENDOR_GESTURE})
@interface ScreenshotSource {
int SCREENSHOT_GLOBAL_ACTIONS = 0;
int SCREENSHOT_KEY_CHORD = 1;
int SCREENSHOT_KEY_OTHER = 2;
int SCREENSHOT_OVERVIEW = 3;
int SCREENSHOT_ACCESSIBILITY_ACTIONS = 4;
int SCREENSHOT_OTHER = 5;
int SCREENSHOT_VENDOR_GESTURE = 6;
}
/**
* @hide
*/
public static final String PARCEL_KEY_SHORTCUTS_ARRAY = "shortcuts_array";
/**
* Request for keyboard shortcuts to be retrieved asynchronously.
*
* @param receiver The callback to be triggered when the result is ready.
*
* @hide
*/
public void requestAppKeyboardShortcuts(final KeyboardShortcutsReceiver receiver, int deviceId);
/**
* Return the touch region for the current IME window, or an empty region if there is none.
*
* @return The region of the IME that is accepting touch inputs, or null if there is no IME, no
* region or there was an error.
*
* @hide
*/
@SystemApi
@RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS)
public Region getCurrentImeTouchRegion();
/**
* Sets that the display should show its content when non-secure keyguard is shown.
*
* @param displayId Display ID.
* @param shouldShow Indicates that the display should show its content when non-secure keyguard
* is shown.
* @see KeyguardManager#isDeviceSecure()
* @see KeyguardManager#isDeviceLocked()
* @hide
*/
@TestApi
default void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow) {
}
/**
* Sets that the display should show system decors.
* <p>
* System decors include status bar, navigation bar, launcher.
* </p>
*
* @param displayId The id of the display.
* @param shouldShow Indicates that the display should show system decors.
* @see #shouldShowSystemDecors(int)
* @hide
*/
@TestApi
default void setShouldShowSystemDecors(int displayId, boolean shouldShow) {
}
/**
* Checks if the display supports showing system decors.
* <p>
* System decors include status bar, navigation bar, launcher.
* </p>
*
* @param displayId The id of the display.
* @see #setShouldShowSystemDecors(int, boolean)
* @hide
*/
@TestApi
default boolean shouldShowSystemDecors(int displayId) {
return false;
}
/**
* Sets the policy for how the display should show IME.
*
* @param displayId Display ID.
* @param imePolicy Indicates the policy for how the display should show IME.
* @hide
*/
@TestApi
default void setDisplayImePolicy(int displayId, @DisplayImePolicy int imePolicy) {
}
/**
* Indicates the policy for how the display should show IME.
*
* @param displayId The id of the display.
* @return The policy for how the display should show IME.
* @hide
*/
@TestApi
default @DisplayImePolicy int getDisplayImePolicy(int displayId) {
return DISPLAY_IME_POLICY_FALLBACK_DISPLAY;
}
/**
* <p>
* Returns whether cross-window blur is currently enabled. This affects both window blur behind
* (see {@link LayoutParams#setBlurBehindRadius}) and window background blur (see
* {@link Window#setBackgroundBlurRadius}).
* </p><p>
* Cross-window blur might not be supported by some devices due to GPU limitations. It can also
* be disabled at runtime, e.g. during battery saving mode, when multimedia tunneling is used or
* when minimal post processing is requested. In such situations, no blur will be computed or
* drawn, so the blur target area will not be blurred. To handle this, the app might want to
* change its theme to one that does not use blurs. To listen for cross-window blur
* enabled/disabled events, use {@link #addCrossWindowBlurEnabledListener}.
* </p>
*
* @see #addCrossWindowBlurEnabledListener
* @see LayoutParams#setBlurBehindRadius
* @see Window#setBackgroundBlurRadius
*/
default boolean isCrossWindowBlurEnabled() {
return false;
}
/**
* <p>
* Adds a listener, which will be called when cross-window blurs are enabled/disabled at
* runtime. This affects both window blur behind (see {@link LayoutParams#setBlurBehindRadius})
* and window background blur (see {@link Window#setBackgroundBlurRadius}).
* </p><p>
* Cross-window blur might not be supported by some devices due to GPU limitations. It can also
* be disabled at runtime, e.g. during battery saving mode, when multimedia tunneling is used or
* when minimal post processing is requested. In such situations, no blur will be computed or
* drawn, so the blur target area will not be blurred. To handle this, the app might want to
* change its theme to one that does not use blurs.
* </p><p>
* The listener will be called on the main thread.
* </p><p>
* If the listener is added successfully, it will be called immediately with the current
* cross-window blur enabled state.
* </p>
*
* @param listener the listener to be added. It will be called back with a boolean parameter,
* which is true if cross-window blur is enabled and false if it is disabled
*
* @see #removeCrossWindowBlurEnabledListener
* @see #isCrossWindowBlurEnabled
* @see LayoutParams#setBlurBehindRadius
* @see Window#setBackgroundBlurRadius
*/
default void addCrossWindowBlurEnabledListener(@NonNull Consumer<Boolean> listener) {
}
/**
* <p>
* Adds a listener, which will be called when cross-window blurs are enabled/disabled at
* runtime. This affects both window blur behind (see {@link LayoutParams#setBlurBehindRadius})
* and window background blur (see {@link Window#setBackgroundBlurRadius}).
* </p><p>
* Cross-window blur might not be supported by some devices due to GPU limitations. It can also
* be disabled at runtime, e.g. during battery saving mode, when multimedia tunneling is used or
* when minimal post processing is requested. In such situations, no blur will be computed or
* drawn, so the blur target area will not be blurred. To handle this, the app might want to
* change its theme to one that does not use blurs.
* </p><p>
* If the listener is added successfully, it will be called immediately with the current
* cross-window blur enabled state.
* </p>
*
* @param executor {@link Executor} to handle the listener callback
* @param listener the listener to be added. It will be called back with a boolean parameter,
* which is true if cross-window blur is enabled and false if it is disabled
*
* @see #removeCrossWindowBlurEnabledListener
* @see #isCrossWindowBlurEnabled
* @see LayoutParams#setBlurBehindRadius
* @see Window#setBackgroundBlurRadius
*/
default void addCrossWindowBlurEnabledListener(@NonNull @CallbackExecutor Executor executor,
@NonNull Consumer<Boolean> listener) {
}
/**
* Removes a listener, previously added with {@link #addCrossWindowBlurEnabledListener}
*
* @param listener the listener to be removed
*
* @see #addCrossWindowBlurEnabledListener
*/
default void removeCrossWindowBlurEnabledListener(@NonNull Consumer<Boolean> listener) {
}
/**
* @hide
*/
static String transitTypeToString(@TransitionType int type) {
switch (type) {
case TRANSIT_NONE: return "NONE";
case TRANSIT_OPEN: return "OPEN";
case TRANSIT_CLOSE: return "CLOSE";
case TRANSIT_TO_FRONT: return "TO_FRONT";
case TRANSIT_TO_BACK: return "TO_BACK";
case TRANSIT_RELAUNCH: return "RELAUNCH";
case TRANSIT_CHANGE: return "CHANGE";
case TRANSIT_KEYGUARD_GOING_AWAY: return "KEYGUARD_GOING_AWAY";
case TRANSIT_KEYGUARD_OCCLUDE: return "KEYGUARD_OCCLUDE";