Debian Codegraph @

core/java/android/view/WindowManagerPolicyConstants.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package android.view;
18
19 import static android.os.IInputConstants.POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY;
20
21 import android.annotation.IntDef;
22 import android.os.PowerManager;
23
24 import java.lang.annotation.Retention;
25 import java.lang.annotation.RetentionPolicy;
26
27 /**
28 * Constants for interfacing with WindowManagerService and WindowManagerPolicyInternal.
29 * @hide
30 */
31 public interface WindowManagerPolicyConstants {
32 // Policy flags. These flags are also defined in frameworks/base/include/ui/Input.h and
33 // frameworks/native/libs/input/android/os/IInputConstants.aidl
34 int FLAG_WAKE = 0x00000001;
35 int FLAG_VIRTUAL = 0x00000002;
36
37 int FLAG_INJECTED_FROM_ACCESSIBILITY = POLICY_FLAG_INJECTED_FROM_ACCESSIBILITY;
38 int FLAG_INJECTED = 0x01000000;
39 int FLAG_TRUSTED = 0x02000000;
40 int FLAG_FILTERED = 0x04000000;
41 int FLAG_DISABLE_KEY_REPEAT = 0x08000000;
42
43 int FLAG_INTERACTIVE = 0x20000000;
44 int FLAG_PASS_TO_USER = 0x40000000;
45
46 // Flags for IActivityTaskManager.keyguardGoingAway()
47 int KEYGUARD_GOING_AWAY_FLAG_TO_SHADE = 1 << 0;
48 int KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS = 1 << 1;
49 int KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER = 1 << 2;
50 int KEYGUARD_GOING_AWAY_FLAG_SUBTLE_WINDOW_ANIMATIONS = 1 << 3;
51 int KEYGUARD_GOING_AWAY_FLAG_TO_LAUNCHER_CLEAR_SNAPSHOT = 1 << 4;
52
53 // Flags used for indicating whether the internal and/or external input devices
54 // of some type are available.
55 int PRESENCE_INTERNAL = 1 << 0;
56 int PRESENCE_EXTERNAL = 1 << 1;
57
58 // Alternate bars position values
59 int ALT_BAR_UNKNOWN = -1;
60 int ALT_BAR_LEFT = 1 << 0;
61 int ALT_BAR_RIGHT = 1 << 1;
62 int ALT_BAR_BOTTOM = 1 << 2;
63 int ALT_BAR_TOP = 1 << 3;
64
65 // Navigation bar position values
66 int NAV_BAR_INVALID = -1;
67 int NAV_BAR_LEFT = 1 << 0;
68 int NAV_BAR_RIGHT = 1 << 1;
69 int NAV_BAR_BOTTOM = 1 << 2;
70
71 // Navigation bar interaction modes
72 int NAV_BAR_MODE_3BUTTON = 0;
73 int NAV_BAR_MODE_2BUTTON = 1;
74 int NAV_BAR_MODE_GESTURAL = 2;
75
76 // Associated overlays for each nav bar mode
77 String NAV_BAR_MODE_3BUTTON_OVERLAY = "com.android.internal.systemui.navbar.threebutton";
78 String NAV_BAR_MODE_2BUTTON_OVERLAY = "com.android.internal.systemui.navbar.twobutton";
79 String NAV_BAR_MODE_GESTURAL_OVERLAY = "com.android.internal.systemui.navbar.gestural";
80
81 /**
82 * Sticky broadcast of the current HDMI plugged state.
83 */
84 String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
85
86 /**
87 * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
88 * plugged in to HDMI, false if not.
89 */
90 String EXTRA_HDMI_PLUGGED_STATE = "state";
91
92 /**
93 * Set to {@code true} when intent was invoked from pressing the home key.
94 * @hide
95 */
96 String EXTRA_FROM_HOME_KEY = "android.intent.extra.FROM_HOME_KEY";
97
98 /**
99 * Extra for the start reason of the HOME intent.
100 * Will be {@link PowerManager#WAKE_REASON_WAKE_KEY} or
101 * {@link PowerManager#WAKE_REASON_POWER_BUTTON} when intent was sent through
102 * {@link PhoneWindowManager#shouldWakeUpWithHomeIntent}.
103 * @hide
104 */
105 String EXTRA_START_REASON = "android.intent.extra.EXTRA_START_REASON";
106
107 // TODO: move this to a more appropriate place.
108 interface PointerEventListener {
109 /**
110 * 1. onPointerEvent will be called on the service.UiThread.
111 * 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a
112 * copy() must be made and the copy must be recycled.
113 **/
114 void onPointerEvent(MotionEvent motionEvent);
115 }
116
117 @IntDef(prefix = { "OFF_BECAUSE_OF_" }, value = {
118 OFF_BECAUSE_OF_ADMIN,
119 OFF_BECAUSE_OF_USER,
120 OFF_BECAUSE_OF_TIMEOUT,
121 })
122 @Retention(RetentionPolicy.SOURCE)
123 public @interface OffReason{}
124
125 static @OffReason int translateSleepReasonToOffReason(
126 @PowerManager.GoToSleepReason int reason) {
127 switch (reason) {
128 case PowerManager.GO_TO_SLEEP_REASON_DEVICE_ADMIN:
129 return OFF_BECAUSE_OF_ADMIN;
130 case PowerManager.GO_TO_SLEEP_REASON_TIMEOUT:
131 case PowerManager.GO_TO_SLEEP_REASON_INATTENTIVE:
132 return OFF_BECAUSE_OF_TIMEOUT;
133 default:
134 return OFF_BECAUSE_OF_USER;
135 }
136 }
137
138 /** Screen turned off because of a device admin */
139 int OFF_BECAUSE_OF_ADMIN = 1;
140 /** Screen turned off because of power button */
141 int OFF_BECAUSE_OF_USER = 2;
142 /** Screen turned off because of timeout */
143 int OFF_BECAUSE_OF_TIMEOUT = 3;
144
145 @IntDef(prefix = { "ON_BECAUSE_OF_" }, value = {
146 ON_BECAUSE_OF_USER,
147 ON_BECAUSE_OF_APPLICATION,
148 ON_BECAUSE_OF_UNKNOWN,
149 })
150 @Retention(RetentionPolicy.SOURCE)
151 public @interface OnReason{}
152
153 /** Convert the on reason to a human readable format */
154 static String onReasonToString(@OnReason int why) {
155 switch (why) {
156 case ON_BECAUSE_OF_USER:
157 return "ON_BECAUSE_OF_USER";
158 case ON_BECAUSE_OF_APPLICATION:
159 return "ON_BECAUSE_OF_APPLICATION";
160 case ON_BECAUSE_OF_UNKNOWN:
161 return "ON_BECAUSE_OF_UNKNOWN";
162 default:
163 return Integer.toString(why);
164 }
165 }
166
167 static @OnReason int translateWakeReasonToOnReason(@PowerManager.WakeReason int reason) {
168 switch (reason) {
169 case PowerManager.WAKE_REASON_POWER_BUTTON:
170 case PowerManager.WAKE_REASON_PLUGGED_IN:
171 case PowerManager.WAKE_REASON_GESTURE:
172 case PowerManager.WAKE_REASON_TAP:
173 case PowerManager.WAKE_REASON_LIFT:
174 case PowerManager.WAKE_REASON_BIOMETRIC:
175 case PowerManager.WAKE_REASON_CAMERA_LAUNCH:
176 case PowerManager.WAKE_REASON_WAKE_KEY:
177 case PowerManager.WAKE_REASON_WAKE_MOTION:
178 case PowerManager.WAKE_REASON_LID:
179 return ON_BECAUSE_OF_USER;
180 case PowerManager.WAKE_REASON_APPLICATION:
181 return ON_BECAUSE_OF_APPLICATION;
182 default:
183 return ON_BECAUSE_OF_UNKNOWN;
184 }
185 }
186
187 /** Screen turned on because of a user-initiated action. */
188 int ON_BECAUSE_OF_USER = 1;
189 /** Screen turned on because of an application request or event */
190 int ON_BECAUSE_OF_APPLICATION = 2;
191 /** Screen turned on for an unknown reason */
192 int ON_BECAUSE_OF_UNKNOWN = 3;
193
194 int APPLICATION_LAYER = 2;
195 int APPLICATION_MEDIA_SUBLAYER = -2;
196 int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1;
197 int APPLICATION_PANEL_SUBLAYER = 1;
198 int APPLICATION_SUB_PANEL_SUBLAYER = 2;
199 int APPLICATION_ABOVE_SUB_PANEL_SUBLAYER = 3;
200
201 /**
202 * Convert the off reason to a human readable format.
203 */
204 static String offReasonToString(int why) {
205 switch (why) {
206 case OFF_BECAUSE_OF_ADMIN:
207 return "OFF_BECAUSE_OF_ADMIN";
208 case OFF_BECAUSE_OF_USER:
209 return "OFF_BECAUSE_OF_USER";
210 case OFF_BECAUSE_OF_TIMEOUT:
211 return "OFF_BECAUSE_OF_TIMEOUT";
212 default:
213 return Integer.toString(why);
214 }
215 }
216
217 /**
218 * How much to multiply the policy's type layer, to reserve room
219 * for multiple windows of the same type and Z-ordering adjustment
220 * with TYPE_LAYER_OFFSET.
221 */
222 int TYPE_LAYER_MULTIPLIER = 10000;
223
224 /**
225 * Offset from TYPE_LAYER_MULTIPLIER for moving a group of windows above
226 * or below others in the same layer.
227 */
228 int TYPE_LAYER_OFFSET = 1000;
229
230 /**
231 * How much to increment the layer for each window, to reserve room
232 * for effect surfaces between them.
233 */
234 int WINDOW_LAYER_MULTIPLIER = 5;
235
236 /**
237 * Animation thumbnail is as far as possible below the window above
238 * the thumbnail (or in other words as far as possible above the window
239 * below it).
240 */
241 int LAYER_OFFSET_THUMBNAIL = WINDOW_LAYER_MULTIPLIER - 1;
242
243 int WATERMARK_LAYER = TYPE_LAYER_MULTIPLIER * 100;
244 int STRICT_MODE_LAYER = TYPE_LAYER_MULTIPLIER * 101;
245 int WINDOW_FREEZE_LAYER = TYPE_LAYER_MULTIPLIER * 200;
246
247 /**
248 * Layers for screen rotation animation. We put these layers above
249 * WINDOW_FREEZE_LAYER so that screen freeze will cover all windows.
250 */
251 int SCREEN_FREEZE_LAYER_BASE = WINDOW_FREEZE_LAYER + TYPE_LAYER_MULTIPLIER;
252 }