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 52 // Flags used for indicating whether the internal and/or external input devices 53 // of some type are available. 54 int PRESENCE_INTERNAL = 1 << 0; 55 int PRESENCE_EXTERNAL = 1 << 1; 56 57 // Alternate bars position values 58 int ALT_BAR_UNKNOWN = -1; 59 int ALT_BAR_LEFT = 1 << 0; 60 int ALT_BAR_RIGHT = 1 << 1; 61 int ALT_BAR_BOTTOM = 1 << 2; 62 int ALT_BAR_TOP = 1 << 3; 63 64 // Navigation bar position values 65 int NAV_BAR_INVALID = -1; 66 int NAV_BAR_LEFT = 1 << 0; 67 int NAV_BAR_RIGHT = 1 << 1; 68 int NAV_BAR_BOTTOM = 1 << 2; 69 70 // Navigation bar interaction modes 71 int NAV_BAR_MODE_3BUTTON = 0; 72 int NAV_BAR_MODE_2BUTTON = 1; 73 int NAV_BAR_MODE_GESTURAL = 2; 74 75 // Associated overlays for each nav bar mode 76 String NAV_BAR_MODE_3BUTTON_OVERLAY = "com.android.internal.systemui.navbar.threebutton"; 77 String NAV_BAR_MODE_2BUTTON_OVERLAY = "com.android.internal.systemui.navbar.twobutton"; 78 String NAV_BAR_MODE_GESTURAL_OVERLAY = "com.android.internal.systemui.navbar.gestural"; 79 80 /** 81 * Sticky broadcast of the current HDMI plugged state. 82 */ 83 String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED"; 84 85 /** 86 * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if 87 * plugged in to HDMI, false if not. 88 */ 89 String EXTRA_HDMI_PLUGGED_STATE = "state"; 90 91 /** 92 * Set to {@code true} when intent was invoked from pressing the home key. 93 * @hide 94 */ 95 String EXTRA_FROM_HOME_KEY = "android.intent.extra.FROM_HOME_KEY"; 96 97 /** 98 * Extra for the start reason of the HOME intent. 99 * Will be {@link PowerManager#WAKE_REASON_WAKE_KEY} or 100 * {@link PowerManager#WAKE_REASON_POWER_BUTTON} when intent was sent through 101 * {@link PhoneWindowManager#shouldWakeUpWithHomeIntent}. 102 * @hide 103 */ 104 String EXTRA_START_REASON = "android.intent.extra.EXTRA_START_REASON"; 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_CAMERA_LAUNCH: 172 case PowerManager.WAKE_REASON_WAKE_KEY: 173 case PowerManager.WAKE_REASON_WAKE_MOTION: 174 case PowerManager.WAKE_REASON_LID: 175 return ON_BECAUSE_OF_USER; 176 case PowerManager.WAKE_REASON_APPLICATION: 177 return ON_BECAUSE_OF_APPLICATION; 178 default: 179 return ON_BECAUSE_OF_UNKNOWN; 180 } 181 } 182 183 /** Screen turned on because of a user-initiated action. */ 184 int ON_BECAUSE_OF_USER = 1; 185 /** Screen turned on because of an application request or event */ 186 int ON_BECAUSE_OF_APPLICATION = 2; 187 /** Screen turned on for an unknown reason */ 188 int ON_BECAUSE_OF_UNKNOWN = 3; 189 190 int APPLICATION_LAYER = 2; 191 int APPLICATION_MEDIA_SUBLAYER = -2; 192 int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1; 193 int APPLICATION_PANEL_SUBLAYER = 1; 194 int APPLICATION_SUB_PANEL_SUBLAYER = 2; 195 int APPLICATION_ABOVE_SUB_PANEL_SUBLAYER = 3; 196 197 /** 198 * Convert the off reason to a human readable format. 199 */ offReasonToString(int why)200 static String offReasonToString(int why) { 201 switch (why) { 202 case OFF_BECAUSE_OF_ADMIN: 203 return "OFF_BECAUSE_OF_ADMIN"; 204 case OFF_BECAUSE_OF_USER: 205 return "OFF_BECAUSE_OF_USER"; 206 case OFF_BECAUSE_OF_TIMEOUT: 207 return "OFF_BECAUSE_OF_TIMEOUT"; 208 default: 209 return Integer.toString(why); 210 } 211 } 212 } 213