The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1 | /* |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2 | * |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | package com.android.internal.policy.impl; |
| 17 | |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 18 | import android.app.ActivityManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 19 | import android.app.ActivityManagerNative; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 20 | import android.app.AppOpsManager; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 21 | import android.app.IUiModeManager; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 22 | import android.app.ProgressDialog; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 23 | import android.app.SearchManager; |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 24 | import android.app.UiModeManager; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 25 | import android.content.ActivityNotFoundException; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 26 | import android.content.BroadcastReceiver; |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 27 | import android.content.ComponentName; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 28 | import android.content.ContentResolver; |
| 29 | import android.content.Context; |
| 30 | import android.content.Intent; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 31 | import android.content.IntentFilter; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 32 | import android.content.ServiceConnection; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 33 | import android.content.pm.ActivityInfo; |
| 34 | import android.content.pm.PackageManager; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 35 | import android.content.pm.ResolveInfo; |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 36 | import android.content.res.CompatibilityInfo; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 37 | import android.content.res.Configuration; |
| 38 | import android.content.res.Resources; |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 39 | import android.content.res.TypedArray; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 40 | import android.database.ContentObserver; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 41 | import android.graphics.PixelFormat; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 42 | import android.graphics.Rect; |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 43 | import android.media.AudioManager; |
| 44 | import android.media.IAudioService; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 45 | import android.media.Ringtone; |
| 46 | import android.media.RingtoneManager; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 47 | import android.os.Bundle; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 48 | import android.os.FactoryTest; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 49 | import android.os.Handler; |
| 50 | import android.os.IBinder; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 51 | import android.os.IRemoteCallback; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 52 | import android.os.Looper; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 53 | import android.os.Message; |
| 54 | import android.os.Messenger; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 55 | import android.os.PowerManager; |
| 56 | import android.os.RemoteException; |
| 57 | import android.os.ServiceManager; |
| 58 | import android.os.SystemClock; |
| 59 | import android.os.SystemProperties; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 60 | import android.os.UEventObserver; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 61 | import android.os.UserHandle; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 62 | import android.os.Vibrator; |
| 63 | import android.provider.Settings; |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 64 | import android.service.dreams.DreamService; |
| 65 | import android.service.dreams.IDreamManager; |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 66 | import android.util.DisplayMetrics; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 67 | import android.util.EventLog; |
| 68 | import android.util.Log; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 69 | import android.util.Slog; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 70 | import android.util.SparseArray; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 71 | import android.view.Display; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 72 | import android.view.Gravity; |
| 73 | import android.view.HapticFeedbackConstants; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 74 | import android.view.IApplicationToken; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 75 | import android.view.IWindowManager; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 76 | import android.view.InputChannel; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 77 | import android.view.InputDevice; |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 78 | import android.view.InputEvent; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 79 | import android.view.InputEventReceiver; |
Jeff Brown | 6b53e8d | 2010-11-10 16:03:06 -0800 | [diff] [blame] | 80 | import android.view.KeyCharacterMap; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 81 | import android.view.KeyCharacterMap.FallbackAction; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 82 | import android.view.KeyEvent; |
| 83 | import android.view.MotionEvent; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 84 | import android.view.Surface; |
| 85 | import android.view.View; |
| 86 | import android.view.ViewConfiguration; |
| 87 | import android.view.Window; |
| 88 | import android.view.WindowManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 89 | import android.view.WindowManagerGlobal; |
| 90 | import android.view.WindowManagerPolicy; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 91 | import android.view.accessibility.AccessibilityEvent; |
| 92 | import android.view.animation.Animation; |
| 93 | import android.view.animation.AnimationUtils; |
| 94 | |
| 95 | import com.android.internal.R; |
| 96 | import com.android.internal.policy.PolicyManager; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 97 | import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 98 | import com.android.internal.statusbar.IStatusBarService; |
| 99 | import com.android.internal.telephony.ITelephony; |
| 100 | import com.android.internal.widget.PointerLocationView; |
| 101 | |
| 102 | import java.io.File; |
| 103 | import java.io.FileReader; |
| 104 | import java.io.IOException; |
| 105 | import java.io.PrintWriter; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 106 | import java.util.HashSet; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 107 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 108 | import static android.view.WindowManager.LayoutParams.*; |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 109 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; |
| 110 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; |
| 111 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 112 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 113 | /** |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 114 | * WindowManagerPolicy implementation for the Android phone UI. This |
| 115 | * introduces a new method suffix, Lp, for an internal lock of the |
| 116 | * PhoneWindowManager. This is used to protect some internal state, and |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 117 | * can be acquired with either the Lw and Li lock held, so has the restrictions |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 118 | * of both of those when held. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 119 | */ |
| 120 | public class PhoneWindowManager implements WindowManagerPolicy { |
| 121 | static final String TAG = "WindowManager"; |
| 122 | static final boolean DEBUG = false; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 123 | static final boolean localLOGV = false; |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 124 | static final boolean DEBUG_LAYOUT = false; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 125 | static final boolean DEBUG_INPUT = false; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 126 | static final boolean DEBUG_STARTING_WINDOW = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 127 | static final boolean SHOW_STARTING_ANIMATIONS = true; |
| 128 | static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 129 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 130 | // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. |
| 131 | // No longer recommended for desk docks; still useful in car docks. |
| 132 | static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; |
| 133 | static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; |
| 134 | |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 135 | static final int LONG_PRESS_POWER_NOTHING = 0; |
| 136 | static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; |
| 137 | static final int LONG_PRESS_POWER_SHUT_OFF = 2; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 138 | static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 139 | |
| 140 | // These need to match the documentation/constant in |
| 141 | // core/res/res/values/config.xml |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 142 | static final int LONG_PRESS_HOME_NOTHING = 0; |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 143 | static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 144 | static final int LONG_PRESS_HOME_ASSIST = 2; |
| 145 | |
| 146 | static final int DOUBLE_TAP_HOME_NOTHING = 0; |
| 147 | static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 148 | |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 149 | static final int APPLICATION_MEDIA_SUBLAYER = -2; |
| 150 | static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 151 | static final int APPLICATION_PANEL_SUBLAYER = 1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 152 | static final int APPLICATION_SUB_PANEL_SUBLAYER = 2; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 153 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 154 | static public final String SYSTEM_DIALOG_REASON_KEY = "reason"; |
| 155 | static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions"; |
| 156 | static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 157 | static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 158 | static public final String SYSTEM_DIALOG_REASON_ASSIST = "assist"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 159 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 160 | /** |
| 161 | * These are the system UI flags that, when changing, can cause the layout |
| 162 | * of the screen to change. |
| 163 | */ |
| 164 | static final int SYSTEM_UI_CHANGING_LAYOUT = |
| 165 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; |
| 166 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 167 | /** |
| 168 | * Keyguard stuff |
| 169 | */ |
| 170 | private WindowState mKeyguardScrim; |
| 171 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 172 | /* Table of Application Launch keys. Maps from key codes to intent categories. |
| 173 | * |
| 174 | * These are special keys that are used to launch particular kinds of applications, |
| 175 | * such as a web browser. HID defines nearly a hundred of them in the Consumer (0x0C) |
| 176 | * usage page. We don't support quite that many yet... |
| 177 | */ |
| 178 | static SparseArray<String> sApplicationLaunchKeyCategories; |
| 179 | static { |
| 180 | sApplicationLaunchKeyCategories = new SparseArray<String>(); |
| 181 | sApplicationLaunchKeyCategories.append( |
| 182 | KeyEvent.KEYCODE_EXPLORER, Intent.CATEGORY_APP_BROWSER); |
| 183 | sApplicationLaunchKeyCategories.append( |
| 184 | KeyEvent.KEYCODE_ENVELOPE, Intent.CATEGORY_APP_EMAIL); |
| 185 | sApplicationLaunchKeyCategories.append( |
| 186 | KeyEvent.KEYCODE_CONTACTS, Intent.CATEGORY_APP_CONTACTS); |
| 187 | sApplicationLaunchKeyCategories.append( |
| 188 | KeyEvent.KEYCODE_CALENDAR, Intent.CATEGORY_APP_CALENDAR); |
| 189 | sApplicationLaunchKeyCategories.append( |
| 190 | KeyEvent.KEYCODE_MUSIC, Intent.CATEGORY_APP_MUSIC); |
| 191 | sApplicationLaunchKeyCategories.append( |
| 192 | KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); |
| 193 | } |
| 194 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 195 | /** |
| 196 | * Lock protecting internal state. Must not call out into window |
| 197 | * manager with lock held. (This lock will be acquired in places |
| 198 | * where the window manager is calling in with its own lock held.) |
| 199 | */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 200 | private final Object mLock = new Object(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 201 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 202 | Context mContext; |
| 203 | IWindowManager mWindowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 204 | WindowManagerFuncs mWindowManagerFuncs; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 205 | PowerManager mPowerManager; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 206 | IStatusBarService mStatusBarService; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 207 | boolean mPreloadedRecentApps; |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 208 | final Object mServiceAquireLock = new Object(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 209 | Vibrator mVibrator; // Vibrator for giving feedback of orientation changes |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 210 | SearchManager mSearchManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 211 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 212 | // Vibrator pattern for haptic feedback of a long press. |
| 213 | long[] mLongPressVibePattern; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 214 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 215 | // Vibrator pattern for haptic feedback of virtual key press. |
| 216 | long[] mVirtualKeyVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 217 | |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 218 | // Vibrator pattern for a short vibration. |
| 219 | long[] mKeyboardTapVibePattern; |
| 220 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 221 | // Vibrator pattern for haptic feedback during boot when safe mode is disabled. |
| 222 | long[] mSafeModeDisabledVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 223 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 224 | // Vibrator pattern for haptic feedback during boot when safe mode is enabled. |
| 225 | long[] mSafeModeEnabledVibePattern; |
Romain Guy | 8154cd3 | 2010-03-29 14:41:15 -0700 | [diff] [blame] | 226 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 227 | /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */ |
| 228 | boolean mEnableShiftMenuBugReports = false; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 229 | |
| 230 | boolean mHeadless; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 231 | boolean mSafeMode; |
| 232 | WindowState mStatusBar = null; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 233 | int mStatusBarHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 234 | WindowState mNavigationBar = null; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 235 | boolean mHasNavigationBar = false; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 236 | boolean mCanHideNavigationBar = false; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 237 | boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side? |
| 238 | boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*? |
| 239 | int[] mNavigationBarHeightForRotation = new int[4]; |
| 240 | int[] mNavigationBarWidthForRotation = new int[4]; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 241 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 242 | WindowState mKeyguard = null; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 243 | KeyguardServiceDelegate mKeyguardDelegate; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 244 | GlobalActions mGlobalActions; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 245 | volatile boolean mPowerKeyHandled; // accessed from input reader and handler thread |
| 246 | boolean mPendingPowerKeyUpCanceled; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 247 | Handler mHandler; |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 248 | WindowState mLastInputMethodWindow = null; |
| 249 | WindowState mLastInputMethodTargetWindow = null; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 250 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 251 | static final int RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS = 0; |
| 252 | static final int RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW = 1; |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 253 | static final int RECENT_APPS_BEHAVIOR_DISMISS = 2; |
| 254 | static final int RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH = 3; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 255 | |
| 256 | RecentApplicationsDialog mRecentAppsDialog; |
| 257 | int mRecentAppsDialogHeldModifiers; |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 258 | boolean mLanguageSwitchKeyPressed; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 259 | |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 260 | int mLidState = LID_ABSENT; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 261 | boolean mHaveBuiltInKeyboard; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 262 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 263 | boolean mSystemReady; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 264 | boolean mSystemBooted; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 265 | boolean mHdmiPlugged; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 266 | int mUiMode; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 267 | int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 268 | int mLidOpenRotation; |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 269 | int mCarDockRotation; |
| 270 | int mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 271 | int mUndockedHdmiRotation; |
| 272 | int mDemoHdmiRotation; |
| 273 | boolean mDemoHdmiRotationLock; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 274 | |
| 275 | int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; |
| 276 | int mUserRotation = Surface.ROTATION_0; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 277 | boolean mAccelerometerDefault; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 278 | |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 279 | int mAllowAllRotations = -1; |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 280 | boolean mCarDockEnablesAccelerometer; |
| 281 | boolean mDeskDockEnablesAccelerometer; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 282 | int mLidKeyboardAccessibility; |
| 283 | int mLidNavigationAccessibility; |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 284 | boolean mLidControlsSleep; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 285 | int mLongPressOnPowerBehavior = -1; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 286 | boolean mScreenOnEarly = false; |
| 287 | boolean mScreenOnFully = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 288 | boolean mOrientationSensorEnabled = false; |
| 289 | int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 290 | boolean mHasSoftInput = false; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 291 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 292 | int mPointerLocationMode = 0; // guarded by mLock |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 293 | |
| 294 | // The last window we were told about in focusChanged. |
| 295 | WindowState mFocusedWindow; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 296 | IApplicationToken mFocusedApp; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 297 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 298 | private final class PointerLocationPointerEventListener implements PointerEventListener { |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 299 | @Override |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 300 | public void onPointerEvent(MotionEvent motionEvent) { |
| 301 | if (mPointerLocationView != null) { |
| 302 | mPointerLocationView.addPointerEvent(motionEvent); |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 303 | } |
| 304 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 305 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 306 | |
| 307 | // Pointer location view state, only modified on the mHandler Looper. |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 308 | PointerLocationPointerEventListener mPointerLocationPointerEventListener; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 309 | PointerLocationView mPointerLocationView; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 310 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 311 | // The current size of the screen; really; extends into the overscan area of |
| 312 | // the screen and doesn't account for any system elements like the status bar. |
| 313 | int mOverscanScreenLeft, mOverscanScreenTop; |
| 314 | int mOverscanScreenWidth, mOverscanScreenHeight; |
| 315 | // The current visible size of the screen; really; (ir)regardless of whether the status |
| 316 | // bar can be hidden but not extending into the overscan area. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 317 | int mUnrestrictedScreenLeft, mUnrestrictedScreenTop; |
| 318 | int mUnrestrictedScreenWidth, mUnrestrictedScreenHeight; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 319 | // Like mOverscanScreen*, but allowed to move into the overscan region where appropriate. |
| 320 | int mRestrictedOverscanScreenLeft, mRestrictedOverscanScreenTop; |
| 321 | int mRestrictedOverscanScreenWidth, mRestrictedOverscanScreenHeight; |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 322 | // The current size of the screen; these may be different than (0,0)-(dw,dh) |
| 323 | // if the status bar can't be hidden; in that case it effectively carves out |
| 324 | // that area of the display from all other windows. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 325 | int mRestrictedScreenLeft, mRestrictedScreenTop; |
| 326 | int mRestrictedScreenWidth, mRestrictedScreenHeight; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 327 | // During layout, the current screen borders accounting for any currently |
| 328 | // visible system UI elements. |
| 329 | int mSystemLeft, mSystemTop, mSystemRight, mSystemBottom; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 330 | // For applications requesting stable content insets, these are them. |
| 331 | int mStableLeft, mStableTop, mStableRight, mStableBottom; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 332 | // For applications requesting stable content insets but have also set the |
| 333 | // fullscreen window flag, these are the stable dimensions without the status bar. |
| 334 | int mStableFullscreenLeft, mStableFullscreenTop; |
| 335 | int mStableFullscreenRight, mStableFullscreenBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 336 | // During layout, the current screen borders with all outer decoration |
| 337 | // (status bar, input method dock) accounted for. |
| 338 | int mCurLeft, mCurTop, mCurRight, mCurBottom; |
| 339 | // During layout, the frame in which content should be displayed |
| 340 | // to the user, accounting for all screen decoration except for any |
| 341 | // space they deem as available for other content. This is usually |
| 342 | // the same as mCur*, but may be larger if the screen decor has supplied |
| 343 | // content insets. |
| 344 | int mContentLeft, mContentTop, mContentRight, mContentBottom; |
Dianne Hackborn | 8e11ef0 | 2010-11-18 19:47:42 -0800 | [diff] [blame] | 345 | // During layout, the current screen borders along which input method |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 346 | // windows are placed. |
| 347 | int mDockLeft, mDockTop, mDockRight, mDockBottom; |
| 348 | // During layout, the layer at which the doc window is placed. |
| 349 | int mDockLayer; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 350 | // During layout, this is the layer of the status bar. |
| 351 | int mStatusBarLayer; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 352 | int mLastSystemUiFlags; |
| 353 | // Bits that we are in the process of clearing, so we want to prevent |
| 354 | // them from being set by applications until everything has been updated |
| 355 | // to have them clear. |
| 356 | int mResettingSystemUiFlags = 0; |
| 357 | // Bits that we are currently always keeping cleared. |
| 358 | int mForceClearedSystemUiFlags = 0; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 359 | // What we last reported to system UI about whether the compatibility |
| 360 | // menu needs to be displayed. |
| 361 | boolean mLastFocusNeedsMenu = false; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 362 | |
| 363 | FakeWindow mHideNavFakeWindow = null; |
| 364 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 365 | static final Rect mTmpParentFrame = new Rect(); |
| 366 | static final Rect mTmpDisplayFrame = new Rect(); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 367 | static final Rect mTmpOverscanFrame = new Rect(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 368 | static final Rect mTmpContentFrame = new Rect(); |
| 369 | static final Rect mTmpVisibleFrame = new Rect(); |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 370 | static final Rect mTmpNavigationFrame = new Rect(); |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 371 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 372 | WindowState mTopFullscreenOpaqueWindowState; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 373 | boolean mTopIsFullscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 374 | boolean mForceStatusBar; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 375 | boolean mForceStatusBarFromKeyguard; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 376 | boolean mHideLockScreen; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 377 | boolean mForcingShowNavBar; |
| 378 | int mForcingShowNavBarLayer; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 379 | |
| 380 | // States of keyguard dismiss. |
| 381 | private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed. |
| 382 | private static final int DISMISS_KEYGUARD_START = 1; // Keyguard needs to be dismissed. |
| 383 | private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed. |
| 384 | int mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
| 385 | |
| 386 | /** The window that is currently dismissing the keyguard. Dismissing the keyguard must only |
| 387 | * be done once per window. */ |
| 388 | private WindowState mWinDismissingKeyguard; |
| 389 | |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 390 | boolean mShowingLockscreen; |
| 391 | boolean mShowingDream; |
| 392 | boolean mDreamingLockscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 393 | boolean mHomePressed; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 394 | boolean mHomeConsumed; |
| 395 | boolean mHomeDoubleTapPending; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 396 | Intent mHomeIntent; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 397 | Intent mCarDockIntent; |
| 398 | Intent mDeskDockIntent; |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 399 | boolean mSearchKeyShortcutPending; |
| 400 | boolean mConsumeSearchKeyUp; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 401 | boolean mAssistKeyLongPressed; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 402 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 403 | // support for activating the lock screen while the screen is on |
| 404 | boolean mAllowLockscreenWhenOn; |
| 405 | int mLockScreenTimeout; |
| 406 | boolean mLockScreenTimerActive; |
| 407 | |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 408 | // Behavior of ENDCALL Button. (See Settings.System.END_BUTTON_BEHAVIOR.) |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 409 | int mEndcallBehavior; |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 410 | |
| 411 | // Behavior of POWER button while in-call and screen on. |
| 412 | // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) |
| 413 | int mIncallPowerBehavior; |
| 414 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 415 | Display mDisplay; |
| 416 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 417 | int mLandscapeRotation = 0; // default landscape rotation |
| 418 | int mSeascapeRotation = 0; // "other" landscape rotation, 180 degrees from mLandscapeRotation |
| 419 | int mPortraitRotation = 0; // default portrait rotation |
| 420 | int mUpsideDownRotation = 0; // "other" portrait rotation |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 421 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 422 | int mOverscanLeft = 0; |
| 423 | int mOverscanTop = 0; |
| 424 | int mOverscanRight = 0; |
| 425 | int mOverscanBottom = 0; |
| 426 | |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 427 | // What we do when the user long presses on home |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 428 | private int mLongPressOnHomeBehavior; |
| 429 | |
| 430 | // What we do when the user double-taps on home |
| 431 | private int mDoubleTapOnHomeBehavior; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 432 | |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 433 | // Screenshot trigger states |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 434 | // Time to volume and power must be pressed within this interval of each other. |
| 435 | private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150; |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 436 | // Increase the chord delay when taking a screenshot from the keyguard |
| 437 | private static final float KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER = 2.5f; |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 438 | private boolean mScreenshotChordEnabled; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 439 | private boolean mVolumeDownKeyTriggered; |
| 440 | private long mVolumeDownKeyTime; |
| 441 | private boolean mVolumeDownKeyConsumedByScreenshotChord; |
| 442 | private boolean mVolumeUpKeyTriggered; |
| 443 | private boolean mPowerKeyTriggered; |
| 444 | private long mPowerKeyTime; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 445 | |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 446 | /* The number of steps between min and max brightness */ |
| 447 | private static final int BRIGHTNESS_STEPS = 10; |
| 448 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 449 | SettingsObserver mSettingsObserver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 450 | ShortcutManager mShortcutManager; |
| 451 | PowerManager.WakeLock mBroadcastWakeLock; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 452 | boolean mHavePendingMediaKeyRepeatWithWakeLock; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 453 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 454 | // Maps global key codes to the components that will handle them. |
| 455 | private GlobalKeyManager mGlobalKeyManager; |
| 456 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 457 | // Fallback actions by key code. |
| 458 | private final SparseArray<KeyCharacterMap.FallbackAction> mFallbackActions = |
| 459 | new SparseArray<KeyCharacterMap.FallbackAction>(); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 460 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 461 | private static final int MSG_ENABLE_POINTER_LOCATION = 1; |
| 462 | private static final int MSG_DISABLE_POINTER_LOCATION = 2; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 463 | private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; |
| 464 | private static final int MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK = 4; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 465 | |
| 466 | private class PolicyHandler extends Handler { |
| 467 | @Override |
| 468 | public void handleMessage(Message msg) { |
| 469 | switch (msg.what) { |
| 470 | case MSG_ENABLE_POINTER_LOCATION: |
| 471 | enablePointerLocation(); |
| 472 | break; |
| 473 | case MSG_DISABLE_POINTER_LOCATION: |
| 474 | disablePointerLocation(); |
| 475 | break; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 476 | case MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK: |
| 477 | dispatchMediaKeyWithWakeLock((KeyEvent)msg.obj); |
| 478 | break; |
| 479 | case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK: |
| 480 | dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj); |
| 481 | break; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 482 | } |
| 483 | } |
| 484 | } |
| 485 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 486 | private UEventObserver mHDMIObserver = new UEventObserver() { |
| 487 | @Override |
| 488 | public void onUEvent(UEventObserver.UEvent event) { |
| 489 | setHdmiPlugged("1".equals(event.get("SWITCH_STATE"))); |
| 490 | } |
| 491 | }; |
| 492 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 493 | class SettingsObserver extends ContentObserver { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 494 | SettingsObserver(Handler handler) { |
| 495 | super(handler); |
| 496 | } |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 497 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 498 | void observe() { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 499 | // Observe all users' changes |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 500 | ContentResolver resolver = mContext.getContentResolver(); |
| 501 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 502 | Settings.System.END_BUTTON_BEHAVIOR), false, this, |
| 503 | UserHandle.USER_ALL); |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 504 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 505 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this, |
| 506 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 507 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 508 | Settings.System.ACCELEROMETER_ROTATION), false, this, |
| 509 | UserHandle.USER_ALL); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 510 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 511 | Settings.System.USER_ROTATION), false, this, |
| 512 | UserHandle.USER_ALL); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 513 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 514 | Settings.System.SCREEN_OFF_TIMEOUT), false, this, |
| 515 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 516 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 517 | Settings.System.POINTER_LOCATION), false, this, |
| 518 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 519 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 520 | Settings.Secure.DEFAULT_INPUT_METHOD), false, this, |
| 521 | UserHandle.USER_ALL); |
Dianne Hackborn | 03759ed | 2009-03-27 16:04:08 -0700 | [diff] [blame] | 522 | resolver.registerContentObserver(Settings.System.getUriFor( |
John Spurlock | 245fd01 | 2013-05-31 10:31:04 -0400 | [diff] [blame] | 523 | OverlayTesting.ENABLED_SETTING), false, this, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 524 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 525 | updateSettings(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | @Override public void onChange(boolean selfChange) { |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 529 | updateSettings(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 530 | updateRotation(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 531 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 532 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 533 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 534 | class MyOrientationListener extends WindowOrientationListener { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 535 | MyOrientationListener(Context context, Handler handler) { |
| 536 | super(context, handler); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 537 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 538 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 539 | @Override |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 540 | public void onProposedRotationChanged(int rotation) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 541 | if (localLOGV) Slog.v(TAG, "onProposedRotationChanged, rotation=" + rotation); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 542 | updateRotation(false); |
| 543 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 544 | } |
| 545 | MyOrientationListener mOrientationListener; |
| 546 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 547 | private static final int HIDEYBAR_NONE = 0; |
| 548 | private static final int HIDEYBAR_SHOWING = 1; |
| 549 | private static final int HIDEYBAR_HIDING = 2; |
| 550 | private int mStatusHideybar; |
| 551 | private int mNavigationHideybar; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 552 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 553 | private SystemGesturesPointerEventListener mSystemGestures; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 554 | |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 555 | IStatusBarService getStatusBarService() { |
| 556 | synchronized (mServiceAquireLock) { |
| 557 | if (mStatusBarService == null) { |
| 558 | mStatusBarService = IStatusBarService.Stub.asInterface( |
| 559 | ServiceManager.getService("statusbar")); |
| 560 | } |
| 561 | return mStatusBarService; |
| 562 | } |
| 563 | } |
| 564 | |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 565 | /* |
| 566 | * We always let the sensor be switched on by default except when |
| 567 | * the user has explicitly disabled sensor based rotation or when the |
| 568 | * screen is switched off. |
| 569 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 570 | boolean needSensorRunningLp() { |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 571 | if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 572 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 573 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT |
| 574 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 575 | // If the application has explicitly requested to follow the |
| 576 | // orientation, then we need to turn the sensor or. |
| 577 | return true; |
| 578 | } |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 579 | if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 580 | (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 581 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 582 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK))) { |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 583 | // enable accelerometer if we are docked in a dock that enables accelerometer |
| 584 | // orientation management, |
| 585 | return true; |
| 586 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 587 | if (mUserRotationMode == USER_ROTATION_LOCKED) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 588 | // If the setting for using the sensor by default is enabled, then |
| 589 | // we will always leave it on. Note that the user could go to |
| 590 | // a window that forces an orientation that does not use the |
| 591 | // sensor and in theory we could turn it off... however, when next |
| 592 | // turning it on we won't have a good value for the current |
| 593 | // orientation for a little bit, which can cause orientation |
| 594 | // changes to lag, so we'd like to keep it always on. (It will |
| 595 | // still be turned off when the screen is off.) |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 596 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 597 | } |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 598 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | /* |
| 602 | * Various use cases for invoking this function |
| 603 | * screen turning off, should always disable listeners if already enabled |
| 604 | * screen turned on and current app has sensor based orientation, enable listeners |
| 605 | * if not already enabled |
| 606 | * screen turned on and current app does not have sensor orientation, disable listeners if |
| 607 | * already enabled |
| 608 | * screen turning on and current app has sensor based orientation, enable listeners if needed |
| 609 | * screen turning on and current app has nosensor based orientation, do nothing |
| 610 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 611 | void updateOrientationListenerLp() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 612 | if (!mOrientationListener.canDetectOrientation()) { |
| 613 | // If sensor is turned off or nonexistent for some reason |
| 614 | return; |
| 615 | } |
| 616 | //Could have been invoked due to screen turning on or off or |
| 617 | //change of the currently visible window's orientation |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 618 | if (localLOGV) Slog.v(TAG, "Screen status="+mScreenOnEarly+ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 619 | ", current orientation="+mCurrentAppOrientation+ |
| 620 | ", SensorEnabled="+mOrientationSensorEnabled); |
| 621 | boolean disable = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 622 | if (mScreenOnEarly) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 623 | if (needSensorRunningLp()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 624 | disable = false; |
| 625 | //enable listener if not already enabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 626 | if (!mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 627 | mOrientationListener.enable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 628 | if(localLOGV) Slog.v(TAG, "Enabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 629 | mOrientationSensorEnabled = true; |
| 630 | } |
| 631 | } |
| 632 | } |
| 633 | //check if sensors need to be disabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 634 | if (disable && mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 635 | mOrientationListener.disable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 636 | if(localLOGV) Slog.v(TAG, "Disabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 637 | mOrientationSensorEnabled = false; |
| 638 | } |
| 639 | } |
| 640 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 641 | private void interceptPowerKeyDown(boolean handled) { |
| 642 | mPowerKeyHandled = handled; |
| 643 | if (!handled) { |
| 644 | mHandler.postDelayed(mPowerLongPress, ViewConfiguration.getGlobalActionKeyTimeout()); |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | private boolean interceptPowerKeyUp(boolean canceled) { |
| 649 | if (!mPowerKeyHandled) { |
| 650 | mHandler.removeCallbacks(mPowerLongPress); |
| 651 | return !canceled; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 652 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 653 | return false; |
| 654 | } |
| 655 | |
| 656 | private void cancelPendingPowerKeyAction() { |
| 657 | if (!mPowerKeyHandled) { |
| 658 | mHandler.removeCallbacks(mPowerLongPress); |
| 659 | } |
Jeff Brown | ff20471 | 2011-10-25 21:27:54 -0700 | [diff] [blame] | 660 | if (mPowerKeyTriggered) { |
| 661 | mPendingPowerKeyUpCanceled = true; |
| 662 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | private void interceptScreenshotChord() { |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 666 | if (mScreenshotChordEnabled |
| 667 | && mVolumeDownKeyTriggered && mPowerKeyTriggered && !mVolumeUpKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 668 | final long now = SystemClock.uptimeMillis(); |
| 669 | if (now <= mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS |
| 670 | && now <= mPowerKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) { |
| 671 | mVolumeDownKeyConsumedByScreenshotChord = true; |
| 672 | cancelPendingPowerKeyAction(); |
| 673 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 674 | mHandler.postDelayed(mScreenshotRunnable, getScreenshotChordLongPressDelay()); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 675 | } |
| 676 | } |
| 677 | } |
| 678 | |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 679 | private long getScreenshotChordLongPressDelay() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 680 | if (mKeyguardDelegate.isShowing()) { |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 681 | // Double the time it takes to take a screenshot from the keyguard |
| 682 | return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER * |
| 683 | ViewConfiguration.getGlobalActionKeyTimeout()); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 684 | } |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 685 | return ViewConfiguration.getGlobalActionKeyTimeout(); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 686 | } |
| 687 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 688 | private void cancelPendingScreenshotChordAction() { |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 689 | mHandler.removeCallbacks(mScreenshotRunnable); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | private final Runnable mPowerLongPress = new Runnable() { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 693 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 694 | public void run() { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 695 | // The context isn't read |
| 696 | if (mLongPressOnPowerBehavior < 0) { |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 697 | mLongPressOnPowerBehavior = mContext.getResources().getInteger( |
| 698 | com.android.internal.R.integer.config_longPressOnPowerBehavior); |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 699 | } |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 700 | int resolvedBehavior = mLongPressOnPowerBehavior; |
| 701 | if (FactoryTest.isLongPressOnPowerOffEnabled()) { |
| 702 | resolvedBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM; |
| 703 | } |
| 704 | |
| 705 | switch (resolvedBehavior) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 706 | case LONG_PRESS_POWER_NOTHING: |
| 707 | break; |
| 708 | case LONG_PRESS_POWER_GLOBAL_ACTIONS: |
| 709 | mPowerKeyHandled = true; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 710 | if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) { |
| 711 | performAuditoryFeedbackForAccessibilityIfNeed(); |
| 712 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 713 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
| 714 | showGlobalActionsDialog(); |
| 715 | break; |
| 716 | case LONG_PRESS_POWER_SHUT_OFF: |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 717 | case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM: |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 718 | mPowerKeyHandled = true; |
| 719 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 720 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 721 | mWindowManagerFuncs.shutdown(resolvedBehavior == LONG_PRESS_POWER_SHUT_OFF); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 722 | break; |
| 723 | } |
| 724 | } |
| 725 | }; |
| 726 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 727 | private final Runnable mScreenshotRunnable = new Runnable() { |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 728 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 729 | public void run() { |
| 730 | takeScreenshot(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 731 | } |
| 732 | }; |
| 733 | |
| 734 | void showGlobalActionsDialog() { |
| 735 | if (mGlobalActions == null) { |
Jeff Brown | 7304c34 | 2012-05-11 18:42:42 -0700 | [diff] [blame] | 736 | mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 737 | } |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 738 | final boolean keyguardShowing = keyguardIsShowingTq(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 739 | mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); |
| 740 | if (keyguardShowing) { |
| 741 | // since it took two seconds of long press to bring this up, |
| 742 | // poke the wake lock so they have some time to see the dialog. |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 743 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 744 | } |
| 745 | } |
| 746 | |
| 747 | boolean isDeviceProvisioned() { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 748 | return Settings.Global.getInt( |
| 749 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 750 | } |
| 751 | |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 752 | private void handleLongPressOnHome() { |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 753 | if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 754 | mHomeConsumed = true; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 755 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 756 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 757 | if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) { |
| 758 | toggleRecentApps(); |
| 759 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_ASSIST) { |
| 760 | launchAssistAction(); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 761 | } |
| 762 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 763 | } |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 764 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 765 | private void handleDoubleTapOnHome() { |
| 766 | if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 767 | mHomeConsumed = true; |
| 768 | toggleRecentApps(); |
| 769 | } |
| 770 | } |
| 771 | |
| 772 | private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable() { |
| 773 | @Override |
| 774 | public void run() { |
| 775 | if (mHomeDoubleTapPending) { |
| 776 | mHomeDoubleTapPending = false; |
| 777 | launchHomeFromHotKey(); |
| 778 | } |
| 779 | } |
| 780 | }; |
| 781 | |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 782 | /** |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 783 | * Create (if necessary) and show or dismiss the recent apps dialog according |
| 784 | * according to the requested behavior. |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 785 | */ |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 786 | void showOrHideRecentAppsDialog(final int behavior) { |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 787 | mHandler.post(new Runnable() { |
| 788 | @Override |
| 789 | public void run() { |
| 790 | if (mRecentAppsDialog == null) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 791 | mRecentAppsDialog = new RecentApplicationsDialog(mContext); |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 792 | } |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 793 | if (mRecentAppsDialog.isShowing()) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 794 | switch (behavior) { |
| 795 | case RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS: |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 796 | case RECENT_APPS_BEHAVIOR_DISMISS: |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 797 | mRecentAppsDialog.dismiss(); |
| 798 | break; |
| 799 | case RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH: |
| 800 | mRecentAppsDialog.dismissAndSwitch(); |
| 801 | break; |
| 802 | case RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW: |
| 803 | default: |
| 804 | break; |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 805 | } |
| 806 | } else { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 807 | switch (behavior) { |
| 808 | case RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS: |
| 809 | mRecentAppsDialog.show(); |
| 810 | break; |
| 811 | case RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW: |
| 812 | try { |
| 813 | mWindowManager.setInTouchMode(false); |
| 814 | } catch (RemoteException e) { |
| 815 | } |
| 816 | mRecentAppsDialog.show(); |
| 817 | break; |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 818 | case RECENT_APPS_BEHAVIOR_DISMISS: |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 819 | case RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH: |
| 820 | default: |
| 821 | break; |
| 822 | } |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 823 | } |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 824 | } |
| 825 | }); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 826 | } |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 827 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 828 | /** {@inheritDoc} */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 829 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 830 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 831 | WindowManagerFuncs windowManagerFuncs) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 832 | mContext = context; |
| 833 | mWindowManager = windowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 834 | mWindowManagerFuncs = windowManagerFuncs; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 835 | mHeadless = "1".equals(SystemProperties.get("ro.config.headless", "0")); |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 836 | mHandler = new PolicyHandler(); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 837 | mOrientationListener = new MyOrientationListener(mContext, mHandler); |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 838 | try { |
| 839 | mOrientationListener.setCurrentRotation(windowManager.getRotation()); |
| 840 | } catch (RemoteException ex) { } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 841 | mSettingsObserver = new SettingsObserver(mHandler); |
| 842 | mSettingsObserver.observe(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 843 | mShortcutManager = new ShortcutManager(context, mHandler); |
| 844 | mShortcutManager.observe(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 845 | mUiMode = context.getResources().getInteger( |
| 846 | com.android.internal.R.integer.config_defaultUiModeType); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 847 | mHomeIntent = new Intent(Intent.ACTION_MAIN, null); |
| 848 | mHomeIntent.addCategory(Intent.CATEGORY_HOME); |
| 849 | mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 850 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 851 | mCarDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 852 | mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK); |
| 853 | mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 854 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 855 | mDeskDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 856 | mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK); |
| 857 | mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 858 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 859 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 860 | mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 861 | mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 862 | "PhoneWindowManager.mBroadcastWakeLock"); |
| 863 | mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 864 | mLidOpenRotation = readRotation( |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 865 | com.android.internal.R.integer.config_lidOpenRotation); |
| 866 | mCarDockRotation = readRotation( |
| 867 | com.android.internal.R.integer.config_carDockRotation); |
| 868 | mDeskDockRotation = readRotation( |
| 869 | com.android.internal.R.integer.config_deskDockRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 870 | mUndockedHdmiRotation = readRotation( |
| 871 | com.android.internal.R.integer.config_undockedHdmiRotation); |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 872 | mCarDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 873 | com.android.internal.R.bool.config_carDockEnablesAccelerometer); |
| 874 | mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 875 | com.android.internal.R.bool.config_deskDockEnablesAccelerometer); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 876 | mLidKeyboardAccessibility = mContext.getResources().getInteger( |
| 877 | com.android.internal.R.integer.config_lidKeyboardAccessibility); |
| 878 | mLidNavigationAccessibility = mContext.getResources().getInteger( |
| 879 | com.android.internal.R.integer.config_lidNavigationAccessibility); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 880 | mLidControlsSleep = mContext.getResources().getBoolean( |
| 881 | com.android.internal.R.bool.config_lidControlsSleep); |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 882 | readConfigurationDependentBehaviors(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 883 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 884 | // register for dock events |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 885 | IntentFilter filter = new IntentFilter(); |
| 886 | filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); |
| 887 | filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE); |
| 888 | filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); |
| 889 | filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 890 | filter.addAction(Intent.ACTION_DOCK_EVENT); |
| 891 | Intent intent = context.registerReceiver(mDockReceiver, filter); |
| 892 | if (intent != null) { |
| 893 | // Retrieve current sticky dock event broadcast. |
| 894 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 895 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 896 | } |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 897 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 898 | // register for dream-related broadcasts |
| 899 | filter = new IntentFilter(); |
| 900 | filter.addAction(Intent.ACTION_DREAMING_STARTED); |
| 901 | filter.addAction(Intent.ACTION_DREAMING_STOPPED); |
| 902 | context.registerReceiver(mDreamReceiver, filter); |
| 903 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 904 | // register for multiuser-relevant broadcasts |
| 905 | filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); |
| 906 | context.registerReceiver(mMultiuserReceiver, filter); |
| 907 | |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 908 | // monitor for system gestures |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 909 | mSystemGestures = new SystemGesturesPointerEventListener(context, |
| 910 | new SystemGesturesPointerEventListener.Callbacks() { |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 911 | @Override |
| 912 | public void onSwipeFromTop() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 913 | if (mStatusBar != null) { |
| 914 | requestHideybars(mStatusBar); |
| 915 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 916 | } |
| 917 | @Override |
| 918 | public void onSwipeFromBottom() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 919 | if (mNavigationBar != null && mNavigationBarOnBottom) { |
| 920 | requestHideybars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 921 | } |
| 922 | } |
| 923 | @Override |
| 924 | public void onSwipeFromRight() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 925 | if (mNavigationBar != null && !mNavigationBarOnBottom) { |
| 926 | requestHideybars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 927 | } |
| 928 | } |
| 929 | @Override |
| 930 | public void onDebug() { |
John Spurlock | 245fd01 | 2013-05-31 10:31:04 -0400 | [diff] [blame] | 931 | if (OverlayTesting.enabled) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 932 | OverlayTesting.toggleForceOverlay(mFocusedWindow, mContext); |
| 933 | } |
| 934 | } |
| 935 | }); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 936 | mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 937 | |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 938 | mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 939 | mLongPressVibePattern = getLongIntArray(mContext.getResources(), |
| 940 | com.android.internal.R.array.config_longPressVibePattern); |
| 941 | mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(), |
| 942 | com.android.internal.R.array.config_virtualKeyVibePattern); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 943 | mKeyboardTapVibePattern = getLongIntArray(mContext.getResources(), |
| 944 | com.android.internal.R.array.config_keyboardTapVibePattern); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 945 | mSafeModeDisabledVibePattern = getLongIntArray(mContext.getResources(), |
| 946 | com.android.internal.R.array.config_safeModeDisabledVibePattern); |
| 947 | mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), |
| 948 | com.android.internal.R.array.config_safeModeEnabledVibePattern); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 949 | |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 950 | mScreenshotChordEnabled = mContext.getResources().getBoolean( |
| 951 | com.android.internal.R.bool.config_enableScreenshotChord); |
| 952 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 953 | mGlobalKeyManager = new GlobalKeyManager(mContext); |
| 954 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 955 | // Controls rotation and the like. |
| 956 | initializeHdmiState(); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 957 | |
| 958 | // Match current screen state. |
| 959 | if (mPowerManager.isScreenOn()) { |
| 960 | screenTurningOn(null); |
| 961 | } else { |
| 962 | screenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER); |
| 963 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 964 | } |
| 965 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 966 | /** |
| 967 | * Read values from config.xml that may be overridden depending on |
| 968 | * the configuration of the device. |
| 969 | * eg. Disable long press on home goes to recents on sw600dp. |
| 970 | */ |
| 971 | private void readConfigurationDependentBehaviors() { |
| 972 | mLongPressOnHomeBehavior = mContext.getResources().getInteger( |
| 973 | com.android.internal.R.integer.config_longPressOnHomeBehavior); |
| 974 | if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING || |
| 975 | mLongPressOnHomeBehavior > LONG_PRESS_HOME_ASSIST) { |
| 976 | mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 977 | } |
| 978 | |
| 979 | mDoubleTapOnHomeBehavior = mContext.getResources().getInteger( |
| 980 | com.android.internal.R.integer.config_doubleTapOnHomeBehavior); |
| 981 | if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING || |
| 982 | mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 983 | mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 984 | } |
| 985 | } |
| 986 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 987 | @Override |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 988 | public void setInitialDisplaySize(Display display, int width, int height, int density) { |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 989 | if (display.getDisplayId() != Display.DEFAULT_DISPLAY) { |
| 990 | throw new IllegalArgumentException("Can only set the default display"); |
| 991 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 992 | mDisplay = display; |
| 993 | |
| 994 | int shortSize, longSize; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 995 | if (width > height) { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 996 | shortSize = height; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 997 | longSize = width; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 998 | mLandscapeRotation = Surface.ROTATION_0; |
| 999 | mSeascapeRotation = Surface.ROTATION_180; |
| 1000 | if (mContext.getResources().getBoolean( |
| 1001 | com.android.internal.R.bool.config_reverseDefaultRotation)) { |
| 1002 | mPortraitRotation = Surface.ROTATION_90; |
| 1003 | mUpsideDownRotation = Surface.ROTATION_270; |
| 1004 | } else { |
| 1005 | mPortraitRotation = Surface.ROTATION_270; |
| 1006 | mUpsideDownRotation = Surface.ROTATION_90; |
| 1007 | } |
| 1008 | } else { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1009 | shortSize = width; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1010 | longSize = height; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1011 | mPortraitRotation = Surface.ROTATION_0; |
| 1012 | mUpsideDownRotation = Surface.ROTATION_180; |
| 1013 | if (mContext.getResources().getBoolean( |
| 1014 | com.android.internal.R.bool.config_reverseDefaultRotation)) { |
| 1015 | mLandscapeRotation = Surface.ROTATION_270; |
| 1016 | mSeascapeRotation = Surface.ROTATION_90; |
| 1017 | } else { |
| 1018 | mLandscapeRotation = Surface.ROTATION_90; |
| 1019 | mSeascapeRotation = Surface.ROTATION_270; |
| 1020 | } |
| 1021 | } |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1022 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1023 | mStatusBarHeight = mContext.getResources().getDimensionPixelSize( |
| 1024 | com.android.internal.R.dimen.status_bar_height); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1025 | |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1026 | // Height of the navigation bar when presented horizontally at bottom |
| 1027 | mNavigationBarHeightForRotation[mPortraitRotation] = |
| 1028 | mNavigationBarHeightForRotation[mUpsideDownRotation] = |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1029 | mContext.getResources().getDimensionPixelSize( |
| 1030 | com.android.internal.R.dimen.navigation_bar_height); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1031 | mNavigationBarHeightForRotation[mLandscapeRotation] = |
| 1032 | mNavigationBarHeightForRotation[mSeascapeRotation] = |
| 1033 | mContext.getResources().getDimensionPixelSize( |
| 1034 | com.android.internal.R.dimen.navigation_bar_height_landscape); |
| 1035 | |
| 1036 | // Width of the navigation bar when presented vertically along one side |
| 1037 | mNavigationBarWidthForRotation[mPortraitRotation] = |
| 1038 | mNavigationBarWidthForRotation[mUpsideDownRotation] = |
| 1039 | mNavigationBarWidthForRotation[mLandscapeRotation] = |
| 1040 | mNavigationBarWidthForRotation[mSeascapeRotation] = |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1041 | mContext.getResources().getDimensionPixelSize( |
| 1042 | com.android.internal.R.dimen.navigation_bar_width); |
| 1043 | |
| 1044 | // SystemUI (status bar) layout policy |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1045 | int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1046 | |
| 1047 | if (shortSizeDp < 600) { |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame^] | 1048 | // Allow the navigation bar to move on small devices (phones). |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1049 | mNavigationBarCanMove = true; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1050 | } |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1051 | |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame^] | 1052 | mHasNavigationBar = mContext.getResources().getBoolean( |
| 1053 | com.android.internal.R.bool.config_showNavigationBar); |
| 1054 | // Allow a system property to override this. Used by the emulator. |
| 1055 | // See also hasNavigationBar(). |
| 1056 | String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); |
| 1057 | if ("1".equals(navBarOverride)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1058 | mHasNavigationBar = false; |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame^] | 1059 | } else if ("0".equals(navBarOverride)) { |
| 1060 | mHasNavigationBar = true; |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1061 | } |
| 1062 | |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame^] | 1063 | if (mHasNavigationBar) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1064 | // The navigation bar is at the right in landscape; it seems always |
| 1065 | // useful to hide it for showing a video. |
| 1066 | mCanHideNavigationBar = true; |
| 1067 | } else { |
| 1068 | mCanHideNavigationBar = false; |
| 1069 | } |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1070 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 1071 | // For demo purposes, allow the rotation of the HDMI display to be controlled. |
| 1072 | // By default, HDMI locks rotation to landscape. |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1073 | if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1074 | mDemoHdmiRotation = mPortraitRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1075 | } else { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1076 | mDemoHdmiRotation = mLandscapeRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1077 | } |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1078 | mDemoHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false); |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1079 | } |
| 1080 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1081 | @Override |
| 1082 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom) { |
| 1083 | if (display.getDisplayId() == Display.DEFAULT_DISPLAY) { |
| 1084 | mOverscanLeft = left; |
| 1085 | mOverscanTop = top; |
| 1086 | mOverscanRight = right; |
| 1087 | mOverscanBottom = bottom; |
| 1088 | } |
| 1089 | } |
| 1090 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1091 | public void updateSettings() { |
| 1092 | ContentResolver resolver = mContext.getContentResolver(); |
| 1093 | boolean updateRotation = false; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1094 | synchronized (mLock) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1095 | mEndcallBehavior = Settings.System.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1096 | Settings.System.END_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1097 | Settings.System.END_BUTTON_BEHAVIOR_DEFAULT, |
| 1098 | UserHandle.USER_CURRENT); |
| 1099 | mIncallPowerBehavior = Settings.Secure.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1100 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1101 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT, |
| 1102 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1103 | |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1104 | // Configure rotation lock. |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1105 | int userRotation = Settings.System.getIntForUser(resolver, |
| 1106 | Settings.System.USER_ROTATION, Surface.ROTATION_0, |
| 1107 | UserHandle.USER_CURRENT); |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1108 | if (mUserRotation != userRotation) { |
| 1109 | mUserRotation = userRotation; |
| 1110 | updateRotation = true; |
| 1111 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1112 | int userRotationMode = Settings.System.getIntForUser(resolver, |
| 1113 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1114 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 1115 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
| 1116 | if (mUserRotationMode != userRotationMode) { |
| 1117 | mUserRotationMode = userRotationMode; |
| 1118 | updateRotation = true; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1119 | updateOrientationListenerLp(); |
| 1120 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1121 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1122 | if (mSystemReady) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1123 | int pointerLocation = Settings.System.getIntForUser(resolver, |
| 1124 | Settings.System.POINTER_LOCATION, 0, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1125 | if (mPointerLocationMode != pointerLocation) { |
| 1126 | mPointerLocationMode = pointerLocation; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1127 | mHandler.sendEmptyMessage(pointerLocation != 0 ? |
| 1128 | MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1129 | } |
| 1130 | } |
| 1131 | // use screen off timeout setting as the timeout for the lockscreen |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1132 | mLockScreenTimeout = Settings.System.getIntForUser(resolver, |
| 1133 | Settings.System.SCREEN_OFF_TIMEOUT, 0, UserHandle.USER_CURRENT); |
| 1134 | String imId = Settings.Secure.getStringForUser(resolver, |
| 1135 | Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1136 | boolean hasSoftInput = imId != null && imId.length() > 0; |
| 1137 | if (mHasSoftInput != hasSoftInput) { |
| 1138 | mHasSoftInput = hasSoftInput; |
| 1139 | updateRotation = true; |
| 1140 | } |
John Spurlock | 245fd01 | 2013-05-31 10:31:04 -0400 | [diff] [blame] | 1141 | OverlayTesting.enabled = Settings.System.getIntForUser(resolver, |
| 1142 | OverlayTesting.ENABLED_SETTING, 0, UserHandle.USER_CURRENT) != 0; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1143 | } |
| 1144 | if (updateRotation) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1145 | updateRotation(true); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1146 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1147 | } |
| 1148 | |
| 1149 | private void enablePointerLocation() { |
| 1150 | if (mPointerLocationView == null) { |
| 1151 | mPointerLocationView = new PointerLocationView(mContext); |
| 1152 | mPointerLocationView.setPrintCoords(false); |
| 1153 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1154 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 1155 | WindowManager.LayoutParams.MATCH_PARENT, |
| 1156 | WindowManager.LayoutParams.MATCH_PARENT); |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1157 | lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1158 | lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
| 1159 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
| 1160 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1161 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
Jeff Brown | 90fc905 | 2012-10-01 14:44:24 -0700 | [diff] [blame] | 1162 | if (ActivityManager.isHighEndGfx()) { |
| 1163 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1164 | lp.privateFlags |= |
| 1165 | WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; |
| 1166 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1167 | lp.format = PixelFormat.TRANSLUCENT; |
| 1168 | lp.setTitle("PointerLocation"); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1169 | WindowManager wm = (WindowManager) |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1170 | mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1171 | lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1172 | wm.addView(mPointerLocationView, lp); |
| 1173 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1174 | mPointerLocationPointerEventListener = new PointerLocationPointerEventListener(); |
| 1175 | mWindowManagerFuncs.registerPointerEventListener(mPointerLocationPointerEventListener); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1176 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1177 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1178 | |
| 1179 | private void disablePointerLocation() { |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1180 | if (mPointerLocationPointerEventListener != null) { |
| 1181 | mWindowManagerFuncs.unregisterPointerEventListener( |
| 1182 | mPointerLocationPointerEventListener); |
| 1183 | mPointerLocationPointerEventListener = null; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1184 | } |
| 1185 | |
| 1186 | if (mPointerLocationView != null) { |
| 1187 | WindowManager wm = (WindowManager) |
| 1188 | mContext.getSystemService(Context.WINDOW_SERVICE); |
| 1189 | wm.removeView(mPointerLocationView); |
| 1190 | mPointerLocationView = null; |
| 1191 | } |
| 1192 | } |
| 1193 | |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1194 | private int readRotation(int resID) { |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1195 | try { |
| 1196 | int rotation = mContext.getResources().getInteger(resID); |
| 1197 | switch (rotation) { |
| 1198 | case 0: |
| 1199 | return Surface.ROTATION_0; |
| 1200 | case 90: |
| 1201 | return Surface.ROTATION_90; |
| 1202 | case 180: |
| 1203 | return Surface.ROTATION_180; |
| 1204 | case 270: |
| 1205 | return Surface.ROTATION_270; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1206 | } |
| 1207 | } catch (Resources.NotFoundException e) { |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1208 | // fall through |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1209 | } |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1210 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1211 | } |
| 1212 | |
| 1213 | /** {@inheritDoc} */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1214 | @Override |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1215 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1216 | int type = attrs.type; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1217 | |
| 1218 | outAppOp[0] = AppOpsManager.OP_NONE; |
| 1219 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1220 | if (type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW |
| 1221 | || type > WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1222 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1223 | } |
| 1224 | String permission = null; |
| 1225 | switch (type) { |
| 1226 | case TYPE_TOAST: |
| 1227 | // XXX right now the app process has complete control over |
| 1228 | // this... should introduce a token to let the system |
| 1229 | // monitor/control what they are doing. |
| 1230 | break; |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 1231 | case TYPE_DREAM: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1232 | case TYPE_INPUT_METHOD: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1233 | case TYPE_WALLPAPER: |
| 1234 | // The window manager will check these. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1235 | break; |
| 1236 | case TYPE_PHONE: |
| 1237 | case TYPE_PRIORITY_PHONE: |
| 1238 | case TYPE_SYSTEM_ALERT: |
| 1239 | case TYPE_SYSTEM_ERROR: |
| 1240 | case TYPE_SYSTEM_OVERLAY: |
| 1241 | permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1242 | outAppOp[0] = AppOpsManager.OP_SYSTEM_ALERT_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1243 | break; |
| 1244 | default: |
| 1245 | permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; |
| 1246 | } |
| 1247 | if (permission != null) { |
| 1248 | if (mContext.checkCallingOrSelfPermission(permission) |
| 1249 | != PackageManager.PERMISSION_GRANTED) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1250 | return WindowManagerGlobal.ADD_PERMISSION_DENIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1251 | } |
| 1252 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1253 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1254 | } |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1255 | |
| 1256 | @Override |
| 1257 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs) { |
| 1258 | |
| 1259 | // If this switch statement is modified, modify the comment in the declarations of |
| 1260 | // the type in {@link WindowManager.LayoutParams} as well. |
| 1261 | switch (attrs.type) { |
| 1262 | default: |
| 1263 | // These are the windows that by default are shown only to the user that created |
| 1264 | // them. If this needs to be overridden, set |
| 1265 | // {@link WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS} in |
| 1266 | // {@link WindowManager.LayoutParams}. Note that permission |
| 1267 | // {@link android.Manifest.permission.INTERNAL_SYSTEM_WINDOW} is required as well. |
| 1268 | if ((attrs.privateFlags & PRIVATE_FLAG_SHOW_FOR_ALL_USERS) == 0) { |
| 1269 | return true; |
| 1270 | } |
| 1271 | break; |
| 1272 | |
| 1273 | // These are the windows that by default are shown to all users. However, to |
| 1274 | // protect against spoofing, check permissions below. |
| 1275 | case TYPE_APPLICATION_STARTING: |
| 1276 | case TYPE_BOOT_PROGRESS: |
| 1277 | case TYPE_DISPLAY_OVERLAY: |
| 1278 | case TYPE_HIDDEN_NAV_CONSUMER: |
| 1279 | case TYPE_KEYGUARD: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1280 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1281 | case TYPE_KEYGUARD_DIALOG: |
| 1282 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1283 | case TYPE_NAVIGATION_BAR: |
| 1284 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1285 | case TYPE_PHONE: |
| 1286 | case TYPE_POINTER: |
| 1287 | case TYPE_PRIORITY_PHONE: |
| 1288 | case TYPE_RECENTS_OVERLAY: |
| 1289 | case TYPE_SEARCH_BAR: |
| 1290 | case TYPE_STATUS_BAR: |
| 1291 | case TYPE_STATUS_BAR_PANEL: |
| 1292 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1293 | case TYPE_SYSTEM_DIALOG: |
| 1294 | case TYPE_UNIVERSE_BACKGROUND: |
| 1295 | case TYPE_VOLUME_OVERLAY: |
| 1296 | break; |
| 1297 | } |
| 1298 | |
| 1299 | // Check if third party app has set window to system window type. |
| 1300 | return mContext.checkCallingOrSelfPermission( |
| 1301 | android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) |
| 1302 | != PackageManager.PERMISSION_GRANTED; |
| 1303 | } |
| 1304 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1305 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1306 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) { |
| 1307 | switch (attrs.type) { |
| 1308 | case TYPE_SYSTEM_OVERLAY: |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1309 | case TYPE_SECURE_SYSTEM_OVERLAY: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1310 | // These types of windows can't receive input events. |
| 1311 | attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1312 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1313 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1314 | break; |
| 1315 | } |
| 1316 | } |
| 1317 | |
| 1318 | void readLidState() { |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 1319 | mLidState = mWindowManagerFuncs.getLidState(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1320 | } |
| 1321 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1322 | private boolean isHidden(int accessibilityMode) { |
| 1323 | switch (accessibilityMode) { |
| 1324 | case 1: |
| 1325 | return mLidState == LID_CLOSED; |
| 1326 | case 2: |
| 1327 | return mLidState == LID_OPEN; |
| 1328 | default: |
| 1329 | return false; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1330 | } |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1331 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1332 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1333 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1334 | @Override |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1335 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 1336 | int navigationPresence) { |
| 1337 | mHaveBuiltInKeyboard = (keyboardPresence & PRESENCE_INTERNAL) != 0; |
| 1338 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1339 | readConfigurationDependentBehaviors(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1340 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1341 | applyLidSwitchState(); |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1342 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1343 | if (config.keyboard == Configuration.KEYBOARD_NOKEYS |
| 1344 | || (keyboardPresence == PRESENCE_INTERNAL |
| 1345 | && isHidden(mLidKeyboardAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1346 | config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1347 | if (!mHasSoftInput) { |
| 1348 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; |
| 1349 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1350 | } |
| 1351 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1352 | if (config.navigation == Configuration.NAVIGATION_NONAV |
| 1353 | || (navigationPresence == PRESENCE_INTERNAL |
| 1354 | && isHidden(mLidNavigationAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1355 | config.navigationHidden = Configuration.NAVIGATIONHIDDEN_YES; |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1356 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1357 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1358 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1359 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1360 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1361 | public int windowTypeToLayerLw(int type) { |
| 1362 | if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1363 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1364 | } |
| 1365 | switch (type) { |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1366 | case TYPE_UNIVERSE_BACKGROUND: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1367 | return 1; |
| 1368 | case TYPE_WALLPAPER: |
| 1369 | // wallpaper is at the bottom, though the window manager may move it. |
| 1370 | return 2; |
| 1371 | case TYPE_PHONE: |
| 1372 | return 3; |
| 1373 | case TYPE_SEARCH_BAR: |
| 1374 | return 4; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1375 | case TYPE_RECENTS_OVERLAY: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1376 | case TYPE_SYSTEM_DIALOG: |
| 1377 | return 5; |
| 1378 | case TYPE_TOAST: |
| 1379 | // toasts and the plugged-in battery thing |
| 1380 | return 6; |
| 1381 | case TYPE_PRIORITY_PHONE: |
| 1382 | // SIM errors and unlock. Not sure if this really should be in a high layer. |
| 1383 | return 7; |
| 1384 | case TYPE_DREAM: |
| 1385 | // used for Dreams (screensavers with TYPE_DREAM windows) |
| 1386 | return 8; |
| 1387 | case TYPE_SYSTEM_ALERT: |
| 1388 | // like the ANR / app crashed dialogs |
| 1389 | return 9; |
| 1390 | case TYPE_INPUT_METHOD: |
| 1391 | // on-screen keyboards and other such input method user interfaces go here. |
| 1392 | return 10; |
| 1393 | case TYPE_INPUT_METHOD_DIALOG: |
| 1394 | // on-screen keyboards and other such input method user interfaces go here. |
| 1395 | return 11; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1396 | case TYPE_KEYGUARD_SCRIM: |
| 1397 | // the safety window that shows behind keyguard while keyguard is starting |
| 1398 | return 12; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1399 | case TYPE_KEYGUARD: |
| 1400 | // the keyguard; nothing on top of these can take focus, since they are |
| 1401 | // responsible for power management when displayed. |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1402 | return 13; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1403 | case TYPE_KEYGUARD_DIALOG: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1404 | return 14; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1405 | case TYPE_STATUS_BAR_SUB_PANEL: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1406 | return 15; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1407 | case TYPE_STATUS_BAR: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1408 | return 16; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1409 | case TYPE_STATUS_BAR_PANEL: |
| 1410 | return 17; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1411 | case TYPE_VOLUME_OVERLAY: |
| 1412 | // the on-screen volume indicator and controller shown when the user |
| 1413 | // changes the device volume |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1414 | return 18; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1415 | case TYPE_SYSTEM_OVERLAY: |
| 1416 | // the on-screen volume indicator and controller shown when the user |
| 1417 | // changes the device volume |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1418 | return 19; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1419 | case TYPE_NAVIGATION_BAR: |
| 1420 | // the navigation bar, if available, shows atop most things |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1421 | return 20; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1422 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1423 | // some panels (e.g. search) need to show on top of the navigation bar |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1424 | return 21; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1425 | case TYPE_SYSTEM_ERROR: |
| 1426 | // system-level error dialogs |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1427 | return 22; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1428 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1429 | // used to highlight the magnified portion of a display |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1430 | return 23; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1431 | case TYPE_DISPLAY_OVERLAY: |
| 1432 | // used to simulate secondary display devices |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1433 | return 24; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1434 | case TYPE_DRAG: |
| 1435 | // the drag layer: input for drag-and-drop is associated with this window, |
| 1436 | // which sits above all other focusable windows |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1437 | return 25; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1438 | case TYPE_SECURE_SYSTEM_OVERLAY: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1439 | return 26; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1440 | case TYPE_BOOT_PROGRESS: |
| 1441 | return 27; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1442 | case TYPE_POINTER: |
| 1443 | // the (mouse) pointer layer |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1444 | return 28; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1445 | case TYPE_HIDDEN_NAV_CONSUMER: |
| 1446 | return 29; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1447 | } |
| 1448 | Log.e(TAG, "Unknown window type: " + type); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1449 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1450 | } |
| 1451 | |
| 1452 | /** {@inheritDoc} */ |
| 1453 | public int subWindowTypeToLayerLw(int type) { |
| 1454 | switch (type) { |
| 1455 | case TYPE_APPLICATION_PANEL: |
| 1456 | case TYPE_APPLICATION_ATTACHED_DIALOG: |
| 1457 | return APPLICATION_PANEL_SUBLAYER; |
| 1458 | case TYPE_APPLICATION_MEDIA: |
| 1459 | return APPLICATION_MEDIA_SUBLAYER; |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 1460 | case TYPE_APPLICATION_MEDIA_OVERLAY: |
| 1461 | return APPLICATION_MEDIA_OVERLAY_SUBLAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1462 | case TYPE_APPLICATION_SUB_PANEL: |
| 1463 | return APPLICATION_SUB_PANEL_SUBLAYER; |
| 1464 | } |
| 1465 | Log.e(TAG, "Unknown sub-window type: " + type); |
| 1466 | return 0; |
| 1467 | } |
| 1468 | |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1469 | public int getMaxWallpaperLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1470 | return windowTypeToLayerLw(TYPE_STATUS_BAR); |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1471 | } |
| 1472 | |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1473 | public int getAboveUniverseLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1474 | return windowTypeToLayerLw(TYPE_SYSTEM_ERROR); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1475 | } |
| 1476 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1477 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1478 | if (mHasNavigationBar) { |
| 1479 | // For a basic navigation bar, when we are in landscape mode we place |
| 1480 | // the navigation bar to the side. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1481 | if (mNavigationBarCanMove && fullWidth > fullHeight) { |
| 1482 | return fullWidth - mNavigationBarWidthForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1483 | } |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1484 | } |
| 1485 | return fullWidth; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1486 | } |
| 1487 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1488 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1489 | if (mHasNavigationBar) { |
| 1490 | // For a basic navigation bar, when we are in portrait mode we place |
| 1491 | // the navigation bar to the bottom. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1492 | if (!mNavigationBarCanMove || fullWidth < fullHeight) { |
| 1493 | return fullHeight - mNavigationBarHeightForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1494 | } |
| 1495 | } |
| 1496 | return fullHeight; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1497 | } |
| 1498 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1499 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
| 1500 | return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1501 | } |
| 1502 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1503 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame^] | 1504 | // There is a separate status bar at the top of the display. We don't count that as part |
| 1505 | // of the fixed decor, since it can hide; however, for purposes of configurations, |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1506 | // we do want to exclude it since applications can't generally use that part |
| 1507 | // of the screen. |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame^] | 1508 | return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation) - mStatusBarHeight; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1509 | } |
| 1510 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1511 | @Override |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1512 | public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs) { |
| 1513 | return attrs.type == WindowManager.LayoutParams.TYPE_KEYGUARD; |
| 1514 | } |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1515 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1516 | @Override |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1517 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs) { |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1518 | switch (attrs.type) { |
| 1519 | case TYPE_STATUS_BAR: |
| 1520 | case TYPE_NAVIGATION_BAR: |
| 1521 | case TYPE_WALLPAPER: |
| 1522 | case TYPE_DREAM: |
| 1523 | case TYPE_UNIVERSE_BACKGROUND: |
| 1524 | case TYPE_KEYGUARD: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1525 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1526 | return false; |
| 1527 | default: |
| 1528 | return true; |
| 1529 | } |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1530 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1531 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1532 | /** {@inheritDoc} */ |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1533 | @Override |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1534 | public View addStartingWindow(IBinder appToken, String packageName, int theme, |
| 1535 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1536 | int icon, int logo, int windowFlags) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1537 | if (!SHOW_STARTING_ANIMATIONS) { |
| 1538 | return null; |
| 1539 | } |
| 1540 | if (packageName == null) { |
| 1541 | return null; |
| 1542 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1543 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1544 | WindowManager wm = null; |
| 1545 | View view = null; |
| 1546 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1547 | try { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1548 | Context context = mContext; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1549 | if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow " + packageName |
| 1550 | + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" |
| 1551 | + Integer.toHexString(theme)); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1552 | if (theme != context.getThemeResId() || labelRes != 0) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1553 | try { |
| 1554 | context = context.createPackageContext(packageName, 0); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1555 | context.setTheme(theme); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1556 | } catch (PackageManager.NameNotFoundException e) { |
| 1557 | // Ignore |
| 1558 | } |
| 1559 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1560 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1561 | Window win = PolicyManager.makeNewWindow(context); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1562 | final TypedArray ta = win.getWindowStyle(); |
| 1563 | if (ta.getBoolean( |
| 1564 | com.android.internal.R.styleable.Window_windowDisablePreview, false) |
| 1565 | || ta.getBoolean( |
| 1566 | com.android.internal.R.styleable.Window_windowShowWallpaper,false)) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1567 | return null; |
| 1568 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1569 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1570 | Resources r = context.getResources(); |
| 1571 | win.setTitle(r.getText(labelRes, nonLocalizedLabel)); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1572 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1573 | win.setType( |
| 1574 | WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); |
| 1575 | // Force the window flags: this is a fake window, so it is not really |
| 1576 | // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM |
| 1577 | // flag because we do know that the next window will take input |
| 1578 | // focus, so we want to get the IME window up on top of us right away. |
| 1579 | win.setFlags( |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1580 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1581 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1582 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1583 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1584 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1585 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1586 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1587 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1588 | |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1589 | if (!compatInfo.supportsScreen()) { |
| 1590 | win.addFlags(WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW); |
| 1591 | } |
| 1592 | |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1593 | win.setDefaultIcon(icon); |
| 1594 | win.setDefaultLogo(logo); |
| 1595 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1596 | win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1597 | WindowManager.LayoutParams.MATCH_PARENT); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1598 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1599 | final WindowManager.LayoutParams params = win.getAttributes(); |
| 1600 | params.token = appToken; |
| 1601 | params.packageName = packageName; |
| 1602 | params.windowAnimations = win.getWindowStyle().getResourceId( |
| 1603 | com.android.internal.R.styleable.Window_windowAnimationStyle, 0); |
Dianne Hackborn | 5d927c2 | 2011-09-02 12:22:18 -0700 | [diff] [blame] | 1604 | params.privateFlags |= |
| 1605 | WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1606 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1607 | params.setTitle("Starting " + packageName); |
| 1608 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1609 | wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
| 1610 | view = win.getDecorView(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1611 | |
| 1612 | if (win.isFloating()) { |
| 1613 | // Whoops, there is no way to display an animation/preview |
| 1614 | // of such a thing! After all that work... let's skip it. |
| 1615 | // (Note that we must do this here because it is in |
| 1616 | // getDecorView() where the theme is evaluated... maybe |
| 1617 | // we should peek the floating attribute from the theme |
| 1618 | // earlier.) |
| 1619 | return null; |
| 1620 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1621 | |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1622 | if (DEBUG_STARTING_WINDOW) Slog.d( |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1623 | TAG, "Adding starting window for " + packageName |
| 1624 | + " / " + appToken + ": " |
| 1625 | + (view.getParent() != null ? view : null)); |
| 1626 | |
| 1627 | wm.addView(view, params); |
| 1628 | |
| 1629 | // Only return the view if it was successfully added to the |
| 1630 | // window manager... which we can tell by it having a parent. |
| 1631 | return view.getParent() != null ? view : null; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1632 | } catch (WindowManager.BadTokenException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1633 | // ignore |
| 1634 | Log.w(TAG, appToken + " already running, starting window not displayed"); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1635 | } catch (RuntimeException e) { |
| 1636 | // don't crash if something else bad happens, for example a |
| 1637 | // failure loading resources because we are loading from an app |
| 1638 | // on external storage that has been unmounted. |
| 1639 | Log.w(TAG, appToken + " failed creating starting window", e); |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1640 | } finally { |
| 1641 | if (view != null && view.getParent() == null) { |
| 1642 | Log.w(TAG, "view not successfully added to wm, removing view"); |
| 1643 | wm.removeViewImmediate(view); |
| 1644 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1645 | } |
| 1646 | |
| 1647 | return null; |
| 1648 | } |
| 1649 | |
| 1650 | /** {@inheritDoc} */ |
| 1651 | public void removeStartingWindow(IBinder appToken, View window) { |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1652 | if (DEBUG_STARTING_WINDOW) { |
| 1653 | RuntimeException e = new RuntimeException("here"); |
| 1654 | e.fillInStackTrace(); |
| 1655 | Log.v(TAG, "Removing starting window for " + appToken + ": " + window, e); |
| 1656 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1657 | |
| 1658 | if (window != null) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1659 | WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1660 | wm.removeView(window); |
| 1661 | } |
| 1662 | } |
| 1663 | |
| 1664 | /** |
| 1665 | * Preflight adding a window to the system. |
| 1666 | * |
| 1667 | * Currently enforces that three window types are singletons: |
| 1668 | * <ul> |
| 1669 | * <li>STATUS_BAR_TYPE</li> |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1670 | * <li>KEYGUARD_TYPE</li> |
| 1671 | * </ul> |
| 1672 | * |
| 1673 | * @param win The window to be added |
| 1674 | * @param attrs Information about the window to be added |
| 1675 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1676 | * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, |
| 1677 | * WindowManagerImpl.ADD_MULTIPLE_SINGLETON |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1678 | */ |
| 1679 | public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) { |
| 1680 | switch (attrs.type) { |
| 1681 | case TYPE_STATUS_BAR: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1682 | mContext.enforceCallingOrSelfPermission( |
| 1683 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1684 | "PhoneWindowManager"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1685 | if (mStatusBar != null) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1686 | if (mStatusBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1687 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1688 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1689 | } |
| 1690 | mStatusBar = win; |
| 1691 | break; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1692 | case TYPE_NAVIGATION_BAR: |
| 1693 | mContext.enforceCallingOrSelfPermission( |
| 1694 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1695 | "PhoneWindowManager"); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1696 | if (mNavigationBar != null) { |
| 1697 | if (mNavigationBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1698 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1699 | } |
| 1700 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1701 | mNavigationBar = win; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 1702 | if (DEBUG_LAYOUT) Slog.i(TAG, "NAVIGATION BAR: " + mNavigationBar); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1703 | break; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1704 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1705 | mContext.enforceCallingOrSelfPermission( |
| 1706 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1707 | "PhoneWindowManager"); |
| 1708 | break; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1709 | case TYPE_STATUS_BAR_PANEL: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1710 | mContext.enforceCallingOrSelfPermission( |
| 1711 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1712 | "PhoneWindowManager"); |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1713 | break; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1714 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1715 | mContext.enforceCallingOrSelfPermission( |
| 1716 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1717 | "PhoneWindowManager"); |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1718 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1719 | case TYPE_KEYGUARD: |
| 1720 | if (mKeyguard != null) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1721 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1722 | } |
| 1723 | mKeyguard = win; |
| 1724 | break; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1725 | case TYPE_KEYGUARD_SCRIM: |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1726 | if (mKeyguardScrim != null) { |
| 1727 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
| 1728 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1729 | mKeyguardScrim = win; |
| 1730 | break; |
| 1731 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1732 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1733 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1734 | } |
| 1735 | |
| 1736 | /** {@inheritDoc} */ |
| 1737 | public void removeWindowLw(WindowState win) { |
| 1738 | if (mStatusBar == win) { |
| 1739 | mStatusBar = null; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1740 | } else if (mKeyguard == win) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1741 | Log.v(TAG, "Removing keyguard window (Did it crash?)"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1742 | mKeyguard = null; |
Jim Miller | c0b676d | 2013-03-22 16:11:08 -0700 | [diff] [blame] | 1743 | mKeyguardDelegate.showScrim(); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1744 | } else if (mKeyguardScrim == win) { |
| 1745 | Log.v(TAG, "Removing keyguard scrim"); |
| 1746 | mKeyguardScrim = null; |
| 1747 | } if (mNavigationBar == win) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1748 | mNavigationBar = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1749 | } |
| 1750 | } |
| 1751 | |
| 1752 | static final boolean PRINT_ANIM = false; |
| 1753 | |
| 1754 | /** {@inheritDoc} */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1755 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1756 | public int selectAnimationLw(WindowState win, int transit) { |
| 1757 | if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win |
| 1758 | + ": transit=" + transit); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1759 | if (win == mStatusBar) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1760 | if (transit == TRANSIT_EXIT |
| 1761 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1762 | return R.anim.dock_top_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1763 | } else if (transit == TRANSIT_ENTER |
| 1764 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1765 | return R.anim.dock_top_enter; |
| 1766 | } |
| 1767 | } else if (win == mNavigationBar) { |
| 1768 | // This can be on either the bottom or the right. |
| 1769 | if (mNavigationBarOnBottom) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1770 | if (transit == TRANSIT_EXIT |
| 1771 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1772 | return R.anim.dock_bottom_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1773 | } else if (transit == TRANSIT_ENTER |
| 1774 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1775 | return R.anim.dock_bottom_enter; |
| 1776 | } |
| 1777 | } else { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1778 | if (transit == TRANSIT_EXIT |
| 1779 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1780 | return R.anim.dock_right_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1781 | } else if (transit == TRANSIT_ENTER |
| 1782 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1783 | return R.anim.dock_right_enter; |
| 1784 | } |
| 1785 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1786 | } |
| 1787 | |
| 1788 | if (transit == TRANSIT_PREVIEW_DONE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1789 | if (win.hasAppShownWindows()) { |
| 1790 | if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT"); |
| 1791 | return com.android.internal.R.anim.app_starting_exit; |
| 1792 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 1793 | } else if (win.getAttrs().type == TYPE_DREAM && mDreamingLockscreen |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1794 | && transit == TRANSIT_ENTER) { |
| 1795 | // Special case: we are animating in a dream, while the keyguard |
| 1796 | // is shown. We don't want an animation on the dream, because |
| 1797 | // we need it shown immediately with the keyguard animating away |
| 1798 | // to reveal it. |
| 1799 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1800 | } |
| 1801 | |
| 1802 | return 0; |
| 1803 | } |
| 1804 | |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1805 | @Override |
| 1806 | public void selectRotationAnimationLw(int anim[]) { |
| 1807 | if (PRINT_ANIM) Slog.i(TAG, "selectRotationAnimation mTopFullscreen=" |
| 1808 | + mTopFullscreenOpaqueWindowState + " rotationAnimation=" |
| 1809 | + (mTopFullscreenOpaqueWindowState == null ? |
| 1810 | "0" : mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation)); |
| 1811 | if (mTopFullscreenOpaqueWindowState != null && mTopIsFullscreen) { |
| 1812 | switch (mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation) { |
| 1813 | case ROTATION_ANIMATION_CROSSFADE: |
| 1814 | anim[0] = R.anim.rotation_animation_xfade_exit; |
| 1815 | anim[1] = R.anim.rotation_animation_enter; |
| 1816 | break; |
| 1817 | case ROTATION_ANIMATION_JUMPCUT: |
| 1818 | anim[0] = R.anim.rotation_animation_jump_exit; |
| 1819 | anim[1] = R.anim.rotation_animation_enter; |
| 1820 | break; |
| 1821 | case ROTATION_ANIMATION_ROTATE: |
| 1822 | default: |
| 1823 | anim[0] = anim[1] = 0; |
| 1824 | break; |
| 1825 | } |
| 1826 | } else { |
| 1827 | anim[0] = anim[1] = 0; |
| 1828 | } |
| 1829 | } |
| 1830 | |
| 1831 | @Override |
| 1832 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 1833 | boolean forceDefault) { |
| 1834 | switch (exitAnimId) { |
| 1835 | case R.anim.rotation_animation_xfade_exit: |
| 1836 | case R.anim.rotation_animation_jump_exit: |
| 1837 | // These are the only cases that matter. |
| 1838 | if (forceDefault) { |
| 1839 | return false; |
| 1840 | } |
| 1841 | int anim[] = new int[2]; |
| 1842 | selectRotationAnimationLw(anim); |
| 1843 | return (exitAnimId == anim[0] && enterAnimId == anim[1]); |
| 1844 | default: |
| 1845 | return true; |
| 1846 | } |
| 1847 | } |
| 1848 | |
| 1849 | @Override |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 1850 | public Animation createForceHideEnterAnimation(boolean onWallpaper) { |
| 1851 | return AnimationUtils.loadAnimation(mContext, onWallpaper |
| 1852 | ? com.android.internal.R.anim.lock_screen_wallpaper_behind_enter |
| 1853 | : com.android.internal.R.anim.lock_screen_behind_enter); |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1854 | } |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 1855 | |
| 1856 | private static void awakenDreams() { |
| 1857 | IDreamManager dreamManager = getDreamManager(); |
| 1858 | if (dreamManager != null) { |
| 1859 | try { |
| 1860 | dreamManager.awaken(); |
| 1861 | } catch (RemoteException e) { |
| 1862 | // fine, stay asleep then |
| 1863 | } |
| 1864 | } |
| 1865 | } |
| 1866 | |
| 1867 | static IDreamManager getDreamManager() { |
| 1868 | return IDreamManager.Stub.asInterface( |
| 1869 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
| 1870 | } |
| 1871 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1872 | static ITelephony getTelephonyService() { |
Mike Lockwood | f5f4ec9 | 2011-11-08 14:05:31 -0800 | [diff] [blame] | 1873 | return ITelephony.Stub.asInterface( |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1874 | ServiceManager.checkService(Context.TELEPHONY_SERVICE)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1875 | } |
| 1876 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1877 | static IAudioService getAudioService() { |
| 1878 | IAudioService audioService = IAudioService.Stub.asInterface( |
| 1879 | ServiceManager.checkService(Context.AUDIO_SERVICE)); |
| 1880 | if (audioService == null) { |
| 1881 | Log.w(TAG, "Unable to find IAudioService interface."); |
| 1882 | } |
| 1883 | return audioService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1884 | } |
| 1885 | |
| 1886 | boolean keyguardOn() { |
| 1887 | return keyguardIsShowingTq() || inKeyguardRestrictedKeyInputMode(); |
| 1888 | } |
| 1889 | |
| 1890 | private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { |
| 1891 | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, |
| 1892 | WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, |
| 1893 | }; |
| 1894 | |
| 1895 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1896 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1897 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1898 | final boolean keyguardOn = keyguardOn(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1899 | final int keyCode = event.getKeyCode(); |
| 1900 | final int repeatCount = event.getRepeatCount(); |
| 1901 | final int metaState = event.getMetaState(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1902 | final int flags = event.getFlags(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1903 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 1904 | final boolean canceled = event.isCanceled(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1905 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 1906 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1907 | Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount=" |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 1908 | + repeatCount + " keyguardOn=" + keyguardOn + " mHomePressed=" + mHomePressed |
| 1909 | + " canceled=" + canceled); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1910 | } |
| 1911 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1912 | // If we think we might have a volume down & power key chord on the way |
| 1913 | // but we're not sure, then tell the dispatcher to wait a little while and |
| 1914 | // try again later before dispatching. |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1915 | if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1916 | if (mVolumeDownKeyTriggered && !mPowerKeyTriggered) { |
| 1917 | final long now = SystemClock.uptimeMillis(); |
| 1918 | final long timeoutTime = mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS; |
| 1919 | if (now < timeoutTime) { |
| 1920 | return timeoutTime - now; |
| 1921 | } |
| 1922 | } |
| 1923 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN |
| 1924 | && mVolumeDownKeyConsumedByScreenshotChord) { |
| 1925 | if (!down) { |
| 1926 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 1927 | } |
| 1928 | return -1; |
| 1929 | } |
| 1930 | } |
| 1931 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1932 | // First we always handle the home key here, so applications |
| 1933 | // can never break it, although if keyguard is on, we do let |
| 1934 | // it handle it, because that gives us the correct 5 second |
| 1935 | // timeout. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1936 | if (keyCode == KeyEvent.KEYCODE_HOME) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1937 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1938 | // If we have released the home key, and didn't do anything else |
| 1939 | // while it was pressed, then it is time to go home! |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1940 | if (!down) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1941 | cancelPreloadRecentApps(); |
| 1942 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1943 | mHomePressed = false; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1944 | if (mHomeConsumed) { |
| 1945 | mHomeConsumed = false; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1946 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1947 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1948 | |
| 1949 | if (canceled) { |
| 1950 | Log.i(TAG, "Ignoring HOME; event canceled."); |
| 1951 | return -1; |
| 1952 | } |
| 1953 | |
| 1954 | // If an incoming call is ringing, HOME is totally disabled. |
| 1955 | // (The user is already on the InCallScreen at this point, |
| 1956 | // and his ONLY options are to answer or reject the call.) |
| 1957 | try { |
| 1958 | ITelephony telephonyService = getTelephonyService(); |
| 1959 | if (telephonyService != null && telephonyService.isRinging()) { |
| 1960 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); |
| 1961 | return -1; |
| 1962 | } |
| 1963 | } catch (RemoteException ex) { |
| 1964 | Log.w(TAG, "RemoteException from getPhoneInterface()", ex); |
| 1965 | } |
| 1966 | |
| 1967 | // Delay handling home if a double-tap is possible. |
| 1968 | if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) { |
| 1969 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case |
| 1970 | mHomeDoubleTapPending = true; |
| 1971 | mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable, |
| 1972 | ViewConfiguration.getDoubleTapTimeout()); |
| 1973 | return -1; |
| 1974 | } |
| 1975 | |
| 1976 | // Go home! |
| 1977 | launchHomeFromHotKey(); |
| 1978 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1979 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1980 | |
| 1981 | // If a system window has focus, then it doesn't make sense |
| 1982 | // right now to interact with applications. |
| 1983 | WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null; |
| 1984 | if (attrs != null) { |
| 1985 | final int type = attrs.type; |
| 1986 | if (type == WindowManager.LayoutParams.TYPE_KEYGUARD |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1987 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1988 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG) { |
| 1989 | // the "app" is keyguard, so give it the key |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1990 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1991 | } |
| 1992 | final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length; |
| 1993 | for (int i=0; i<typeCount; i++) { |
| 1994 | if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) { |
| 1995 | // don't do anything, but also don't pass it to the app |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1996 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1997 | } |
| 1998 | } |
| 1999 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2000 | |
| 2001 | // Remember that home is pressed and handle special actions. |
| 2002 | if (repeatCount == 0) { |
| 2003 | mHomePressed = true; |
| 2004 | if (mHomeDoubleTapPending) { |
| 2005 | mHomeDoubleTapPending = false; |
| 2006 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); |
| 2007 | handleDoubleTapOnHome(); |
| 2008 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI |
| 2009 | || mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 2010 | preloadRecentApps(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2011 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2012 | } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { |
| 2013 | if (!keyguardOn) { |
| 2014 | handleLongPressOnHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2015 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2016 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2017 | return -1; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2018 | } else if (keyCode == KeyEvent.KEYCODE_MENU) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2019 | // Hijack modified menu keys for debugging features |
| 2020 | final int chordBug = KeyEvent.META_SHIFT_ON; |
| 2021 | |
| 2022 | if (down && repeatCount == 0) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2023 | if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2024 | Intent intent = new Intent(Intent.ACTION_BUG_REPORT); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2025 | mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, |
| 2026 | null, null, null, 0, null, null); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2027 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2028 | } else if (SHOW_PROCESSES_ON_ALT_MENU && |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2029 | (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2030 | Intent service = new Intent(); |
| 2031 | service.setClassName(mContext, "com.android.server.LoadAverageService"); |
| 2032 | ContentResolver res = mContext.getContentResolver(); |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2033 | boolean shown = Settings.Global.getInt( |
| 2034 | res, Settings.Global.SHOW_PROCESSES, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2035 | if (!shown) { |
| 2036 | mContext.startService(service); |
| 2037 | } else { |
| 2038 | mContext.stopService(service); |
| 2039 | } |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2040 | Settings.Global.putInt( |
| 2041 | res, Settings.Global.SHOW_PROCESSES, shown ? 0 : 1); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2042 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2043 | } |
| 2044 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2045 | } else if (keyCode == KeyEvent.KEYCODE_SEARCH) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2046 | if (down) { |
| 2047 | if (repeatCount == 0) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2048 | mSearchKeyShortcutPending = true; |
| 2049 | mConsumeSearchKeyUp = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2050 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2051 | } else { |
| 2052 | mSearchKeyShortcutPending = false; |
| 2053 | if (mConsumeSearchKeyUp) { |
| 2054 | mConsumeSearchKeyUp = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2055 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2056 | } |
| 2057 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2058 | return 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2059 | } else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) { |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2060 | if (!keyguardOn) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2061 | if (down && repeatCount == 0) { |
| 2062 | preloadRecentApps(); |
| 2063 | } else if (!down) { |
| 2064 | toggleRecentApps(); |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2065 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2066 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2067 | return -1; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2068 | } else if (keyCode == KeyEvent.KEYCODE_ASSIST) { |
| 2069 | if (down) { |
| 2070 | if (repeatCount == 0) { |
| 2071 | mAssistKeyLongPressed = false; |
| 2072 | } else if (repeatCount == 1) { |
| 2073 | mAssistKeyLongPressed = true; |
| 2074 | if (!keyguardOn) { |
| 2075 | launchAssistLongPressAction(); |
| 2076 | } |
| 2077 | } |
| 2078 | } else { |
| 2079 | if (mAssistKeyLongPressed) { |
| 2080 | mAssistKeyLongPressed = false; |
| 2081 | } else { |
| 2082 | if (!keyguardOn) { |
| 2083 | launchAssistAction(); |
| 2084 | } |
| 2085 | } |
| 2086 | } |
| 2087 | return -1; |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 2088 | } else if (keyCode == KeyEvent.KEYCODE_SYSRQ) { |
| 2089 | if (down && repeatCount == 0) { |
| 2090 | mHandler.post(mScreenshotRunnable); |
| 2091 | } |
| 2092 | return -1; |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 2093 | } else if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP |
| 2094 | || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) { |
| 2095 | if (down) { |
| 2096 | int direction = keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP ? 1 : -1; |
| 2097 | |
| 2098 | // Disable autobrightness if it's on |
| 2099 | int auto = Settings.System.getIntForUser( |
| 2100 | mContext.getContentResolver(), |
| 2101 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2102 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2103 | UserHandle.USER_CURRENT_OR_SELF); |
| 2104 | if (auto != 0) { |
| 2105 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2106 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2107 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2108 | UserHandle.USER_CURRENT_OR_SELF); |
| 2109 | } |
| 2110 | |
| 2111 | int min = mPowerManager.getMinimumScreenBrightnessSetting(); |
| 2112 | int max = mPowerManager.getMaximumScreenBrightnessSetting(); |
| 2113 | int step = (max - min + BRIGHTNESS_STEPS - 1) / BRIGHTNESS_STEPS * direction; |
| 2114 | int brightness = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 2115 | Settings.System.SCREEN_BRIGHTNESS, |
| 2116 | mPowerManager.getDefaultScreenBrightnessSetting(), |
| 2117 | UserHandle.USER_CURRENT_OR_SELF); |
| 2118 | brightness += step; |
| 2119 | // Make sure we don't go beyond the limits. |
| 2120 | brightness = Math.min(max, brightness); |
| 2121 | brightness = Math.max(min, brightness); |
| 2122 | |
| 2123 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2124 | Settings.System.SCREEN_BRIGHTNESS, brightness, |
| 2125 | UserHandle.USER_CURRENT_OR_SELF); |
| 2126 | Intent intent = new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG); |
| 2127 | mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF); |
| 2128 | } |
| 2129 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2130 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2131 | |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2132 | // Shortcuts are invoked through Search+key, so intercept those here |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2133 | // Any printing key that is chorded with Search should be consumed |
| 2134 | // even if no shortcut was invoked. This prevents text from being |
| 2135 | // inadvertently inserted when using a keyboard that has built-in macro |
| 2136 | // shortcut keys (that emit Search+x) and some of them are not registered. |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2137 | if (mSearchKeyShortcutPending) { |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2138 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
| 2139 | if (kcm.isPrintingKey(keyCode)) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2140 | mConsumeSearchKeyUp = true; |
| 2141 | mSearchKeyShortcutPending = false; |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2142 | if (down && repeatCount == 0 && !keyguardOn) { |
| 2143 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState); |
| 2144 | if (shortcutIntent != null) { |
| 2145 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2146 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2147 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2148 | } catch (ActivityNotFoundException ex) { |
| 2149 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2150 | + "the activity to which it is registered was not found: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2151 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode), ex); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2152 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2153 | } else { |
| 2154 | Slog.i(TAG, "Dropping unregistered shortcut key combination: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2155 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2156 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2157 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2158 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2159 | } |
| 2160 | } |
| 2161 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2162 | // Invoke shortcuts using Meta. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2163 | if (down && repeatCount == 0 && !keyguardOn |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2164 | && (metaState & KeyEvent.META_META_ON) != 0) { |
| 2165 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2166 | if (kcm.isPrintingKey(keyCode)) { |
| 2167 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, |
| 2168 | metaState & ~(KeyEvent.META_META_ON |
| 2169 | | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON)); |
| 2170 | if (shortcutIntent != null) { |
| 2171 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2172 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2173 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2174 | } catch (ActivityNotFoundException ex) { |
| 2175 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2176 | + "the activity to which it is registered was not found: " |
| 2177 | + "META+" + KeyEvent.keyCodeToString(keyCode), ex); |
| 2178 | } |
| 2179 | return -1; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2180 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2181 | } |
| 2182 | } |
| 2183 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2184 | // Handle application launch keys. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2185 | if (down && repeatCount == 0 && !keyguardOn) { |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2186 | String category = sApplicationLaunchKeyCategories.get(keyCode); |
| 2187 | if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 2188 | Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2189 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2190 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2191 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2192 | } catch (ActivityNotFoundException ex) { |
| 2193 | Slog.w(TAG, "Dropping application launch key because " |
| 2194 | + "the activity to which it is registered was not found: " |
| 2195 | + "keyCode=" + keyCode + ", category=" + category, ex); |
| 2196 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2197 | return -1; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2198 | } |
| 2199 | } |
| 2200 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2201 | // Display task switcher for ALT-TAB or Meta-TAB. |
| 2202 | if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) { |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2203 | if (mRecentAppsDialogHeldModifiers == 0 && !keyguardOn) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2204 | final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK; |
| 2205 | if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON) |
| 2206 | || KeyEvent.metaStateHasModifiers( |
| 2207 | shiftlessModifiers, KeyEvent.META_META_ON)) { |
| 2208 | mRecentAppsDialogHeldModifiers = shiftlessModifiers; |
| 2209 | showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW); |
| 2210 | return -1; |
| 2211 | } |
| 2212 | } |
| 2213 | } else if (!down && mRecentAppsDialogHeldModifiers != 0 |
| 2214 | && (metaState & mRecentAppsDialogHeldModifiers) == 0) { |
| 2215 | mRecentAppsDialogHeldModifiers = 0; |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2216 | showOrHideRecentAppsDialog(keyguardOn ? RECENT_APPS_BEHAVIOR_DISMISS : |
| 2217 | RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2218 | } |
| 2219 | |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 2220 | // Handle keyboard language switching. |
| 2221 | if (down && repeatCount == 0 |
| 2222 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2223 | || (keyCode == KeyEvent.KEYCODE_SPACE |
| 2224 | && (metaState & KeyEvent.META_CTRL_MASK) != 0))) { |
| 2225 | int direction = (metaState & KeyEvent.META_SHIFT_MASK) != 0 ? -1 : 1; |
| 2226 | mWindowManagerFuncs.switchKeyboardLayout(event.getDeviceId(), direction); |
| 2227 | return -1; |
| 2228 | } |
| 2229 | if (mLanguageSwitchKeyPressed && !down |
| 2230 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2231 | || keyCode == KeyEvent.KEYCODE_SPACE)) { |
| 2232 | mLanguageSwitchKeyPressed = false; |
| 2233 | return -1; |
| 2234 | } |
| 2235 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 2236 | if (mGlobalKeyManager.handleGlobalKey(mContext, keyCode, event)) { |
| 2237 | return -1; |
| 2238 | } |
| 2239 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2240 | // Let the application handle the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2241 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2242 | } |
| 2243 | |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2244 | /** {@inheritDoc} */ |
| 2245 | @Override |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2246 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2247 | // Note: This method is only called if the initial down was unhandled. |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2248 | if (DEBUG_INPUT) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2249 | Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction() |
| 2250 | + ", flags=" + event.getFlags() |
| 2251 | + ", keyCode=" + event.getKeyCode() |
| 2252 | + ", scanCode=" + event.getScanCode() |
| 2253 | + ", metaState=" + event.getMetaState() |
| 2254 | + ", repeatCount=" + event.getRepeatCount() |
| 2255 | + ", policyFlags=" + policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2256 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2257 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2258 | KeyEvent fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2259 | if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 2260 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2261 | final int keyCode = event.getKeyCode(); |
| 2262 | final int metaState = event.getMetaState(); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2263 | final boolean initialDown = event.getAction() == KeyEvent.ACTION_DOWN |
| 2264 | && event.getRepeatCount() == 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2265 | |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2266 | // Check for fallback actions specified by the key character map. |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2267 | final FallbackAction fallbackAction; |
| 2268 | if (initialDown) { |
| 2269 | fallbackAction = kcm.getFallbackAction(keyCode, metaState); |
| 2270 | } else { |
| 2271 | fallbackAction = mFallbackActions.get(keyCode); |
| 2272 | } |
| 2273 | |
| 2274 | if (fallbackAction != null) { |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2275 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2276 | Slog.d(TAG, "Fallback: keyCode=" + fallbackAction.keyCode |
| 2277 | + " metaState=" + Integer.toHexString(fallbackAction.metaState)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2278 | } |
| 2279 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2280 | final int flags = event.getFlags() | KeyEvent.FLAG_FALLBACK; |
| 2281 | fallbackEvent = KeyEvent.obtain( |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2282 | event.getDownTime(), event.getEventTime(), |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2283 | event.getAction(), fallbackAction.keyCode, |
| 2284 | event.getRepeatCount(), fallbackAction.metaState, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2285 | event.getDeviceId(), event.getScanCode(), |
| 2286 | flags, event.getSource(), null); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2287 | |
| 2288 | if (!interceptFallback(win, fallbackEvent, policyFlags)) { |
| 2289 | fallbackEvent.recycle(); |
| 2290 | fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2291 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2292 | |
| 2293 | if (initialDown) { |
| 2294 | mFallbackActions.put(keyCode, fallbackAction); |
| 2295 | } else if (event.getAction() == KeyEvent.ACTION_UP) { |
| 2296 | mFallbackActions.remove(keyCode); |
| 2297 | fallbackAction.recycle(); |
| 2298 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2299 | } |
| 2300 | } |
| 2301 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2302 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2303 | if (fallbackEvent == null) { |
| 2304 | Slog.d(TAG, "No fallback."); |
| 2305 | } else { |
| 2306 | Slog.d(TAG, "Performing fallback: " + fallbackEvent); |
| 2307 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2308 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2309 | return fallbackEvent; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2310 | } |
| 2311 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2312 | private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) { |
| 2313 | int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags, true); |
| 2314 | if ((actions & ACTION_PASS_TO_USER) != 0) { |
| 2315 | long delayMillis = interceptKeyBeforeDispatching( |
| 2316 | win, fallbackEvent, policyFlags); |
| 2317 | if (delayMillis == 0) { |
| 2318 | return true; |
| 2319 | } |
| 2320 | } |
| 2321 | return false; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 2322 | } |
| 2323 | |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2324 | private void launchAssistLongPressAction() { |
| 2325 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 2326 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
| 2327 | |
| 2328 | // launch the search activity |
| 2329 | Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); |
| 2330 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2331 | try { |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2332 | // TODO: This only stops the factory-installed search manager. |
| 2333 | // Need to formalize an API to handle others |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2334 | SearchManager searchManager = getSearchManager(); |
| 2335 | if (searchManager != null) { |
| 2336 | searchManager.stopSearch(); |
| 2337 | } |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2338 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2339 | } catch (ActivityNotFoundException e) { |
| 2340 | Slog.w(TAG, "No activity to handle assist long press action.", e); |
| 2341 | } |
| 2342 | } |
| 2343 | |
| 2344 | private void launchAssistAction() { |
| 2345 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 2346 | Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 2347 | .getAssistIntent(mContext, true, UserHandle.USER_CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2348 | if (intent != null) { |
| 2349 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 2350 | | Intent.FLAG_ACTIVITY_SINGLE_TOP |
| 2351 | | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 2352 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2353 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2354 | } catch (ActivityNotFoundException e) { |
| 2355 | Slog.w(TAG, "No activity to handle assist action.", e); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2356 | } |
| 2357 | } |
| 2358 | } |
| 2359 | |
| 2360 | private SearchManager getSearchManager() { |
| 2361 | if (mSearchManager == null) { |
| 2362 | mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); |
| 2363 | } |
| 2364 | return mSearchManager; |
| 2365 | } |
| 2366 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2367 | private void preloadRecentApps() { |
| 2368 | mPreloadedRecentApps = true; |
| 2369 | try { |
| 2370 | IStatusBarService statusbar = getStatusBarService(); |
| 2371 | if (statusbar != null) { |
| 2372 | statusbar.preloadRecentApps(); |
| 2373 | } |
| 2374 | } catch (RemoteException e) { |
| 2375 | Slog.e(TAG, "RemoteException when preloading recent apps", e); |
| 2376 | // re-acquire status bar service next time it is needed. |
| 2377 | mStatusBarService = null; |
| 2378 | } |
| 2379 | } |
| 2380 | |
| 2381 | private void cancelPreloadRecentApps() { |
| 2382 | if (mPreloadedRecentApps) { |
| 2383 | mPreloadedRecentApps = false; |
| 2384 | try { |
| 2385 | IStatusBarService statusbar = getStatusBarService(); |
| 2386 | if (statusbar != null) { |
| 2387 | statusbar.cancelPreloadRecentApps(); |
| 2388 | } |
| 2389 | } catch (RemoteException e) { |
| 2390 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
| 2391 | // re-acquire status bar service next time it is needed. |
| 2392 | mStatusBarService = null; |
| 2393 | } |
| 2394 | } |
| 2395 | } |
| 2396 | |
| 2397 | private void toggleRecentApps() { |
| 2398 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2399 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS); |
| 2400 | try { |
| 2401 | IStatusBarService statusbar = getStatusBarService(); |
| 2402 | if (statusbar != null) { |
| 2403 | statusbar.toggleRecentApps(); |
| 2404 | } |
| 2405 | } catch (RemoteException e) { |
| 2406 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
| 2407 | // re-acquire status bar service next time it is needed. |
| 2408 | mStatusBarService = null; |
| 2409 | } |
| 2410 | } |
| 2411 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2412 | /** |
| 2413 | * A home key -> launch home action was detected. Take the appropriate action |
| 2414 | * given the situation with the keyguard. |
| 2415 | */ |
| 2416 | void launchHomeFromHotKey() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2417 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowingAndNotHidden()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2418 | // don't launch home if keyguard showing |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2419 | } else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2420 | // when in keyguard restricted mode, must first verify unlock |
| 2421 | // before launching home |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2422 | mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2423 | public void onKeyguardExitResult(boolean success) { |
| 2424 | if (success) { |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2425 | try { |
| 2426 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2427 | } catch (RemoteException e) { |
| 2428 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2429 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2430 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2431 | } |
| 2432 | } |
| 2433 | }); |
| 2434 | } else { |
| 2435 | // no keyguard stuff to worry about, just launch home! |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2436 | try { |
| 2437 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2438 | } catch (RemoteException e) { |
| 2439 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2440 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2441 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2442 | } |
| 2443 | } |
| 2444 | |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2445 | private final Runnable mClearHideNavigationFlag = new Runnable() { |
| 2446 | @Override |
| 2447 | public void run() { |
| 2448 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
| 2449 | // Clear flags. |
| 2450 | mForceClearedSystemUiFlags &= |
| 2451 | ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 2452 | } |
| 2453 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2454 | } |
| 2455 | }; |
| 2456 | |
| 2457 | /** |
| 2458 | * Input handler used while nav bar is hidden. Captures any touch on the screen, |
| 2459 | * to determine when the nav bar should be shown and prevent applications from |
| 2460 | * receiving those touches. |
| 2461 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2462 | final class HideNavInputEventReceiver extends InputEventReceiver { |
| 2463 | public HideNavInputEventReceiver(InputChannel inputChannel, Looper looper) { |
| 2464 | super(inputChannel, looper); |
| 2465 | } |
| 2466 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2467 | @Override |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2468 | public void onInputEvent(InputEvent event) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2469 | boolean handled = false; |
| 2470 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 2471 | if (event instanceof MotionEvent |
| 2472 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 2473 | final MotionEvent motionEvent = (MotionEvent)event; |
| 2474 | if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2475 | // When the user taps down, we re-show the nav bar. |
| 2476 | boolean changed = false; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2477 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2478 | // Any user activity always causes us to show the |
| 2479 | // navigation controls, if they had been hidden. |
| 2480 | // We also clear the low profile and only content |
| 2481 | // flags so that tapping on the screen will atomically |
| 2482 | // restore all currently hidden screen decorations. |
| 2483 | int newVal = mResettingSystemUiFlags | |
| 2484 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| 2485 | View.SYSTEM_UI_FLAG_LOW_PROFILE | |
| 2486 | View.SYSTEM_UI_FLAG_FULLSCREEN; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2487 | if (mResettingSystemUiFlags != newVal) { |
| 2488 | mResettingSystemUiFlags = newVal; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2489 | changed = true; |
| 2490 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2491 | // We don't allow the system's nav bar to be hidden |
| 2492 | // again for 1 second, to prevent applications from |
| 2493 | // spamming us and keeping it from being shown. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2494 | newVal = mForceClearedSystemUiFlags | |
| 2495 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2496 | if (mForceClearedSystemUiFlags != newVal) { |
| 2497 | mForceClearedSystemUiFlags = newVal; |
| 2498 | changed = true; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2499 | mHandler.postDelayed(mClearHideNavigationFlag, 1000); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2500 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2501 | } |
| 2502 | if (changed) { |
| 2503 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 2504 | } |
| 2505 | } |
| 2506 | } |
| 2507 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2508 | finishInputEvent(event, handled); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2509 | } |
| 2510 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2511 | } |
| 2512 | final InputEventReceiver.Factory mHideNavInputEventReceiverFactory = |
| 2513 | new InputEventReceiver.Factory() { |
| 2514 | @Override |
| 2515 | public InputEventReceiver createInputEventReceiver( |
| 2516 | InputChannel inputChannel, Looper looper) { |
| 2517 | return new HideNavInputEventReceiver(inputChannel, looper); |
| 2518 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2519 | }; |
| 2520 | |
| 2521 | @Override |
| 2522 | public int adjustSystemUiVisibilityLw(int visibility) { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2523 | if (mStatusBar != null && mStatusHideybar == HIDEYBAR_SHOWING && |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2524 | 0 == (visibility & View.STATUS_BAR_OVERLAY)) { |
| 2525 | mStatusHideybar = HIDEYBAR_HIDING; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2526 | mStatusBar.hideLw(true); |
| 2527 | } |
John Spurlock | e3b642e | 2013-05-09 15:51:32 -0400 | [diff] [blame] | 2528 | if (mNavigationBar != null && mNavigationHideybar == HIDEYBAR_SHOWING && |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2529 | 0 == (visibility & View.NAVIGATION_BAR_OVERLAY)) { |
| 2530 | mNavigationHideybar = HIDEYBAR_HIDING; |
| 2531 | mNavigationBar.hideLw(true); |
| 2532 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2533 | // Reset any bits in mForceClearingStatusBarVisibility that |
| 2534 | // are now clear. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2535 | mResettingSystemUiFlags &= visibility; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2536 | // Clear any bits in the new visibility that are currently being |
| 2537 | // force cleared, before reporting it. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2538 | return visibility & ~mResettingSystemUiFlags |
| 2539 | & ~mForceClearedSystemUiFlags; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2540 | } |
| 2541 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2542 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2543 | public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset) { |
| 2544 | final int fl = attrs.flags; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2545 | final int systemUiVisibility = (attrs.systemUiVisibility|attrs.subtreeSystemUiVisibility); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2546 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2547 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2548 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2549 | int availRight, availBottom; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2550 | if (mCanHideNavigationBar && |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2551 | (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2552 | availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 2553 | availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
| 2554 | } else { |
| 2555 | availRight = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 2556 | availBottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
| 2557 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2558 | if ((systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2559 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 2560 | contentInset.set(mStableFullscreenLeft, mStableFullscreenTop, |
| 2561 | availRight - mStableFullscreenRight, |
| 2562 | availBottom - mStableFullscreenBottom); |
| 2563 | } else { |
| 2564 | contentInset.set(mStableLeft, mStableTop, |
| 2565 | availRight - mStableRight, availBottom - mStableBottom); |
| 2566 | } |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2567 | } else if ((fl & FLAG_FULLSCREEN) != 0 || (fl & FLAG_LAYOUT_IN_OVERSCAN) != 0) { |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2568 | contentInset.setEmpty(); |
| 2569 | } else if ((systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2570 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) { |
| 2571 | contentInset.set(mCurLeft, mCurTop, |
| 2572 | availRight - mCurRight, availBottom - mCurBottom); |
| 2573 | } else { |
| 2574 | contentInset.set(mCurLeft, mCurTop, |
| 2575 | availRight - mCurRight, availBottom - mCurBottom); |
| 2576 | } |
| 2577 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2578 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2579 | contentInset.setEmpty(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2580 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2581 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2582 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2583 | @Override |
| 2584 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
| 2585 | int displayRotation) { |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2586 | final int overscanLeft, overscanTop, overscanRight, overscanBottom; |
| 2587 | if (isDefaultDisplay) { |
| 2588 | switch (displayRotation) { |
| 2589 | case Surface.ROTATION_90: |
| 2590 | overscanLeft = mOverscanTop; |
| 2591 | overscanTop = mOverscanRight; |
| 2592 | overscanRight = mOverscanBottom; |
| 2593 | overscanBottom = mOverscanLeft; |
| 2594 | break; |
| 2595 | case Surface.ROTATION_180: |
| 2596 | overscanLeft = mOverscanRight; |
| 2597 | overscanTop = mOverscanBottom; |
| 2598 | overscanRight = mOverscanLeft; |
| 2599 | overscanBottom = mOverscanTop; |
| 2600 | break; |
| 2601 | case Surface.ROTATION_270: |
| 2602 | overscanLeft = mOverscanBottom; |
| 2603 | overscanTop = mOverscanLeft; |
| 2604 | overscanRight = mOverscanTop; |
| 2605 | overscanBottom = mOverscanRight; |
| 2606 | break; |
| 2607 | default: |
| 2608 | overscanLeft = mOverscanLeft; |
| 2609 | overscanTop = mOverscanTop; |
| 2610 | overscanRight = mOverscanRight; |
| 2611 | overscanBottom = mOverscanBottom; |
| 2612 | break; |
| 2613 | } |
| 2614 | } else { |
| 2615 | overscanLeft = 0; |
| 2616 | overscanTop = 0; |
| 2617 | overscanRight = 0; |
| 2618 | overscanBottom = 0; |
| 2619 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2620 | mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0; |
| 2621 | mOverscanScreenTop = mRestrictedOverscanScreenTop = 0; |
| 2622 | mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth; |
| 2623 | mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2624 | mSystemLeft = 0; |
| 2625 | mSystemTop = 0; |
| 2626 | mSystemRight = displayWidth; |
| 2627 | mSystemBottom = displayHeight; |
| 2628 | mUnrestrictedScreenLeft = overscanLeft; |
| 2629 | mUnrestrictedScreenTop = overscanTop; |
| 2630 | mUnrestrictedScreenWidth = displayWidth - overscanLeft - overscanRight; |
| 2631 | mUnrestrictedScreenHeight = displayHeight - overscanTop - overscanBottom; |
| 2632 | mRestrictedScreenLeft = mUnrestrictedScreenLeft; |
| 2633 | mRestrictedScreenTop = mUnrestrictedScreenTop; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2634 | mRestrictedScreenWidth = mSystemGestures.screenWidth = mUnrestrictedScreenWidth; |
| 2635 | mRestrictedScreenHeight = mSystemGestures.screenHeight = mUnrestrictedScreenHeight; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2636 | mDockLeft = mContentLeft = mStableLeft = mStableFullscreenLeft |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2637 | = mCurLeft = mUnrestrictedScreenLeft; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2638 | mDockTop = mContentTop = mStableTop = mStableFullscreenTop |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2639 | = mCurTop = mUnrestrictedScreenTop; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2640 | mDockRight = mContentRight = mStableRight = mStableFullscreenRight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2641 | = mCurRight = displayWidth - overscanRight; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2642 | mDockBottom = mContentBottom = mStableBottom = mStableFullscreenBottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2643 | = mCurBottom = displayHeight - overscanBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2644 | mDockLayer = 0x10000000; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 2645 | mStatusBarLayer = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2646 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2647 | // start with the current dock rect, which will be (0,0,displayWidth,displayHeight) |
| 2648 | final Rect pf = mTmpParentFrame; |
| 2649 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2650 | final Rect of = mTmpOverscanFrame; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2651 | final Rect vf = mTmpVisibleFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2652 | pf.left = df.left = of.left = vf.left = mDockLeft; |
| 2653 | pf.top = df.top = of.top = vf.top = mDockTop; |
| 2654 | pf.right = df.right = of.right = vf.right = mDockRight; |
| 2655 | pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2656 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2657 | if (isDefaultDisplay) { |
| 2658 | // For purposes of putting out fake window up to steal focus, we will |
| 2659 | // drive nav being hidden only by whether it is requested. |
| 2660 | boolean navVisible = (mLastSystemUiFlags&View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2661 | boolean overlayAllowed = (mLastSystemUiFlags&View.SYSTEM_UI_FLAG_ALLOW_OVERLAY) != 0; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2662 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2663 | // When the navigation bar isn't visible, we put up a fake |
| 2664 | // input window to catch all touch events. This way we can |
| 2665 | // detect when the user presses anywhere to bring back the nav |
| 2666 | // bar and ensure the application doesn't see the event. |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2667 | if (navVisible || overlayAllowed) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2668 | if (mHideNavFakeWindow != null) { |
| 2669 | mHideNavFakeWindow.dismiss(); |
| 2670 | mHideNavFakeWindow = null; |
| 2671 | } |
| 2672 | } else if (mHideNavFakeWindow == null) { |
| 2673 | mHideNavFakeWindow = mWindowManagerFuncs.addFakeWindow( |
| 2674 | mHandler.getLooper(), mHideNavInputEventReceiverFactory, |
| 2675 | "hidden nav", WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER, |
| 2676 | 0, false, false, true); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2677 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2678 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2679 | // For purposes of positioning and showing the nav bar, if we have |
| 2680 | // decided that it can't be hidden (because of the screen aspect ratio), |
| 2681 | // then take that into account. |
| 2682 | navVisible |= !mCanHideNavigationBar; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2683 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2684 | boolean updateSysUiVisibility = false; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2685 | if (mNavigationBar != null) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2686 | boolean navBarHideyShowing = mNavigationHideybar == HIDEYBAR_SHOWING; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2687 | // Force the navigation bar to its appropriate place and |
| 2688 | // size. We need to do this directly, instead of relying on |
| 2689 | // it to bubble up from the nav bar, because this needs to |
| 2690 | // change atomically with screen rotations. |
| 2691 | mNavigationBarOnBottom = (!mNavigationBarCanMove || displayWidth < displayHeight); |
| 2692 | if (mNavigationBarOnBottom) { |
| 2693 | // It's a system nav bar or a portrait screen; nav bar goes on bottom. |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2694 | int top = displayHeight - overscanBottom |
| 2695 | - mNavigationBarHeightForRotation[displayRotation]; |
| 2696 | mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2697 | mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2698 | if (navBarHideyShowing) { |
| 2699 | mNavigationBar.showLw(true); |
| 2700 | } else if (navVisible) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2701 | mNavigationBar.showLw(true); |
| 2702 | mDockBottom = mTmpNavigationFrame.top; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2703 | mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop; |
| 2704 | mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2705 | } else { |
| 2706 | // We currently want to hide the navigation UI. |
| 2707 | mNavigationBar.hideLw(true); |
| 2708 | } |
| 2709 | if (navVisible && !mNavigationBar.isAnimatingLw()) { |
| 2710 | // If the nav bar is currently requested to be visible, |
| 2711 | // and not in the process of animating on or off, then |
| 2712 | // we can tell the app that it is covered by it. |
| 2713 | mSystemBottom = mTmpNavigationFrame.top; |
| 2714 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2715 | } else { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2716 | // Landscape screen; nav bar goes to the right. |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2717 | int left = displayWidth - overscanRight |
| 2718 | - mNavigationBarWidthForRotation[displayRotation]; |
| 2719 | mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2720 | mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2721 | if (navBarHideyShowing) { |
| 2722 | mNavigationBar.showLw(true); |
| 2723 | } else if (navVisible) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2724 | mNavigationBar.showLw(true); |
| 2725 | mDockRight = mTmpNavigationFrame.left; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2726 | mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft; |
| 2727 | mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2728 | } else { |
| 2729 | // We currently want to hide the navigation UI. |
| 2730 | mNavigationBar.hideLw(true); |
| 2731 | } |
| 2732 | if (navVisible && !mNavigationBar.isAnimatingLw()) { |
| 2733 | // If the nav bar is currently requested to be visible, |
| 2734 | // and not in the process of animating on or off, then |
| 2735 | // we can tell the app that it is covered by it. |
| 2736 | mSystemRight = mTmpNavigationFrame.left; |
| 2737 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2738 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2739 | // Make sure the content and current rectangles are updated to |
| 2740 | // account for the restrictions from the navigation bar. |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2741 | mContentTop = mCurTop = mDockTop; |
| 2742 | mContentBottom = mCurBottom = mDockBottom; |
| 2743 | mContentLeft = mCurLeft = mDockLeft; |
| 2744 | mContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2745 | mStatusBarLayer = mNavigationBar.getSurfaceLayer(); |
| 2746 | // And compute the final frame. |
| 2747 | mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2748 | mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2749 | if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2750 | if (mNavigationHideybar == HIDEYBAR_HIDING && !mNavigationBar.isVisibleLw()) { |
| 2751 | // Finished animating out, clean up and reset alpha |
| 2752 | mNavigationHideybar = HIDEYBAR_NONE; |
| 2753 | updateSysUiVisibility = true; |
| 2754 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2755 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2756 | if (DEBUG_LAYOUT) Slog.i(TAG, String.format("mDock rect: (%d,%d - %d,%d)", |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2757 | mDockLeft, mDockTop, mDockRight, mDockBottom)); |
| 2758 | |
| 2759 | // decide where the status bar goes ahead of time |
| 2760 | if (mStatusBar != null) { |
| 2761 | // apply any navigation bar insets |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2762 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 2763 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 2764 | pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft; |
| 2765 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight |
| 2766 | + mUnrestrictedScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2767 | vf.left = mStableLeft; |
| 2768 | vf.top = mStableTop; |
| 2769 | vf.right = mStableRight; |
| 2770 | vf.bottom = mStableBottom; |
| 2771 | |
| 2772 | mStatusBarLayer = mStatusBar.getSurfaceLayer(); |
| 2773 | |
| 2774 | // Let the status bar determine its size. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2775 | mStatusBar.computeFrameLw(pf, df, vf, vf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2776 | |
| 2777 | // For layout, the status bar is always at the top with our fixed height. |
| 2778 | mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 2779 | |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2780 | boolean statusBarOverlay = (mLastSystemUiFlags & View.STATUS_BAR_OVERLAY) != 0; |
| 2781 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2782 | // If the status bar is hidden, we don't want to cause |
| 2783 | // windows behind it to scroll. |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2784 | if (mStatusBar.isVisibleLw() && !statusBarOverlay) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2785 | // Status bar may go away, so the screen area it occupies |
| 2786 | // is available to apps but just covering them when the |
| 2787 | // status bar is visible. |
| 2788 | mDockTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 2789 | |
| 2790 | mContentTop = mCurTop = mDockTop; |
| 2791 | mContentBottom = mCurBottom = mDockBottom; |
| 2792 | mContentLeft = mCurLeft = mDockLeft; |
| 2793 | mContentRight = mCurRight = mDockRight; |
| 2794 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2795 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar: " + |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2796 | String.format( |
| 2797 | "dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]", |
| 2798 | mDockLeft, mDockTop, mDockRight, mDockBottom, |
| 2799 | mContentLeft, mContentTop, mContentRight, mContentBottom, |
| 2800 | mCurLeft, mCurTop, mCurRight, mCurBottom)); |
| 2801 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2802 | if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw() && !statusBarOverlay) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2803 | // If the status bar is currently requested to be visible, |
| 2804 | // and not in the process of animating on or off, then |
| 2805 | // we can tell the app that it is covered by it. |
| 2806 | mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 2807 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2808 | |
| 2809 | if (mStatusHideybar == HIDEYBAR_HIDING && !mStatusBar.isVisibleLw()) { |
| 2810 | // Finished animating out, clean up and reset alpha |
| 2811 | mStatusHideybar = HIDEYBAR_NONE; |
| 2812 | updateSysUiVisibility = true; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2813 | } |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 2814 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2815 | if (updateSysUiVisibility) { |
| 2816 | updateSystemUiVisibilityLw(); |
| 2817 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2818 | } |
| 2819 | } |
| 2820 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 2821 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 2822 | @Override |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 2823 | public int getSystemDecorRectLw(Rect systemRect) { |
| 2824 | systemRect.left = mSystemLeft; |
| 2825 | systemRect.top = mSystemTop; |
| 2826 | systemRect.right = mSystemRight; |
| 2827 | systemRect.bottom = mSystemBottom; |
| 2828 | if (mStatusBar != null) return mStatusBar.getSurfaceLayer(); |
| 2829 | if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer(); |
| 2830 | return 0; |
| 2831 | } |
| 2832 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 2833 | @Override |
| 2834 | public void getContentRectLw(Rect r) { |
| 2835 | r.set(mContentLeft, mContentTop, mContentRight, mContentBottom); |
| 2836 | } |
| 2837 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2838 | void setAttachedWindowFrames(WindowState win, int fl, int adjust, WindowState attached, |
| 2839 | boolean insetDecors, Rect pf, Rect df, Rect of, Rect cf, Rect vf) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2840 | if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) { |
| 2841 | // Here's a special case: if this attached window is a panel that is |
| 2842 | // above the dock window, and the window it is attached to is below |
| 2843 | // the dock window, then the frames we computed for the window it is |
| 2844 | // attached to can not be used because the dock is effectively part |
| 2845 | // of the underlying window and the attached window is floating on top |
| 2846 | // of the whole thing. So, we ignore the attached window and explicitly |
| 2847 | // compute the frames that would be appropriate without the dock. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2848 | df.left = of.left = cf.left = vf.left = mDockLeft; |
| 2849 | df.top = of.top = cf.top = vf.top = mDockTop; |
| 2850 | df.right = of.right = cf.right = vf.right = mDockRight; |
| 2851 | df.bottom = of.bottom = cf.bottom = vf.bottom = mDockBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2852 | } else { |
| 2853 | // The effective display frame of the attached window depends on |
| 2854 | // whether it is taking care of insetting its content. If not, |
| 2855 | // we need to use the parent's content frame so that the entire |
| 2856 | // window is positioned within that content. Otherwise we can use |
| 2857 | // the display frame and let the attached window take care of |
| 2858 | // positioning its content appropriately. |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2859 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2860 | cf.set(attached.getOverscanFrameLw()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2861 | } else { |
| 2862 | // If the window is resizing, then we want to base the content |
| 2863 | // frame on our attached content frame to resize... however, |
| 2864 | // things can be tricky if the attached window is NOT in resize |
| 2865 | // mode, in which case its content frame will be larger. |
| 2866 | // Ungh. So to deal with that, make sure the content frame |
| 2867 | // we end up using is not covering the IM dock. |
| 2868 | cf.set(attached.getContentFrameLw()); |
| 2869 | if (attached.getSurfaceLayer() < mDockLayer) { |
| 2870 | if (cf.left < mContentLeft) cf.left = mContentLeft; |
| 2871 | if (cf.top < mContentTop) cf.top = mContentTop; |
| 2872 | if (cf.right > mContentRight) cf.right = mContentRight; |
| 2873 | if (cf.bottom > mContentBottom) cf.bottom = mContentBottom; |
| 2874 | } |
| 2875 | } |
| 2876 | df.set(insetDecors ? attached.getDisplayFrameLw() : cf); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2877 | of.set(insetDecors ? attached.getOverscanFrameLw() : cf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2878 | vf.set(attached.getVisibleFrameLw()); |
| 2879 | } |
| 2880 | // The LAYOUT_IN_SCREEN flag is used to determine whether the attached |
| 2881 | // window should be positioned relative to its parent or the entire |
| 2882 | // screen. |
| 2883 | pf.set((fl & FLAG_LAYOUT_IN_SCREEN) == 0 |
| 2884 | ? attached.getFrameLw() : df); |
| 2885 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2886 | |
| 2887 | private void applyStableConstraints(int sysui, int fl, Rect r) { |
| 2888 | if ((sysui & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2889 | // If app is requesting a stable layout, don't let the |
| 2890 | // content insets go below the stable values. |
| 2891 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 2892 | if (r.left < mStableFullscreenLeft) r.left = mStableFullscreenLeft; |
| 2893 | if (r.top < mStableFullscreenTop) r.top = mStableFullscreenTop; |
| 2894 | if (r.right > mStableFullscreenRight) r.right = mStableFullscreenRight; |
| 2895 | if (r.bottom > mStableFullscreenBottom) r.bottom = mStableFullscreenBottom; |
| 2896 | } else { |
| 2897 | if (r.left < mStableLeft) r.left = mStableLeft; |
| 2898 | if (r.top < mStableTop) r.top = mStableTop; |
| 2899 | if (r.right > mStableRight) r.right = mStableRight; |
| 2900 | if (r.bottom > mStableBottom) r.bottom = mStableBottom; |
| 2901 | } |
| 2902 | } |
| 2903 | } |
| 2904 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2905 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2906 | @Override |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 2907 | public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs, |
| 2908 | WindowState attached) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2909 | // we've already done the status bar |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 2910 | if (win == mStatusBar || win == mNavigationBar) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2911 | return; |
| 2912 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2913 | final boolean isDefaultDisplay = win.isDefaultDisplay(); |
| 2914 | final boolean needsToOffsetInputMethodTarget = isDefaultDisplay && |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 2915 | (win == mLastInputMethodTargetWindow && mLastInputMethodWindow != null); |
| 2916 | if (needsToOffsetInputMethodTarget) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2917 | if (DEBUG_LAYOUT) Slog.i(TAG, "Offset ime target window by the last ime window state"); |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 2918 | offsetInputMethodWindowLw(mLastInputMethodWindow); |
| 2919 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2920 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2921 | final int fl = attrs.flags; |
| 2922 | final int sim = attrs.softInputMode; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2923 | final int sysUiFl = win.getSystemUiVisibility(); |
| 2924 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2925 | final Rect pf = mTmpParentFrame; |
| 2926 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2927 | final Rect of = mTmpOverscanFrame; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2928 | final Rect cf = mTmpContentFrame; |
| 2929 | final Rect vf = mTmpVisibleFrame; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2930 | |
| 2931 | final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 2932 | && mNavigationBar != null && mNavigationBar.isVisibleLw()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2933 | |
Craig Mautner | f683b56 | 2012-10-02 11:10:57 -0700 | [diff] [blame] | 2934 | final int adjust = sim & SOFT_INPUT_MASK_ADJUST; |
| 2935 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2936 | if (!isDefaultDisplay) { |
| 2937 | if (attached != null) { |
| 2938 | // If this window is attached to another, our display |
| 2939 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2940 | setAttachedWindowFrames(win, fl, adjust, attached, true, pf, df, of, cf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2941 | } else { |
| 2942 | // Give the window full screen. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2943 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 2944 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 2945 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2946 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2947 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2948 | = mOverscanScreenTop + mOverscanScreenHeight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2949 | } |
| 2950 | } else if (attrs.type == TYPE_INPUT_METHOD) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2951 | pf.left = df.left = of.left = cf.left = vf.left = mDockLeft; |
| 2952 | pf.top = df.top = of.top = cf.top = vf.top = mDockTop; |
| 2953 | pf.right = df.right = of.right = cf.right = vf.right = mDockRight; |
| 2954 | pf.bottom = df.bottom = of.bottom = cf.bottom = vf.bottom = mDockBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2955 | // IM dock windows always go to the bottom of the screen. |
| 2956 | attrs.gravity = Gravity.BOTTOM; |
| 2957 | mDockLayer = win.getSurfaceLayer(); |
| 2958 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2959 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) |
| 2960 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2961 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2962 | + "): IN_SCREEN, INSET_DECOR"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2963 | // This is the case for a normal activity window: we want it |
| 2964 | // to cover all of the screen space, and it can take care of |
| 2965 | // moving its contents to account for screen decorations that |
| 2966 | // intrude into that space. |
| 2967 | if (attached != null) { |
| 2968 | // If this window is attached to another, our display |
| 2969 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2970 | setAttachedWindowFrames(win, fl, adjust, attached, true, pf, df, of, cf, vf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2971 | } else { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2972 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 2973 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2974 | // Status bar panels are the only windows who can go on top of |
| 2975 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 2976 | // permission, so they have the same privileges as the status |
| 2977 | // bar itself. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2978 | // |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 2979 | // However, they should still dodge the navigation bar if it exists. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2980 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2981 | pf.left = df.left = of.left = hasNavBar |
| 2982 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 2983 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 2984 | pf.right = df.right = of.right = hasNavBar |
| 2985 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
| 2986 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 2987 | pf.bottom = df.bottom = of.bottom = hasNavBar |
| 2988 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
| 2989 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2990 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2991 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 2992 | "Laying out status bar window: (%d,%d - %d,%d)", |
| 2993 | pf.left, pf.top, pf.right, pf.bottom)); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2994 | } else if ((attrs.flags&FLAG_LAYOUT_IN_OVERSCAN) != 0 |
| 2995 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 2996 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 2997 | // Asking to layout into the overscan region, so give it that pure |
| 2998 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2999 | pf.left = df.left = of.left = mOverscanScreenLeft; |
| 3000 | pf.top = df.top = of.top = mOverscanScreenTop; |
| 3001 | pf.right = df.right = of.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3002 | pf.bottom = df.bottom = of.bottom = mOverscanScreenTop |
| 3003 | + mOverscanScreenHeight; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3004 | } else if (mCanHideNavigationBar |
| 3005 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3006 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3007 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3008 | // Asking for layout as if the nav bar is hidden, lets the |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3009 | // application extend into the unrestricted overscan screen area. We |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3010 | // only do this for application windows to ensure no window that |
| 3011 | // can be above the nav bar can do this. |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3012 | pf.left = df.left = mOverscanScreenLeft; |
| 3013 | pf.top = df.top = mOverscanScreenTop; |
| 3014 | pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3015 | pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3016 | // We need to tell the app about where the frame inside the overscan |
| 3017 | // is, so it can inset its content by that amount -- it didn't ask |
| 3018 | // to actually extend itself into the overscan region. |
| 3019 | of.left = mUnrestrictedScreenLeft; |
| 3020 | of.top = mUnrestrictedScreenTop; |
| 3021 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3022 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3023 | } else { |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3024 | pf.left = df.left = mRestrictedOverscanScreenLeft; |
| 3025 | pf.top = df.top = mRestrictedOverscanScreenTop; |
| 3026 | pf.right = df.right = mRestrictedOverscanScreenLeft |
| 3027 | + mRestrictedOverscanScreenWidth; |
| 3028 | pf.bottom = df.bottom = mRestrictedOverscanScreenTop |
| 3029 | + mRestrictedOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3030 | // We need to tell the app about where the frame inside the overscan |
| 3031 | // is, so it can inset its content by that amount -- it didn't ask |
| 3032 | // to actually extend itself into the overscan region. |
| 3033 | of.left = mUnrestrictedScreenLeft; |
| 3034 | of.top = mUnrestrictedScreenTop; |
| 3035 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3036 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3037 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3038 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3039 | if ((attrs.flags&FLAG_FULLSCREEN) == 0) { |
| 3040 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
| 3041 | cf.left = mDockLeft; |
| 3042 | cf.top = mDockTop; |
| 3043 | cf.right = mDockRight; |
| 3044 | cf.bottom = mDockBottom; |
| 3045 | } else { |
| 3046 | cf.left = mContentLeft; |
| 3047 | cf.top = mContentTop; |
| 3048 | cf.right = mContentRight; |
| 3049 | cf.bottom = mContentBottom; |
| 3050 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3051 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3052 | // Full screen windows are always given a layout that is as if the |
| 3053 | // status bar and other transient decors are gone. This is to avoid |
| 3054 | // bad states when moving from a window that is not hding the |
| 3055 | // status bar to one that is. |
| 3056 | cf.left = mRestrictedScreenLeft; |
| 3057 | cf.top = mRestrictedScreenTop; |
| 3058 | cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 3059 | cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3060 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3061 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3062 | applyStableConstraints(sysUiFl, fl, cf); |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3063 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3064 | vf.left = mCurLeft; |
| 3065 | vf.top = mCurTop; |
| 3066 | vf.right = mCurRight; |
| 3067 | vf.bottom = mCurBottom; |
| 3068 | } else { |
| 3069 | vf.set(cf); |
| 3070 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3071 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3072 | } else if ((fl & FLAG_LAYOUT_IN_SCREEN) != 0 || (sysUiFl |
| 3073 | & (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 3074 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3075 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3076 | "): IN_SCREEN"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3077 | // A window that has requested to fill the entire screen just |
| 3078 | // gets everything, period. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3079 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3080 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3081 | pf.left = df.left = of.left = cf.left = hasNavBar |
| 3082 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3083 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3084 | pf.right = df.right = of.right = cf.right = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3085 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3086 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3087 | pf.bottom = df.bottom = of.bottom = cf.bottom = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3088 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3089 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3090 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3091 | "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)", |
| 3092 | pf.left, pf.top, pf.right, pf.bottom)); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 3093 | } else if (attrs.type == TYPE_NAVIGATION_BAR |
| 3094 | || attrs.type == TYPE_NAVIGATION_BAR_PANEL) { |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3095 | // The navigation bar has Real Ultimate Power. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3096 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3097 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3098 | pf.right = df.right = of.right = mUnrestrictedScreenLeft |
| 3099 | + mUnrestrictedScreenWidth; |
| 3100 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop |
| 3101 | + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3102 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3103 | "Laying out navigation bar window: (%d,%d - %d,%d)", |
| 3104 | pf.left, pf.top, pf.right, pf.bottom)); |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3105 | } else if ((attrs.type == TYPE_SECURE_SYSTEM_OVERLAY |
| 3106 | || attrs.type == TYPE_BOOT_PROGRESS) |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 3107 | && ((fl & FLAG_FULLSCREEN) != 0)) { |
| 3108 | // Fullscreen secure system overlays get what they ask for. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3109 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3110 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3111 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3112 | + mOverscanScreenWidth; |
| 3113 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3114 | + mOverscanScreenHeight; |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 3115 | } else if (attrs.type == TYPE_BOOT_PROGRESS |
| 3116 | || attrs.type == TYPE_UNIVERSE_BACKGROUND) { |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3117 | // Boot progress screen always covers entire display. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3118 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3119 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3120 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3121 | + mOverscanScreenWidth; |
| 3122 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3123 | + mOverscanScreenHeight; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3124 | } else if (attrs.type == WindowManager.LayoutParams.TYPE_WALLPAPER) { |
| 3125 | // The wallpaper mostly goes into the overscan region. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3126 | pf.left = df.left = of.left = cf.left = mRestrictedOverscanScreenLeft; |
| 3127 | pf.top = df.top = of.top = cf.top = mRestrictedOverscanScreenTop; |
| 3128 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3129 | = mRestrictedOverscanScreenLeft + mRestrictedOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3130 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3131 | = mRestrictedOverscanScreenTop + mRestrictedOverscanScreenHeight; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3132 | } else if ((attrs.flags & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
| 3133 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3134 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3135 | // Asking to layout into the overscan region, so give it that pure |
| 3136 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3137 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3138 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3139 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3140 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3141 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3142 | = mOverscanScreenTop + mOverscanScreenHeight; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3143 | } else if (mCanHideNavigationBar |
| 3144 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3145 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3146 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3147 | // Asking for layout as if the nav bar is hidden, lets the |
| 3148 | // application extend into the unrestricted screen area. We |
| 3149 | // only do this for application windows to ensure no window that |
| 3150 | // can be above the nav bar can do this. |
| 3151 | // XXX This assumes that an app asking for this will also |
| 3152 | // ask for layout in only content. We can't currently figure out |
| 3153 | // what the screen would be if only laying out to hide the nav bar. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3154 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3155 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3156 | pf.right = df.right = of.right = cf.right = mUnrestrictedScreenLeft |
| 3157 | + mUnrestrictedScreenWidth; |
| 3158 | pf.bottom = df.bottom = of.bottom = cf.bottom = mUnrestrictedScreenTop |
| 3159 | + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3160 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3161 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3162 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3163 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3164 | + mRestrictedScreenWidth; |
| 3165 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3166 | + mRestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3167 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3168 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3169 | applyStableConstraints(sysUiFl, fl, cf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3170 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3171 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3172 | vf.left = mCurLeft; |
| 3173 | vf.top = mCurTop; |
| 3174 | vf.right = mCurRight; |
| 3175 | vf.bottom = mCurBottom; |
| 3176 | } else { |
| 3177 | vf.set(cf); |
| 3178 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3179 | } else if (attached != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3180 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3181 | "): attached to " + attached); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3182 | // A child window should be placed inside of the same visible |
| 3183 | // frame that its parent had. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3184 | setAttachedWindowFrames(win, fl, adjust, attached, false, pf, df, of, cf, vf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3185 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3186 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3187 | "): normal window"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3188 | // Otherwise, a normal window must be placed inside the content |
| 3189 | // of all screen decorations. |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3190 | if (attrs.type == TYPE_STATUS_BAR_PANEL) { |
| 3191 | // Status bar panels are the only windows who can go on top of |
| 3192 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3193 | // permission, so they have the same privileges as the status |
| 3194 | // bar itself. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3195 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3196 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3197 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3198 | + mRestrictedScreenWidth; |
| 3199 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3200 | + mRestrictedScreenHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3201 | } else { |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3202 | pf.left = mContentLeft; |
| 3203 | pf.top = mContentTop; |
| 3204 | pf.right = mContentRight; |
| 3205 | pf.bottom = mContentBottom; |
| 3206 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3207 | df.left = of.left = cf.left = mDockLeft; |
| 3208 | df.top = of.top = cf.top = mDockTop; |
| 3209 | df.right = of.right = cf.right = mDockRight; |
| 3210 | df.bottom = of.bottom = cf.bottom = mDockBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3211 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3212 | df.left = of.left = cf.left = mContentLeft; |
| 3213 | df.top = of.top = cf.top = mContentTop; |
| 3214 | df.right = of.right = cf.right = mContentRight; |
| 3215 | df.bottom = of.bottom = cf.bottom = mContentBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3216 | } |
| 3217 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3218 | vf.left = mCurLeft; |
| 3219 | vf.top = mCurTop; |
| 3220 | vf.right = mCurRight; |
| 3221 | vf.bottom = mCurBottom; |
| 3222 | } else { |
| 3223 | vf.set(cf); |
| 3224 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3225 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3226 | } |
| 3227 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3228 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3229 | if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3230 | df.left = df.top = of.left = of.top = cf.left = cf.top = vf.left = vf.top = -10000; |
| 3231 | df.right = df.bottom = of.right = of.bottom = cf.right = cf.bottom |
| 3232 | = vf.right = vf.bottom = 10000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3233 | } |
| 3234 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3235 | if (DEBUG_LAYOUT) Slog.v(TAG, "Compute frame " + attrs.getTitle() |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 3236 | + ": sim=#" + Integer.toHexString(sim) |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3237 | + " attach=" + attached + " type=" + attrs.type |
| 3238 | + String.format(" flags=0x%08x", fl) |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 3239 | + " pf=" + pf.toShortString() + " df=" + df.toShortString() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3240 | + " of=" + of.toShortString() |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 3241 | + " cf=" + cf.toShortString() + " vf=" + vf.toShortString()); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3242 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3243 | win.computeFrameLw(pf, df, of, cf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3244 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3245 | // Dock windows carve out the bottom of the screen, so normal windows |
| 3246 | // can't appear underneath them. |
Craig Mautner | 8bd206b | 2012-10-03 10:32:02 -0700 | [diff] [blame] | 3247 | if (attrs.type == TYPE_INPUT_METHOD && win.isVisibleOrBehindKeyguardLw() |
| 3248 | && !win.getGivenInsetsPendingLw()) { |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3249 | setLastInputMethodWindowLw(null, null); |
| 3250 | offsetInputMethodWindowLw(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3251 | } |
| 3252 | } |
| 3253 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3254 | private void offsetInputMethodWindowLw(WindowState win) { |
| 3255 | int top = win.getContentFrameLw().top; |
| 3256 | top += win.getGivenContentInsetsLw().top; |
| 3257 | if (mContentBottom > top) { |
| 3258 | mContentBottom = top; |
| 3259 | } |
| 3260 | top = win.getVisibleFrameLw().top; |
| 3261 | top += win.getGivenVisibleInsetsLw().top; |
| 3262 | if (mCurBottom > top) { |
| 3263 | mCurBottom = top; |
| 3264 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3265 | if (DEBUG_LAYOUT) Slog.v(TAG, "Input method: mDockBottom=" |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3266 | + mDockBottom + " mContentBottom=" |
| 3267 | + mContentBottom + " mCurBottom=" + mCurBottom); |
| 3268 | } |
| 3269 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3270 | /** {@inheritDoc} */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 3271 | @Override |
| 3272 | public void finishLayoutLw() { |
| 3273 | return; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3274 | } |
| 3275 | |
| 3276 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3277 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3278 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3279 | mTopFullscreenOpaqueWindowState = null; |
| 3280 | mForceStatusBar = false; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3281 | mForceStatusBarFromKeyguard = false; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3282 | mForcingShowNavBar = false; |
| 3283 | mForcingShowNavBarLayer = -1; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3284 | |
| 3285 | mHideLockScreen = false; |
| 3286 | mAllowLockscreenWhenOn = false; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3287 | mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3288 | mShowingLockscreen = false; |
| 3289 | mShowingDream = false; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3290 | } |
| 3291 | |
| 3292 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3293 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3294 | public void applyPostLayoutPolicyLw(WindowState win, |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3295 | WindowManager.LayoutParams attrs) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3296 | if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw=" |
| 3297 | + win.isVisibleOrBehindKeyguardLw()); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3298 | if (mTopFullscreenOpaqueWindowState == null && (win.getAttrs().privateFlags |
| 3299 | &WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_SHOW_NAV_BAR) != 0) { |
| 3300 | if (mForcingShowNavBarLayer < 0) { |
| 3301 | mForcingShowNavBar = true; |
| 3302 | mForcingShowNavBarLayer = win.getSurfaceLayer(); |
| 3303 | } |
| 3304 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3305 | if (mTopFullscreenOpaqueWindowState == null && |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 3306 | win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3307 | if ((attrs.flags & FLAG_FORCE_NOT_FULLSCREEN) != 0) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3308 | if (attrs.type == TYPE_KEYGUARD) { |
| 3309 | mForceStatusBarFromKeyguard = true; |
| 3310 | } else { |
| 3311 | mForceStatusBar = true; |
| 3312 | } |
| 3313 | } |
| 3314 | if (attrs.type == TYPE_KEYGUARD) { |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3315 | mShowingLockscreen = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3316 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3317 | boolean applyWindow = attrs.type >= FIRST_APPLICATION_WINDOW |
| 3318 | && attrs.type <= LAST_APPLICATION_WINDOW; |
| 3319 | if (attrs.type == TYPE_DREAM) { |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3320 | // If the lockscreen was showing when the dream started then wait |
| 3321 | // for the dream to draw before hiding the lockscreen. |
| 3322 | if (!mDreamingLockscreen |
| 3323 | || (win.isVisibleLw() && win.hasDrawnLw())) { |
| 3324 | mShowingDream = true; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3325 | applyWindow = true; |
| 3326 | } |
| 3327 | } |
| 3328 | if (applyWindow |
Dianne Hackborn | 6493e64 | 2010-10-01 13:06:30 -0700 | [diff] [blame] | 3329 | && attrs.x == 0 && attrs.y == 0 |
| 3330 | && attrs.width == WindowManager.LayoutParams.MATCH_PARENT |
| 3331 | && attrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3332 | if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3333 | mTopFullscreenOpaqueWindowState = win; |
| 3334 | if ((attrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3335 | if (DEBUG_LAYOUT) Slog.v(TAG, "Setting mHideLockScreen to true by win " + win); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3336 | mHideLockScreen = true; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3337 | mForceStatusBarFromKeyguard = false; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3338 | } |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3339 | if ((attrs.flags & FLAG_DISMISS_KEYGUARD) != 0 |
| 3340 | && mDismissKeyguard == DISMISS_KEYGUARD_NONE) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3341 | if (DEBUG_LAYOUT) Slog.v(TAG, "Setting mDismissKeyguard true by win " + win); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3342 | mDismissKeyguard = mWinDismissingKeyguard == win ? |
| 3343 | DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START; |
| 3344 | mWinDismissingKeyguard = win; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3345 | mForceStatusBarFromKeyguard = mShowingLockscreen && isKeyguardSecure(); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3346 | } |
| 3347 | if ((attrs.flags & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) { |
| 3348 | mAllowLockscreenWhenOn = true; |
| 3349 | } |
| 3350 | } |
| 3351 | } |
| 3352 | } |
| 3353 | |
| 3354 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3355 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3356 | public int finishPostLayoutPolicyLw() { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3357 | int changes = 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3358 | boolean topIsFullscreen = false; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3359 | |
| 3360 | final WindowManager.LayoutParams lp = (mTopFullscreenOpaqueWindowState != null) |
| 3361 | ? mTopFullscreenOpaqueWindowState.getAttrs() |
| 3362 | : null; |
| 3363 | |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3364 | // If we are not currently showing a dream then remember the current |
| 3365 | // lockscreen state. We will use this to determine whether the dream |
| 3366 | // started while the lockscreen was showing and remember this state |
| 3367 | // while the dream is showing. |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3368 | if (!mShowingDream) { |
| 3369 | mDreamingLockscreen = mShowingLockscreen; |
| 3370 | } |
| 3371 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3372 | if (mStatusBar != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3373 | if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3374 | + " forcefkg=" + mForceStatusBarFromKeyguard |
Dianne Hackborn | d70bc2f | 2009-10-06 23:25:51 -0700 | [diff] [blame] | 3375 | + " top=" + mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3376 | if (mForceStatusBar || mForceStatusBarFromKeyguard) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3377 | if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced"); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3378 | if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3379 | } else if (mTopFullscreenOpaqueWindowState != null) { |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3380 | if (localLOGV) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3381 | Slog.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw() |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3382 | + " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw()); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3383 | Slog.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs() |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3384 | + " lp.flags=0x" + Integer.toHexString(lp.flags)); |
| 3385 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3386 | topIsFullscreen = (lp.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0 |
| 3387 | || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3388 | // The subtle difference between the window for mTopFullscreenOpaqueWindowState |
| 3389 | // and mTopIsFullscreen is that that mTopIsFullscreen is set only if the window |
| 3390 | // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the |
| 3391 | // case though. |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3392 | if (mStatusHideybar == HIDEYBAR_SHOWING) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3393 | if (mStatusBar.showLw(true)) { |
| 3394 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3395 | } |
| 3396 | } else if (topIsFullscreen) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3397 | if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar"); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3398 | if (mStatusBar.hideLw(true)) { |
| 3399 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
Daniel Sandler | 9c00d5b | 2011-09-13 14:04:26 -0400 | [diff] [blame] | 3400 | |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3401 | mHandler.post(new Runnable() { |
| 3402 | @Override |
| 3403 | public void run() { |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 3404 | try { |
| 3405 | IStatusBarService statusbar = getStatusBarService(); |
| 3406 | if (statusbar != null) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 3407 | statusbar.collapsePanels(); |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 3408 | } |
| 3409 | } catch (RemoteException ex) { |
| 3410 | // re-acquire status bar service next time it is needed. |
| 3411 | mStatusBarService = null; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3412 | } |
| 3413 | }}); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3414 | } else { |
Craig Mautner | c5a6e44 | 2013-06-05 17:22:35 -0700 | [diff] [blame] | 3415 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar already hiding"); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 3416 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3417 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3418 | if (DEBUG_LAYOUT) Slog.v(TAG, "** SHOWING status bar: top is not fullscreen"); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3419 | if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3420 | } |
| 3421 | } |
| 3422 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3423 | |
Joe Onorato | 644f9c3 | 2011-01-25 12:06:23 -0800 | [diff] [blame] | 3424 | mTopIsFullscreen = topIsFullscreen; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3425 | |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3426 | // Hide the key guard if a visible window explicitly specifies that it wants to be |
| 3427 | // displayed when the screen is locked. |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 3428 | if (mKeyguard != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3429 | if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard=" |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3430 | + mHideLockScreen); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3431 | if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !mKeyguardDelegate.isSecure()) { |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3432 | if (mKeyguard.hideLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3433 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3434 | | FINISH_LAYOUT_REDO_CONFIG |
| 3435 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3436 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3437 | if (mKeyguardDelegate.isShowing()) { |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 3438 | mHandler.post(new Runnable() { |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3439 | @Override |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 3440 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3441 | mKeyguardDelegate.keyguardDone(false, false); |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 3442 | } |
| 3443 | }); |
| 3444 | } |
Dianne Hackborn | 0572658 | 2009-09-22 17:28:24 -0700 | [diff] [blame] | 3445 | } else if (mHideLockScreen) { |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3446 | if (mKeyguard.hideLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3447 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3448 | | FINISH_LAYOUT_REDO_CONFIG |
| 3449 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3450 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3451 | mKeyguardDelegate.setHidden(true); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3452 | } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) { |
| 3453 | // This is the case of keyguard isSecure() and not mHideLockScreen. |
| 3454 | if (mDismissKeyguard == DISMISS_KEYGUARD_START) { |
| 3455 | // Only launch the next keyguard unlock window once per window. |
| 3456 | if (mKeyguard.showLw(true)) { |
| 3457 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3458 | | FINISH_LAYOUT_REDO_CONFIG |
| 3459 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3460 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3461 | mKeyguardDelegate.setHidden(false); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3462 | mHandler.post(new Runnable() { |
| 3463 | @Override |
| 3464 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3465 | mKeyguardDelegate.dismiss(); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3466 | } |
| 3467 | }); |
| 3468 | } |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 3469 | } else { |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3470 | mWinDismissingKeyguard = null; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3471 | if (mKeyguard.showLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3472 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3473 | | FINISH_LAYOUT_REDO_CONFIG |
| 3474 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3475 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3476 | mKeyguardDelegate.setHidden(false); |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 3477 | } |
| 3478 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3479 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3480 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3481 | // If the navigation bar has been hidden or shown, we need to do another |
| 3482 | // layout pass to update that window. |
| 3483 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3484 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3485 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3486 | // update since mAllowLockscreenWhenOn might have changed |
| 3487 | updateLockScreenTimeout(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3488 | return changes; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3489 | } |
| 3490 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3491 | public boolean allowAppAnimationsLw() { |
Craig Mautner | f03e4c5 | 2012-06-14 14:11:27 -0700 | [diff] [blame] | 3492 | if (mKeyguard != null && mKeyguard.isVisibleLw() && !mKeyguard.isAnimatingLw()) { |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3493 | // If keyguard is currently visible, no reason to animate |
| 3494 | // behind it. |
| 3495 | return false; |
| 3496 | } |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3497 | return true; |
| 3498 | } |
| 3499 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3500 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus) { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3501 | mFocusedWindow = newFocus; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3502 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3503 | // If the navigation bar has been hidden or shown, we need to do another |
| 3504 | // layout pass to update that window. |
| 3505 | return FINISH_LAYOUT_REDO_LAYOUT; |
| 3506 | } |
| 3507 | return 0; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3508 | } |
| 3509 | |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 3510 | /** {@inheritDoc} */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3511 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3512 | // do nothing if headless |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 3513 | if (mHeadless) return; |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3514 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3515 | // lid changed state |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3516 | final int newLidState = lidOpen ? LID_OPEN : LID_CLOSED; |
| 3517 | if (newLidState == mLidState) { |
| 3518 | return; |
| 3519 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3520 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3521 | mLidState = newLidState; |
| 3522 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3523 | updateRotation(true); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3524 | |
| 3525 | if (lidOpen) { |
| 3526 | if (keyguardIsShowingTq()) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3527 | mKeyguardDelegate.onWakeKeyWhenKeyguardShowingTq(KeyEvent.KEYCODE_POWER); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3528 | } else { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3529 | mPowerManager.wakeUp(SystemClock.uptimeMillis()); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3530 | } |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3531 | } else if (!mLidControlsSleep) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3532 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3533 | } |
| 3534 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3535 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3536 | void setHdmiPlugged(boolean plugged) { |
| 3537 | if (mHdmiPlugged != plugged) { |
| 3538 | mHdmiPlugged = plugged; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3539 | updateRotation(true, true); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3540 | Intent intent = new Intent(ACTION_HDMI_PLUGGED); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3541 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3542 | intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 3543 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3544 | } |
| 3545 | } |
| 3546 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3547 | void initializeHdmiState() { |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 3548 | boolean plugged = false; |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3549 | // watch for HDMI plug messages if the hdmi switch exists |
| 3550 | if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) { |
| 3551 | mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi"); |
| 3552 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3553 | final String filename = "/sys/class/switch/hdmi/state"; |
| 3554 | FileReader reader = null; |
| 3555 | try { |
| 3556 | reader = new FileReader(filename); |
| 3557 | char[] buf = new char[15]; |
| 3558 | int n = reader.read(buf); |
| 3559 | if (n > 1) { |
| 3560 | plugged = 0 != Integer.parseInt(new String(buf, 0, n-1)); |
| 3561 | } |
| 3562 | } catch (IOException ex) { |
| 3563 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 3564 | } catch (NumberFormatException ex) { |
| 3565 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 3566 | } finally { |
| 3567 | if (reader != null) { |
| 3568 | try { |
| 3569 | reader.close(); |
| 3570 | } catch (IOException ex) { |
| 3571 | } |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3572 | } |
| 3573 | } |
| 3574 | } |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 3575 | // This dance forces the code in setHdmiPlugged to run. |
| 3576 | // Always do this so the sticky intent is stuck (to false) if there is no hdmi. |
| 3577 | mHdmiPlugged = !plugged; |
| 3578 | setHdmiPlugged(!mHdmiPlugged); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3579 | } |
| 3580 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3581 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3582 | * @return Whether music is being played right now. |
| 3583 | */ |
| 3584 | boolean isMusicActive() { |
Eric Laurent | 413cb9d | 2009-07-17 11:52:43 -0700 | [diff] [blame] | 3585 | final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); |
| 3586 | if (am == null) { |
| 3587 | Log.w(TAG, "isMusicActive: couldn't get AudioManager reference"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3588 | return false; |
| 3589 | } |
Eric Laurent | 413cb9d | 2009-07-17 11:52:43 -0700 | [diff] [blame] | 3590 | return am.isMusicActive(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3591 | } |
| 3592 | |
| 3593 | /** |
| 3594 | * Tell the audio service to adjust the volume appropriate to the event. |
| 3595 | * @param keycode |
| 3596 | */ |
Mike Lockwood | a53e381 | 2009-09-25 10:51:39 -0400 | [diff] [blame] | 3597 | void handleVolumeKey(int stream, int keycode) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3598 | IAudioService audioService = getAudioService(); |
| 3599 | if (audioService == null) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3600 | return; |
| 3601 | } |
| 3602 | try { |
| 3603 | // since audio is playing, we shouldn't have to hold a wake lock |
| 3604 | // during the call, but we do it as a precaution for the rare possibility |
| 3605 | // that the music stops right before we call this |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 3606 | // TODO: Actually handle MUTE. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3607 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3608 | audioService.adjustStreamVolume(stream, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3609 | keycode == KeyEvent.KEYCODE_VOLUME_UP |
| 3610 | ? AudioManager.ADJUST_RAISE |
| 3611 | : AudioManager.ADJUST_LOWER, |
Dianne Hackborn | ba50b97c | 2013-04-30 15:04:46 -0700 | [diff] [blame] | 3612 | 0, |
| 3613 | mContext.getBasePackageName()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3614 | } catch (RemoteException e) { |
| 3615 | Log.w(TAG, "IAudioService.adjustStreamVolume() threw RemoteException " + e); |
| 3616 | } finally { |
| 3617 | mBroadcastWakeLock.release(); |
| 3618 | } |
| 3619 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3620 | |
Dianne Hackborn | c0e3f24 | 2011-08-19 14:19:10 -0700 | [diff] [blame] | 3621 | final Object mScreenshotLock = new Object(); |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3622 | ServiceConnection mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3623 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3624 | final Runnable mScreenshotTimeout = new Runnable() { |
| 3625 | @Override public void run() { |
| 3626 | synchronized (mScreenshotLock) { |
| 3627 | if (mScreenshotConnection != null) { |
| 3628 | mContext.unbindService(mScreenshotConnection); |
| 3629 | mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3630 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3631 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3632 | } |
| 3633 | }; |
| 3634 | |
| 3635 | // Assume this is called from the Handler thread. |
| 3636 | private void takeScreenshot() { |
| 3637 | synchronized (mScreenshotLock) { |
| 3638 | if (mScreenshotConnection != null) { |
| 3639 | return; |
| 3640 | } |
| 3641 | ComponentName cn = new ComponentName("com.android.systemui", |
| 3642 | "com.android.systemui.screenshot.TakeScreenshotService"); |
| 3643 | Intent intent = new Intent(); |
| 3644 | intent.setComponent(cn); |
| 3645 | ServiceConnection conn = new ServiceConnection() { |
| 3646 | @Override |
| 3647 | public void onServiceConnected(ComponentName name, IBinder service) { |
| 3648 | synchronized (mScreenshotLock) { |
| 3649 | if (mScreenshotConnection != this) { |
| 3650 | return; |
| 3651 | } |
| 3652 | Messenger messenger = new Messenger(service); |
| 3653 | Message msg = Message.obtain(null, 1); |
| 3654 | final ServiceConnection myConn = this; |
| 3655 | Handler h = new Handler(mHandler.getLooper()) { |
| 3656 | @Override |
| 3657 | public void handleMessage(Message msg) { |
| 3658 | synchronized (mScreenshotLock) { |
| 3659 | if (mScreenshotConnection == myConn) { |
| 3660 | mContext.unbindService(mScreenshotConnection); |
| 3661 | mScreenshotConnection = null; |
| 3662 | mHandler.removeCallbacks(mScreenshotTimeout); |
| 3663 | } |
| 3664 | } |
| 3665 | } |
| 3666 | }; |
| 3667 | msg.replyTo = new Messenger(h); |
Winson Chung | a63bb84 | 2011-10-17 10:26:28 -0700 | [diff] [blame] | 3668 | msg.arg1 = msg.arg2 = 0; |
| 3669 | if (mStatusBar != null && mStatusBar.isVisibleLw()) |
| 3670 | msg.arg1 = 1; |
| 3671 | if (mNavigationBar != null && mNavigationBar.isVisibleLw()) |
| 3672 | msg.arg2 = 1; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3673 | try { |
| 3674 | messenger.send(msg); |
| 3675 | } catch (RemoteException e) { |
| 3676 | } |
| 3677 | } |
| 3678 | } |
| 3679 | @Override |
| 3680 | public void onServiceDisconnected(ComponentName name) {} |
| 3681 | }; |
Amith Yamasani | 27b89e6 | 2013-01-16 12:30:11 -0800 | [diff] [blame] | 3682 | if (mContext.bindServiceAsUser( |
| 3683 | intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3684 | mScreenshotConnection = conn; |
| 3685 | mHandler.postDelayed(mScreenshotTimeout, 10000); |
| 3686 | } |
| 3687 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3688 | } |
| 3689 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3690 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3691 | @Override |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 3692 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3693 | if (!mSystemBooted) { |
| 3694 | // If we have not yet booted, don't let key events do anything. |
| 3695 | return 0; |
| 3696 | } |
| 3697 | |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 3698 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 3699 | final boolean canceled = event.isCanceled(); |
| 3700 | final int keyCode = event.getKeyCode(); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 3701 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 3702 | final boolean isInjected = (policyFlags & WindowManagerPolicy.FLAG_INJECTED) != 0; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 3703 | |
Mike Lockwood | c72b15f | 2009-11-28 20:58:22 -0500 | [diff] [blame] | 3704 | // If screen is off then we treat the case where the keyguard is open but hidden |
| 3705 | // the same as if it were open and in front. |
| 3706 | // This will prevent any keys other than the power button from waking the screen |
| 3707 | // when the keyguard is hidden by another activity. |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3708 | final boolean keyguardActive = (mKeyguardDelegate == null ? false : |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3709 | (isScreenOn ? |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3710 | mKeyguardDelegate.isShowingAndNotHidden() : |
| 3711 | mKeyguardDelegate.isShowing())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3712 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3713 | if (keyCode == KeyEvent.KEYCODE_POWER) { |
| 3714 | policyFlags |= WindowManagerPolicy.FLAG_WAKE; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 3715 | } |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3716 | final boolean isWakeKey = (policyFlags & (WindowManagerPolicy.FLAG_WAKE |
| 3717 | | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 3718 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 3719 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3720 | Log.d(TAG, "interceptKeyTq keycode=" + keyCode |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3721 | + " screenIsOn=" + isScreenOn + " keyguardActive=" + keyguardActive |
| 3722 | + " policyFlags=" + Integer.toHexString(policyFlags) |
| 3723 | + " isWakeKey=" + isWakeKey); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3724 | } |
| 3725 | |
Jeff Brown | 98392ef | 2011-09-12 18:24:59 -0700 | [diff] [blame] | 3726 | if (down && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 |
| 3727 | && event.getRepeatCount() == 0) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3728 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
| 3729 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3730 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3731 | // Basic policy based on screen state and keyguard. |
| 3732 | // FIXME: This policy isn't quite correct. We shouldn't care whether the screen |
| 3733 | // is on or off, really. We should care about whether the device is in an |
| 3734 | // interactive state or is in suspend pretending to be "off". |
| 3735 | // The primary screen might be turned off due to proximity sensor or |
| 3736 | // because we are presenting media on an auxiliary screen or remotely controlling |
| 3737 | // the device some other way (which is why we have an exemption here for injected |
| 3738 | // events). |
| 3739 | int result; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 3740 | if ((isScreenOn && !mHeadless) || (isInjected && !isWakeKey)) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3741 | // When the screen is on or if the key is injected pass the key to the application. |
| 3742 | result = ACTION_PASS_TO_USER; |
| 3743 | } else { |
| 3744 | // When the screen is off and the key is not injected, determine whether |
| 3745 | // to wake the device but don't pass the key to the application. |
| 3746 | result = 0; |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 3747 | if (down && isWakeKey && isWakeKeyWhenScreenOff(keyCode)) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3748 | if (keyguardActive) { |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 3749 | // If the keyguard is showing, let it wake the device when ready. |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3750 | mKeyguardDelegate.onWakeKeyWhenKeyguardShowingTq(keyCode); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3751 | } else { |
| 3752 | // Otherwise, wake the device ourselves. |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3753 | result |= ACTION_WAKE_UP; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3754 | } |
| 3755 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3756 | } |
| 3757 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 3758 | // If the key would be handled globally, just return the result, don't worry about special |
| 3759 | // key processing. |
| 3760 | if (mGlobalKeyManager.shouldHandleGlobalKey(keyCode, event)) { |
| 3761 | return result; |
| 3762 | } |
| 3763 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3764 | // Handle special keys. |
| 3765 | switch (keyCode) { |
| 3766 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 3767 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 3768 | case KeyEvent.KEYCODE_VOLUME_MUTE: { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3769 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { |
| 3770 | if (down) { |
| 3771 | if (isScreenOn && !mVolumeDownKeyTriggered |
| 3772 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 3773 | mVolumeDownKeyTriggered = true; |
| 3774 | mVolumeDownKeyTime = event.getDownTime(); |
| 3775 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 3776 | cancelPendingPowerKeyAction(); |
| 3777 | interceptScreenshotChord(); |
| 3778 | } |
| 3779 | } else { |
| 3780 | mVolumeDownKeyTriggered = false; |
| 3781 | cancelPendingScreenshotChordAction(); |
| 3782 | } |
| 3783 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { |
| 3784 | if (down) { |
| 3785 | if (isScreenOn && !mVolumeUpKeyTriggered |
| 3786 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 3787 | mVolumeUpKeyTriggered = true; |
| 3788 | cancelPendingPowerKeyAction(); |
| 3789 | cancelPendingScreenshotChordAction(); |
| 3790 | } |
| 3791 | } else { |
| 3792 | mVolumeUpKeyTriggered = false; |
| 3793 | cancelPendingScreenshotChordAction(); |
| 3794 | } |
| 3795 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3796 | if (down) { |
| 3797 | ITelephony telephonyService = getTelephonyService(); |
| 3798 | if (telephonyService != null) { |
| 3799 | try { |
| 3800 | if (telephonyService.isRinging()) { |
| 3801 | // If an incoming call is ringing, either VOLUME key means |
| 3802 | // "silence ringer". We handle these keys here, rather than |
| 3803 | // in the InCallScreen, to make sure we'll respond to them |
| 3804 | // even if the InCallScreen hasn't come to the foreground yet. |
| 3805 | // Look for the DOWN event here, to agree with the "fallback" |
| 3806 | // behavior in the InCallScreen. |
| 3807 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 3808 | + " VOLUME key-down while ringing: Silence ringer!"); |
| 3809 | |
| 3810 | // Silence the ringer. (It's safe to call this |
| 3811 | // even if the ringer has already been silenced.) |
| 3812 | telephonyService.silenceRinger(); |
| 3813 | |
| 3814 | // And *don't* pass this key thru to the current activity |
| 3815 | // (which is probably the InCallScreen.) |
| 3816 | result &= ~ACTION_PASS_TO_USER; |
| 3817 | break; |
| 3818 | } |
| 3819 | if (telephonyService.isOffhook() |
| 3820 | && (result & ACTION_PASS_TO_USER) == 0) { |
| 3821 | // If we are in call but we decided not to pass the key to |
| 3822 | // the application, handle the volume change here. |
| 3823 | handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keyCode); |
| 3824 | break; |
| 3825 | } |
| 3826 | } catch (RemoteException ex) { |
| 3827 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
| 3828 | } |
| 3829 | } |
| 3830 | |
| 3831 | if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { |
| 3832 | // If music is playing but we decided not to pass the key to the |
| 3833 | // application, handle the volume change here. |
| 3834 | handleVolumeKey(AudioManager.STREAM_MUSIC, keyCode); |
| 3835 | break; |
| 3836 | } |
| 3837 | } |
| 3838 | break; |
| 3839 | } |
| 3840 | |
| 3841 | case KeyEvent.KEYCODE_ENDCALL: { |
| 3842 | result &= ~ACTION_PASS_TO_USER; |
| 3843 | if (down) { |
| 3844 | ITelephony telephonyService = getTelephonyService(); |
| 3845 | boolean hungUp = false; |
| 3846 | if (telephonyService != null) { |
| 3847 | try { |
| 3848 | hungUp = telephonyService.endCall(); |
| 3849 | } catch (RemoteException ex) { |
| 3850 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
| 3851 | } |
| 3852 | } |
| 3853 | interceptPowerKeyDown(!isScreenOn || hungUp); |
| 3854 | } else { |
| 3855 | if (interceptPowerKeyUp(canceled)) { |
| 3856 | if ((mEndcallBehavior |
| 3857 | & Settings.System.END_BUTTON_BEHAVIOR_HOME) != 0) { |
| 3858 | if (goHome()) { |
| 3859 | break; |
Dianne Hackborn | 0041e97 | 2009-07-24 17:14:43 -0700 | [diff] [blame] | 3860 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3861 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3862 | if ((mEndcallBehavior |
| 3863 | & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3864 | result = (result & ~ACTION_WAKE_UP) | ACTION_GO_TO_SLEEP; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3865 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3866 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3867 | } |
| 3868 | break; |
| 3869 | } |
| 3870 | |
| 3871 | case KeyEvent.KEYCODE_POWER: { |
| 3872 | result &= ~ACTION_PASS_TO_USER; |
| 3873 | if (down) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3874 | if (isScreenOn && !mPowerKeyTriggered |
| 3875 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 3876 | mPowerKeyTriggered = true; |
| 3877 | mPowerKeyTime = event.getDownTime(); |
| 3878 | interceptScreenshotChord(); |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3879 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3880 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3881 | ITelephony telephonyService = getTelephonyService(); |
| 3882 | boolean hungUp = false; |
| 3883 | if (telephonyService != null) { |
| 3884 | try { |
| 3885 | if (telephonyService.isRinging()) { |
| 3886 | // Pressing Power while there's a ringing incoming |
| 3887 | // call should silence the ringer. |
| 3888 | telephonyService.silenceRinger(); |
| 3889 | } else if ((mIncallPowerBehavior |
| 3890 | & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 |
| 3891 | && telephonyService.isOffhook()) { |
| 3892 | // Otherwise, if "Power button ends call" is enabled, |
| 3893 | // the Power button will hang up any current active call. |
| 3894 | hungUp = telephonyService.endCall(); |
| 3895 | } |
| 3896 | } catch (RemoteException ex) { |
| 3897 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
| 3898 | } |
| 3899 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3900 | interceptPowerKeyDown(!isScreenOn || hungUp |
| 3901 | || mVolumeDownKeyTriggered || mVolumeUpKeyTriggered); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3902 | } else { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3903 | mPowerKeyTriggered = false; |
| 3904 | cancelPendingScreenshotChordAction(); |
| 3905 | if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3906 | result = (result & ~ACTION_WAKE_UP) | ACTION_GO_TO_SLEEP; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3907 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3908 | mPendingPowerKeyUpCanceled = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3909 | } |
| 3910 | break; |
| 3911 | } |
| 3912 | |
| 3913 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 3914 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 3915 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 3916 | if (down) { |
| 3917 | ITelephony telephonyService = getTelephonyService(); |
| 3918 | if (telephonyService != null) { |
| 3919 | try { |
| 3920 | if (!telephonyService.isIdle()) { |
| 3921 | // Suppress PLAY/PAUSE toggle when phone is ringing or in-call |
| 3922 | // to avoid music playback. |
| 3923 | break; |
| 3924 | } |
| 3925 | } catch (RemoteException ex) { |
| 3926 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 3927 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3928 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3929 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3930 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 3931 | case KeyEvent.KEYCODE_MUTE: |
| 3932 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 3933 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 3934 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 3935 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 3936 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
| 3937 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: { |
| 3938 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 3939 | // Only do this if we would otherwise not pass it to the user. In that |
| 3940 | // case, the PhoneWindow class will do the same thing, except it will |
| 3941 | // only do it if the showing app doesn't process the key on its own. |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 3942 | // Note that we need to make a copy of the key event here because the |
| 3943 | // original key event will be recycled when we return. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3944 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 3945 | Message msg = mHandler.obtainMessage(MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK, |
| 3946 | new KeyEvent(event)); |
| 3947 | msg.setAsynchronous(true); |
| 3948 | msg.sendToTarget(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3949 | } |
| 3950 | break; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3951 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3952 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3953 | case KeyEvent.KEYCODE_CALL: { |
| 3954 | if (down) { |
| 3955 | ITelephony telephonyService = getTelephonyService(); |
| 3956 | if (telephonyService != null) { |
| 3957 | try { |
| 3958 | if (telephonyService.isRinging()) { |
| 3959 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 3960 | + " CALL key-down while ringing: Answer the call!"); |
| 3961 | telephonyService.answerRingingCall(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3962 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3963 | // And *don't* pass this key thru to the current activity |
| 3964 | // (which is presumably the InCallScreen.) |
| 3965 | result &= ~ACTION_PASS_TO_USER; |
| 3966 | } |
| 3967 | } catch (RemoteException ex) { |
| 3968 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3969 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3970 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3971 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3972 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3973 | } |
| 3974 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3975 | return result; |
| 3976 | } |
| 3977 | |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 3978 | /** |
| 3979 | * When the screen is off we ignore some keys that might otherwise typically |
| 3980 | * be considered wake keys. We filter them out here. |
| 3981 | * |
| 3982 | * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it |
| 3983 | * is always considered a wake key. |
| 3984 | */ |
| 3985 | private boolean isWakeKeyWhenScreenOff(int keyCode) { |
| 3986 | switch (keyCode) { |
| 3987 | // ignore volume keys unless docked |
| 3988 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 3989 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 3990 | case KeyEvent.KEYCODE_VOLUME_MUTE: |
| 3991 | return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 3992 | |
| 3993 | // ignore media and camera keys |
| 3994 | case KeyEvent.KEYCODE_MUTE: |
| 3995 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 3996 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 3997 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 3998 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 3999 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4000 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4001 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4002 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4003 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
| 4004 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
| 4005 | case KeyEvent.KEYCODE_CAMERA: |
| 4006 | return false; |
| 4007 | } |
| 4008 | return true; |
| 4009 | } |
| 4010 | |
| 4011 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4012 | /** {@inheritDoc} */ |
| 4013 | @Override |
| 4014 | public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags) { |
| 4015 | int result = 0; |
| 4016 | |
| 4017 | final boolean isWakeMotion = (policyFlags |
| 4018 | & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; |
| 4019 | if (isWakeMotion) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4020 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) { |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4021 | // If the keyguard is showing, let it decide what to do with the wake motion. |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 4022 | mKeyguardDelegate.onWakeMotionWhenKeyguardShowing(); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4023 | } else { |
| 4024 | // Otherwise, wake the device ourselves. |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 4025 | result |= ACTION_WAKE_UP; |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4026 | } |
| 4027 | } |
| 4028 | return result; |
| 4029 | } |
| 4030 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4031 | void dispatchMediaKeyWithWakeLock(KeyEvent event) { |
| 4032 | if (DEBUG_INPUT) { |
| 4033 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: " + event); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4034 | } |
| 4035 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4036 | if (mHavePendingMediaKeyRepeatWithWakeLock) { |
| 4037 | if (DEBUG_INPUT) { |
| 4038 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: canceled repeat"); |
| 4039 | } |
| 4040 | |
| 4041 | mHandler.removeMessages(MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK); |
| 4042 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4043 | mBroadcastWakeLock.release(); // pending repeat was holding onto the wake lock |
| 4044 | } |
| 4045 | |
| 4046 | dispatchMediaKeyWithWakeLockToAudioService(event); |
| 4047 | |
| 4048 | if (event.getAction() == KeyEvent.ACTION_DOWN |
| 4049 | && event.getRepeatCount() == 0) { |
| 4050 | mHavePendingMediaKeyRepeatWithWakeLock = true; |
| 4051 | |
| 4052 | Message msg = mHandler.obtainMessage( |
| 4053 | MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK, event); |
| 4054 | msg.setAsynchronous(true); |
| 4055 | mHandler.sendMessageDelayed(msg, ViewConfiguration.getKeyRepeatTimeout()); |
| 4056 | } else { |
| 4057 | mBroadcastWakeLock.release(); |
| 4058 | } |
| 4059 | } |
| 4060 | |
| 4061 | void dispatchMediaKeyRepeatWithWakeLock(KeyEvent event) { |
| 4062 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4063 | |
| 4064 | KeyEvent repeatEvent = KeyEvent.changeTimeRepeat(event, |
| 4065 | SystemClock.uptimeMillis(), 1, event.getFlags() | KeyEvent.FLAG_LONG_PRESS); |
| 4066 | if (DEBUG_INPUT) { |
| 4067 | Slog.d(TAG, "dispatchMediaKeyRepeatWithWakeLock: " + repeatEvent); |
| 4068 | } |
| 4069 | |
| 4070 | dispatchMediaKeyWithWakeLockToAudioService(repeatEvent); |
| 4071 | mBroadcastWakeLock.release(); |
| 4072 | } |
| 4073 | |
| 4074 | void dispatchMediaKeyWithWakeLockToAudioService(KeyEvent event) { |
| 4075 | if (ActivityManagerNative.isSystemReady()) { |
| 4076 | IAudioService audioService = getAudioService(); |
| 4077 | if (audioService != null) { |
| 4078 | try { |
| 4079 | audioService.dispatchMediaKeyEventUnderWakelock(event); |
| 4080 | } catch (RemoteException e) { |
| 4081 | Log.e(TAG, "dispatchMediaKeyEvent threw exception " + e); |
Jean-Michel Trivi | c680222 | 2012-04-30 11:15:03 -0700 | [diff] [blame] | 4082 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4083 | } |
| 4084 | } |
| 4085 | } |
| 4086 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4087 | BroadcastReceiver mDockReceiver = new BroadcastReceiver() { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4088 | @Override |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4089 | public void onReceive(Context context, Intent intent) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 4090 | if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { |
| 4091 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 4092 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4093 | } else { |
| 4094 | try { |
| 4095 | IUiModeManager uiModeService = IUiModeManager.Stub.asInterface( |
| 4096 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 4097 | mUiMode = uiModeService.getCurrentModeType(); |
| 4098 | } catch (RemoteException e) { |
| 4099 | } |
Dianne Hackborn | 80fa166 | 2009-10-07 14:02:10 -0700 | [diff] [blame] | 4100 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4101 | updateRotation(true); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4102 | synchronized (mLock) { |
| 4103 | updateOrientationListenerLp(); |
| 4104 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4105 | } |
| 4106 | }; |
| 4107 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4108 | BroadcastReceiver mDreamReceiver = new BroadcastReceiver() { |
| 4109 | @Override |
| 4110 | public void onReceive(Context context, Intent intent) { |
| 4111 | if (Intent.ACTION_DREAMING_STARTED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4112 | if (mKeyguardDelegate != null) { |
| 4113 | mKeyguardDelegate.onDreamingStarted(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4114 | } |
| 4115 | } else if (Intent.ACTION_DREAMING_STOPPED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4116 | if (mKeyguardDelegate != null) { |
| 4117 | mKeyguardDelegate.onDreamingStopped(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4118 | } |
| 4119 | } |
| 4120 | } |
| 4121 | }; |
| 4122 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4123 | BroadcastReceiver mMultiuserReceiver = new BroadcastReceiver() { |
| 4124 | @Override |
| 4125 | public void onReceive(Context context, Intent intent) { |
| 4126 | if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { |
| 4127 | // tickle the settings observer: this first ensures that we're |
| 4128 | // observing the relevant settings for the newly-active user, |
| 4129 | // and then updates our own bookkeeping based on the now- |
| 4130 | // current user. |
| 4131 | mSettingsObserver.onChange(false); |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4132 | |
| 4133 | // force a re-application of focused window sysui visibility. |
| 4134 | // the window may never have been shown for this user |
| 4135 | // e.g. the keyguard when going through the new-user setup flow |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4136 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4137 | mLastSystemUiFlags = 0; |
| 4138 | updateSystemUiVisibilityLw(); |
| 4139 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4140 | } |
| 4141 | } |
| 4142 | }; |
| 4143 | |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4144 | private void requestHideybars(WindowState swipeTarget) { |
| 4145 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4146 | boolean sb = checkShowHideybar("status", mStatusHideybar, mStatusBar); |
| 4147 | boolean nb = checkShowHideybar("navigation", mNavigationHideybar, mNavigationBar); |
| 4148 | if (sb || nb) { |
| 4149 | WindowState hideyTarget = sb ? mStatusBar : mNavigationBar; |
| 4150 | if (sb ^ nb && hideyTarget != swipeTarget) { |
| 4151 | if (DEBUG) Slog.d(TAG, "Not showing hideybar, wrong swipe target"); |
| 4152 | return; |
| 4153 | } |
| 4154 | mStatusHideybar = sb ? HIDEYBAR_SHOWING : mStatusHideybar; |
| 4155 | mNavigationHideybar = nb ? HIDEYBAR_SHOWING : mNavigationHideybar; |
| 4156 | updateSystemUiVisibilityLw(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 4157 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4158 | } |
| 4159 | } |
| 4160 | |
| 4161 | private boolean checkShowHideybar(String tag, int hideybar, WindowState win) { |
| 4162 | if (hideybar == HIDEYBAR_SHOWING) { |
| 4163 | if (DEBUG) Slog.d(TAG, "Not showing " + tag + " hideybar, already shown"); |
| 4164 | return false; |
John Spurlock | e3b642e | 2013-05-09 15:51:32 -0400 | [diff] [blame] | 4165 | } else if (win == null) { |
| 4166 | if (DEBUG) Slog.d(TAG, "Not showing " + tag + " hideybar, bar doesn't exist"); |
| 4167 | return false; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4168 | } else if (win.isDisplayedLw()) { |
| 4169 | if (DEBUG) Slog.d(TAG, "Not showing " + tag + " hideybar, bar already visible"); |
| 4170 | return false; |
| 4171 | } else { |
| 4172 | return true; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 4173 | } |
| 4174 | } |
| 4175 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4176 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4177 | public void screenTurnedOff(int why) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4178 | EventLog.writeEvent(70000, 0); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4179 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4180 | mScreenOnEarly = false; |
| 4181 | mScreenOnFully = false; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4182 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4183 | if (mKeyguardDelegate != null) { |
| 4184 | mKeyguardDelegate.onScreenTurnedOff(why); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4185 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4186 | synchronized (mLock) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4187 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4188 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4189 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4190 | } |
| 4191 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4192 | @Override |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 4193 | public void screenTurningOn(final ScreenOnListener screenOnListener) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4194 | EventLog.writeEvent(70000, 1); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 4195 | if (false) { |
| 4196 | RuntimeException here = new RuntimeException("here"); |
| 4197 | here.fillInStackTrace(); |
| 4198 | Slog.i(TAG, "Screen turning on...", here); |
| 4199 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4200 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4201 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4202 | mScreenOnEarly = true; |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4203 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4204 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4205 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4206 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4207 | waitForKeyguard(screenOnListener); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4208 | } |
| 4209 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4210 | private void waitForKeyguard(final ScreenOnListener screenOnListener) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4211 | if (mKeyguardDelegate != null) { |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4212 | if (screenOnListener != null) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4213 | mKeyguardDelegate.onScreenTurnedOn(new KeyguardServiceDelegate.ShowListener() { |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4214 | @Override |
| 4215 | public void onShown(IBinder windowToken) { |
| 4216 | waitForKeyguardWindowDrawn(windowToken, screenOnListener); |
| 4217 | } |
| 4218 | }); |
| 4219 | return; |
| 4220 | } else { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4221 | mKeyguardDelegate.onScreenTurnedOn(null); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4222 | } |
| 4223 | } else { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4224 | Slog.i(TAG, "No keyguard interface!"); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4225 | } |
| 4226 | finishScreenTurningOn(screenOnListener); |
| 4227 | } |
| 4228 | |
| 4229 | private void waitForKeyguardWindowDrawn(IBinder windowToken, |
| 4230 | final ScreenOnListener screenOnListener) { |
| 4231 | if (windowToken != null) { |
| 4232 | try { |
| 4233 | if (mWindowManager.waitForWindowDrawn( |
| 4234 | windowToken, new IRemoteCallback.Stub() { |
| 4235 | @Override |
| 4236 | public void sendResult(Bundle data) { |
| 4237 | Slog.i(TAG, "Lock screen displayed!"); |
| 4238 | finishScreenTurningOn(screenOnListener); |
| 4239 | } |
| 4240 | })) { |
| 4241 | return; |
| 4242 | } |
| 4243 | } catch (RemoteException ex) { |
| 4244 | // Can't happen in system process. |
| 4245 | } |
| 4246 | } |
| 4247 | |
| 4248 | Slog.i(TAG, "No lock screen!"); |
| 4249 | finishScreenTurningOn(screenOnListener); |
| 4250 | } |
| 4251 | |
| 4252 | private void finishScreenTurningOn(ScreenOnListener screenOnListener) { |
| 4253 | synchronized (mLock) { |
| 4254 | mScreenOnFully = true; |
| 4255 | } |
| 4256 | |
Jeff Brown | 4fc4527 | 2012-10-10 18:28:14 -0700 | [diff] [blame] | 4257 | try { |
| 4258 | mWindowManager.setEventDispatching(true); |
| 4259 | } catch (RemoteException unhandled) { |
| 4260 | } |
| 4261 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4262 | if (screenOnListener != null) { |
| 4263 | screenOnListener.onScreenOn(); |
| 4264 | } |
| 4265 | } |
| 4266 | |
| 4267 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4268 | public boolean isScreenOnEarly() { |
| 4269 | return mScreenOnEarly; |
| 4270 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4271 | |
| 4272 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4273 | public boolean isScreenOnFully() { |
| 4274 | return mScreenOnFully; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4275 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4276 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4277 | /** {@inheritDoc} */ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4278 | public void enableKeyguard(boolean enabled) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4279 | if (mKeyguardDelegate != null) { |
| 4280 | mKeyguardDelegate.setKeyguardEnabled(enabled); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4281 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4282 | } |
| 4283 | |
| 4284 | /** {@inheritDoc} */ |
| 4285 | public void exitKeyguardSecurely(OnKeyguardExitResult callback) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4286 | if (mKeyguardDelegate != null) { |
| 4287 | mKeyguardDelegate.verifyUnlock(callback); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4288 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4289 | } |
| 4290 | |
Mike Lockwood | f791330 | 2009-11-28 22:27:10 -0500 | [diff] [blame] | 4291 | private boolean keyguardIsShowingTq() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4292 | if (mKeyguardDelegate == null) return false; |
| 4293 | return mKeyguardDelegate.isShowingAndNotHidden(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4294 | } |
| 4295 | |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4296 | |
| 4297 | /** {@inheritDoc} */ |
| 4298 | public boolean isKeyguardLocked() { |
| 4299 | return keyguardOn(); |
| 4300 | } |
| 4301 | |
| 4302 | /** {@inheritDoc} */ |
| 4303 | public boolean isKeyguardSecure() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4304 | if (mKeyguardDelegate == null) return false; |
| 4305 | return mKeyguardDelegate.isSecure(); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4306 | } |
| 4307 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4308 | /** {@inheritDoc} */ |
| 4309 | public boolean inKeyguardRestrictedKeyInputMode() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4310 | if (mKeyguardDelegate == null) return false; |
| 4311 | return mKeyguardDelegate.isInputRestricted(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4312 | } |
| 4313 | |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4314 | public void dismissKeyguardLw() { |
Jim Miller | 195b551 | 2013-02-28 03:35:57 -0800 | [diff] [blame] | 4315 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4316 | mHandler.post(new Runnable() { |
| 4317 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4318 | if (mKeyguardDelegate.isDismissable()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4319 | // Can we just finish the keyguard straight away? |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4320 | mKeyguardDelegate.keyguardDone(false, true); |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4321 | } else { |
| 4322 | // ask the keyguard to prompt the user to authenticate if necessary |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4323 | mKeyguardDelegate.dismiss(); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4324 | } |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4325 | } |
| 4326 | }); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4327 | } |
| 4328 | } |
| 4329 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4330 | void sendCloseSystemWindows() { |
| 4331 | sendCloseSystemWindows(mContext, null); |
| 4332 | } |
| 4333 | |
| 4334 | void sendCloseSystemWindows(String reason) { |
| 4335 | sendCloseSystemWindows(mContext, reason); |
| 4336 | } |
| 4337 | |
| 4338 | static void sendCloseSystemWindows(Context context, String reason) { |
| 4339 | if (ActivityManagerNative.isSystemReady()) { |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 4340 | try { |
| 4341 | ActivityManagerNative.getDefault().closeSystemDialogs(reason); |
| 4342 | } catch (RemoteException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4343 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4344 | } |
| 4345 | } |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 4346 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4347 | @Override |
| 4348 | public int rotationForOrientationLw(int orientation, int lastRotation) { |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4349 | if (false) { |
| 4350 | Slog.v(TAG, "rotationForOrientationLw(orient=" |
| 4351 | + orientation + ", last=" + lastRotation |
| 4352 | + "); user=" + mUserRotation + " " |
| 4353 | + ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) |
| 4354 | ? "USER_ROTATION_LOCKED" : "") |
| 4355 | ); |
| 4356 | } |
| 4357 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4358 | synchronized (mLock) { |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4359 | int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 |
| 4360 | if (sensorRotation < 0) { |
Jeff Brown | 0f862b4 | 2012-09-27 21:11:01 -0700 | [diff] [blame] | 4361 | sensorRotation = lastRotation; |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4362 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4363 | |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4364 | final int preferredRotation; |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 4365 | if (mLidState == LID_OPEN && mLidOpenRotation >= 0) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4366 | // Ignore sensor when lid switch is open and rotation is forced. |
| 4367 | preferredRotation = mLidOpenRotation; |
| 4368 | } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4369 | && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4370 | // Ignore sensor when in car dock unless explicitly enabled. |
| 4371 | // This case can override the behavior of NOSENSOR, and can also |
| 4372 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4373 | preferredRotation = mCarDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4374 | ? sensorRotation : mCarDockRotation; |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 4375 | } else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 4376 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 4377 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4378 | && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4379 | // Ignore sensor when in desk dock unless explicitly enabled. |
| 4380 | // This case can override the behavior of NOSENSOR, and can also |
| 4381 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4382 | preferredRotation = mDeskDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4383 | ? sensorRotation : mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4384 | } else if (mHdmiPlugged && mDemoHdmiRotationLock) { |
| 4385 | // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled. |
Jeff Brown | eb3e4b9 | 2011-12-06 19:54:24 -0800 | [diff] [blame] | 4386 | // Note that the dock orientation overrides the HDMI orientation. |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4387 | preferredRotation = mDemoHdmiRotation; |
| 4388 | } else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED |
| 4389 | && mUndockedHdmiRotation >= 0) { |
| 4390 | // Ignore sensor when plugged into HDMI and an undocked orientation has |
| 4391 | // been specified in the configuration (only for legacy devices without |
| 4392 | // full multi-display support). |
| 4393 | // Note that the dock orientation overrides the HDMI orientation. |
| 4394 | preferredRotation = mUndockedHdmiRotation; |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4395 | } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { |
| 4396 | // Application just wants to remain locked in the last rotation. |
| 4397 | preferredRotation = lastRotation; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4398 | } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4399 | && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4400 | || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED |
| 4401 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE |
| 4402 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT |
| 4403 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER)) |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4404 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 4405 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4406 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 4407 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { |
| 4408 | // Otherwise, use sensor only if requested by the application or enabled |
| 4409 | // by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR. |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4410 | if (mAllowAllRotations < 0) { |
| 4411 | // Can't read this during init() because the context doesn't |
| 4412 | // have display metrics at that time so we cannot determine |
| 4413 | // tablet vs. phone then. |
| 4414 | mAllowAllRotations = mContext.getResources().getBoolean( |
| 4415 | com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; |
| 4416 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4417 | if (sensorRotation != Surface.ROTATION_180 |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4418 | || mAllowAllRotations == 1 |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4419 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4420 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4421 | preferredRotation = sensorRotation; |
| 4422 | } else { |
| 4423 | preferredRotation = lastRotation; |
| 4424 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4425 | } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED |
| 4426 | && orientation != ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { |
| 4427 | // Apply rotation lock. Does not apply to NOSENSOR. |
| 4428 | // The idea is that the user rotation expresses a weak preference for the direction |
| 4429 | // of gravity and as NOSENSOR is never affected by gravity, then neither should |
| 4430 | // NOSENSOR be affected by rotation lock (although it will be affected by docks). |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 4431 | preferredRotation = mUserRotation; |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4432 | } else { |
| 4433 | // No overriding preference. |
| 4434 | // We will do exactly what the application asked us to do. |
| 4435 | preferredRotation = -1; |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4436 | } |
| 4437 | |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4438 | switch (orientation) { |
| 4439 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4440 | // Return portrait unless overridden. |
| 4441 | if (isAnyPortrait(preferredRotation)) { |
| 4442 | return preferredRotation; |
| 4443 | } |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4444 | return mPortraitRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4445 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4446 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4447 | // Return landscape unless overridden. |
| 4448 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4449 | return preferredRotation; |
| 4450 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4451 | return mLandscapeRotation; |
| 4452 | |
| 4453 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4454 | // Return reverse portrait unless overridden. |
| 4455 | if (isAnyPortrait(preferredRotation)) { |
| 4456 | return preferredRotation; |
| 4457 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4458 | return mUpsideDownRotation; |
| 4459 | |
| 4460 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4461 | // Return seascape unless overridden. |
| 4462 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4463 | return preferredRotation; |
| 4464 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4465 | return mSeascapeRotation; |
| 4466 | |
| 4467 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4468 | case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4469 | // Return either landscape rotation. |
| 4470 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4471 | return preferredRotation; |
| 4472 | } |
| 4473 | if (isLandscapeOrSeascape(lastRotation)) { |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 4474 | return lastRotation; |
| 4475 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4476 | return mLandscapeRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4477 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4478 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4479 | case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4480 | // Return either portrait rotation. |
| 4481 | if (isAnyPortrait(preferredRotation)) { |
| 4482 | return preferredRotation; |
| 4483 | } |
| 4484 | if (isAnyPortrait(lastRotation)) { |
| 4485 | return lastRotation; |
| 4486 | } |
| 4487 | return mPortraitRotation; |
| 4488 | |
| 4489 | default: |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 4490 | // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, |
| 4491 | // just return the preferred orientation we already calculated. |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4492 | if (preferredRotation >= 0) { |
| 4493 | return preferredRotation; |
| 4494 | } |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 4495 | return Surface.ROTATION_0; |
Daniel Sandler | e7e5ac2 | 2011-02-22 16:10:21 -0500 | [diff] [blame] | 4496 | } |
| 4497 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4498 | } |
| 4499 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4500 | @Override |
| 4501 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation) { |
| 4502 | switch (orientation) { |
| 4503 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
| 4504 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
| 4505 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
| 4506 | return isAnyPortrait(rotation); |
| 4507 | |
| 4508 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
| 4509 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
| 4510 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
| 4511 | return isLandscapeOrSeascape(rotation); |
| 4512 | |
| 4513 | default: |
| 4514 | return true; |
| 4515 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4516 | } |
| 4517 | |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4518 | @Override |
| 4519 | public void setRotationLw(int rotation) { |
| 4520 | mOrientationListener.setCurrentRotation(rotation); |
| 4521 | } |
| 4522 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4523 | private boolean isLandscapeOrSeascape(int rotation) { |
| 4524 | return rotation == mLandscapeRotation || rotation == mSeascapeRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4525 | } |
| 4526 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4527 | private boolean isAnyPortrait(int rotation) { |
| 4528 | return rotation == mPortraitRotation || rotation == mUpsideDownRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4529 | } |
| 4530 | |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4531 | public int getUserRotationMode() { |
| 4532 | return Settings.System.getIntForUser(mContext.getContentResolver(), |
Brett Chabot | 7e55c40 | 2013-05-16 19:38:08 -0700 | [diff] [blame] | 4533 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
| 4534 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 4535 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4536 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4537 | |
| 4538 | // User rotation: to be used when all else fails in assigning an orientation to the device |
| 4539 | public void setUserRotationMode(int mode, int rot) { |
| 4540 | ContentResolver res = mContext.getContentResolver(); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4541 | |
| 4542 | // mUserRotationMode and mUserRotation will be assigned by the content observer |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4543 | if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4544 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4545 | Settings.System.USER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4546 | rot, |
| 4547 | UserHandle.USER_CURRENT); |
| 4548 | Settings.System.putIntForUser(res, |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4549 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4550 | 0, |
| 4551 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4552 | } else { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4553 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4554 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4555 | 1, |
| 4556 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4557 | } |
| 4558 | } |
| 4559 | |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 4560 | public void setSafeMode(boolean safeMode) { |
| 4561 | mSafeMode = safeMode; |
| 4562 | performHapticFeedbackLw(null, safeMode |
| 4563 | ? HapticFeedbackConstants.SAFE_MODE_ENABLED |
| 4564 | : HapticFeedbackConstants.SAFE_MODE_DISABLED, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4565 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4566 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 4567 | static long[] getLongIntArray(Resources r, int resid) { |
| 4568 | int[] ar = r.getIntArray(resid); |
| 4569 | if (ar == null) { |
| 4570 | return null; |
| 4571 | } |
| 4572 | long[] out = new long[ar.length]; |
| 4573 | for (int i=0; i<ar.length; i++) { |
| 4574 | out[i] = ar[i]; |
| 4575 | } |
| 4576 | return out; |
| 4577 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4578 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4579 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4580 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4581 | public void systemReady() { |
Jim Miller | 195b551 | 2013-02-28 03:35:57 -0800 | [diff] [blame] | 4582 | if (!mHeadless) { |
| 4583 | mKeyguardDelegate = new KeyguardServiceDelegate(mContext, null); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4584 | mKeyguardDelegate.onSystemReady(); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4585 | } |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 4586 | synchronized (mLock) { |
| 4587 | updateOrientationListenerLp(); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 4588 | mSystemReady = true; |
| 4589 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4590 | @Override |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 4591 | public void run() { |
| 4592 | updateSettings(); |
| 4593 | } |
| 4594 | }); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4595 | } |
| 4596 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4597 | |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 4598 | /** {@inheritDoc} */ |
| 4599 | public void systemBooted() { |
| 4600 | synchronized (mLock) { |
| 4601 | mSystemBooted = true; |
| 4602 | } |
| 4603 | } |
| 4604 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4605 | ProgressDialog mBootMsgDialog = null; |
| 4606 | |
| 4607 | /** {@inheritDoc} */ |
| 4608 | public void showBootMessage(final CharSequence msg, final boolean always) { |
Mike Lockwood | aa5bf14 | 2011-09-21 13:03:40 -0400 | [diff] [blame] | 4609 | if (mHeadless) return; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4610 | mHandler.post(new Runnable() { |
| 4611 | @Override public void run() { |
| 4612 | if (mBootMsgDialog == null) { |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 4613 | mBootMsgDialog = new ProgressDialog(mContext) { |
| 4614 | // This dialog will consume all events coming in to |
| 4615 | // it, to avoid it trying to do things too early in boot. |
| 4616 | @Override public boolean dispatchKeyEvent(KeyEvent event) { |
| 4617 | return true; |
| 4618 | } |
| 4619 | @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 4620 | return true; |
| 4621 | } |
| 4622 | @Override public boolean dispatchTouchEvent(MotionEvent ev) { |
| 4623 | return true; |
| 4624 | } |
| 4625 | @Override public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 4626 | return true; |
| 4627 | } |
| 4628 | @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 4629 | return true; |
| 4630 | } |
| 4631 | @Override public boolean dispatchPopulateAccessibilityEvent( |
| 4632 | AccessibilityEvent event) { |
| 4633 | return true; |
| 4634 | } |
| 4635 | }; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4636 | mBootMsgDialog.setTitle(R.string.android_upgrading_title); |
| 4637 | mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); |
| 4638 | mBootMsgDialog.setIndeterminate(true); |
| 4639 | mBootMsgDialog.getWindow().setType( |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4640 | WindowManager.LayoutParams.TYPE_BOOT_PROGRESS); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4641 | mBootMsgDialog.getWindow().addFlags( |
| 4642 | WindowManager.LayoutParams.FLAG_DIM_BEHIND |
| 4643 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); |
| 4644 | mBootMsgDialog.getWindow().setDimAmount(1); |
Dianne Hackborn | d9efb95 | 2011-12-07 14:56:51 -0800 | [diff] [blame] | 4645 | WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes(); |
| 4646 | lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 4647 | mBootMsgDialog.getWindow().setAttributes(lp); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4648 | mBootMsgDialog.setCancelable(false); |
| 4649 | mBootMsgDialog.show(); |
| 4650 | } |
| 4651 | mBootMsgDialog.setMessage(msg); |
| 4652 | } |
| 4653 | }); |
| 4654 | } |
| 4655 | |
| 4656 | /** {@inheritDoc} */ |
| 4657 | public void hideBootMessages() { |
| 4658 | mHandler.post(new Runnable() { |
| 4659 | @Override public void run() { |
| 4660 | if (mBootMsgDialog != null) { |
| 4661 | mBootMsgDialog.dismiss(); |
| 4662 | mBootMsgDialog = null; |
| 4663 | } |
| 4664 | } |
| 4665 | }); |
| 4666 | } |
| 4667 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4668 | /** {@inheritDoc} */ |
| 4669 | public void userActivity() { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4670 | // *************************************** |
| 4671 | // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE |
| 4672 | // *************************************** |
| 4673 | // THIS IS CALLED FROM DEEP IN THE POWER MANAGER |
| 4674 | // WITH ITS LOCKS HELD. |
| 4675 | // |
| 4676 | // This code must be VERY careful about the locks |
| 4677 | // it acquires. |
| 4678 | // In fact, the current code acquires way too many, |
| 4679 | // and probably has lurking deadlocks. |
| 4680 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4681 | synchronized (mScreenLockTimeout) { |
| 4682 | if (mLockScreenTimerActive) { |
| 4683 | // reset the timer |
| 4684 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 4685 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 4686 | } |
| 4687 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 4688 | } |
| 4689 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4690 | class ScreenLockTimeout implements Runnable { |
| 4691 | Bundle options; |
| 4692 | |
| 4693 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4694 | public void run() { |
| 4695 | synchronized (this) { |
| 4696 | if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4697 | if (mKeyguardDelegate != null) { |
| 4698 | mKeyguardDelegate.doKeyguardTimeout(options); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4699 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4700 | mLockScreenTimerActive = false; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4701 | options = null; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4702 | } |
| 4703 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4704 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4705 | public void setLockOptions(Bundle options) { |
| 4706 | this.options = options; |
| 4707 | } |
| 4708 | } |
| 4709 | |
| 4710 | ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout(); |
| 4711 | |
| 4712 | public void lockNow(Bundle options) { |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 4713 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); |
| 4714 | mHandler.removeCallbacks(mScreenLockTimeout); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4715 | if (options != null) { |
| 4716 | // In case multiple calls are made to lockNow, we don't wipe out the options |
| 4717 | // until the runnable actually executes. |
| 4718 | mScreenLockTimeout.setLockOptions(options); |
| 4719 | } |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 4720 | mHandler.post(mScreenLockTimeout); |
| 4721 | } |
| 4722 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4723 | private void updateLockScreenTimeout() { |
| 4724 | synchronized (mScreenLockTimeout) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4725 | boolean enable = (mAllowLockscreenWhenOn && mScreenOnEarly && |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4726 | mKeyguardDelegate != null && mKeyguardDelegate.isSecure()); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4727 | if (mLockScreenTimerActive != enable) { |
| 4728 | if (enable) { |
| 4729 | if (localLOGV) Log.v(TAG, "setting lockscreen timer"); |
| 4730 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 4731 | } else { |
| 4732 | if (localLOGV) Log.v(TAG, "clearing lockscreen timer"); |
| 4733 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 4734 | } |
| 4735 | mLockScreenTimerActive = enable; |
| 4736 | } |
| 4737 | } |
| 4738 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4739 | |
| 4740 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4741 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4742 | public void enableScreenAfterBoot() { |
| 4743 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4744 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4745 | updateRotation(true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4746 | } |
Dianne Hackborn | f54c8f9 | 2009-09-19 14:03:57 -0700 | [diff] [blame] | 4747 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4748 | private void applyLidSwitchState() { |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4749 | if (mLidState == LID_CLOSED && mLidControlsSleep) { |
| 4750 | mPowerManager.goToSleep(SystemClock.uptimeMillis()); |
| 4751 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4752 | } |
| 4753 | |
| 4754 | void updateRotation(boolean alwaysSendConfiguration) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4755 | try { |
| 4756 | //set orientation on WindowManager |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 4757 | mWindowManager.updateRotation(alwaysSendConfiguration, false); |
| 4758 | } catch (RemoteException e) { |
| 4759 | // Ignore |
| 4760 | } |
| 4761 | } |
| 4762 | |
| 4763 | void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout) { |
| 4764 | try { |
| 4765 | //set orientation on WindowManager |
| 4766 | mWindowManager.updateRotation(alwaysSendConfiguration, forceRelayout); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4767 | } catch (RemoteException e) { |
| 4768 | // Ignore |
| 4769 | } |
| 4770 | } |
| 4771 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4772 | /** |
| 4773 | * Return an Intent to launch the currently active dock app as home. Returns |
| 4774 | * null if the standard home should be launched, which is the case if any of the following is |
| 4775 | * true: |
| 4776 | * <ul> |
| 4777 | * <li>The device is not in either car mode or desk mode |
| 4778 | * <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false |
| 4779 | * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false |
| 4780 | * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME |
| 4781 | * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME |
| 4782 | * </ul> |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4783 | * @return A dock intent. |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4784 | */ |
| 4785 | Intent createHomeDockIntent() { |
| 4786 | Intent intent = null; |
| 4787 | |
| 4788 | // What home does is based on the mode, not the dock state. That |
| 4789 | // is, when in car mode you should be taken to car home regardless |
| 4790 | // of whether we are actually in a car dock. |
| 4791 | if (mUiMode == Configuration.UI_MODE_TYPE_CAR) { |
| 4792 | if (ENABLE_CAR_DOCK_HOME_CAPTURE) { |
| 4793 | intent = mCarDockIntent; |
| 4794 | } |
| 4795 | } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { |
| 4796 | if (ENABLE_DESK_DOCK_HOME_CAPTURE) { |
| 4797 | intent = mDeskDockIntent; |
| 4798 | } |
| 4799 | } |
| 4800 | |
| 4801 | if (intent == null) { |
| 4802 | return null; |
| 4803 | } |
| 4804 | |
| 4805 | ActivityInfo ai = null; |
| 4806 | ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser( |
| 4807 | intent, |
| 4808 | PackageManager.MATCH_DEFAULT_ONLY, |
| 4809 | UserHandle.USER_CURRENT); |
| 4810 | if (info != null) { |
| 4811 | ai = info.activityInfo; |
| 4812 | } |
| 4813 | if (ai != null |
| 4814 | && ai.metaData != null |
| 4815 | && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { |
| 4816 | intent = new Intent(intent); |
| 4817 | intent.setClassName(ai.packageName, ai.name); |
| 4818 | return intent; |
| 4819 | } |
| 4820 | |
| 4821 | return null; |
| 4822 | } |
| 4823 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4824 | void startDockOrHome() { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 4825 | awakenDreams(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4826 | |
| 4827 | Intent dock = createHomeDockIntent(); |
| 4828 | if (dock != null) { |
| 4829 | try { |
| 4830 | mContext.startActivityAsUser(dock, UserHandle.CURRENT); |
| 4831 | return; |
| 4832 | } catch (ActivityNotFoundException e) { |
| 4833 | } |
| 4834 | } |
| 4835 | |
Dianne Hackborn | d888399 | 2012-09-07 15:58:52 -0700 | [diff] [blame] | 4836 | mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4837 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4838 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4839 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4840 | * goes to the home screen |
| 4841 | * @return whether it did anything |
| 4842 | */ |
| 4843 | boolean goHome() { |
| 4844 | if (false) { |
| 4845 | // This code always brings home to the front. |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 4846 | try { |
| 4847 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 4848 | } catch (RemoteException e) { |
| 4849 | } |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 4850 | sendCloseSystemWindows(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4851 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4852 | } else { |
| 4853 | // This code brings home to the front or, if it is already |
| 4854 | // at the front, puts the device to sleep. |
| 4855 | try { |
Wink Saville | d2e6a33 | 2010-02-12 12:12:06 -0800 | [diff] [blame] | 4856 | if (SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1) { |
| 4857 | /// Roll back EndcallBehavior as the cupcake design to pass P1 lab entry. |
| 4858 | Log.d(TAG, "UTS-TEST-MODE"); |
| 4859 | } else { |
| 4860 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 4861 | sendCloseSystemWindows(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4862 | Intent dock = createHomeDockIntent(); |
| 4863 | if (dock != null) { |
| 4864 | int result = ActivityManagerNative.getDefault() |
| 4865 | .startActivityAsUser(null, null, dock, |
| 4866 | dock.resolveTypeIfNeeded(mContext.getContentResolver()), |
| 4867 | null, null, 0, |
| 4868 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
| 4869 | null, null, null, UserHandle.USER_CURRENT); |
| 4870 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
| 4871 | return false; |
| 4872 | } |
| 4873 | } |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4874 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4875 | int result = ActivityManagerNative.getDefault() |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 4876 | .startActivityAsUser(null, null, mHomeIntent, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4877 | mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 4878 | null, null, 0, |
| 4879 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
Dianne Hackborn | 5e03e2c | 2012-09-06 14:21:19 -0700 | [diff] [blame] | 4880 | null, null, null, UserHandle.USER_CURRENT); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 4881 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4882 | return false; |
| 4883 | } |
| 4884 | } catch (RemoteException ex) { |
| 4885 | // bummer, the activity manager, which is in this process, is dead |
| 4886 | } |
| 4887 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4888 | return true; |
| 4889 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4890 | |
| 4891 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4892 | public void setCurrentOrientationLw(int newOrientation) { |
| 4893 | synchronized (mLock) { |
| 4894 | if (newOrientation != mCurrentAppOrientation) { |
| 4895 | mCurrentAppOrientation = newOrientation; |
| 4896 | updateOrientationListenerLp(); |
| 4897 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4898 | } |
| 4899 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4900 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 4901 | private void performAuditoryFeedbackForAccessibilityIfNeed() { |
| 4902 | if (!isGlobalAccessibilityGestureEnabled()) { |
| 4903 | return; |
| 4904 | } |
| 4905 | AudioManager audioManager = (AudioManager) mContext.getSystemService( |
| 4906 | Context.AUDIO_SERVICE); |
| 4907 | if (audioManager.isSilentMode()) { |
| 4908 | return; |
| 4909 | } |
| 4910 | Ringtone ringTone = RingtoneManager.getRingtone(mContext, |
| 4911 | Settings.System.DEFAULT_NOTIFICATION_URI); |
| 4912 | ringTone.setStreamType(AudioManager.STREAM_MUSIC); |
| 4913 | ringTone.play(); |
| 4914 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4915 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 4916 | private boolean isGlobalAccessibilityGestureEnabled() { |
| 4917 | return Settings.Global.getInt(mContext.getContentResolver(), |
| 4918 | Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1; |
| 4919 | } |
| 4920 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4921 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4922 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { |
Svetoslav Ganov | 9617921 | 2012-10-10 14:17:45 -0700 | [diff] [blame] | 4923 | if (!mVibrator.hasVibrator()) { |
| 4924 | return false; |
| 4925 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4926 | final boolean hapticsDisabled = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 4927 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) == 0; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4928 | if (!always && (hapticsDisabled || mKeyguardDelegate.isShowingAndNotHidden())) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4929 | return false; |
| 4930 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4931 | long[] pattern = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4932 | switch (effectId) { |
| 4933 | case HapticFeedbackConstants.LONG_PRESS: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4934 | pattern = mLongPressVibePattern; |
| 4935 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 4936 | case HapticFeedbackConstants.VIRTUAL_KEY: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4937 | pattern = mVirtualKeyVibePattern; |
| 4938 | break; |
| 4939 | case HapticFeedbackConstants.KEYBOARD_TAP: |
| 4940 | pattern = mKeyboardTapVibePattern; |
| 4941 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 4942 | case HapticFeedbackConstants.SAFE_MODE_DISABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4943 | pattern = mSafeModeDisabledVibePattern; |
| 4944 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 4945 | case HapticFeedbackConstants.SAFE_MODE_ENABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4946 | pattern = mSafeModeEnabledVibePattern; |
| 4947 | break; |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4948 | default: |
| 4949 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4950 | } |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 4951 | int owningUid; |
| 4952 | String owningPackage; |
| 4953 | if (win != null) { |
| 4954 | owningUid = win.getOwningUid(); |
| 4955 | owningPackage = win.getOwningPackage(); |
| 4956 | } else { |
| 4957 | owningUid = android.os.Process.myUid(); |
| 4958 | owningPackage = mContext.getBasePackageName(); |
| 4959 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4960 | if (pattern.length == 1) { |
| 4961 | // One-shot vibration |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 4962 | mVibrator.vibrate(owningUid, owningPackage, pattern[0]); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4963 | } else { |
| 4964 | // Pattern vibration |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 4965 | mVibrator.vibrate(owningUid, owningPackage, pattern, -1); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4966 | } |
| 4967 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4968 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4969 | |
| 4970 | @Override |
| 4971 | public void keepScreenOnStartedLw() { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 4972 | } |
| 4973 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4974 | @Override |
| 4975 | public void keepScreenOnStoppedLw() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4976 | if (mKeyguardDelegate != null && !mKeyguardDelegate.isShowingAndNotHidden()) { |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4977 | long curTime = SystemClock.uptimeMillis(); |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 4978 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4979 | } |
| 4980 | } |
Mike Lockwood | fcb3924 | 2009-10-21 23:01:07 -0400 | [diff] [blame] | 4981 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4982 | private int updateSystemUiVisibilityLw() { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4983 | // If there is no window focused, there will be nobody to handle the events |
| 4984 | // anyway, so just hang on in whatever state we're in until things settle down. |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4985 | if (mFocusedWindow == null) { |
| 4986 | return 0; |
| 4987 | } |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 4988 | if (mFocusedWindow.getAttrs().type == TYPE_KEYGUARD && mHideLockScreen == true) { |
| 4989 | // We are updating at a point where the keyguard has gotten |
| 4990 | // focus, but we were last in a state where the top window is |
| 4991 | // hiding it. This is probably because the keyguard as been |
| 4992 | // shown while the top window was displayed, so we want to ignore |
| 4993 | // it here because this is just a very transient change and it |
| 4994 | // will quickly lose focus once it correctly gets hidden. |
| 4995 | return 0; |
| 4996 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 4997 | |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 4998 | int tmpVisibility = mFocusedWindow.getSystemUiVisibility() |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 4999 | & ~mResettingSystemUiFlags |
| 5000 | & ~mForceClearedSystemUiFlags; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5001 | if (mForcingShowNavBar && mFocusedWindow.getSurfaceLayer() < mForcingShowNavBarLayer) { |
| 5002 | tmpVisibility &= ~View.SYSTEM_UI_CLEARABLE_FLAGS; |
| 5003 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5004 | final int visibility = updateHideybarsLw(tmpVisibility); |
| 5005 | final int diff = visibility ^ mLastSystemUiFlags; |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 5006 | final boolean needsMenu = mFocusedWindow.getNeedsMenuLw(mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 5007 | if (diff == 0 && mLastFocusNeedsMenu == needsMenu |
| 5008 | && mFocusedApp == mFocusedWindow.getAppToken()) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5009 | return 0; |
| 5010 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5011 | mLastSystemUiFlags = visibility; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5012 | mLastFocusNeedsMenu = needsMenu; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 5013 | mFocusedApp = mFocusedWindow.getAppToken(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5014 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5015 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5016 | public void run() { |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5017 | try { |
| 5018 | IStatusBarService statusbar = getStatusBarService(); |
| 5019 | if (statusbar != null) { |
| 5020 | statusbar.setSystemUiVisibility(visibility, 0xffffffff); |
| 5021 | statusbar.topAppWindowChanged(needsMenu); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5022 | } |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5023 | } catch (RemoteException e) { |
| 5024 | // re-acquire status bar service next time it is needed. |
| 5025 | mStatusBarService = null; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5026 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5027 | } |
| 5028 | }); |
| 5029 | return diff; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5030 | } |
| 5031 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5032 | private int updateHideybarsLw(int tmpVisibility) { |
John Spurlock | 245fd01 | 2013-05-31 10:31:04 -0400 | [diff] [blame] | 5033 | if (OverlayTesting.enabled) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5034 | tmpVisibility = OverlayTesting.applyForced(mFocusedWindow, tmpVisibility); |
| 5035 | } |
| 5036 | boolean statusBarHasFocus = |
| 5037 | mFocusedWindow.getAttrs().type == TYPE_STATUS_BAR; |
| 5038 | if (statusBarHasFocus) { |
| 5039 | // prevent status bar interaction from clearing certain flags |
| 5040 | int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
| 5041 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
| 5042 | | View.SYSTEM_UI_FLAG_ALLOW_OVERLAY; |
| 5043 | tmpVisibility = (tmpVisibility & ~flags) | (mLastSystemUiFlags & flags); |
| 5044 | } |
| 5045 | boolean overlayAllowed = (tmpVisibility & View.SYSTEM_UI_FLAG_ALLOW_OVERLAY) != 0; |
| 5046 | if (mStatusHideybar == HIDEYBAR_SHOWING) { |
| 5047 | // status hideybar requested |
| 5048 | boolean hideStatusBarWM = |
| 5049 | (mFocusedWindow.getAttrs().flags |
| 5050 | & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; |
| 5051 | boolean hideStatusBarSysui = |
| 5052 | (tmpVisibility & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
| 5053 | |
| 5054 | boolean statusHideyAllowed = |
| 5055 | hideStatusBarWM |
| 5056 | || (hideStatusBarSysui && overlayAllowed) |
| 5057 | || statusBarHasFocus; |
| 5058 | |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 5059 | if (mStatusBar == null || !statusHideyAllowed) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5060 | mStatusHideybar = HIDEYBAR_NONE; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 5061 | if (mStatusBar != null && hideStatusBarSysui) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5062 | // clear the clearable flags instead |
| 5063 | int newVal = mResettingSystemUiFlags | View.SYSTEM_UI_CLEARABLE_FLAGS; |
| 5064 | if (newVal != mResettingSystemUiFlags) { |
| 5065 | mResettingSystemUiFlags = newVal; |
| 5066 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 5067 | } |
| 5068 | } |
| 5069 | } else { |
| 5070 | // show status hideybar |
| 5071 | tmpVisibility |= View.STATUS_BAR_OVERLAY; |
| 5072 | if ((mLastSystemUiFlags & View.STATUS_BAR_OVERLAY) == 0) { |
John Spurlock | d85618e | 2013-05-28 14:58:50 -0400 | [diff] [blame] | 5073 | tmpVisibility &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5074 | mStatusBar.showLw(true); |
| 5075 | } |
| 5076 | } |
| 5077 | } |
| 5078 | if (mNavigationHideybar == HIDEYBAR_SHOWING) { |
| 5079 | // navigation hideybar requested |
| 5080 | boolean hideNavigationBarSysui = |
| 5081 | (tmpVisibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; |
| 5082 | boolean navigationHideyAllowed = |
John Spurlock | e3b642e | 2013-05-09 15:51:32 -0400 | [diff] [blame] | 5083 | hideNavigationBarSysui && overlayAllowed && mNavigationBar != null; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5084 | if (!navigationHideyAllowed) { |
| 5085 | mNavigationHideybar = HIDEYBAR_NONE; |
| 5086 | } else { |
| 5087 | // show navigation hideybar |
| 5088 | tmpVisibility |= View.NAVIGATION_BAR_OVERLAY; |
| 5089 | if ((mLastSystemUiFlags & View.NAVIGATION_BAR_OVERLAY) == 0) { |
John Spurlock | d85618e | 2013-05-28 14:58:50 -0400 | [diff] [blame] | 5090 | tmpVisibility &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5091 | mNavigationBar.showLw(true); |
| 5092 | } |
| 5093 | } |
| 5094 | } |
| 5095 | return tmpVisibility; |
| 5096 | } |
| 5097 | |
| 5098 | // TODO temporary helper that allows testing overlay bars on existing apps |
| 5099 | private static final class OverlayTesting { |
John Spurlock | 245fd01 | 2013-05-31 10:31:04 -0400 | [diff] [blame] | 5100 | static String ENABLED_SETTING = "overlay_testing_enabled"; |
| 5101 | static boolean enabled = false; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5102 | private static final HashSet<String> sForced = new HashSet<String>(); |
| 5103 | |
| 5104 | private static String parseActivity(WindowState win) { |
| 5105 | if (win != null && win.getAppToken() != null) { |
| 5106 | String str = win.getAppToken().toString(); |
| 5107 | int end = str.lastIndexOf(' '); |
| 5108 | if (end > 0) { |
| 5109 | int start = str.lastIndexOf(' ', end - 1); |
| 5110 | if (start > -1) { |
| 5111 | return str.substring(start + 1, end); |
| 5112 | } |
| 5113 | } |
| 5114 | } |
| 5115 | return null; |
| 5116 | } |
| 5117 | |
| 5118 | public static int applyForced(WindowState focused, int vis) { |
| 5119 | if (sForced.contains(parseActivity(focused))) { |
| 5120 | vis |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| 5121 | View.SYSTEM_UI_FLAG_FULLSCREEN | |
| 5122 | View.SYSTEM_UI_FLAG_ALLOW_OVERLAY; |
| 5123 | } |
| 5124 | return vis; |
| 5125 | } |
| 5126 | |
| 5127 | public static void toggleForceOverlay(WindowState focused, Context context) { |
| 5128 | String activity = parseActivity(focused); |
| 5129 | if (activity != null) { |
| 5130 | String action; |
| 5131 | if (sForced.contains(activity)) { |
| 5132 | sForced.remove(activity); |
| 5133 | action = "Force overlay disabled"; |
| 5134 | } else { |
| 5135 | sForced.add(activity); |
| 5136 | action = "Force overlay enabled"; |
| 5137 | } |
| 5138 | android.widget.Toast.makeText(context, |
| 5139 | action + " for " + activity, android.widget.Toast.LENGTH_SHORT).show(); |
| 5140 | } |
| 5141 | } |
| 5142 | } |
| 5143 | |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5144 | // Use this instead of checking config_showNavigationBar so that it can be consistently |
| 5145 | // overridden by qemu.hw.mainkeys in the emulator. |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5146 | @Override |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5147 | public boolean hasNavigationBar() { |
| 5148 | return mHasNavigationBar; |
| 5149 | } |
| 5150 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 5151 | @Override |
| 5152 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target) { |
| 5153 | mLastInputMethodWindow = ime; |
| 5154 | mLastInputMethodTargetWindow = target; |
| 5155 | } |
| 5156 | |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5157 | @Override |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5158 | public void setCurrentUserLw(int newUserId) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5159 | if (mKeyguardDelegate != null) { |
| 5160 | mKeyguardDelegate.setCurrentUser(newUserId); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5161 | } |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 5162 | if (mStatusBarService != null) { |
| 5163 | try { |
| 5164 | mStatusBarService.setCurrentUser(newUserId); |
| 5165 | } catch (RemoteException e) { |
| 5166 | // oh well |
| 5167 | } |
| 5168 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5169 | setLastInputMethodWindowLw(null, null); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5170 | } |
| 5171 | |
| 5172 | @Override |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 5173 | public void showAssistant() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5174 | mKeyguardDelegate.showAssistant(); |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 5175 | } |
| 5176 | |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 5177 | @Override |
| 5178 | public boolean canMagnifyWindow(int windowType) { |
| 5179 | switch (windowType) { |
| 5180 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD: |
| 5181 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG: |
| 5182 | case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR: |
| 5183 | case WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY: { |
| 5184 | return false; |
| 5185 | } |
| 5186 | } |
| 5187 | return true; |
| 5188 | } |
| 5189 | |
| 5190 | @Override |
| 5191 | public boolean isTopLevelWindow(int windowType) { |
| 5192 | if (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW |
| 5193 | && windowType <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 5194 | return (windowType == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG); |
| 5195 | } |
| 5196 | return true; |
| 5197 | } |
| 5198 | |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 5199 | @Override |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 5200 | public void dump(String prefix, PrintWriter pw, String[] args) { |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5201 | pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5202 | pw.print(" mSystemReady="); pw.print(mSystemReady); |
| 5203 | pw.print(" mSystemBooted="); pw.println(mSystemBooted); |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 5204 | pw.print(prefix); pw.print("mLidState="); pw.print(mLidState); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5205 | pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); |
| 5206 | pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5207 | if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 |
| 5208 | || mForceClearedSystemUiFlags != 0) { |
| 5209 | pw.print(prefix); pw.print("mLastSystemUiFlags=0x"); |
| 5210 | pw.print(Integer.toHexString(mLastSystemUiFlags)); |
| 5211 | pw.print(" mResettingSystemUiFlags=0x"); |
| 5212 | pw.print(Integer.toHexString(mResettingSystemUiFlags)); |
| 5213 | pw.print(" mForceClearedSystemUiFlags=0x"); |
| 5214 | pw.println(Integer.toHexString(mForceClearedSystemUiFlags)); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5215 | } |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5216 | if (mLastFocusNeedsMenu) { |
| 5217 | pw.print(prefix); pw.print("mLastFocusNeedsMenu="); |
| 5218 | pw.println(mLastFocusNeedsMenu); |
| 5219 | } |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5220 | pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); |
| 5221 | pw.print(" mDockMode="); pw.print(mDockMode); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5222 | pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); |
| 5223 | pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); |
| 5224 | pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); |
| 5225 | pw.print(" mUserRotation="); pw.print(mUserRotation); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 5226 | pw.print(" mAllowAllRotations="); pw.println(mAllowAllRotations); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5227 | pw.print(prefix); pw.print("mCurrentAppOrientation="); pw.println(mCurrentAppOrientation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5228 | pw.print(prefix); pw.print("mCarDockEnablesAccelerometer="); |
| 5229 | pw.print(mCarDockEnablesAccelerometer); |
| 5230 | pw.print(" mDeskDockEnablesAccelerometer="); |
| 5231 | pw.println(mDeskDockEnablesAccelerometer); |
| 5232 | pw.print(prefix); pw.print("mLidKeyboardAccessibility="); |
| 5233 | pw.print(mLidKeyboardAccessibility); |
| 5234 | pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5235 | pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep); |
| 5236 | pw.print(prefix); pw.print("mLongPressOnPowerBehavior="); |
| 5237 | pw.print(mLongPressOnPowerBehavior); |
| 5238 | pw.print(" mHasSoftInput="); pw.println(mHasSoftInput); |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 5239 | pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly); |
| 5240 | pw.print(" mScreenOnFully="); pw.print(mScreenOnFully); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5241 | pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 5242 | pw.print(prefix); pw.print("mOverscanScreen=("); pw.print(mOverscanScreenLeft); |
| 5243 | pw.print(","); pw.print(mOverscanScreenTop); |
| 5244 | pw.print(") "); pw.print(mOverscanScreenWidth); |
| 5245 | pw.print("x"); pw.println(mOverscanScreenHeight); |
| 5246 | if (mOverscanLeft != 0 || mOverscanTop != 0 |
| 5247 | || mOverscanRight != 0 || mOverscanBottom != 0) { |
| 5248 | pw.print(prefix); pw.print("mOverscan left="); pw.print(mOverscanLeft); |
| 5249 | pw.print(" top="); pw.print(mOverscanTop); |
| 5250 | pw.print(" right="); pw.print(mOverscanRight); |
| 5251 | pw.print(" bottom="); pw.println(mOverscanBottom); |
| 5252 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 5253 | pw.print(prefix); pw.print("mRestrictedOverscanScreen=("); |
| 5254 | pw.print(mRestrictedOverscanScreenLeft); |
| 5255 | pw.print(","); pw.print(mRestrictedOverscanScreenTop); |
| 5256 | pw.print(") "); pw.print(mRestrictedOverscanScreenWidth); |
| 5257 | pw.print("x"); pw.println(mRestrictedOverscanScreenHeight); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5258 | pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft); |
| 5259 | pw.print(","); pw.print(mUnrestrictedScreenTop); |
| 5260 | pw.print(") "); pw.print(mUnrestrictedScreenWidth); |
| 5261 | pw.print("x"); pw.println(mUnrestrictedScreenHeight); |
| 5262 | pw.print(prefix); pw.print("mRestrictedScreen=("); pw.print(mRestrictedScreenLeft); |
| 5263 | pw.print(","); pw.print(mRestrictedScreenTop); |
| 5264 | pw.print(") "); pw.print(mRestrictedScreenWidth); |
| 5265 | pw.print("x"); pw.println(mRestrictedScreenHeight); |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 5266 | pw.print(prefix); pw.print("mStableFullscreen=("); pw.print(mStableFullscreenLeft); |
| 5267 | pw.print(","); pw.print(mStableFullscreenTop); |
| 5268 | pw.print(")-("); pw.print(mStableFullscreenRight); |
| 5269 | pw.print(","); pw.print(mStableFullscreenBottom); pw.println(")"); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 5270 | pw.print(prefix); pw.print("mStable=("); pw.print(mStableLeft); |
| 5271 | pw.print(","); pw.print(mStableTop); |
| 5272 | pw.print(")-("); pw.print(mStableRight); |
| 5273 | pw.print(","); pw.print(mStableBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5274 | pw.print(prefix); pw.print("mSystem=("); pw.print(mSystemLeft); |
| 5275 | pw.print(","); pw.print(mSystemTop); |
| 5276 | pw.print(")-("); pw.print(mSystemRight); |
| 5277 | pw.print(","); pw.print(mSystemBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5278 | pw.print(prefix); pw.print("mCur=("); pw.print(mCurLeft); |
| 5279 | pw.print(","); pw.print(mCurTop); |
| 5280 | pw.print(")-("); pw.print(mCurRight); |
| 5281 | pw.print(","); pw.print(mCurBottom); pw.println(")"); |
| 5282 | pw.print(prefix); pw.print("mContent=("); pw.print(mContentLeft); |
| 5283 | pw.print(","); pw.print(mContentTop); |
| 5284 | pw.print(")-("); pw.print(mContentRight); |
| 5285 | pw.print(","); pw.print(mContentBottom); pw.println(")"); |
| 5286 | pw.print(prefix); pw.print("mDock=("); pw.print(mDockLeft); |
| 5287 | pw.print(","); pw.print(mDockTop); |
| 5288 | pw.print(")-("); pw.print(mDockRight); |
| 5289 | pw.print(","); pw.print(mDockBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5290 | pw.print(prefix); pw.print("mDockLayer="); pw.print(mDockLayer); |
| 5291 | pw.print(" mStatusBarLayer="); pw.println(mStatusBarLayer); |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5292 | pw.print(prefix); pw.print("mShowingLockscreen="); pw.print(mShowingLockscreen); |
| 5293 | pw.print(" mShowingDream="); pw.print(mShowingDream); |
| 5294 | pw.print(" mDreamingLockscreen="); pw.println(mDreamingLockscreen); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5295 | if (mLastInputMethodWindow != null) { |
| 5296 | pw.print(prefix); pw.print("mLastInputMethodWindow="); |
| 5297 | pw.println(mLastInputMethodWindow); |
| 5298 | } |
| 5299 | if (mLastInputMethodTargetWindow != null) { |
| 5300 | pw.print(prefix); pw.print("mLastInputMethodTargetWindow="); |
| 5301 | pw.println(mLastInputMethodTargetWindow); |
| 5302 | } |
| 5303 | if (mStatusBar != null) { |
| 5304 | pw.print(prefix); pw.print("mStatusBar="); |
| 5305 | pw.println(mStatusBar); |
| 5306 | } |
| 5307 | if (mNavigationBar != null) { |
| 5308 | pw.print(prefix); pw.print("mNavigationBar="); |
| 5309 | pw.println(mNavigationBar); |
| 5310 | } |
| 5311 | if (mKeyguard != null) { |
| 5312 | pw.print(prefix); pw.print("mKeyguard="); |
| 5313 | pw.println(mKeyguard); |
| 5314 | } |
| 5315 | if (mFocusedWindow != null) { |
| 5316 | pw.print(prefix); pw.print("mFocusedWindow="); |
| 5317 | pw.println(mFocusedWindow); |
| 5318 | } |
| 5319 | if (mFocusedApp != null) { |
| 5320 | pw.print(prefix); pw.print("mFocusedApp="); |
| 5321 | pw.println(mFocusedApp); |
| 5322 | } |
| 5323 | if (mWinDismissingKeyguard != null) { |
| 5324 | pw.print(prefix); pw.print("mWinDismissingKeyguard="); |
| 5325 | pw.println(mWinDismissingKeyguard); |
| 5326 | } |
| 5327 | if (mTopFullscreenOpaqueWindowState != null) { |
| 5328 | pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); |
| 5329 | pw.println(mTopFullscreenOpaqueWindowState); |
| 5330 | } |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5331 | if (mForcingShowNavBar) { |
| 5332 | pw.print(prefix); pw.print("mForcingShowNavBar="); |
| 5333 | pw.println(mForcingShowNavBar); pw.print( "mForcingShowNavBarLayer="); |
| 5334 | pw.println(mForcingShowNavBarLayer); |
| 5335 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5336 | pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5337 | pw.print(" mHideLockScreen="); pw.println(mHideLockScreen); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5338 | pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); |
| 5339 | pw.print(" mForceStatusBarFromKeyguard="); |
| 5340 | pw.println(mForceStatusBarFromKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5341 | pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 5342 | pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5343 | pw.print(" mHomePressed="); pw.println(mHomePressed); |
| 5344 | pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); |
| 5345 | pw.print(" mLockScreenTimeout="); pw.print(mLockScreenTimeout); |
| 5346 | pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive); |
| 5347 | pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior); |
| 5348 | pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior); |
| 5349 | pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior); |
| 5350 | pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation); |
| 5351 | pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); |
| 5352 | pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); |
| 5353 | pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 5354 | pw.print(prefix); pw.print("mDemoHdmiRotation="); pw.print(mDemoHdmiRotation); |
| 5355 | pw.print(" mDemoHdmiRotationLock="); pw.println(mDemoHdmiRotationLock); |
| 5356 | pw.print(prefix); pw.print("mUndockedHdmiRotation="); pw.println(mUndockedHdmiRotation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5357 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5358 | } |