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