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