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; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 24 | import android.app.StatusBarManager; |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 25 | import android.app.UiModeManager; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 26 | import android.content.ActivityNotFoundException; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 27 | import android.content.BroadcastReceiver; |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 28 | import android.content.ComponentName; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 29 | import android.content.ContentResolver; |
| 30 | import android.content.Context; |
| 31 | import android.content.Intent; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 32 | import android.content.IntentFilter; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 33 | import android.content.ServiceConnection; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 34 | import android.content.pm.ActivityInfo; |
| 35 | import android.content.pm.PackageManager; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 36 | import android.content.pm.ResolveInfo; |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 37 | import android.content.res.CompatibilityInfo; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 38 | import android.content.res.Configuration; |
| 39 | import android.content.res.Resources; |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 40 | import android.content.res.TypedArray; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 41 | import android.database.ContentObserver; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 42 | import android.graphics.PixelFormat; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 43 | import android.graphics.Rect; |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 44 | import android.media.AudioManager; |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 45 | import android.media.AudioSystem; |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 46 | import android.media.IAudioService; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 47 | import android.media.Ringtone; |
| 48 | import android.media.RingtoneManager; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 49 | import android.os.Bundle; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 50 | import android.os.FactoryTest; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 51 | import android.os.Handler; |
| 52 | import android.os.IBinder; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 53 | import android.os.IRemoteCallback; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 54 | import android.os.Looper; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 55 | import android.os.Message; |
| 56 | import android.os.Messenger; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 57 | import android.os.PowerManager; |
| 58 | import android.os.RemoteException; |
| 59 | import android.os.ServiceManager; |
| 60 | import android.os.SystemClock; |
| 61 | import android.os.SystemProperties; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 62 | import android.os.UEventObserver; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 63 | import android.os.UserHandle; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 64 | import android.os.Vibrator; |
| 65 | import android.provider.Settings; |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 66 | import android.service.dreams.DreamService; |
| 67 | import android.service.dreams.IDreamManager; |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 68 | import android.util.DisplayMetrics; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 69 | import android.util.EventLog; |
| 70 | import android.util.Log; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 71 | import android.util.Slog; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 72 | import android.util.SparseArray; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 73 | import android.view.Display; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 74 | import android.view.Gravity; |
| 75 | import android.view.HapticFeedbackConstants; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 76 | import android.view.IApplicationToken; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 77 | import android.view.IWindowManager; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 78 | import android.view.InputChannel; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 79 | import android.view.InputDevice; |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 80 | import android.view.InputEvent; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 81 | import android.view.InputEventReceiver; |
Jeff Brown | 6b53e8d | 2010-11-10 16:03:06 -0800 | [diff] [blame] | 82 | import android.view.KeyCharacterMap; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 83 | import android.view.KeyCharacterMap.FallbackAction; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 84 | import android.view.KeyEvent; |
| 85 | import android.view.MotionEvent; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 86 | import android.view.Surface; |
| 87 | import android.view.View; |
| 88 | import android.view.ViewConfiguration; |
| 89 | import android.view.Window; |
| 90 | import android.view.WindowManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 91 | import android.view.WindowManagerGlobal; |
| 92 | import android.view.WindowManagerPolicy; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 93 | import android.view.accessibility.AccessibilityEvent; |
| 94 | import android.view.animation.Animation; |
| 95 | import android.view.animation.AnimationUtils; |
| 96 | |
| 97 | import com.android.internal.R; |
| 98 | import com.android.internal.policy.PolicyManager; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 99 | import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 100 | import com.android.internal.statusbar.IStatusBarService; |
| 101 | import com.android.internal.telephony.ITelephony; |
| 102 | import com.android.internal.widget.PointerLocationView; |
| 103 | |
| 104 | import java.io.File; |
| 105 | import java.io.FileReader; |
| 106 | import java.io.IOException; |
| 107 | import java.io.PrintWriter; |
Craig Mautner | 0392442 | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 108 | import java.util.HashSet; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 109 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 110 | import static android.view.WindowManager.LayoutParams.*; |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 111 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; |
| 112 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; |
| 113 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 114 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 115 | /** |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 116 | * WindowManagerPolicy implementation for the Android phone UI. This |
| 117 | * introduces a new method suffix, Lp, for an internal lock of the |
| 118 | * PhoneWindowManager. This is used to protect some internal state, and |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 119 | * 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] | 120 | * of both of those when held. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 121 | */ |
| 122 | public class PhoneWindowManager implements WindowManagerPolicy { |
| 123 | static final String TAG = "WindowManager"; |
| 124 | static final boolean DEBUG = false; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 125 | static final boolean localLOGV = false; |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 126 | static final boolean DEBUG_LAYOUT = false; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 127 | static final boolean DEBUG_INPUT = false; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 128 | static final boolean DEBUG_STARTING_WINDOW = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 129 | static final boolean SHOW_STARTING_ANIMATIONS = true; |
| 130 | static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 131 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 132 | // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. |
| 133 | // No longer recommended for desk docks; still useful in car docks. |
| 134 | static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; |
| 135 | static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; |
| 136 | |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 137 | static final int LONG_PRESS_POWER_NOTHING = 0; |
| 138 | static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; |
| 139 | static final int LONG_PRESS_POWER_SHUT_OFF = 2; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 140 | static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 141 | |
| 142 | // These need to match the documentation/constant in |
| 143 | // core/res/res/values/config.xml |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 144 | static final int LONG_PRESS_HOME_NOTHING = 0; |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 145 | static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 146 | static final int LONG_PRESS_HOME_ASSIST = 2; |
| 147 | |
| 148 | static final int DOUBLE_TAP_HOME_NOTHING = 0; |
| 149 | static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 150 | |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 151 | static final int APPLICATION_MEDIA_SUBLAYER = -2; |
| 152 | static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 153 | static final int APPLICATION_PANEL_SUBLAYER = 1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 154 | static final int APPLICATION_SUB_PANEL_SUBLAYER = 2; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 155 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 156 | static public final String SYSTEM_DIALOG_REASON_KEY = "reason"; |
| 157 | static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions"; |
| 158 | static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 159 | static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 160 | static public final String SYSTEM_DIALOG_REASON_ASSIST = "assist"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 161 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 162 | /** |
| 163 | * These are the system UI flags that, when changing, can cause the layout |
| 164 | * of the screen to change. |
| 165 | */ |
| 166 | static final int SYSTEM_UI_CHANGING_LAYOUT = |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 167 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | 7f4820a | 2013-10-08 12:54:35 -0400 | [diff] [blame] | 168 | | View.SYSTEM_UI_FLAG_FULLSCREEN |
| 169 | | View.STATUS_BAR_TRANSLUCENT |
| 170 | | View.NAVIGATION_BAR_TRANSLUCENT; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 171 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 172 | /** |
| 173 | * Keyguard stuff |
| 174 | */ |
| 175 | private WindowState mKeyguardScrim; |
| 176 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 177 | /* Table of Application Launch keys. Maps from key codes to intent categories. |
| 178 | * |
| 179 | * These are special keys that are used to launch particular kinds of applications, |
| 180 | * such as a web browser. HID defines nearly a hundred of them in the Consumer (0x0C) |
| 181 | * usage page. We don't support quite that many yet... |
| 182 | */ |
| 183 | static SparseArray<String> sApplicationLaunchKeyCategories; |
| 184 | static { |
| 185 | sApplicationLaunchKeyCategories = new SparseArray<String>(); |
| 186 | sApplicationLaunchKeyCategories.append( |
| 187 | KeyEvent.KEYCODE_EXPLORER, Intent.CATEGORY_APP_BROWSER); |
| 188 | sApplicationLaunchKeyCategories.append( |
| 189 | KeyEvent.KEYCODE_ENVELOPE, Intent.CATEGORY_APP_EMAIL); |
| 190 | sApplicationLaunchKeyCategories.append( |
| 191 | KeyEvent.KEYCODE_CONTACTS, Intent.CATEGORY_APP_CONTACTS); |
| 192 | sApplicationLaunchKeyCategories.append( |
| 193 | KeyEvent.KEYCODE_CALENDAR, Intent.CATEGORY_APP_CALENDAR); |
| 194 | sApplicationLaunchKeyCategories.append( |
| 195 | KeyEvent.KEYCODE_MUSIC, Intent.CATEGORY_APP_MUSIC); |
| 196 | sApplicationLaunchKeyCategories.append( |
| 197 | KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); |
| 198 | } |
| 199 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 200 | /** |
| 201 | * Lock protecting internal state. Must not call out into window |
| 202 | * manager with lock held. (This lock will be acquired in places |
| 203 | * where the window manager is calling in with its own lock held.) |
| 204 | */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 205 | private final Object mLock = new Object(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 206 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 207 | Context mContext; |
| 208 | IWindowManager mWindowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 209 | WindowManagerFuncs mWindowManagerFuncs; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 210 | PowerManager mPowerManager; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 211 | IStatusBarService mStatusBarService; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 212 | boolean mPreloadedRecentApps; |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 213 | final Object mServiceAquireLock = new Object(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 214 | Vibrator mVibrator; // Vibrator for giving feedback of orientation changes |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 215 | SearchManager mSearchManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 216 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 217 | // Vibrator pattern for haptic feedback of a long press. |
| 218 | long[] mLongPressVibePattern; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 219 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 220 | // Vibrator pattern for haptic feedback of virtual key press. |
| 221 | long[] mVirtualKeyVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 222 | |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 223 | // Vibrator pattern for a short vibration. |
| 224 | long[] mKeyboardTapVibePattern; |
| 225 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 226 | // Vibrator pattern for haptic feedback during boot when safe mode is disabled. |
| 227 | long[] mSafeModeDisabledVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 228 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 229 | // Vibrator pattern for haptic feedback during boot when safe mode is enabled. |
| 230 | long[] mSafeModeEnabledVibePattern; |
Romain Guy | 8154cd3 | 2010-03-29 14:41:15 -0700 | [diff] [blame] | 231 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 232 | /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */ |
| 233 | boolean mEnableShiftMenuBugReports = false; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 234 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 235 | boolean mSafeMode; |
| 236 | WindowState mStatusBar = null; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 237 | int mStatusBarHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 238 | WindowState mNavigationBar = null; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 239 | boolean mHasNavigationBar = false; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 240 | boolean mCanHideNavigationBar = false; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 241 | boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side? |
| 242 | boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*? |
| 243 | int[] mNavigationBarHeightForRotation = new int[4]; |
| 244 | int[] mNavigationBarWidthForRotation = new int[4]; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 245 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 246 | WindowState mKeyguard = null; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 247 | KeyguardServiceDelegate mKeyguardDelegate; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 248 | GlobalActions mGlobalActions; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 249 | volatile boolean mPowerKeyHandled; // accessed from input reader and handler thread |
| 250 | boolean mPendingPowerKeyUpCanceled; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 251 | Handler mHandler; |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 252 | WindowState mLastInputMethodWindow = null; |
| 253 | WindowState mLastInputMethodTargetWindow = null; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 254 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 255 | static final int RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS = 0; |
| 256 | static final int RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW = 1; |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 257 | static final int RECENT_APPS_BEHAVIOR_DISMISS = 2; |
| 258 | static final int RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH = 3; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 259 | |
| 260 | RecentApplicationsDialog mRecentAppsDialog; |
| 261 | int mRecentAppsDialogHeldModifiers; |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 262 | boolean mLanguageSwitchKeyPressed; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 263 | |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 264 | int mLidState = LID_ABSENT; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 265 | boolean mHaveBuiltInKeyboard; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 266 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 267 | boolean mSystemReady; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 268 | boolean mSystemBooted; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 269 | boolean mHdmiPlugged; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 270 | int mUiMode; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 271 | int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 272 | int mLidOpenRotation; |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 273 | int mCarDockRotation; |
| 274 | int mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 275 | int mUndockedHdmiRotation; |
| 276 | int mDemoHdmiRotation; |
| 277 | boolean mDemoHdmiRotationLock; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 278 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 279 | // Default display does not rotate, apps that require non-default orientation will have to |
| 280 | // have the orientation emulated. |
| 281 | private boolean mForceDefaultOrientation = false; |
| 282 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 283 | int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; |
| 284 | int mUserRotation = Surface.ROTATION_0; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 285 | boolean mAccelerometerDefault; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 286 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 287 | boolean mSupportAutoRotation; |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 288 | int mAllowAllRotations = -1; |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 289 | boolean mCarDockEnablesAccelerometer; |
| 290 | boolean mDeskDockEnablesAccelerometer; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 291 | int mLidKeyboardAccessibility; |
| 292 | int mLidNavigationAccessibility; |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 293 | boolean mLidControlsSleep; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 294 | int mLongPressOnPowerBehavior = -1; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 295 | boolean mScreenOnEarly = false; |
| 296 | boolean mScreenOnFully = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 297 | boolean mOrientationSensorEnabled = false; |
| 298 | int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 299 | boolean mHasSoftInput = false; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 300 | boolean mTouchExplorationEnabled = false; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 301 | boolean mTranslucentDecorEnabled = true; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 302 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 303 | int mPointerLocationMode = 0; // guarded by mLock |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 304 | |
| 305 | // The last window we were told about in focusChanged. |
| 306 | WindowState mFocusedWindow; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 307 | IApplicationToken mFocusedApp; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 308 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 309 | private final class PointerLocationPointerEventListener implements PointerEventListener { |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 310 | @Override |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 311 | public void onPointerEvent(MotionEvent motionEvent) { |
| 312 | if (mPointerLocationView != null) { |
| 313 | mPointerLocationView.addPointerEvent(motionEvent); |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 314 | } |
| 315 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 316 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 317 | |
| 318 | // Pointer location view state, only modified on the mHandler Looper. |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 319 | PointerLocationPointerEventListener mPointerLocationPointerEventListener; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 320 | PointerLocationView mPointerLocationView; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 321 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 322 | // The current size of the screen; really; extends into the overscan area of |
| 323 | // the screen and doesn't account for any system elements like the status bar. |
| 324 | int mOverscanScreenLeft, mOverscanScreenTop; |
| 325 | int mOverscanScreenWidth, mOverscanScreenHeight; |
| 326 | // The current visible size of the screen; really; (ir)regardless of whether the status |
| 327 | // bar can be hidden but not extending into the overscan area. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 328 | int mUnrestrictedScreenLeft, mUnrestrictedScreenTop; |
| 329 | int mUnrestrictedScreenWidth, mUnrestrictedScreenHeight; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 330 | // Like mOverscanScreen*, but allowed to move into the overscan region where appropriate. |
| 331 | int mRestrictedOverscanScreenLeft, mRestrictedOverscanScreenTop; |
| 332 | int mRestrictedOverscanScreenWidth, mRestrictedOverscanScreenHeight; |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 333 | // The current size of the screen; these may be different than (0,0)-(dw,dh) |
| 334 | // if the status bar can't be hidden; in that case it effectively carves out |
| 335 | // that area of the display from all other windows. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 336 | int mRestrictedScreenLeft, mRestrictedScreenTop; |
| 337 | int mRestrictedScreenWidth, mRestrictedScreenHeight; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 338 | // During layout, the current screen borders accounting for any currently |
| 339 | // visible system UI elements. |
| 340 | int mSystemLeft, mSystemTop, mSystemRight, mSystemBottom; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 341 | // For applications requesting stable content insets, these are them. |
| 342 | int mStableLeft, mStableTop, mStableRight, mStableBottom; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 343 | // For applications requesting stable content insets but have also set the |
| 344 | // fullscreen window flag, these are the stable dimensions without the status bar. |
| 345 | int mStableFullscreenLeft, mStableFullscreenTop; |
| 346 | int mStableFullscreenRight, mStableFullscreenBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 347 | // During layout, the current screen borders with all outer decoration |
| 348 | // (status bar, input method dock) accounted for. |
| 349 | int mCurLeft, mCurTop, mCurRight, mCurBottom; |
| 350 | // During layout, the frame in which content should be displayed |
| 351 | // to the user, accounting for all screen decoration except for any |
| 352 | // space they deem as available for other content. This is usually |
| 353 | // the same as mCur*, but may be larger if the screen decor has supplied |
| 354 | // content insets. |
| 355 | int mContentLeft, mContentTop, mContentRight, mContentBottom; |
Dianne Hackborn | 8e11ef0 | 2010-11-18 19:47:42 -0800 | [diff] [blame] | 356 | // 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] | 357 | // windows are placed. |
| 358 | int mDockLeft, mDockTop, mDockRight, mDockBottom; |
| 359 | // During layout, the layer at which the doc window is placed. |
| 360 | int mDockLayer; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 361 | // During layout, this is the layer of the status bar. |
| 362 | int mStatusBarLayer; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 363 | int mLastSystemUiFlags; |
| 364 | // Bits that we are in the process of clearing, so we want to prevent |
| 365 | // them from being set by applications until everything has been updated |
| 366 | // to have them clear. |
| 367 | int mResettingSystemUiFlags = 0; |
| 368 | // Bits that we are currently always keeping cleared. |
| 369 | int mForceClearedSystemUiFlags = 0; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 370 | // What we last reported to system UI about whether the compatibility |
| 371 | // menu needs to be displayed. |
| 372 | boolean mLastFocusNeedsMenu = false; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 373 | |
| 374 | FakeWindow mHideNavFakeWindow = null; |
| 375 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 376 | static final Rect mTmpParentFrame = new Rect(); |
| 377 | static final Rect mTmpDisplayFrame = new Rect(); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 378 | static final Rect mTmpOverscanFrame = new Rect(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 379 | static final Rect mTmpContentFrame = new Rect(); |
| 380 | static final Rect mTmpVisibleFrame = new Rect(); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 381 | static final Rect mTmpDecorFrame = new Rect(); |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 382 | static final Rect mTmpNavigationFrame = new Rect(); |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 383 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 384 | WindowState mTopFullscreenOpaqueWindowState; |
Craig Mautner | 0392442 | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 385 | HashSet<IApplicationToken> mAppsToBeHidden = new HashSet<IApplicationToken>(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 386 | boolean mTopIsFullscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 387 | boolean mForceStatusBar; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 388 | boolean mForceStatusBarFromKeyguard; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 389 | boolean mHideLockScreen; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 390 | boolean mForcingShowNavBar; |
| 391 | int mForcingShowNavBarLayer; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 392 | |
| 393 | // States of keyguard dismiss. |
| 394 | private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed. |
| 395 | private static final int DISMISS_KEYGUARD_START = 1; // Keyguard needs to be dismissed. |
| 396 | private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed. |
| 397 | int mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
| 398 | |
| 399 | /** The window that is currently dismissing the keyguard. Dismissing the keyguard must only |
| 400 | * be done once per window. */ |
| 401 | private WindowState mWinDismissingKeyguard; |
| 402 | |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 403 | boolean mShowingLockscreen; |
| 404 | boolean mShowingDream; |
| 405 | boolean mDreamingLockscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 406 | boolean mHomePressed; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 407 | boolean mHomeConsumed; |
| 408 | boolean mHomeDoubleTapPending; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 409 | Intent mHomeIntent; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 410 | Intent mCarDockIntent; |
| 411 | Intent mDeskDockIntent; |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 412 | boolean mSearchKeyShortcutPending; |
| 413 | boolean mConsumeSearchKeyUp; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 414 | boolean mAssistKeyLongPressed; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 415 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 416 | // support for activating the lock screen while the screen is on |
| 417 | boolean mAllowLockscreenWhenOn; |
| 418 | int mLockScreenTimeout; |
| 419 | boolean mLockScreenTimerActive; |
| 420 | |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 421 | // 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] | 422 | int mEndcallBehavior; |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 423 | |
| 424 | // Behavior of POWER button while in-call and screen on. |
| 425 | // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) |
| 426 | int mIncallPowerBehavior; |
| 427 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 428 | Display mDisplay; |
| 429 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 430 | int mLandscapeRotation = 0; // default landscape rotation |
| 431 | int mSeascapeRotation = 0; // "other" landscape rotation, 180 degrees from mLandscapeRotation |
| 432 | int mPortraitRotation = 0; // default portrait rotation |
| 433 | int mUpsideDownRotation = 0; // "other" portrait rotation |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 434 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 435 | int mOverscanLeft = 0; |
| 436 | int mOverscanTop = 0; |
| 437 | int mOverscanRight = 0; |
| 438 | int mOverscanBottom = 0; |
| 439 | |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 440 | // What we do when the user long presses on home |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 441 | private int mLongPressOnHomeBehavior; |
| 442 | |
| 443 | // What we do when the user double-taps on home |
| 444 | private int mDoubleTapOnHomeBehavior; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 445 | |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 446 | // Screenshot trigger states |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 447 | // Time to volume and power must be pressed within this interval of each other. |
| 448 | private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150; |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 449 | // Increase the chord delay when taking a screenshot from the keyguard |
| 450 | private static final float KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER = 2.5f; |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 451 | private boolean mScreenshotChordEnabled; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 452 | private boolean mVolumeDownKeyTriggered; |
| 453 | private long mVolumeDownKeyTime; |
| 454 | private boolean mVolumeDownKeyConsumedByScreenshotChord; |
| 455 | private boolean mVolumeUpKeyTriggered; |
| 456 | private boolean mPowerKeyTriggered; |
| 457 | private long mPowerKeyTime; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 458 | |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 459 | /* The number of steps between min and max brightness */ |
| 460 | private static final int BRIGHTNESS_STEPS = 10; |
| 461 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 462 | SettingsObserver mSettingsObserver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 463 | ShortcutManager mShortcutManager; |
| 464 | PowerManager.WakeLock mBroadcastWakeLock; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 465 | boolean mHavePendingMediaKeyRepeatWithWakeLock; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 466 | |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 467 | private int mCurrentUserId; |
| 468 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 469 | // Maps global key codes to the components that will handle them. |
| 470 | private GlobalKeyManager mGlobalKeyManager; |
| 471 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 472 | // Fallback actions by key code. |
| 473 | private final SparseArray<KeyCharacterMap.FallbackAction> mFallbackActions = |
| 474 | new SparseArray<KeyCharacterMap.FallbackAction>(); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 475 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 476 | private static final int MSG_ENABLE_POINTER_LOCATION = 1; |
| 477 | private static final int MSG_DISABLE_POINTER_LOCATION = 2; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 478 | private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; |
| 479 | 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] | 480 | |
| 481 | private class PolicyHandler extends Handler { |
| 482 | @Override |
| 483 | public void handleMessage(Message msg) { |
| 484 | switch (msg.what) { |
| 485 | case MSG_ENABLE_POINTER_LOCATION: |
| 486 | enablePointerLocation(); |
| 487 | break; |
| 488 | case MSG_DISABLE_POINTER_LOCATION: |
| 489 | disablePointerLocation(); |
| 490 | break; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 491 | case MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK: |
| 492 | dispatchMediaKeyWithWakeLock((KeyEvent)msg.obj); |
| 493 | break; |
| 494 | case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK: |
| 495 | dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj); |
| 496 | break; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 497 | } |
| 498 | } |
| 499 | } |
| 500 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 501 | private UEventObserver mHDMIObserver = new UEventObserver() { |
| 502 | @Override |
| 503 | public void onUEvent(UEventObserver.UEvent event) { |
| 504 | setHdmiPlugged("1".equals(event.get("SWITCH_STATE"))); |
| 505 | } |
| 506 | }; |
| 507 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 508 | class SettingsObserver extends ContentObserver { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 509 | SettingsObserver(Handler handler) { |
| 510 | super(handler); |
| 511 | } |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 512 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 513 | void observe() { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 514 | // Observe all users' changes |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 515 | ContentResolver resolver = mContext.getContentResolver(); |
| 516 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 517 | Settings.System.END_BUTTON_BEHAVIOR), false, this, |
| 518 | UserHandle.USER_ALL); |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 519 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 520 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this, |
| 521 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 522 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 523 | Settings.System.ACCELEROMETER_ROTATION), false, this, |
| 524 | UserHandle.USER_ALL); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 525 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 526 | Settings.System.USER_ROTATION), false, this, |
| 527 | UserHandle.USER_ALL); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 528 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 529 | Settings.System.SCREEN_OFF_TIMEOUT), false, this, |
| 530 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 531 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 532 | Settings.System.POINTER_LOCATION), false, this, |
| 533 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 534 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 535 | Settings.Secure.DEFAULT_INPUT_METHOD), false, this, |
| 536 | UserHandle.USER_ALL); |
Dianne Hackborn | 03759ed | 2009-03-27 16:04:08 -0700 | [diff] [blame] | 537 | resolver.registerContentObserver(Settings.System.getUriFor( |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 538 | Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS), false, this, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 539 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 540 | updateSettings(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 541 | } |
| 542 | |
| 543 | @Override public void onChange(boolean selfChange) { |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 544 | updateSettings(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 545 | updateRotation(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 546 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 547 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 548 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 549 | class MyOrientationListener extends WindowOrientationListener { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 550 | MyOrientationListener(Context context, Handler handler) { |
| 551 | super(context, handler); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 552 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 553 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 554 | @Override |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 555 | public void onProposedRotationChanged(int rotation) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 556 | if (localLOGV) Slog.v(TAG, "onProposedRotationChanged, rotation=" + rotation); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 557 | updateRotation(false); |
| 558 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 559 | } |
| 560 | MyOrientationListener mOrientationListener; |
| 561 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 562 | private final BarController mStatusBarController = new BarController("StatusBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 563 | View.STATUS_BAR_TRANSIENT, |
| 564 | View.STATUS_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 565 | View.STATUS_BAR_TRANSLUCENT, |
| 566 | StatusBarManager.WINDOW_STATUS_BAR, |
| 567 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 568 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 569 | private final BarController mNavigationBarController = new BarController("NavigationBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 570 | View.NAVIGATION_BAR_TRANSIENT, |
| 571 | View.NAVIGATION_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 572 | View.NAVIGATION_BAR_TRANSLUCENT, |
| 573 | StatusBarManager.WINDOW_NAVIGATION_BAR, |
| 574 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 575 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 576 | private ImmersiveModeConfirmation mImmersiveModeConfirmation; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 577 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 578 | private SystemGesturesPointerEventListener mSystemGestures; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 579 | |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 580 | IStatusBarService getStatusBarService() { |
| 581 | synchronized (mServiceAquireLock) { |
| 582 | if (mStatusBarService == null) { |
| 583 | mStatusBarService = IStatusBarService.Stub.asInterface( |
| 584 | ServiceManager.getService("statusbar")); |
| 585 | } |
| 586 | return mStatusBarService; |
| 587 | } |
| 588 | } |
| 589 | |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 590 | /* |
| 591 | * We always let the sensor be switched on by default except when |
| 592 | * the user has explicitly disabled sensor based rotation or when the |
| 593 | * screen is switched off. |
| 594 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 595 | boolean needSensorRunningLp() { |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 596 | if (mSupportAutoRotation) { |
| 597 | if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 598 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 599 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT |
| 600 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { |
| 601 | // If the application has explicitly requested to follow the |
| 602 | // orientation, then we need to turn the sensor on. |
| 603 | return true; |
| 604 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 605 | } |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 606 | if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 607 | (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 608 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 609 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK))) { |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 610 | // enable accelerometer if we are docked in a dock that enables accelerometer |
| 611 | // orientation management, |
| 612 | return true; |
| 613 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 614 | if (mUserRotationMode == USER_ROTATION_LOCKED) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 615 | // If the setting for using the sensor by default is enabled, then |
| 616 | // we will always leave it on. Note that the user could go to |
| 617 | // a window that forces an orientation that does not use the |
| 618 | // sensor and in theory we could turn it off... however, when next |
| 619 | // turning it on we won't have a good value for the current |
| 620 | // orientation for a little bit, which can cause orientation |
| 621 | // changes to lag, so we'd like to keep it always on. (It will |
| 622 | // still be turned off when the screen is off.) |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 623 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 624 | } |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 625 | return mSupportAutoRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 626 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 627 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 628 | /* |
| 629 | * Various use cases for invoking this function |
| 630 | * screen turning off, should always disable listeners if already enabled |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 631 | * screen turned on and current app has sensor based orientation, enable listeners |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 632 | * if not already enabled |
| 633 | * screen turned on and current app does not have sensor orientation, disable listeners if |
| 634 | * already enabled |
| 635 | * screen turning on and current app has sensor based orientation, enable listeners if needed |
| 636 | * screen turning on and current app has nosensor based orientation, do nothing |
| 637 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 638 | void updateOrientationListenerLp() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 639 | if (!mOrientationListener.canDetectOrientation()) { |
| 640 | // If sensor is turned off or nonexistent for some reason |
| 641 | return; |
| 642 | } |
| 643 | //Could have been invoked due to screen turning on or off or |
| 644 | //change of the currently visible window's orientation |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 645 | if (localLOGV) Slog.v(TAG, "Screen status="+mScreenOnEarly+ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 646 | ", current orientation="+mCurrentAppOrientation+ |
| 647 | ", SensorEnabled="+mOrientationSensorEnabled); |
| 648 | boolean disable = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 649 | if (mScreenOnEarly) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 650 | if (needSensorRunningLp()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 651 | disable = false; |
| 652 | //enable listener if not already enabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 653 | if (!mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 654 | mOrientationListener.enable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 655 | if(localLOGV) Slog.v(TAG, "Enabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 656 | mOrientationSensorEnabled = true; |
| 657 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 658 | } |
| 659 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 660 | //check if sensors need to be disabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 661 | if (disable && mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 662 | mOrientationListener.disable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 663 | if(localLOGV) Slog.v(TAG, "Disabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 664 | mOrientationSensorEnabled = false; |
| 665 | } |
| 666 | } |
| 667 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 668 | private void interceptPowerKeyDown(boolean handled) { |
| 669 | mPowerKeyHandled = handled; |
| 670 | if (!handled) { |
| 671 | mHandler.postDelayed(mPowerLongPress, ViewConfiguration.getGlobalActionKeyTimeout()); |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | private boolean interceptPowerKeyUp(boolean canceled) { |
| 676 | if (!mPowerKeyHandled) { |
| 677 | mHandler.removeCallbacks(mPowerLongPress); |
| 678 | return !canceled; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 679 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 680 | return false; |
| 681 | } |
| 682 | |
| 683 | private void cancelPendingPowerKeyAction() { |
| 684 | if (!mPowerKeyHandled) { |
| 685 | mHandler.removeCallbacks(mPowerLongPress); |
| 686 | } |
Jeff Brown | ff20471 | 2011-10-25 21:27:54 -0700 | [diff] [blame] | 687 | if (mPowerKeyTriggered) { |
| 688 | mPendingPowerKeyUpCanceled = true; |
| 689 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | private void interceptScreenshotChord() { |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 693 | if (mScreenshotChordEnabled |
| 694 | && mVolumeDownKeyTriggered && mPowerKeyTriggered && !mVolumeUpKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 695 | final long now = SystemClock.uptimeMillis(); |
| 696 | if (now <= mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS |
| 697 | && now <= mPowerKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) { |
| 698 | mVolumeDownKeyConsumedByScreenshotChord = true; |
| 699 | cancelPendingPowerKeyAction(); |
| 700 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 701 | mHandler.postDelayed(mScreenshotRunnable, getScreenshotChordLongPressDelay()); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 702 | } |
| 703 | } |
| 704 | } |
| 705 | |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 706 | private long getScreenshotChordLongPressDelay() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 707 | if (mKeyguardDelegate.isShowing()) { |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 708 | // Double the time it takes to take a screenshot from the keyguard |
| 709 | return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER * |
| 710 | ViewConfiguration.getGlobalActionKeyTimeout()); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 711 | } |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 712 | return ViewConfiguration.getGlobalActionKeyTimeout(); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 713 | } |
| 714 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 715 | private void cancelPendingScreenshotChordAction() { |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 716 | mHandler.removeCallbacks(mScreenshotRunnable); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | private final Runnable mPowerLongPress = new Runnable() { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 720 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 721 | public void run() { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 722 | // The context isn't read |
| 723 | if (mLongPressOnPowerBehavior < 0) { |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 724 | mLongPressOnPowerBehavior = mContext.getResources().getInteger( |
| 725 | com.android.internal.R.integer.config_longPressOnPowerBehavior); |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 726 | } |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 727 | int resolvedBehavior = mLongPressOnPowerBehavior; |
| 728 | if (FactoryTest.isLongPressOnPowerOffEnabled()) { |
| 729 | resolvedBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM; |
| 730 | } |
| 731 | |
| 732 | switch (resolvedBehavior) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 733 | case LONG_PRESS_POWER_NOTHING: |
| 734 | break; |
| 735 | case LONG_PRESS_POWER_GLOBAL_ACTIONS: |
| 736 | mPowerKeyHandled = true; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 737 | if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) { |
| 738 | performAuditoryFeedbackForAccessibilityIfNeed(); |
| 739 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 740 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
| 741 | showGlobalActionsDialog(); |
| 742 | break; |
| 743 | case LONG_PRESS_POWER_SHUT_OFF: |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 744 | case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM: |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 745 | mPowerKeyHandled = true; |
| 746 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 747 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 748 | mWindowManagerFuncs.shutdown(resolvedBehavior == LONG_PRESS_POWER_SHUT_OFF); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 749 | break; |
| 750 | } |
| 751 | } |
| 752 | }; |
| 753 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 754 | private final Runnable mScreenshotRunnable = new Runnable() { |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 755 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 756 | public void run() { |
| 757 | takeScreenshot(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 758 | } |
| 759 | }; |
| 760 | |
| 761 | void showGlobalActionsDialog() { |
| 762 | if (mGlobalActions == null) { |
Jeff Brown | 7304c34 | 2012-05-11 18:42:42 -0700 | [diff] [blame] | 763 | mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 764 | } |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 765 | final boolean keyguardShowing = keyguardIsShowingTq(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 766 | mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); |
| 767 | if (keyguardShowing) { |
| 768 | // since it took two seconds of long press to bring this up, |
| 769 | // 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] | 770 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 771 | } |
| 772 | } |
| 773 | |
| 774 | boolean isDeviceProvisioned() { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 775 | return Settings.Global.getInt( |
| 776 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 777 | } |
| 778 | |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 779 | private void handleLongPressOnHome() { |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 780 | if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 781 | mHomeConsumed = true; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 782 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 783 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 784 | if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) { |
| 785 | toggleRecentApps(); |
| 786 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_ASSIST) { |
| 787 | launchAssistAction(); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 788 | } |
| 789 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 790 | } |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 791 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 792 | private void handleDoubleTapOnHome() { |
| 793 | if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 794 | mHomeConsumed = true; |
| 795 | toggleRecentApps(); |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable() { |
| 800 | @Override |
| 801 | public void run() { |
| 802 | if (mHomeDoubleTapPending) { |
| 803 | mHomeDoubleTapPending = false; |
| 804 | launchHomeFromHotKey(); |
| 805 | } |
| 806 | } |
| 807 | }; |
| 808 | |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 809 | /** |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 810 | * Create (if necessary) and show or dismiss the recent apps dialog according |
| 811 | * according to the requested behavior. |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 812 | */ |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 813 | void showOrHideRecentAppsDialog(final int behavior) { |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 814 | mHandler.post(new Runnable() { |
| 815 | @Override |
| 816 | public void run() { |
| 817 | if (mRecentAppsDialog == null) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 818 | mRecentAppsDialog = new RecentApplicationsDialog(mContext); |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 819 | } |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 820 | if (mRecentAppsDialog.isShowing()) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 821 | switch (behavior) { |
| 822 | case RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS: |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 823 | case RECENT_APPS_BEHAVIOR_DISMISS: |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 824 | mRecentAppsDialog.dismiss(); |
| 825 | break; |
| 826 | case RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH: |
| 827 | mRecentAppsDialog.dismissAndSwitch(); |
| 828 | break; |
| 829 | case RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW: |
| 830 | default: |
| 831 | break; |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 832 | } |
| 833 | } else { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 834 | switch (behavior) { |
| 835 | case RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS: |
| 836 | mRecentAppsDialog.show(); |
| 837 | break; |
| 838 | case RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW: |
| 839 | try { |
| 840 | mWindowManager.setInTouchMode(false); |
| 841 | } catch (RemoteException e) { |
| 842 | } |
| 843 | mRecentAppsDialog.show(); |
| 844 | break; |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 845 | case RECENT_APPS_BEHAVIOR_DISMISS: |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 846 | case RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH: |
| 847 | default: |
| 848 | break; |
| 849 | } |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 850 | } |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 851 | } |
| 852 | }); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 853 | } |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 854 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 855 | /** {@inheritDoc} */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 856 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 857 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 858 | WindowManagerFuncs windowManagerFuncs) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 859 | mContext = context; |
| 860 | mWindowManager = windowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 861 | mWindowManagerFuncs = windowManagerFuncs; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 862 | mHandler = new PolicyHandler(); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 863 | mOrientationListener = new MyOrientationListener(mContext, mHandler); |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 864 | try { |
| 865 | mOrientationListener.setCurrentRotation(windowManager.getRotation()); |
| 866 | } catch (RemoteException ex) { } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 867 | mSettingsObserver = new SettingsObserver(mHandler); |
| 868 | mSettingsObserver.observe(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 869 | mShortcutManager = new ShortcutManager(context, mHandler); |
| 870 | mShortcutManager.observe(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 871 | mUiMode = context.getResources().getInteger( |
| 872 | com.android.internal.R.integer.config_defaultUiModeType); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 873 | mHomeIntent = new Intent(Intent.ACTION_MAIN, null); |
| 874 | mHomeIntent.addCategory(Intent.CATEGORY_HOME); |
| 875 | mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 876 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 877 | mCarDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 878 | mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK); |
| 879 | mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 880 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 881 | mDeskDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 882 | mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK); |
| 883 | mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 884 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 885 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 886 | mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 887 | mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 888 | "PhoneWindowManager.mBroadcastWakeLock"); |
| 889 | mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 890 | mSupportAutoRotation = mContext.getResources().getBoolean( |
| 891 | com.android.internal.R.bool.config_supportAutoRotation); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 892 | mLidOpenRotation = readRotation( |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 893 | com.android.internal.R.integer.config_lidOpenRotation); |
| 894 | mCarDockRotation = readRotation( |
| 895 | com.android.internal.R.integer.config_carDockRotation); |
| 896 | mDeskDockRotation = readRotation( |
| 897 | com.android.internal.R.integer.config_deskDockRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 898 | mUndockedHdmiRotation = readRotation( |
| 899 | com.android.internal.R.integer.config_undockedHdmiRotation); |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 900 | mCarDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 901 | com.android.internal.R.bool.config_carDockEnablesAccelerometer); |
| 902 | mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 903 | com.android.internal.R.bool.config_deskDockEnablesAccelerometer); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 904 | mLidKeyboardAccessibility = mContext.getResources().getInteger( |
| 905 | com.android.internal.R.integer.config_lidKeyboardAccessibility); |
| 906 | mLidNavigationAccessibility = mContext.getResources().getInteger( |
| 907 | com.android.internal.R.integer.config_lidNavigationAccessibility); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 908 | mLidControlsSleep = mContext.getResources().getBoolean( |
| 909 | com.android.internal.R.bool.config_lidControlsSleep); |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 910 | mTranslucentDecorEnabled = mContext.getResources().getBoolean( |
| 911 | com.android.internal.R.bool.config_enableTranslucentDecor); |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 912 | readConfigurationDependentBehaviors(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 913 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 914 | // register for dock events |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 915 | IntentFilter filter = new IntentFilter(); |
| 916 | filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); |
| 917 | filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE); |
| 918 | filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); |
| 919 | filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 920 | filter.addAction(Intent.ACTION_DOCK_EVENT); |
| 921 | Intent intent = context.registerReceiver(mDockReceiver, filter); |
| 922 | if (intent != null) { |
| 923 | // Retrieve current sticky dock event broadcast. |
| 924 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 925 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 926 | } |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 927 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 928 | // register for dream-related broadcasts |
| 929 | filter = new IntentFilter(); |
| 930 | filter.addAction(Intent.ACTION_DREAMING_STARTED); |
| 931 | filter.addAction(Intent.ACTION_DREAMING_STOPPED); |
| 932 | context.registerReceiver(mDreamReceiver, filter); |
| 933 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 934 | // register for multiuser-relevant broadcasts |
| 935 | filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); |
| 936 | context.registerReceiver(mMultiuserReceiver, filter); |
| 937 | |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 938 | // monitor for system gestures |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 939 | mSystemGestures = new SystemGesturesPointerEventListener(context, |
| 940 | new SystemGesturesPointerEventListener.Callbacks() { |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 941 | @Override |
| 942 | public void onSwipeFromTop() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 943 | if (mStatusBar != null) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 944 | requestTransientBars(mStatusBar); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 945 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 946 | } |
| 947 | @Override |
| 948 | public void onSwipeFromBottom() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 949 | if (mNavigationBar != null && mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 950 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 951 | } |
| 952 | } |
| 953 | @Override |
| 954 | public void onSwipeFromRight() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 955 | if (mNavigationBar != null && !mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 956 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 957 | } |
| 958 | } |
| 959 | @Override |
| 960 | public void onDebug() { |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 961 | // no-op |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 962 | } |
| 963 | }); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 964 | mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 965 | mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 966 | |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 967 | mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 968 | mLongPressVibePattern = getLongIntArray(mContext.getResources(), |
| 969 | com.android.internal.R.array.config_longPressVibePattern); |
| 970 | mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(), |
| 971 | com.android.internal.R.array.config_virtualKeyVibePattern); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 972 | mKeyboardTapVibePattern = getLongIntArray(mContext.getResources(), |
| 973 | com.android.internal.R.array.config_keyboardTapVibePattern); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 974 | mSafeModeDisabledVibePattern = getLongIntArray(mContext.getResources(), |
| 975 | com.android.internal.R.array.config_safeModeDisabledVibePattern); |
| 976 | mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), |
| 977 | com.android.internal.R.array.config_safeModeEnabledVibePattern); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 978 | |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 979 | mScreenshotChordEnabled = mContext.getResources().getBoolean( |
| 980 | com.android.internal.R.bool.config_enableScreenshotChord); |
| 981 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 982 | mGlobalKeyManager = new GlobalKeyManager(mContext); |
| 983 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 984 | // Controls rotation and the like. |
| 985 | initializeHdmiState(); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 986 | |
| 987 | // Match current screen state. |
| 988 | if (mPowerManager.isScreenOn()) { |
| 989 | screenTurningOn(null); |
| 990 | } else { |
| 991 | screenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER); |
| 992 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 993 | } |
| 994 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 995 | /** |
| 996 | * Read values from config.xml that may be overridden depending on |
| 997 | * the configuration of the device. |
| 998 | * eg. Disable long press on home goes to recents on sw600dp. |
| 999 | */ |
| 1000 | private void readConfigurationDependentBehaviors() { |
| 1001 | mLongPressOnHomeBehavior = mContext.getResources().getInteger( |
| 1002 | com.android.internal.R.integer.config_longPressOnHomeBehavior); |
| 1003 | if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING || |
| 1004 | mLongPressOnHomeBehavior > LONG_PRESS_HOME_ASSIST) { |
| 1005 | mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1006 | } |
| 1007 | |
| 1008 | mDoubleTapOnHomeBehavior = mContext.getResources().getInteger( |
| 1009 | com.android.internal.R.integer.config_doubleTapOnHomeBehavior); |
| 1010 | if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING || |
| 1011 | mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 1012 | mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1013 | } |
| 1014 | } |
| 1015 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1016 | @Override |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1017 | public void setInitialDisplaySize(Display display, int width, int height, int density) { |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 1018 | // This method might be called before the policy has been fully initialized |
| 1019 | // or for other displays we don't care about. |
| 1020 | if (mContext == null || display.getDisplayId() != Display.DEFAULT_DISPLAY) { |
| 1021 | return; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1022 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1023 | mDisplay = display; |
| 1024 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1025 | final Resources res = mContext.getResources(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1026 | int shortSize, longSize; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1027 | if (width > height) { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1028 | shortSize = height; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1029 | longSize = width; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1030 | mLandscapeRotation = Surface.ROTATION_0; |
| 1031 | mSeascapeRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1032 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1033 | mPortraitRotation = Surface.ROTATION_90; |
| 1034 | mUpsideDownRotation = Surface.ROTATION_270; |
| 1035 | } else { |
| 1036 | mPortraitRotation = Surface.ROTATION_270; |
| 1037 | mUpsideDownRotation = Surface.ROTATION_90; |
| 1038 | } |
| 1039 | } else { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1040 | shortSize = width; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1041 | longSize = height; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1042 | mPortraitRotation = Surface.ROTATION_0; |
| 1043 | mUpsideDownRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1044 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1045 | mLandscapeRotation = Surface.ROTATION_270; |
| 1046 | mSeascapeRotation = Surface.ROTATION_90; |
| 1047 | } else { |
| 1048 | mLandscapeRotation = Surface.ROTATION_90; |
| 1049 | mSeascapeRotation = Surface.ROTATION_270; |
| 1050 | } |
| 1051 | } |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1052 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1053 | mStatusBarHeight = |
| 1054 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1055 | |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1056 | // Height of the navigation bar when presented horizontally at bottom |
| 1057 | mNavigationBarHeightForRotation[mPortraitRotation] = |
| 1058 | mNavigationBarHeightForRotation[mUpsideDownRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1059 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1060 | mNavigationBarHeightForRotation[mLandscapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1061 | mNavigationBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize( |
| 1062 | com.android.internal.R.dimen.navigation_bar_height_landscape); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1063 | |
| 1064 | // Width of the navigation bar when presented vertically along one side |
| 1065 | mNavigationBarWidthForRotation[mPortraitRotation] = |
| 1066 | mNavigationBarWidthForRotation[mUpsideDownRotation] = |
| 1067 | mNavigationBarWidthForRotation[mLandscapeRotation] = |
| 1068 | mNavigationBarWidthForRotation[mSeascapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1069 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1070 | |
| 1071 | // SystemUI (status bar) layout policy |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1072 | int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1073 | int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1074 | |
Craig Mautner | d4ec3324 | 2013-07-22 10:37:43 -0700 | [diff] [blame] | 1075 | // Allow the navigation bar to move on small devices (phones). |
| 1076 | mNavigationBarCanMove = shortSizeDp < 600; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1077 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1078 | mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1079 | // Allow a system property to override this. Used by the emulator. |
| 1080 | // See also hasNavigationBar(). |
| 1081 | String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); |
| 1082 | if ("1".equals(navBarOverride)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1083 | mHasNavigationBar = false; |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1084 | } else if ("0".equals(navBarOverride)) { |
| 1085 | mHasNavigationBar = true; |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1086 | } |
| 1087 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 1088 | // For demo purposes, allow the rotation of the HDMI display to be controlled. |
| 1089 | // By default, HDMI locks rotation to landscape. |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1090 | if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1091 | mDemoHdmiRotation = mPortraitRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1092 | } else { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1093 | mDemoHdmiRotation = mLandscapeRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1094 | } |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1095 | mDemoHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1096 | |
| 1097 | // Only force the default orientation if the screen is xlarge, at least 960dp x 720dp, per |
| 1098 | // http://developer.android.com/guide/practices/screens_support.html#range |
| 1099 | mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 && |
| 1100 | res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) && |
| 1101 | // For debug purposes the next line turns this feature off with: |
| 1102 | // $ adb shell setprop config.override_forced_orient true |
| 1103 | // $ adb shell wm size reset |
| 1104 | !"true".equals(SystemProperties.get("config.override_forced_orient")); |
| 1105 | } |
| 1106 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1107 | /** |
| 1108 | * @return whether the navigation bar can be hidden, e.g. the device has a |
| 1109 | * navigation bar and touch exploration is not enabled |
| 1110 | */ |
| 1111 | private boolean canHideNavigationBar() { |
| 1112 | return mHasNavigationBar && !mTouchExplorationEnabled; |
| 1113 | } |
| 1114 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1115 | @Override |
| 1116 | public boolean isDefaultOrientationForced() { |
| 1117 | return mForceDefaultOrientation; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1118 | } |
| 1119 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1120 | @Override |
| 1121 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom) { |
| 1122 | if (display.getDisplayId() == Display.DEFAULT_DISPLAY) { |
| 1123 | mOverscanLeft = left; |
| 1124 | mOverscanTop = top; |
| 1125 | mOverscanRight = right; |
| 1126 | mOverscanBottom = bottom; |
| 1127 | } |
| 1128 | } |
| 1129 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1130 | public void updateSettings() { |
| 1131 | ContentResolver resolver = mContext.getContentResolver(); |
| 1132 | boolean updateRotation = false; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1133 | synchronized (mLock) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1134 | mEndcallBehavior = Settings.System.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1135 | Settings.System.END_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1136 | Settings.System.END_BUTTON_BEHAVIOR_DEFAULT, |
| 1137 | UserHandle.USER_CURRENT); |
| 1138 | mIncallPowerBehavior = Settings.Secure.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1139 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1140 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT, |
| 1141 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1142 | |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1143 | // Configure rotation lock. |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1144 | int userRotation = Settings.System.getIntForUser(resolver, |
| 1145 | Settings.System.USER_ROTATION, Surface.ROTATION_0, |
| 1146 | UserHandle.USER_CURRENT); |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1147 | if (mUserRotation != userRotation) { |
| 1148 | mUserRotation = userRotation; |
| 1149 | updateRotation = true; |
| 1150 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1151 | int userRotationMode = Settings.System.getIntForUser(resolver, |
| 1152 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1153 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 1154 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
| 1155 | if (mUserRotationMode != userRotationMode) { |
| 1156 | mUserRotationMode = userRotationMode; |
| 1157 | updateRotation = true; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1158 | updateOrientationListenerLp(); |
| 1159 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1160 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1161 | if (mSystemReady) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1162 | int pointerLocation = Settings.System.getIntForUser(resolver, |
| 1163 | Settings.System.POINTER_LOCATION, 0, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1164 | if (mPointerLocationMode != pointerLocation) { |
| 1165 | mPointerLocationMode = pointerLocation; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1166 | mHandler.sendEmptyMessage(pointerLocation != 0 ? |
| 1167 | MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1168 | } |
| 1169 | } |
| 1170 | // use screen off timeout setting as the timeout for the lockscreen |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1171 | mLockScreenTimeout = Settings.System.getIntForUser(resolver, |
| 1172 | Settings.System.SCREEN_OFF_TIMEOUT, 0, UserHandle.USER_CURRENT); |
| 1173 | String imId = Settings.Secure.getStringForUser(resolver, |
| 1174 | Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1175 | boolean hasSoftInput = imId != null && imId.length() > 0; |
| 1176 | if (mHasSoftInput != hasSoftInput) { |
| 1177 | mHasSoftInput = hasSoftInput; |
| 1178 | updateRotation = true; |
| 1179 | } |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1180 | if (mImmersiveModeConfirmation != null) { |
| 1181 | mImmersiveModeConfirmation.loadSetting(); |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1182 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1183 | } |
| 1184 | if (updateRotation) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1185 | updateRotation(true); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1186 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1187 | } |
| 1188 | |
| 1189 | private void enablePointerLocation() { |
| 1190 | if (mPointerLocationView == null) { |
| 1191 | mPointerLocationView = new PointerLocationView(mContext); |
| 1192 | mPointerLocationView.setPrintCoords(false); |
| 1193 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1194 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 1195 | WindowManager.LayoutParams.MATCH_PARENT, |
| 1196 | WindowManager.LayoutParams.MATCH_PARENT); |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1197 | lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1198 | lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
| 1199 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
| 1200 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1201 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
Jeff Brown | 90fc905 | 2012-10-01 14:44:24 -0700 | [diff] [blame] | 1202 | if (ActivityManager.isHighEndGfx()) { |
| 1203 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1204 | lp.privateFlags |= |
| 1205 | WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; |
| 1206 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1207 | lp.format = PixelFormat.TRANSLUCENT; |
| 1208 | lp.setTitle("PointerLocation"); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1209 | WindowManager wm = (WindowManager) |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1210 | mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1211 | lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1212 | wm.addView(mPointerLocationView, lp); |
| 1213 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1214 | mPointerLocationPointerEventListener = new PointerLocationPointerEventListener(); |
| 1215 | mWindowManagerFuncs.registerPointerEventListener(mPointerLocationPointerEventListener); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1216 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1217 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1218 | |
| 1219 | private void disablePointerLocation() { |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1220 | if (mPointerLocationPointerEventListener != null) { |
| 1221 | mWindowManagerFuncs.unregisterPointerEventListener( |
| 1222 | mPointerLocationPointerEventListener); |
| 1223 | mPointerLocationPointerEventListener = null; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1224 | } |
| 1225 | |
| 1226 | if (mPointerLocationView != null) { |
| 1227 | WindowManager wm = (WindowManager) |
| 1228 | mContext.getSystemService(Context.WINDOW_SERVICE); |
| 1229 | wm.removeView(mPointerLocationView); |
| 1230 | mPointerLocationView = null; |
| 1231 | } |
| 1232 | } |
| 1233 | |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1234 | private int readRotation(int resID) { |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1235 | try { |
| 1236 | int rotation = mContext.getResources().getInteger(resID); |
| 1237 | switch (rotation) { |
| 1238 | case 0: |
| 1239 | return Surface.ROTATION_0; |
| 1240 | case 90: |
| 1241 | return Surface.ROTATION_90; |
| 1242 | case 180: |
| 1243 | return Surface.ROTATION_180; |
| 1244 | case 270: |
| 1245 | return Surface.ROTATION_270; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1246 | } |
| 1247 | } catch (Resources.NotFoundException e) { |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1248 | // fall through |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1249 | } |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1250 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1251 | } |
| 1252 | |
| 1253 | /** {@inheritDoc} */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1254 | @Override |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1255 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1256 | int type = attrs.type; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1257 | |
| 1258 | outAppOp[0] = AppOpsManager.OP_NONE; |
| 1259 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1260 | if (type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW |
| 1261 | || type > WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1262 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1263 | } |
| 1264 | String permission = null; |
| 1265 | switch (type) { |
| 1266 | case TYPE_TOAST: |
| 1267 | // XXX right now the app process has complete control over |
| 1268 | // this... should introduce a token to let the system |
| 1269 | // monitor/control what they are doing. |
| 1270 | break; |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 1271 | case TYPE_DREAM: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1272 | case TYPE_INPUT_METHOD: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1273 | case TYPE_WALLPAPER: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1274 | case TYPE_PRIVATE_PRESENTATION: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1275 | // The window manager will check these. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1276 | break; |
| 1277 | case TYPE_PHONE: |
| 1278 | case TYPE_PRIORITY_PHONE: |
| 1279 | case TYPE_SYSTEM_ALERT: |
| 1280 | case TYPE_SYSTEM_ERROR: |
| 1281 | case TYPE_SYSTEM_OVERLAY: |
| 1282 | permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1283 | outAppOp[0] = AppOpsManager.OP_SYSTEM_ALERT_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1284 | break; |
| 1285 | default: |
| 1286 | permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; |
| 1287 | } |
| 1288 | if (permission != null) { |
| 1289 | if (mContext.checkCallingOrSelfPermission(permission) |
| 1290 | != PackageManager.PERMISSION_GRANTED) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1291 | return WindowManagerGlobal.ADD_PERMISSION_DENIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1292 | } |
| 1293 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1294 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1295 | } |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1296 | |
| 1297 | @Override |
| 1298 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs) { |
| 1299 | |
| 1300 | // If this switch statement is modified, modify the comment in the declarations of |
| 1301 | // the type in {@link WindowManager.LayoutParams} as well. |
| 1302 | switch (attrs.type) { |
| 1303 | default: |
| 1304 | // These are the windows that by default are shown only to the user that created |
| 1305 | // them. If this needs to be overridden, set |
| 1306 | // {@link WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS} in |
| 1307 | // {@link WindowManager.LayoutParams}. Note that permission |
| 1308 | // {@link android.Manifest.permission.INTERNAL_SYSTEM_WINDOW} is required as well. |
| 1309 | if ((attrs.privateFlags & PRIVATE_FLAG_SHOW_FOR_ALL_USERS) == 0) { |
| 1310 | return true; |
| 1311 | } |
| 1312 | break; |
| 1313 | |
| 1314 | // These are the windows that by default are shown to all users. However, to |
| 1315 | // protect against spoofing, check permissions below. |
| 1316 | case TYPE_APPLICATION_STARTING: |
| 1317 | case TYPE_BOOT_PROGRESS: |
| 1318 | case TYPE_DISPLAY_OVERLAY: |
| 1319 | case TYPE_HIDDEN_NAV_CONSUMER: |
| 1320 | case TYPE_KEYGUARD: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1321 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1322 | case TYPE_KEYGUARD_DIALOG: |
| 1323 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1324 | case TYPE_NAVIGATION_BAR: |
| 1325 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1326 | case TYPE_PHONE: |
| 1327 | case TYPE_POINTER: |
| 1328 | case TYPE_PRIORITY_PHONE: |
| 1329 | case TYPE_RECENTS_OVERLAY: |
| 1330 | case TYPE_SEARCH_BAR: |
| 1331 | case TYPE_STATUS_BAR: |
| 1332 | case TYPE_STATUS_BAR_PANEL: |
| 1333 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1334 | case TYPE_SYSTEM_DIALOG: |
| 1335 | case TYPE_UNIVERSE_BACKGROUND: |
| 1336 | case TYPE_VOLUME_OVERLAY: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1337 | case TYPE_PRIVATE_PRESENTATION: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1338 | break; |
| 1339 | } |
| 1340 | |
| 1341 | // Check if third party app has set window to system window type. |
| 1342 | return mContext.checkCallingOrSelfPermission( |
| 1343 | android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) |
| 1344 | != PackageManager.PERMISSION_GRANTED; |
| 1345 | } |
| 1346 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1347 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1348 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) { |
| 1349 | switch (attrs.type) { |
| 1350 | case TYPE_SYSTEM_OVERLAY: |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1351 | case TYPE_SECURE_SYSTEM_OVERLAY: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1352 | // These types of windows can't receive input events. |
| 1353 | attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1354 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1355 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1356 | break; |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | void readLidState() { |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 1361 | mLidState = mWindowManagerFuncs.getLidState(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1362 | } |
| 1363 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1364 | private boolean isHidden(int accessibilityMode) { |
| 1365 | switch (accessibilityMode) { |
| 1366 | case 1: |
| 1367 | return mLidState == LID_CLOSED; |
| 1368 | case 2: |
| 1369 | return mLidState == LID_OPEN; |
| 1370 | default: |
| 1371 | return false; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1372 | } |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1373 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1374 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1375 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1376 | @Override |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1377 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 1378 | int navigationPresence) { |
| 1379 | mHaveBuiltInKeyboard = (keyboardPresence & PRESENCE_INTERNAL) != 0; |
| 1380 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1381 | readConfigurationDependentBehaviors(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1382 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1383 | applyLidSwitchState(); |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1384 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1385 | if (config.keyboard == Configuration.KEYBOARD_NOKEYS |
| 1386 | || (keyboardPresence == PRESENCE_INTERNAL |
| 1387 | && isHidden(mLidKeyboardAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1388 | config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1389 | if (!mHasSoftInput) { |
| 1390 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; |
| 1391 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1392 | } |
| 1393 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1394 | if (config.navigation == Configuration.NAVIGATION_NONAV |
| 1395 | || (navigationPresence == PRESENCE_INTERNAL |
| 1396 | && isHidden(mLidNavigationAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1397 | config.navigationHidden = Configuration.NAVIGATIONHIDDEN_YES; |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1398 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1399 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1400 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1401 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1402 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1403 | public int windowTypeToLayerLw(int type) { |
| 1404 | if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1405 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1406 | } |
| 1407 | switch (type) { |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1408 | case TYPE_UNIVERSE_BACKGROUND: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1409 | return 1; |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1410 | case TYPE_PRIVATE_PRESENTATION: |
| 1411 | return 2; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1412 | case TYPE_WALLPAPER: |
| 1413 | // wallpaper is at the bottom, though the window manager may move it. |
| 1414 | return 2; |
| 1415 | case TYPE_PHONE: |
| 1416 | return 3; |
| 1417 | case TYPE_SEARCH_BAR: |
| 1418 | return 4; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1419 | case TYPE_RECENTS_OVERLAY: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1420 | case TYPE_SYSTEM_DIALOG: |
| 1421 | return 5; |
| 1422 | case TYPE_TOAST: |
| 1423 | // toasts and the plugged-in battery thing |
| 1424 | return 6; |
| 1425 | case TYPE_PRIORITY_PHONE: |
| 1426 | // SIM errors and unlock. Not sure if this really should be in a high layer. |
| 1427 | return 7; |
| 1428 | case TYPE_DREAM: |
| 1429 | // used for Dreams (screensavers with TYPE_DREAM windows) |
| 1430 | return 8; |
| 1431 | case TYPE_SYSTEM_ALERT: |
| 1432 | // like the ANR / app crashed dialogs |
| 1433 | return 9; |
| 1434 | case TYPE_INPUT_METHOD: |
| 1435 | // on-screen keyboards and other such input method user interfaces go here. |
| 1436 | return 10; |
| 1437 | case TYPE_INPUT_METHOD_DIALOG: |
| 1438 | // on-screen keyboards and other such input method user interfaces go here. |
| 1439 | return 11; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1440 | case TYPE_KEYGUARD_SCRIM: |
| 1441 | // the safety window that shows behind keyguard while keyguard is starting |
| 1442 | return 12; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1443 | case TYPE_KEYGUARD: |
| 1444 | // the keyguard; nothing on top of these can take focus, since they are |
| 1445 | // responsible for power management when displayed. |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1446 | return 13; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1447 | case TYPE_KEYGUARD_DIALOG: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1448 | return 14; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1449 | case TYPE_STATUS_BAR_SUB_PANEL: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1450 | return 15; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1451 | case TYPE_STATUS_BAR: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1452 | return 16; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1453 | case TYPE_STATUS_BAR_PANEL: |
| 1454 | return 17; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1455 | case TYPE_VOLUME_OVERLAY: |
| 1456 | // the on-screen volume indicator and controller shown when the user |
| 1457 | // changes the device volume |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1458 | return 18; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1459 | case TYPE_SYSTEM_OVERLAY: |
| 1460 | // the on-screen volume indicator and controller shown when the user |
| 1461 | // changes the device volume |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1462 | return 19; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1463 | case TYPE_NAVIGATION_BAR: |
| 1464 | // the navigation bar, if available, shows atop most things |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1465 | return 20; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1466 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1467 | // 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] | 1468 | return 21; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1469 | case TYPE_SYSTEM_ERROR: |
| 1470 | // system-level error dialogs |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1471 | return 22; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1472 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1473 | // used to highlight the magnified portion of a display |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1474 | return 23; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1475 | case TYPE_DISPLAY_OVERLAY: |
| 1476 | // used to simulate secondary display devices |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1477 | return 24; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1478 | case TYPE_DRAG: |
| 1479 | // the drag layer: input for drag-and-drop is associated with this window, |
| 1480 | // which sits above all other focusable windows |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1481 | return 25; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1482 | case TYPE_SECURE_SYSTEM_OVERLAY: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1483 | return 26; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1484 | case TYPE_BOOT_PROGRESS: |
| 1485 | return 27; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1486 | case TYPE_POINTER: |
| 1487 | // the (mouse) pointer layer |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1488 | return 28; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1489 | case TYPE_HIDDEN_NAV_CONSUMER: |
| 1490 | return 29; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1491 | } |
| 1492 | Log.e(TAG, "Unknown window type: " + type); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1493 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1494 | } |
| 1495 | |
| 1496 | /** {@inheritDoc} */ |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1497 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1498 | public int subWindowTypeToLayerLw(int type) { |
| 1499 | switch (type) { |
| 1500 | case TYPE_APPLICATION_PANEL: |
| 1501 | case TYPE_APPLICATION_ATTACHED_DIALOG: |
| 1502 | return APPLICATION_PANEL_SUBLAYER; |
| 1503 | case TYPE_APPLICATION_MEDIA: |
| 1504 | return APPLICATION_MEDIA_SUBLAYER; |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 1505 | case TYPE_APPLICATION_MEDIA_OVERLAY: |
| 1506 | return APPLICATION_MEDIA_OVERLAY_SUBLAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1507 | case TYPE_APPLICATION_SUB_PANEL: |
| 1508 | return APPLICATION_SUB_PANEL_SUBLAYER; |
| 1509 | } |
| 1510 | Log.e(TAG, "Unknown sub-window type: " + type); |
| 1511 | return 0; |
| 1512 | } |
| 1513 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1514 | @Override |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1515 | public int getMaxWallpaperLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1516 | return windowTypeToLayerLw(TYPE_STATUS_BAR); |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1517 | } |
| 1518 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1519 | @Override |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1520 | public int getAboveUniverseLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1521 | return windowTypeToLayerLw(TYPE_SYSTEM_ERROR); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1522 | } |
| 1523 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1524 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1525 | if (mHasNavigationBar) { |
| 1526 | // For a basic navigation bar, when we are in landscape mode we place |
| 1527 | // the navigation bar to the side. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1528 | if (mNavigationBarCanMove && fullWidth > fullHeight) { |
| 1529 | return fullWidth - mNavigationBarWidthForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1530 | } |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1531 | } |
| 1532 | return fullWidth; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1533 | } |
| 1534 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1535 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1536 | if (mHasNavigationBar) { |
| 1537 | // For a basic navigation bar, when we are in portrait mode we place |
| 1538 | // the navigation bar to the bottom. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1539 | if (!mNavigationBarCanMove || fullWidth < fullHeight) { |
| 1540 | return fullHeight - mNavigationBarHeightForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1541 | } |
| 1542 | } |
| 1543 | return fullHeight; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1544 | } |
| 1545 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1546 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
| 1547 | return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1548 | } |
| 1549 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1550 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1551 | // There is a separate status bar at the top of the display. We don't count that as part |
| 1552 | // 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] | 1553 | // we do want to exclude it since applications can't generally use that part |
| 1554 | // of the screen. |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1555 | return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation) - mStatusBarHeight; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1556 | } |
| 1557 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1558 | @Override |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1559 | public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs) { |
| 1560 | return attrs.type == WindowManager.LayoutParams.TYPE_KEYGUARD; |
| 1561 | } |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1562 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1563 | @Override |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1564 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs) { |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1565 | switch (attrs.type) { |
| 1566 | case TYPE_STATUS_BAR: |
| 1567 | case TYPE_NAVIGATION_BAR: |
| 1568 | case TYPE_WALLPAPER: |
| 1569 | case TYPE_DREAM: |
| 1570 | case TYPE_UNIVERSE_BACKGROUND: |
| 1571 | case TYPE_KEYGUARD: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1572 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1573 | return false; |
| 1574 | default: |
| 1575 | return true; |
| 1576 | } |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1577 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1578 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1579 | /** {@inheritDoc} */ |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1580 | @Override |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1581 | public View addStartingWindow(IBinder appToken, String packageName, int theme, |
| 1582 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1583 | int icon, int logo, int windowFlags) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1584 | if (!SHOW_STARTING_ANIMATIONS) { |
| 1585 | return null; |
| 1586 | } |
| 1587 | if (packageName == null) { |
| 1588 | return null; |
| 1589 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1590 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1591 | WindowManager wm = null; |
| 1592 | View view = null; |
| 1593 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1594 | try { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1595 | Context context = mContext; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1596 | if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow " + packageName |
| 1597 | + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" |
| 1598 | + Integer.toHexString(theme)); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1599 | if (theme != context.getThemeResId() || labelRes != 0) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1600 | try { |
| 1601 | context = context.createPackageContext(packageName, 0); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1602 | context.setTheme(theme); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1603 | } catch (PackageManager.NameNotFoundException e) { |
| 1604 | // Ignore |
| 1605 | } |
| 1606 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1607 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1608 | Window win = PolicyManager.makeNewWindow(context); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1609 | final TypedArray ta = win.getWindowStyle(); |
| 1610 | if (ta.getBoolean( |
| 1611 | com.android.internal.R.styleable.Window_windowDisablePreview, false) |
| 1612 | || ta.getBoolean( |
| 1613 | com.android.internal.R.styleable.Window_windowShowWallpaper,false)) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1614 | return null; |
| 1615 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1616 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1617 | Resources r = context.getResources(); |
| 1618 | win.setTitle(r.getText(labelRes, nonLocalizedLabel)); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1619 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1620 | win.setType( |
| 1621 | WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); |
| 1622 | // Force the window flags: this is a fake window, so it is not really |
| 1623 | // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM |
| 1624 | // flag because we do know that the next window will take input |
| 1625 | // focus, so we want to get the IME window up on top of us right away. |
| 1626 | win.setFlags( |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1627 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1628 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1629 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1630 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1631 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1632 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1633 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1634 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1635 | |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1636 | win.setDefaultIcon(icon); |
| 1637 | win.setDefaultLogo(logo); |
| 1638 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1639 | win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1640 | WindowManager.LayoutParams.MATCH_PARENT); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1641 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1642 | final WindowManager.LayoutParams params = win.getAttributes(); |
| 1643 | params.token = appToken; |
| 1644 | params.packageName = packageName; |
| 1645 | params.windowAnimations = win.getWindowStyle().getResourceId( |
| 1646 | com.android.internal.R.styleable.Window_windowAnimationStyle, 0); |
Dianne Hackborn | 5d927c2 | 2011-09-02 12:22:18 -0700 | [diff] [blame] | 1647 | params.privateFlags |= |
| 1648 | WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1649 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1650 | |
| 1651 | if (!compatInfo.supportsScreen()) { |
| 1652 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; |
| 1653 | } |
| 1654 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1655 | params.setTitle("Starting " + packageName); |
| 1656 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1657 | wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
| 1658 | view = win.getDecorView(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1659 | |
| 1660 | if (win.isFloating()) { |
| 1661 | // Whoops, there is no way to display an animation/preview |
| 1662 | // of such a thing! After all that work... let's skip it. |
| 1663 | // (Note that we must do this here because it is in |
| 1664 | // getDecorView() where the theme is evaluated... maybe |
| 1665 | // we should peek the floating attribute from the theme |
| 1666 | // earlier.) |
| 1667 | return null; |
| 1668 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1669 | |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1670 | if (DEBUG_STARTING_WINDOW) Slog.d( |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1671 | TAG, "Adding starting window for " + packageName |
| 1672 | + " / " + appToken + ": " |
| 1673 | + (view.getParent() != null ? view : null)); |
| 1674 | |
| 1675 | wm.addView(view, params); |
| 1676 | |
| 1677 | // Only return the view if it was successfully added to the |
| 1678 | // window manager... which we can tell by it having a parent. |
| 1679 | return view.getParent() != null ? view : null; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1680 | } catch (WindowManager.BadTokenException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1681 | // ignore |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 1682 | Log.w(TAG, appToken + " already running, starting window not displayed. " + |
| 1683 | e.getMessage()); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1684 | } catch (RuntimeException e) { |
| 1685 | // don't crash if something else bad happens, for example a |
| 1686 | // failure loading resources because we are loading from an app |
| 1687 | // on external storage that has been unmounted. |
| 1688 | Log.w(TAG, appToken + " failed creating starting window", e); |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1689 | } finally { |
| 1690 | if (view != null && view.getParent() == null) { |
| 1691 | Log.w(TAG, "view not successfully added to wm, removing view"); |
| 1692 | wm.removeViewImmediate(view); |
| 1693 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1694 | } |
| 1695 | |
| 1696 | return null; |
| 1697 | } |
| 1698 | |
| 1699 | /** {@inheritDoc} */ |
| 1700 | public void removeStartingWindow(IBinder appToken, View window) { |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1701 | if (DEBUG_STARTING_WINDOW) { |
| 1702 | RuntimeException e = new RuntimeException("here"); |
| 1703 | e.fillInStackTrace(); |
| 1704 | Log.v(TAG, "Removing starting window for " + appToken + ": " + window, e); |
| 1705 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1706 | |
| 1707 | if (window != null) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1708 | WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1709 | wm.removeView(window); |
| 1710 | } |
| 1711 | } |
| 1712 | |
| 1713 | /** |
| 1714 | * Preflight adding a window to the system. |
| 1715 | * |
| 1716 | * Currently enforces that three window types are singletons: |
| 1717 | * <ul> |
| 1718 | * <li>STATUS_BAR_TYPE</li> |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1719 | * <li>KEYGUARD_TYPE</li> |
| 1720 | * </ul> |
| 1721 | * |
| 1722 | * @param win The window to be added |
| 1723 | * @param attrs Information about the window to be added |
| 1724 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1725 | * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, |
| 1726 | * WindowManagerImpl.ADD_MULTIPLE_SINGLETON |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1727 | */ |
| 1728 | public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) { |
| 1729 | switch (attrs.type) { |
| 1730 | case TYPE_STATUS_BAR: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1731 | mContext.enforceCallingOrSelfPermission( |
| 1732 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1733 | "PhoneWindowManager"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1734 | if (mStatusBar != null) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1735 | if (mStatusBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1736 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1737 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1738 | } |
| 1739 | mStatusBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1740 | mStatusBarController.setWindow(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1741 | break; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1742 | case TYPE_NAVIGATION_BAR: |
| 1743 | mContext.enforceCallingOrSelfPermission( |
| 1744 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1745 | "PhoneWindowManager"); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1746 | if (mNavigationBar != null) { |
| 1747 | if (mNavigationBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1748 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1749 | } |
| 1750 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1751 | mNavigationBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1752 | mNavigationBarController.setWindow(win); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 1753 | if (DEBUG_LAYOUT) Slog.i(TAG, "NAVIGATION BAR: " + mNavigationBar); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1754 | break; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1755 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1756 | mContext.enforceCallingOrSelfPermission( |
| 1757 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1758 | "PhoneWindowManager"); |
| 1759 | break; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1760 | case TYPE_STATUS_BAR_PANEL: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1761 | mContext.enforceCallingOrSelfPermission( |
| 1762 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1763 | "PhoneWindowManager"); |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1764 | break; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1765 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1766 | mContext.enforceCallingOrSelfPermission( |
| 1767 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1768 | "PhoneWindowManager"); |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1769 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1770 | case TYPE_KEYGUARD: |
| 1771 | if (mKeyguard != null) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1772 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1773 | } |
| 1774 | mKeyguard = win; |
| 1775 | break; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1776 | case TYPE_KEYGUARD_SCRIM: |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1777 | if (mKeyguardScrim != null) { |
| 1778 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
| 1779 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1780 | mKeyguardScrim = win; |
| 1781 | break; |
| 1782 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1783 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1784 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1785 | } |
| 1786 | |
| 1787 | /** {@inheritDoc} */ |
| 1788 | public void removeWindowLw(WindowState win) { |
| 1789 | if (mStatusBar == win) { |
| 1790 | mStatusBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1791 | mStatusBarController.setWindow(null); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1792 | } else if (mKeyguard == win) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1793 | Log.v(TAG, "Removing keyguard window (Did it crash?)"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1794 | mKeyguard = null; |
Jim Miller | c0b676d | 2013-03-22 16:11:08 -0700 | [diff] [blame] | 1795 | mKeyguardDelegate.showScrim(); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1796 | } else if (mKeyguardScrim == win) { |
| 1797 | Log.v(TAG, "Removing keyguard scrim"); |
| 1798 | mKeyguardScrim = null; |
| 1799 | } if (mNavigationBar == win) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1800 | mNavigationBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1801 | mNavigationBarController.setWindow(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1802 | } |
| 1803 | } |
| 1804 | |
| 1805 | static final boolean PRINT_ANIM = false; |
| 1806 | |
| 1807 | /** {@inheritDoc} */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1808 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1809 | public int selectAnimationLw(WindowState win, int transit) { |
| 1810 | if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win |
| 1811 | + ": transit=" + transit); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1812 | if (win == mStatusBar) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1813 | if (transit == TRANSIT_EXIT |
| 1814 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1815 | return R.anim.dock_top_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1816 | } else if (transit == TRANSIT_ENTER |
| 1817 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1818 | return R.anim.dock_top_enter; |
| 1819 | } |
| 1820 | } else if (win == mNavigationBar) { |
| 1821 | // This can be on either the bottom or the right. |
| 1822 | if (mNavigationBarOnBottom) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1823 | if (transit == TRANSIT_EXIT |
| 1824 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1825 | return R.anim.dock_bottom_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1826 | } else if (transit == TRANSIT_ENTER |
| 1827 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1828 | return R.anim.dock_bottom_enter; |
| 1829 | } |
| 1830 | } else { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1831 | if (transit == TRANSIT_EXIT |
| 1832 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1833 | return R.anim.dock_right_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1834 | } else if (transit == TRANSIT_ENTER |
| 1835 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1836 | return R.anim.dock_right_enter; |
| 1837 | } |
| 1838 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1839 | } |
| 1840 | |
| 1841 | if (transit == TRANSIT_PREVIEW_DONE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1842 | if (win.hasAppShownWindows()) { |
| 1843 | if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT"); |
| 1844 | return com.android.internal.R.anim.app_starting_exit; |
| 1845 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 1846 | } else if (win.getAttrs().type == TYPE_DREAM && mDreamingLockscreen |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1847 | && transit == TRANSIT_ENTER) { |
| 1848 | // Special case: we are animating in a dream, while the keyguard |
| 1849 | // is shown. We don't want an animation on the dream, because |
| 1850 | // we need it shown immediately with the keyguard animating away |
| 1851 | // to reveal it. |
| 1852 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1853 | } |
| 1854 | |
| 1855 | return 0; |
| 1856 | } |
| 1857 | |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1858 | @Override |
| 1859 | public void selectRotationAnimationLw(int anim[]) { |
| 1860 | if (PRINT_ANIM) Slog.i(TAG, "selectRotationAnimation mTopFullscreen=" |
| 1861 | + mTopFullscreenOpaqueWindowState + " rotationAnimation=" |
| 1862 | + (mTopFullscreenOpaqueWindowState == null ? |
| 1863 | "0" : mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation)); |
| 1864 | if (mTopFullscreenOpaqueWindowState != null && mTopIsFullscreen) { |
| 1865 | switch (mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation) { |
| 1866 | case ROTATION_ANIMATION_CROSSFADE: |
| 1867 | anim[0] = R.anim.rotation_animation_xfade_exit; |
| 1868 | anim[1] = R.anim.rotation_animation_enter; |
| 1869 | break; |
| 1870 | case ROTATION_ANIMATION_JUMPCUT: |
| 1871 | anim[0] = R.anim.rotation_animation_jump_exit; |
| 1872 | anim[1] = R.anim.rotation_animation_enter; |
| 1873 | break; |
| 1874 | case ROTATION_ANIMATION_ROTATE: |
| 1875 | default: |
| 1876 | anim[0] = anim[1] = 0; |
| 1877 | break; |
| 1878 | } |
| 1879 | } else { |
| 1880 | anim[0] = anim[1] = 0; |
| 1881 | } |
| 1882 | } |
| 1883 | |
| 1884 | @Override |
| 1885 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 1886 | boolean forceDefault) { |
| 1887 | switch (exitAnimId) { |
| 1888 | case R.anim.rotation_animation_xfade_exit: |
| 1889 | case R.anim.rotation_animation_jump_exit: |
| 1890 | // These are the only cases that matter. |
| 1891 | if (forceDefault) { |
| 1892 | return false; |
| 1893 | } |
| 1894 | int anim[] = new int[2]; |
| 1895 | selectRotationAnimationLw(anim); |
| 1896 | return (exitAnimId == anim[0] && enterAnimId == anim[1]); |
| 1897 | default: |
| 1898 | return true; |
| 1899 | } |
| 1900 | } |
| 1901 | |
| 1902 | @Override |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 1903 | public Animation createForceHideEnterAnimation(boolean onWallpaper) { |
| 1904 | return AnimationUtils.loadAnimation(mContext, onWallpaper |
| 1905 | ? com.android.internal.R.anim.lock_screen_wallpaper_behind_enter |
| 1906 | : com.android.internal.R.anim.lock_screen_behind_enter); |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1907 | } |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 1908 | |
| 1909 | private static void awakenDreams() { |
| 1910 | IDreamManager dreamManager = getDreamManager(); |
| 1911 | if (dreamManager != null) { |
| 1912 | try { |
| 1913 | dreamManager.awaken(); |
| 1914 | } catch (RemoteException e) { |
| 1915 | // fine, stay asleep then |
| 1916 | } |
| 1917 | } |
| 1918 | } |
| 1919 | |
| 1920 | static IDreamManager getDreamManager() { |
| 1921 | return IDreamManager.Stub.asInterface( |
| 1922 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
| 1923 | } |
| 1924 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1925 | static ITelephony getTelephonyService() { |
Mike Lockwood | f5f4ec9 | 2011-11-08 14:05:31 -0800 | [diff] [blame] | 1926 | return ITelephony.Stub.asInterface( |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1927 | ServiceManager.checkService(Context.TELEPHONY_SERVICE)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1928 | } |
| 1929 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1930 | static IAudioService getAudioService() { |
| 1931 | IAudioService audioService = IAudioService.Stub.asInterface( |
| 1932 | ServiceManager.checkService(Context.AUDIO_SERVICE)); |
| 1933 | if (audioService == null) { |
| 1934 | Log.w(TAG, "Unable to find IAudioService interface."); |
| 1935 | } |
| 1936 | return audioService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1937 | } |
| 1938 | |
| 1939 | boolean keyguardOn() { |
| 1940 | return keyguardIsShowingTq() || inKeyguardRestrictedKeyInputMode(); |
| 1941 | } |
| 1942 | |
| 1943 | private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { |
| 1944 | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, |
| 1945 | WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, |
| 1946 | }; |
| 1947 | |
| 1948 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1949 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1950 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1951 | final boolean keyguardOn = keyguardOn(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1952 | final int keyCode = event.getKeyCode(); |
| 1953 | final int repeatCount = event.getRepeatCount(); |
| 1954 | final int metaState = event.getMetaState(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1955 | final int flags = event.getFlags(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1956 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 1957 | final boolean canceled = event.isCanceled(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1958 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 1959 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1960 | Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount=" |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 1961 | + repeatCount + " keyguardOn=" + keyguardOn + " mHomePressed=" + mHomePressed |
| 1962 | + " canceled=" + canceled); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1963 | } |
| 1964 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1965 | // If we think we might have a volume down & power key chord on the way |
| 1966 | // but we're not sure, then tell the dispatcher to wait a little while and |
| 1967 | // try again later before dispatching. |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1968 | if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1969 | if (mVolumeDownKeyTriggered && !mPowerKeyTriggered) { |
| 1970 | final long now = SystemClock.uptimeMillis(); |
| 1971 | final long timeoutTime = mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS; |
| 1972 | if (now < timeoutTime) { |
| 1973 | return timeoutTime - now; |
| 1974 | } |
| 1975 | } |
| 1976 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN |
| 1977 | && mVolumeDownKeyConsumedByScreenshotChord) { |
| 1978 | if (!down) { |
| 1979 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 1980 | } |
| 1981 | return -1; |
| 1982 | } |
| 1983 | } |
| 1984 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1985 | // First we always handle the home key here, so applications |
| 1986 | // can never break it, although if keyguard is on, we do let |
| 1987 | // it handle it, because that gives us the correct 5 second |
| 1988 | // timeout. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1989 | if (keyCode == KeyEvent.KEYCODE_HOME) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1990 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1991 | // If we have released the home key, and didn't do anything else |
| 1992 | // while it was pressed, then it is time to go home! |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1993 | if (!down) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1994 | cancelPreloadRecentApps(); |
| 1995 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1996 | mHomePressed = false; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1997 | if (mHomeConsumed) { |
| 1998 | mHomeConsumed = false; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1999 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2000 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2001 | |
| 2002 | if (canceled) { |
| 2003 | Log.i(TAG, "Ignoring HOME; event canceled."); |
| 2004 | return -1; |
| 2005 | } |
| 2006 | |
| 2007 | // If an incoming call is ringing, HOME is totally disabled. |
| 2008 | // (The user is already on the InCallScreen at this point, |
| 2009 | // and his ONLY options are to answer or reject the call.) |
| 2010 | try { |
| 2011 | ITelephony telephonyService = getTelephonyService(); |
| 2012 | if (telephonyService != null && telephonyService.isRinging()) { |
| 2013 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); |
| 2014 | return -1; |
| 2015 | } |
| 2016 | } catch (RemoteException ex) { |
| 2017 | Log.w(TAG, "RemoteException from getPhoneInterface()", ex); |
| 2018 | } |
| 2019 | |
| 2020 | // Delay handling home if a double-tap is possible. |
| 2021 | if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) { |
| 2022 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case |
| 2023 | mHomeDoubleTapPending = true; |
| 2024 | mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable, |
| 2025 | ViewConfiguration.getDoubleTapTimeout()); |
| 2026 | return -1; |
| 2027 | } |
| 2028 | |
| 2029 | // Go home! |
| 2030 | launchHomeFromHotKey(); |
| 2031 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2032 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2033 | |
| 2034 | // If a system window has focus, then it doesn't make sense |
| 2035 | // right now to interact with applications. |
| 2036 | WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null; |
| 2037 | if (attrs != null) { |
| 2038 | final int type = attrs.type; |
| 2039 | if (type == WindowManager.LayoutParams.TYPE_KEYGUARD |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2040 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2041 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG) { |
| 2042 | // the "app" is keyguard, so give it the key |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2043 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2044 | } |
| 2045 | final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length; |
| 2046 | for (int i=0; i<typeCount; i++) { |
| 2047 | if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) { |
| 2048 | // 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] | 2049 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2050 | } |
| 2051 | } |
| 2052 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2053 | |
| 2054 | // Remember that home is pressed and handle special actions. |
| 2055 | if (repeatCount == 0) { |
| 2056 | mHomePressed = true; |
| 2057 | if (mHomeDoubleTapPending) { |
| 2058 | mHomeDoubleTapPending = false; |
| 2059 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); |
| 2060 | handleDoubleTapOnHome(); |
| 2061 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI |
| 2062 | || mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 2063 | preloadRecentApps(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2064 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2065 | } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { |
| 2066 | if (!keyguardOn) { |
| 2067 | handleLongPressOnHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2068 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2069 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2070 | return -1; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2071 | } else if (keyCode == KeyEvent.KEYCODE_MENU) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2072 | // Hijack modified menu keys for debugging features |
| 2073 | final int chordBug = KeyEvent.META_SHIFT_ON; |
| 2074 | |
| 2075 | if (down && repeatCount == 0) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2076 | if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2077 | Intent intent = new Intent(Intent.ACTION_BUG_REPORT); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2078 | mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, |
| 2079 | null, null, null, 0, null, null); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2080 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2081 | } else if (SHOW_PROCESSES_ON_ALT_MENU && |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2082 | (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2083 | Intent service = new Intent(); |
| 2084 | service.setClassName(mContext, "com.android.server.LoadAverageService"); |
| 2085 | ContentResolver res = mContext.getContentResolver(); |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2086 | boolean shown = Settings.Global.getInt( |
| 2087 | res, Settings.Global.SHOW_PROCESSES, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2088 | if (!shown) { |
| 2089 | mContext.startService(service); |
| 2090 | } else { |
| 2091 | mContext.stopService(service); |
| 2092 | } |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2093 | Settings.Global.putInt( |
| 2094 | res, Settings.Global.SHOW_PROCESSES, shown ? 0 : 1); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2095 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2096 | } |
| 2097 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2098 | } else if (keyCode == KeyEvent.KEYCODE_SEARCH) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2099 | if (down) { |
| 2100 | if (repeatCount == 0) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2101 | mSearchKeyShortcutPending = true; |
| 2102 | mConsumeSearchKeyUp = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2103 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2104 | } else { |
| 2105 | mSearchKeyShortcutPending = false; |
| 2106 | if (mConsumeSearchKeyUp) { |
| 2107 | mConsumeSearchKeyUp = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2108 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2109 | } |
| 2110 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2111 | return 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2112 | } else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) { |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2113 | if (!keyguardOn) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2114 | if (down && repeatCount == 0) { |
| 2115 | preloadRecentApps(); |
| 2116 | } else if (!down) { |
| 2117 | toggleRecentApps(); |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2118 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2119 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2120 | return -1; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2121 | } else if (keyCode == KeyEvent.KEYCODE_ASSIST) { |
| 2122 | if (down) { |
| 2123 | if (repeatCount == 0) { |
| 2124 | mAssistKeyLongPressed = false; |
| 2125 | } else if (repeatCount == 1) { |
| 2126 | mAssistKeyLongPressed = true; |
| 2127 | if (!keyguardOn) { |
| 2128 | launchAssistLongPressAction(); |
| 2129 | } |
| 2130 | } |
| 2131 | } else { |
| 2132 | if (mAssistKeyLongPressed) { |
| 2133 | mAssistKeyLongPressed = false; |
| 2134 | } else { |
| 2135 | if (!keyguardOn) { |
| 2136 | launchAssistAction(); |
| 2137 | } |
| 2138 | } |
| 2139 | } |
| 2140 | return -1; |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 2141 | } else if (keyCode == KeyEvent.KEYCODE_SYSRQ) { |
| 2142 | if (down && repeatCount == 0) { |
| 2143 | mHandler.post(mScreenshotRunnable); |
| 2144 | } |
| 2145 | return -1; |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 2146 | } else if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP |
| 2147 | || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) { |
| 2148 | if (down) { |
| 2149 | int direction = keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP ? 1 : -1; |
| 2150 | |
| 2151 | // Disable autobrightness if it's on |
| 2152 | int auto = Settings.System.getIntForUser( |
| 2153 | mContext.getContentResolver(), |
| 2154 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2155 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2156 | UserHandle.USER_CURRENT_OR_SELF); |
| 2157 | if (auto != 0) { |
| 2158 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2159 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2160 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2161 | UserHandle.USER_CURRENT_OR_SELF); |
| 2162 | } |
| 2163 | |
| 2164 | int min = mPowerManager.getMinimumScreenBrightnessSetting(); |
| 2165 | int max = mPowerManager.getMaximumScreenBrightnessSetting(); |
| 2166 | int step = (max - min + BRIGHTNESS_STEPS - 1) / BRIGHTNESS_STEPS * direction; |
| 2167 | int brightness = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 2168 | Settings.System.SCREEN_BRIGHTNESS, |
| 2169 | mPowerManager.getDefaultScreenBrightnessSetting(), |
| 2170 | UserHandle.USER_CURRENT_OR_SELF); |
| 2171 | brightness += step; |
| 2172 | // Make sure we don't go beyond the limits. |
| 2173 | brightness = Math.min(max, brightness); |
| 2174 | brightness = Math.max(min, brightness); |
| 2175 | |
| 2176 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2177 | Settings.System.SCREEN_BRIGHTNESS, brightness, |
| 2178 | UserHandle.USER_CURRENT_OR_SELF); |
| 2179 | Intent intent = new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG); |
| 2180 | mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF); |
| 2181 | } |
| 2182 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2183 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2184 | |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2185 | // Shortcuts are invoked through Search+key, so intercept those here |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2186 | // Any printing key that is chorded with Search should be consumed |
| 2187 | // even if no shortcut was invoked. This prevents text from being |
| 2188 | // inadvertently inserted when using a keyboard that has built-in macro |
| 2189 | // 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] | 2190 | if (mSearchKeyShortcutPending) { |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2191 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
| 2192 | if (kcm.isPrintingKey(keyCode)) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2193 | mConsumeSearchKeyUp = true; |
| 2194 | mSearchKeyShortcutPending = false; |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2195 | if (down && repeatCount == 0 && !keyguardOn) { |
| 2196 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState); |
| 2197 | if (shortcutIntent != null) { |
| 2198 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2199 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2200 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2201 | } catch (ActivityNotFoundException ex) { |
| 2202 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2203 | + "the activity to which it is registered was not found: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2204 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode), ex); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2205 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2206 | } else { |
| 2207 | Slog.i(TAG, "Dropping unregistered shortcut key combination: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2208 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2209 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2210 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2211 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2212 | } |
| 2213 | } |
| 2214 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2215 | // Invoke shortcuts using Meta. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2216 | if (down && repeatCount == 0 && !keyguardOn |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2217 | && (metaState & KeyEvent.META_META_ON) != 0) { |
| 2218 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2219 | if (kcm.isPrintingKey(keyCode)) { |
| 2220 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, |
| 2221 | metaState & ~(KeyEvent.META_META_ON |
| 2222 | | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON)); |
| 2223 | if (shortcutIntent != null) { |
| 2224 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2225 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2226 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2227 | } catch (ActivityNotFoundException ex) { |
| 2228 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2229 | + "the activity to which it is registered was not found: " |
| 2230 | + "META+" + KeyEvent.keyCodeToString(keyCode), ex); |
| 2231 | } |
| 2232 | return -1; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2233 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2234 | } |
| 2235 | } |
| 2236 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2237 | // Handle application launch keys. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2238 | if (down && repeatCount == 0 && !keyguardOn) { |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2239 | String category = sApplicationLaunchKeyCategories.get(keyCode); |
| 2240 | if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 2241 | Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2242 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2243 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2244 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2245 | } catch (ActivityNotFoundException ex) { |
| 2246 | Slog.w(TAG, "Dropping application launch key because " |
| 2247 | + "the activity to which it is registered was not found: " |
| 2248 | + "keyCode=" + keyCode + ", category=" + category, ex); |
| 2249 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2250 | return -1; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2251 | } |
| 2252 | } |
| 2253 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2254 | // Display task switcher for ALT-TAB or Meta-TAB. |
| 2255 | if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) { |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2256 | if (mRecentAppsDialogHeldModifiers == 0 && !keyguardOn) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2257 | final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK; |
| 2258 | if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON) |
| 2259 | || KeyEvent.metaStateHasModifiers( |
| 2260 | shiftlessModifiers, KeyEvent.META_META_ON)) { |
| 2261 | mRecentAppsDialogHeldModifiers = shiftlessModifiers; |
| 2262 | showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW); |
| 2263 | return -1; |
| 2264 | } |
| 2265 | } |
| 2266 | } else if (!down && mRecentAppsDialogHeldModifiers != 0 |
| 2267 | && (metaState & mRecentAppsDialogHeldModifiers) == 0) { |
| 2268 | mRecentAppsDialogHeldModifiers = 0; |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2269 | showOrHideRecentAppsDialog(keyguardOn ? RECENT_APPS_BEHAVIOR_DISMISS : |
| 2270 | RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2271 | } |
| 2272 | |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 2273 | // Handle keyboard language switching. |
| 2274 | if (down && repeatCount == 0 |
| 2275 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2276 | || (keyCode == KeyEvent.KEYCODE_SPACE |
| 2277 | && (metaState & KeyEvent.META_CTRL_MASK) != 0))) { |
| 2278 | int direction = (metaState & KeyEvent.META_SHIFT_MASK) != 0 ? -1 : 1; |
| 2279 | mWindowManagerFuncs.switchKeyboardLayout(event.getDeviceId(), direction); |
| 2280 | return -1; |
| 2281 | } |
| 2282 | if (mLanguageSwitchKeyPressed && !down |
| 2283 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2284 | || keyCode == KeyEvent.KEYCODE_SPACE)) { |
| 2285 | mLanguageSwitchKeyPressed = false; |
| 2286 | return -1; |
| 2287 | } |
| 2288 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 2289 | if (mGlobalKeyManager.handleGlobalKey(mContext, keyCode, event)) { |
| 2290 | return -1; |
| 2291 | } |
| 2292 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2293 | // Let the application handle the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2294 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2295 | } |
| 2296 | |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2297 | /** {@inheritDoc} */ |
| 2298 | @Override |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2299 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2300 | // Note: This method is only called if the initial down was unhandled. |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2301 | if (DEBUG_INPUT) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2302 | Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction() |
| 2303 | + ", flags=" + event.getFlags() |
| 2304 | + ", keyCode=" + event.getKeyCode() |
| 2305 | + ", scanCode=" + event.getScanCode() |
| 2306 | + ", metaState=" + event.getMetaState() |
| 2307 | + ", repeatCount=" + event.getRepeatCount() |
| 2308 | + ", policyFlags=" + policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2309 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2310 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2311 | KeyEvent fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2312 | if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 2313 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2314 | final int keyCode = event.getKeyCode(); |
| 2315 | final int metaState = event.getMetaState(); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2316 | final boolean initialDown = event.getAction() == KeyEvent.ACTION_DOWN |
| 2317 | && event.getRepeatCount() == 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2318 | |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2319 | // Check for fallback actions specified by the key character map. |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2320 | final FallbackAction fallbackAction; |
| 2321 | if (initialDown) { |
| 2322 | fallbackAction = kcm.getFallbackAction(keyCode, metaState); |
| 2323 | } else { |
| 2324 | fallbackAction = mFallbackActions.get(keyCode); |
| 2325 | } |
| 2326 | |
| 2327 | if (fallbackAction != null) { |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2328 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2329 | Slog.d(TAG, "Fallback: keyCode=" + fallbackAction.keyCode |
| 2330 | + " metaState=" + Integer.toHexString(fallbackAction.metaState)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2331 | } |
| 2332 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2333 | final int flags = event.getFlags() | KeyEvent.FLAG_FALLBACK; |
| 2334 | fallbackEvent = KeyEvent.obtain( |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2335 | event.getDownTime(), event.getEventTime(), |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2336 | event.getAction(), fallbackAction.keyCode, |
| 2337 | event.getRepeatCount(), fallbackAction.metaState, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2338 | event.getDeviceId(), event.getScanCode(), |
| 2339 | flags, event.getSource(), null); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2340 | |
| 2341 | if (!interceptFallback(win, fallbackEvent, policyFlags)) { |
| 2342 | fallbackEvent.recycle(); |
| 2343 | fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2344 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2345 | |
| 2346 | if (initialDown) { |
| 2347 | mFallbackActions.put(keyCode, fallbackAction); |
| 2348 | } else if (event.getAction() == KeyEvent.ACTION_UP) { |
| 2349 | mFallbackActions.remove(keyCode); |
| 2350 | fallbackAction.recycle(); |
| 2351 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2352 | } |
| 2353 | } |
| 2354 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2355 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2356 | if (fallbackEvent == null) { |
| 2357 | Slog.d(TAG, "No fallback."); |
| 2358 | } else { |
| 2359 | Slog.d(TAG, "Performing fallback: " + fallbackEvent); |
| 2360 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2361 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2362 | return fallbackEvent; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2363 | } |
| 2364 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2365 | private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 2366 | int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2367 | if ((actions & ACTION_PASS_TO_USER) != 0) { |
| 2368 | long delayMillis = interceptKeyBeforeDispatching( |
| 2369 | win, fallbackEvent, policyFlags); |
| 2370 | if (delayMillis == 0) { |
| 2371 | return true; |
| 2372 | } |
| 2373 | } |
| 2374 | return false; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 2375 | } |
| 2376 | |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2377 | private void launchAssistLongPressAction() { |
| 2378 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 2379 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
| 2380 | |
| 2381 | // launch the search activity |
| 2382 | Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); |
| 2383 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2384 | try { |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2385 | // TODO: This only stops the factory-installed search manager. |
| 2386 | // Need to formalize an API to handle others |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2387 | SearchManager searchManager = getSearchManager(); |
| 2388 | if (searchManager != null) { |
| 2389 | searchManager.stopSearch(); |
| 2390 | } |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2391 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2392 | } catch (ActivityNotFoundException e) { |
| 2393 | Slog.w(TAG, "No activity to handle assist long press action.", e); |
| 2394 | } |
| 2395 | } |
| 2396 | |
| 2397 | private void launchAssistAction() { |
| 2398 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 2399 | Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 2400 | .getAssistIntent(mContext, true, UserHandle.USER_CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2401 | if (intent != null) { |
| 2402 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 2403 | | Intent.FLAG_ACTIVITY_SINGLE_TOP |
| 2404 | | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 2405 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2406 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2407 | } catch (ActivityNotFoundException e) { |
| 2408 | Slog.w(TAG, "No activity to handle assist action.", e); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2409 | } |
| 2410 | } |
| 2411 | } |
| 2412 | |
| 2413 | private SearchManager getSearchManager() { |
| 2414 | if (mSearchManager == null) { |
| 2415 | mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); |
| 2416 | } |
| 2417 | return mSearchManager; |
| 2418 | } |
| 2419 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2420 | private void preloadRecentApps() { |
| 2421 | mPreloadedRecentApps = true; |
| 2422 | try { |
| 2423 | IStatusBarService statusbar = getStatusBarService(); |
| 2424 | if (statusbar != null) { |
| 2425 | statusbar.preloadRecentApps(); |
| 2426 | } |
| 2427 | } catch (RemoteException e) { |
| 2428 | Slog.e(TAG, "RemoteException when preloading recent apps", e); |
| 2429 | // re-acquire status bar service next time it is needed. |
| 2430 | mStatusBarService = null; |
| 2431 | } |
| 2432 | } |
| 2433 | |
| 2434 | private void cancelPreloadRecentApps() { |
| 2435 | if (mPreloadedRecentApps) { |
| 2436 | mPreloadedRecentApps = false; |
| 2437 | try { |
| 2438 | IStatusBarService statusbar = getStatusBarService(); |
| 2439 | if (statusbar != null) { |
| 2440 | statusbar.cancelPreloadRecentApps(); |
| 2441 | } |
| 2442 | } catch (RemoteException e) { |
| 2443 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
| 2444 | // re-acquire status bar service next time it is needed. |
| 2445 | mStatusBarService = null; |
| 2446 | } |
| 2447 | } |
| 2448 | } |
| 2449 | |
| 2450 | private void toggleRecentApps() { |
| 2451 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2452 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS); |
| 2453 | try { |
| 2454 | IStatusBarService statusbar = getStatusBarService(); |
| 2455 | if (statusbar != null) { |
| 2456 | statusbar.toggleRecentApps(); |
| 2457 | } |
| 2458 | } catch (RemoteException e) { |
| 2459 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
| 2460 | // re-acquire status bar service next time it is needed. |
| 2461 | mStatusBarService = null; |
| 2462 | } |
| 2463 | } |
| 2464 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2465 | /** |
| 2466 | * A home key -> launch home action was detected. Take the appropriate action |
| 2467 | * given the situation with the keyguard. |
| 2468 | */ |
| 2469 | void launchHomeFromHotKey() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2470 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowingAndNotHidden()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2471 | // don't launch home if keyguard showing |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2472 | } else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2473 | // when in keyguard restricted mode, must first verify unlock |
| 2474 | // before launching home |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2475 | mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2476 | public void onKeyguardExitResult(boolean success) { |
| 2477 | if (success) { |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2478 | try { |
| 2479 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2480 | } catch (RemoteException e) { |
| 2481 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2482 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2483 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2484 | } |
| 2485 | } |
| 2486 | }); |
| 2487 | } else { |
| 2488 | // no keyguard stuff to worry about, just launch home! |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2489 | try { |
| 2490 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2491 | } catch (RemoteException e) { |
| 2492 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2493 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2494 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2495 | } |
| 2496 | } |
| 2497 | |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2498 | private final Runnable mClearHideNavigationFlag = new Runnable() { |
| 2499 | @Override |
| 2500 | public void run() { |
| 2501 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
| 2502 | // Clear flags. |
| 2503 | mForceClearedSystemUiFlags &= |
| 2504 | ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 2505 | } |
| 2506 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2507 | } |
| 2508 | }; |
| 2509 | |
| 2510 | /** |
| 2511 | * Input handler used while nav bar is hidden. Captures any touch on the screen, |
| 2512 | * to determine when the nav bar should be shown and prevent applications from |
| 2513 | * receiving those touches. |
| 2514 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2515 | final class HideNavInputEventReceiver extends InputEventReceiver { |
| 2516 | public HideNavInputEventReceiver(InputChannel inputChannel, Looper looper) { |
| 2517 | super(inputChannel, looper); |
| 2518 | } |
| 2519 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2520 | @Override |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2521 | public void onInputEvent(InputEvent event) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2522 | boolean handled = false; |
| 2523 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 2524 | if (event instanceof MotionEvent |
| 2525 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 2526 | final MotionEvent motionEvent = (MotionEvent)event; |
| 2527 | if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2528 | // When the user taps down, we re-show the nav bar. |
| 2529 | boolean changed = false; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2530 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2531 | // Any user activity always causes us to show the |
| 2532 | // navigation controls, if they had been hidden. |
| 2533 | // We also clear the low profile and only content |
| 2534 | // flags so that tapping on the screen will atomically |
| 2535 | // restore all currently hidden screen decorations. |
| 2536 | int newVal = mResettingSystemUiFlags | |
| 2537 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| 2538 | View.SYSTEM_UI_FLAG_LOW_PROFILE | |
| 2539 | View.SYSTEM_UI_FLAG_FULLSCREEN; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2540 | if (mResettingSystemUiFlags != newVal) { |
| 2541 | mResettingSystemUiFlags = newVal; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2542 | changed = true; |
| 2543 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2544 | // We don't allow the system's nav bar to be hidden |
| 2545 | // again for 1 second, to prevent applications from |
| 2546 | // spamming us and keeping it from being shown. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2547 | newVal = mForceClearedSystemUiFlags | |
| 2548 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2549 | if (mForceClearedSystemUiFlags != newVal) { |
| 2550 | mForceClearedSystemUiFlags = newVal; |
| 2551 | changed = true; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2552 | mHandler.postDelayed(mClearHideNavigationFlag, 1000); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2553 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2554 | } |
| 2555 | if (changed) { |
| 2556 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 2557 | } |
| 2558 | } |
| 2559 | } |
| 2560 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2561 | finishInputEvent(event, handled); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2562 | } |
| 2563 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2564 | } |
| 2565 | final InputEventReceiver.Factory mHideNavInputEventReceiverFactory = |
| 2566 | new InputEventReceiver.Factory() { |
| 2567 | @Override |
| 2568 | public InputEventReceiver createInputEventReceiver( |
| 2569 | InputChannel inputChannel, Looper looper) { |
| 2570 | return new HideNavInputEventReceiver(inputChannel, looper); |
| 2571 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2572 | }; |
| 2573 | |
| 2574 | @Override |
| 2575 | public int adjustSystemUiVisibilityLw(int visibility) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2576 | mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
| 2577 | mNavigationBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2578 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2579 | // Reset any bits in mForceClearingStatusBarVisibility that |
| 2580 | // are now clear. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2581 | mResettingSystemUiFlags &= visibility; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2582 | // Clear any bits in the new visibility that are currently being |
| 2583 | // force cleared, before reporting it. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2584 | return visibility & ~mResettingSystemUiFlags |
| 2585 | & ~mForceClearedSystemUiFlags; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2586 | } |
| 2587 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2588 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2589 | public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset) { |
| 2590 | final int fl = attrs.flags; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2591 | final int systemUiVisibility = (attrs.systemUiVisibility|attrs.subtreeSystemUiVisibility); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2592 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2593 | 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] | 2594 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2595 | int availRight, availBottom; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 2596 | if (canHideNavigationBar() && |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2597 | (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2598 | availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 2599 | availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
| 2600 | } else { |
| 2601 | availRight = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 2602 | availBottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
| 2603 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2604 | if ((systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2605 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 2606 | contentInset.set(mStableFullscreenLeft, mStableFullscreenTop, |
| 2607 | availRight - mStableFullscreenRight, |
| 2608 | availBottom - mStableFullscreenBottom); |
| 2609 | } else { |
| 2610 | contentInset.set(mStableLeft, mStableTop, |
| 2611 | availRight - mStableRight, availBottom - mStableBottom); |
| 2612 | } |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2613 | } else if ((fl & FLAG_FULLSCREEN) != 0 || (fl & FLAG_LAYOUT_IN_OVERSCAN) != 0) { |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2614 | contentInset.setEmpty(); |
| 2615 | } else if ((systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2616 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) { |
| 2617 | contentInset.set(mCurLeft, mCurTop, |
| 2618 | availRight - mCurRight, availBottom - mCurBottom); |
| 2619 | } else { |
| 2620 | contentInset.set(mCurLeft, mCurTop, |
| 2621 | availRight - mCurRight, availBottom - mCurBottom); |
| 2622 | } |
| 2623 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2624 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2625 | contentInset.setEmpty(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2626 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2627 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2628 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2629 | @Override |
| 2630 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
| 2631 | int displayRotation) { |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2632 | final int overscanLeft, overscanTop, overscanRight, overscanBottom; |
| 2633 | if (isDefaultDisplay) { |
| 2634 | switch (displayRotation) { |
| 2635 | case Surface.ROTATION_90: |
| 2636 | overscanLeft = mOverscanTop; |
| 2637 | overscanTop = mOverscanRight; |
| 2638 | overscanRight = mOverscanBottom; |
| 2639 | overscanBottom = mOverscanLeft; |
| 2640 | break; |
| 2641 | case Surface.ROTATION_180: |
| 2642 | overscanLeft = mOverscanRight; |
| 2643 | overscanTop = mOverscanBottom; |
| 2644 | overscanRight = mOverscanLeft; |
| 2645 | overscanBottom = mOverscanTop; |
| 2646 | break; |
| 2647 | case Surface.ROTATION_270: |
| 2648 | overscanLeft = mOverscanBottom; |
| 2649 | overscanTop = mOverscanLeft; |
| 2650 | overscanRight = mOverscanTop; |
| 2651 | overscanBottom = mOverscanRight; |
| 2652 | break; |
| 2653 | default: |
| 2654 | overscanLeft = mOverscanLeft; |
| 2655 | overscanTop = mOverscanTop; |
| 2656 | overscanRight = mOverscanRight; |
| 2657 | overscanBottom = mOverscanBottom; |
| 2658 | break; |
| 2659 | } |
| 2660 | } else { |
| 2661 | overscanLeft = 0; |
| 2662 | overscanTop = 0; |
| 2663 | overscanRight = 0; |
| 2664 | overscanBottom = 0; |
| 2665 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2666 | mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0; |
| 2667 | mOverscanScreenTop = mRestrictedOverscanScreenTop = 0; |
| 2668 | mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth; |
| 2669 | mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2670 | mSystemLeft = 0; |
| 2671 | mSystemTop = 0; |
| 2672 | mSystemRight = displayWidth; |
| 2673 | mSystemBottom = displayHeight; |
| 2674 | mUnrestrictedScreenLeft = overscanLeft; |
| 2675 | mUnrestrictedScreenTop = overscanTop; |
| 2676 | mUnrestrictedScreenWidth = displayWidth - overscanLeft - overscanRight; |
| 2677 | mUnrestrictedScreenHeight = displayHeight - overscanTop - overscanBottom; |
| 2678 | mRestrictedScreenLeft = mUnrestrictedScreenLeft; |
| 2679 | mRestrictedScreenTop = mUnrestrictedScreenTop; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2680 | mRestrictedScreenWidth = mSystemGestures.screenWidth = mUnrestrictedScreenWidth; |
| 2681 | mRestrictedScreenHeight = mSystemGestures.screenHeight = mUnrestrictedScreenHeight; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2682 | mDockLeft = mContentLeft = mStableLeft = mStableFullscreenLeft |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2683 | = mCurLeft = mUnrestrictedScreenLeft; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2684 | mDockTop = mContentTop = mStableTop = mStableFullscreenTop |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2685 | = mCurTop = mUnrestrictedScreenTop; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2686 | mDockRight = mContentRight = mStableRight = mStableFullscreenRight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2687 | = mCurRight = displayWidth - overscanRight; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2688 | mDockBottom = mContentBottom = mStableBottom = mStableFullscreenBottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2689 | = mCurBottom = displayHeight - overscanBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2690 | mDockLayer = 0x10000000; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 2691 | mStatusBarLayer = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2692 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2693 | // start with the current dock rect, which will be (0,0,displayWidth,displayHeight) |
| 2694 | final Rect pf = mTmpParentFrame; |
| 2695 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2696 | final Rect of = mTmpOverscanFrame; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2697 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2698 | final Rect dcf = mTmpDecorFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2699 | pf.left = df.left = of.left = vf.left = mDockLeft; |
| 2700 | pf.top = df.top = of.top = vf.top = mDockTop; |
| 2701 | pf.right = df.right = of.right = vf.right = mDockRight; |
| 2702 | pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2703 | dcf.setEmpty(); // Decor frame N/A for system bars. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2704 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2705 | if (isDefaultDisplay) { |
| 2706 | // For purposes of putting out fake window up to steal focus, we will |
| 2707 | // drive nav being hidden only by whether it is requested. |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2708 | final int sysui = mLastSystemUiFlags; |
| 2709 | boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2710 | boolean navTranslucent = (sysui & View.NAVIGATION_BAR_TRANSLUCENT) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 2711 | boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0; |
| 2712 | boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
| 2713 | boolean navAllowedHidden = immersive || immersiveSticky; |
| 2714 | navTranslucent &= !immersiveSticky; // transient trumps translucent |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 2715 | navTranslucent &= areTranslucentBarsAllowed(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2716 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2717 | // When the navigation bar isn't visible, we put up a fake |
| 2718 | // input window to catch all touch events. This way we can |
| 2719 | // detect when the user presses anywhere to bring back the nav |
| 2720 | // bar and ensure the application doesn't see the event. |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 2721 | if (navVisible || navAllowedHidden) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2722 | if (mHideNavFakeWindow != null) { |
| 2723 | mHideNavFakeWindow.dismiss(); |
| 2724 | mHideNavFakeWindow = null; |
| 2725 | } |
| 2726 | } else if (mHideNavFakeWindow == null) { |
| 2727 | mHideNavFakeWindow = mWindowManagerFuncs.addFakeWindow( |
| 2728 | mHandler.getLooper(), mHideNavInputEventReceiverFactory, |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 2729 | "hidden nav", WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER, 0, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2730 | 0, false, false, true); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2731 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2732 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2733 | // For purposes of positioning and showing the nav bar, if we have |
| 2734 | // decided that it can't be hidden (because of the screen aspect ratio), |
| 2735 | // then take that into account. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 2736 | navVisible |= !canHideNavigationBar(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2737 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2738 | boolean updateSysUiVisibility = false; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2739 | if (mNavigationBar != null) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2740 | boolean transientNavBarShowing = mNavigationBarController.isTransientShowing(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2741 | // Force the navigation bar to its appropriate place and |
| 2742 | // size. We need to do this directly, instead of relying on |
| 2743 | // it to bubble up from the nav bar, because this needs to |
| 2744 | // change atomically with screen rotations. |
| 2745 | mNavigationBarOnBottom = (!mNavigationBarCanMove || displayWidth < displayHeight); |
| 2746 | if (mNavigationBarOnBottom) { |
| 2747 | // 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] | 2748 | int top = displayHeight - overscanBottom |
| 2749 | - mNavigationBarHeightForRotation[displayRotation]; |
| 2750 | mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2751 | mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 2752 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2753 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2754 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2755 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2756 | mDockBottom = mTmpNavigationFrame.top; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2757 | mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop; |
| 2758 | mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2759 | } else { |
| 2760 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2761 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2762 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2763 | if (navVisible && !navTranslucent && !mNavigationBar.isAnimatingLw() |
| 2764 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2765 | // If the opaque nav bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2766 | // and not in the process of animating on or off, then |
| 2767 | // we can tell the app that it is covered by it. |
| 2768 | mSystemBottom = mTmpNavigationFrame.top; |
| 2769 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2770 | } else { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2771 | // Landscape screen; nav bar goes to the right. |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2772 | int left = displayWidth - overscanRight |
| 2773 | - mNavigationBarWidthForRotation[displayRotation]; |
| 2774 | mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2775 | mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 2776 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2777 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2778 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2779 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2780 | mDockRight = mTmpNavigationFrame.left; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2781 | mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft; |
| 2782 | mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2783 | } else { |
| 2784 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2785 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2786 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2787 | if (navVisible && !navTranslucent && !mNavigationBar.isAnimatingLw() |
| 2788 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2789 | // If the nav bar is currently requested to be visible, |
| 2790 | // and not in the process of animating on or off, then |
| 2791 | // we can tell the app that it is covered by it. |
| 2792 | mSystemRight = mTmpNavigationFrame.left; |
| 2793 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2794 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2795 | // Make sure the content and current rectangles are updated to |
| 2796 | // account for the restrictions from the navigation bar. |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2797 | mContentTop = mCurTop = mDockTop; |
| 2798 | mContentBottom = mCurBottom = mDockBottom; |
| 2799 | mContentLeft = mCurLeft = mDockLeft; |
| 2800 | mContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2801 | mStatusBarLayer = mNavigationBar.getSurfaceLayer(); |
| 2802 | // And compute the final frame. |
| 2803 | mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2804 | mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2805 | if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2806 | if (mNavigationBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2807 | updateSysUiVisibility = true; |
| 2808 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2809 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2810 | 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] | 2811 | mDockLeft, mDockTop, mDockRight, mDockBottom)); |
| 2812 | |
| 2813 | // decide where the status bar goes ahead of time |
| 2814 | if (mStatusBar != null) { |
| 2815 | // apply any navigation bar insets |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2816 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 2817 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 2818 | pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft; |
| 2819 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight |
| 2820 | + mUnrestrictedScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2821 | vf.left = mStableLeft; |
| 2822 | vf.top = mStableTop; |
| 2823 | vf.right = mStableRight; |
| 2824 | vf.bottom = mStableBottom; |
| 2825 | |
| 2826 | mStatusBarLayer = mStatusBar.getSurfaceLayer(); |
| 2827 | |
| 2828 | // Let the status bar determine its size. |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2829 | mStatusBar.computeFrameLw(pf, df, vf, vf, vf, dcf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2830 | |
| 2831 | // For layout, the status bar is always at the top with our fixed height. |
| 2832 | mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 2833 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2834 | boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2835 | boolean statusBarTranslucent = (sysui & View.STATUS_BAR_TRANSLUCENT) != 0; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 2836 | statusBarTranslucent &= areTranslucentBarsAllowed(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2837 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2838 | // If the status bar is hidden, we don't want to cause |
| 2839 | // windows behind it to scroll. |
John Spurlock | eda1f69 | 2013-09-16 11:38:44 -0400 | [diff] [blame] | 2840 | if (mStatusBar.isVisibleLw() && !statusBarTransient) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2841 | // Status bar may go away, so the screen area it occupies |
| 2842 | // is available to apps but just covering them when the |
| 2843 | // status bar is visible. |
| 2844 | mDockTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 2845 | |
| 2846 | mContentTop = mCurTop = mDockTop; |
| 2847 | mContentBottom = mCurBottom = mDockBottom; |
| 2848 | mContentLeft = mCurLeft = mDockLeft; |
| 2849 | mContentRight = mCurRight = mDockRight; |
| 2850 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2851 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar: " + |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2852 | String.format( |
| 2853 | "dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]", |
| 2854 | mDockLeft, mDockTop, mDockRight, mDockBottom, |
| 2855 | mContentLeft, mContentTop, mContentRight, mContentBottom, |
| 2856 | mCurLeft, mCurTop, mCurRight, mCurBottom)); |
| 2857 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2858 | if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2859 | && !statusBarTransient && !statusBarTranslucent |
| 2860 | && !mStatusBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2861 | // If the opaque status bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2862 | // and not in the process of animating on or off, then |
| 2863 | // we can tell the app that it is covered by it. |
| 2864 | mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 2865 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2866 | if (mStatusBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2867 | updateSysUiVisibility = true; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2868 | } |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 2869 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2870 | if (updateSysUiVisibility) { |
| 2871 | updateSystemUiVisibilityLw(); |
| 2872 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2873 | } |
| 2874 | } |
| 2875 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 2876 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 2877 | @Override |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2878 | public int getSystemDecorLayerLw() { |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 2879 | if (mStatusBar != null) return mStatusBar.getSurfaceLayer(); |
| 2880 | if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer(); |
| 2881 | return 0; |
| 2882 | } |
| 2883 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 2884 | @Override |
| 2885 | public void getContentRectLw(Rect r) { |
| 2886 | r.set(mContentLeft, mContentTop, mContentRight, mContentBottom); |
| 2887 | } |
| 2888 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2889 | void setAttachedWindowFrames(WindowState win, int fl, int adjust, WindowState attached, |
| 2890 | 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] | 2891 | if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) { |
| 2892 | // Here's a special case: if this attached window is a panel that is |
| 2893 | // above the dock window, and the window it is attached to is below |
| 2894 | // the dock window, then the frames we computed for the window it is |
| 2895 | // attached to can not be used because the dock is effectively part |
| 2896 | // of the underlying window and the attached window is floating on top |
| 2897 | // of the whole thing. So, we ignore the attached window and explicitly |
| 2898 | // compute the frames that would be appropriate without the dock. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2899 | df.left = of.left = cf.left = vf.left = mDockLeft; |
| 2900 | df.top = of.top = cf.top = vf.top = mDockTop; |
| 2901 | df.right = of.right = cf.right = vf.right = mDockRight; |
| 2902 | df.bottom = of.bottom = cf.bottom = vf.bottom = mDockBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2903 | } else { |
| 2904 | // The effective display frame of the attached window depends on |
| 2905 | // whether it is taking care of insetting its content. If not, |
| 2906 | // we need to use the parent's content frame so that the entire |
| 2907 | // window is positioned within that content. Otherwise we can use |
| 2908 | // the display frame and let the attached window take care of |
| 2909 | // positioning its content appropriately. |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2910 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2911 | cf.set(attached.getOverscanFrameLw()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2912 | } else { |
| 2913 | // If the window is resizing, then we want to base the content |
| 2914 | // frame on our attached content frame to resize... however, |
| 2915 | // things can be tricky if the attached window is NOT in resize |
| 2916 | // mode, in which case its content frame will be larger. |
| 2917 | // Ungh. So to deal with that, make sure the content frame |
| 2918 | // we end up using is not covering the IM dock. |
| 2919 | cf.set(attached.getContentFrameLw()); |
| 2920 | if (attached.getSurfaceLayer() < mDockLayer) { |
| 2921 | if (cf.left < mContentLeft) cf.left = mContentLeft; |
| 2922 | if (cf.top < mContentTop) cf.top = mContentTop; |
| 2923 | if (cf.right > mContentRight) cf.right = mContentRight; |
| 2924 | if (cf.bottom > mContentBottom) cf.bottom = mContentBottom; |
| 2925 | } |
| 2926 | } |
| 2927 | df.set(insetDecors ? attached.getDisplayFrameLw() : cf); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2928 | of.set(insetDecors ? attached.getOverscanFrameLw() : cf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2929 | vf.set(attached.getVisibleFrameLw()); |
| 2930 | } |
| 2931 | // The LAYOUT_IN_SCREEN flag is used to determine whether the attached |
| 2932 | // window should be positioned relative to its parent or the entire |
| 2933 | // screen. |
| 2934 | pf.set((fl & FLAG_LAYOUT_IN_SCREEN) == 0 |
| 2935 | ? attached.getFrameLw() : df); |
| 2936 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2937 | |
| 2938 | private void applyStableConstraints(int sysui, int fl, Rect r) { |
| 2939 | if ((sysui & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2940 | // If app is requesting a stable layout, don't let the |
| 2941 | // content insets go below the stable values. |
| 2942 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 2943 | if (r.left < mStableFullscreenLeft) r.left = mStableFullscreenLeft; |
| 2944 | if (r.top < mStableFullscreenTop) r.top = mStableFullscreenTop; |
| 2945 | if (r.right > mStableFullscreenRight) r.right = mStableFullscreenRight; |
| 2946 | if (r.bottom > mStableFullscreenBottom) r.bottom = mStableFullscreenBottom; |
| 2947 | } else { |
| 2948 | if (r.left < mStableLeft) r.left = mStableLeft; |
| 2949 | if (r.top < mStableTop) r.top = mStableTop; |
| 2950 | if (r.right > mStableRight) r.right = mStableRight; |
| 2951 | if (r.bottom > mStableBottom) r.bottom = mStableBottom; |
| 2952 | } |
| 2953 | } |
| 2954 | } |
| 2955 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2956 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2957 | @Override |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 2958 | public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs, |
| 2959 | WindowState attached) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2960 | // we've already done the status bar |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 2961 | if (win == mStatusBar || win == mNavigationBar) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2962 | return; |
| 2963 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2964 | final boolean isDefaultDisplay = win.isDefaultDisplay(); |
| 2965 | final boolean needsToOffsetInputMethodTarget = isDefaultDisplay && |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 2966 | (win == mLastInputMethodTargetWindow && mLastInputMethodWindow != null); |
| 2967 | if (needsToOffsetInputMethodTarget) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2968 | 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] | 2969 | offsetInputMethodWindowLw(mLastInputMethodWindow); |
| 2970 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2971 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2972 | final int fl = attrs.flags; |
| 2973 | final int sim = attrs.softInputMode; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2974 | final int sysUiFl = win.getSystemUiVisibility(); |
| 2975 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2976 | final Rect pf = mTmpParentFrame; |
| 2977 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2978 | final Rect of = mTmpOverscanFrame; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2979 | final Rect cf = mTmpContentFrame; |
| 2980 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2981 | final Rect dcf = mTmpDecorFrame; |
| 2982 | dcf.setEmpty(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2983 | |
| 2984 | final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 2985 | && mNavigationBar != null && mNavigationBar.isVisibleLw()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2986 | |
Craig Mautner | f683b56 | 2012-10-02 11:10:57 -0700 | [diff] [blame] | 2987 | final int adjust = sim & SOFT_INPUT_MASK_ADJUST; |
| 2988 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2989 | if (!isDefaultDisplay) { |
| 2990 | if (attached != null) { |
| 2991 | // If this window is attached to another, our display |
| 2992 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2993 | setAttachedWindowFrames(win, fl, adjust, attached, true, pf, df, of, cf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2994 | } else { |
| 2995 | // Give the window full screen. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2996 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 2997 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 2998 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2999 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3000 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3001 | = mOverscanScreenTop + mOverscanScreenHeight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3002 | } |
| 3003 | } else if (attrs.type == TYPE_INPUT_METHOD) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3004 | pf.left = df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3005 | pf.top = df.top = of.top = cf.top = vf.top = mDockTop; |
| 3006 | pf.right = df.right = of.right = cf.right = vf.right = mDockRight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3007 | // IM dock windows layout below the nav bar... |
John Spurlock | 57beb3b | 2013-10-10 10:27:44 -0400 | [diff] [blame] | 3008 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3009 | // ...with content insets above the nav bar |
| 3010 | cf.bottom = vf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3011 | // IM dock windows always go to the bottom of the screen. |
| 3012 | attrs.gravity = Gravity.BOTTOM; |
| 3013 | mDockLayer = win.getSurfaceLayer(); |
| 3014 | } else { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3015 | |
| 3016 | // Default policy decor for the default display |
| 3017 | dcf.left = mSystemLeft; |
| 3018 | dcf.top = mSystemTop; |
| 3019 | dcf.right = mSystemRight; |
| 3020 | dcf.bottom = mSystemBottom; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3021 | final boolean inheritTranslucentDecor = (attrs.privateFlags |
| 3022 | & WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR) != 0; |
John Spurlock | 65567d4 | 2013-10-08 10:08:32 -0400 | [diff] [blame] | 3023 | final boolean isAppWindow = |
| 3024 | attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW && |
| 3025 | attrs.type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 3026 | final boolean topAtRest = |
| 3027 | win == mTopFullscreenOpaqueWindowState && !win.isAnimatingLw(); |
| 3028 | if (isAppWindow && !inheritTranslucentDecor && !topAtRest) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3029 | if ((sysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 |
| 3030 | && (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0 |
| 3031 | && (fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3032 | // Ensure policy decor includes status bar |
| 3033 | dcf.top = mStableTop; |
| 3034 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3035 | if ((fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == 0 |
John Spurlock | 8e0ca28 | 2013-10-03 11:46:06 -0400 | [diff] [blame] | 3036 | && (sysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3037 | // Ensure policy decor includes navigation bar |
| 3038 | dcf.bottom = mStableBottom; |
| 3039 | dcf.right = mStableRight; |
| 3040 | } |
| 3041 | } |
| 3042 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3043 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) |
| 3044 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3045 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3046 | + "): IN_SCREEN, INSET_DECOR"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3047 | // This is the case for a normal activity window: we want it |
| 3048 | // to cover all of the screen space, and it can take care of |
| 3049 | // moving its contents to account for screen decorations that |
| 3050 | // intrude into that space. |
| 3051 | if (attached != null) { |
| 3052 | // If this window is attached to another, our display |
| 3053 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3054 | 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] | 3055 | } else { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3056 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3057 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3058 | // Status bar panels are the only windows who can go on top of |
| 3059 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3060 | // permission, so they have the same privileges as the status |
| 3061 | // bar itself. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3062 | // |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3063 | // However, they should still dodge the navigation bar if it exists. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3064 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3065 | pf.left = df.left = of.left = hasNavBar |
| 3066 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3067 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3068 | pf.right = df.right = of.right = hasNavBar |
| 3069 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
| 3070 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3071 | pf.bottom = df.bottom = of.bottom = hasNavBar |
| 3072 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
| 3073 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3074 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3075 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3076 | "Laying out status bar window: (%d,%d - %d,%d)", |
| 3077 | pf.left, pf.top, pf.right, pf.bottom)); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3078 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3079 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3080 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3081 | // Asking to layout into the overscan region, so give it that pure |
| 3082 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3083 | pf.left = df.left = of.left = mOverscanScreenLeft; |
| 3084 | pf.top = df.top = of.top = mOverscanScreenTop; |
| 3085 | pf.right = df.right = of.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3086 | pf.bottom = df.bottom = of.bottom = mOverscanScreenTop |
| 3087 | + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3088 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3089 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 3090 | && (attrs.type == WindowManager.LayoutParams.TYPE_KEYGUARD || ( |
| 3091 | attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3092 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW))) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3093 | // Asking for layout as if the nav bar is hidden, lets the |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3094 | // application extend into the unrestricted overscan screen area. We |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3095 | // only do this for application windows to ensure no window that |
| 3096 | // can be above the nav bar can do this. |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3097 | pf.left = df.left = mOverscanScreenLeft; |
| 3098 | pf.top = df.top = mOverscanScreenTop; |
| 3099 | pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3100 | pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3101 | // We need to tell the app about where the frame inside the overscan |
| 3102 | // is, so it can inset its content by that amount -- it didn't ask |
| 3103 | // to actually extend itself into the overscan region. |
| 3104 | of.left = mUnrestrictedScreenLeft; |
| 3105 | of.top = mUnrestrictedScreenTop; |
| 3106 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3107 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3108 | } else { |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3109 | pf.left = df.left = mRestrictedOverscanScreenLeft; |
| 3110 | pf.top = df.top = mRestrictedOverscanScreenTop; |
| 3111 | pf.right = df.right = mRestrictedOverscanScreenLeft |
| 3112 | + mRestrictedOverscanScreenWidth; |
| 3113 | pf.bottom = df.bottom = mRestrictedOverscanScreenTop |
| 3114 | + mRestrictedOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3115 | // We need to tell the app about where the frame inside the overscan |
| 3116 | // is, so it can inset its content by that amount -- it didn't ask |
| 3117 | // to actually extend itself into the overscan region. |
| 3118 | of.left = mUnrestrictedScreenLeft; |
| 3119 | of.top = mUnrestrictedScreenTop; |
| 3120 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3121 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3122 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3123 | |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3124 | if ((fl & FLAG_FULLSCREEN) == 0) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3125 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
| 3126 | cf.left = mDockLeft; |
| 3127 | cf.top = mDockTop; |
| 3128 | cf.right = mDockRight; |
| 3129 | cf.bottom = mDockBottom; |
| 3130 | } else { |
| 3131 | cf.left = mContentLeft; |
| 3132 | cf.top = mContentTop; |
| 3133 | cf.right = mContentRight; |
| 3134 | cf.bottom = mContentBottom; |
| 3135 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3136 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3137 | // Full screen windows are always given a layout that is as if the |
| 3138 | // status bar and other transient decors are gone. This is to avoid |
| 3139 | // bad states when moving from a window that is not hding the |
| 3140 | // status bar to one that is. |
| 3141 | cf.left = mRestrictedScreenLeft; |
| 3142 | cf.top = mRestrictedScreenTop; |
| 3143 | cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 3144 | cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3145 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3146 | applyStableConstraints(sysUiFl, fl, cf); |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3147 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3148 | vf.left = mCurLeft; |
| 3149 | vf.top = mCurTop; |
| 3150 | vf.right = mCurRight; |
| 3151 | vf.bottom = mCurBottom; |
| 3152 | } else { |
| 3153 | vf.set(cf); |
| 3154 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3155 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3156 | } else if ((fl & FLAG_LAYOUT_IN_SCREEN) != 0 || (sysUiFl |
| 3157 | & (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 3158 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3159 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3160 | "): IN_SCREEN"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3161 | // A window that has requested to fill the entire screen just |
| 3162 | // gets everything, period. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3163 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3164 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3165 | pf.left = df.left = of.left = cf.left = hasNavBar |
| 3166 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3167 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3168 | pf.right = df.right = of.right = cf.right = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3169 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3170 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3171 | pf.bottom = df.bottom = of.bottom = cf.bottom = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3172 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3173 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3174 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3175 | "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)", |
| 3176 | pf.left, pf.top, pf.right, pf.bottom)); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 3177 | } else if (attrs.type == TYPE_NAVIGATION_BAR |
| 3178 | || attrs.type == TYPE_NAVIGATION_BAR_PANEL) { |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3179 | // The navigation bar has Real Ultimate Power. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3180 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3181 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3182 | pf.right = df.right = of.right = mUnrestrictedScreenLeft |
| 3183 | + mUnrestrictedScreenWidth; |
| 3184 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop |
| 3185 | + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3186 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3187 | "Laying out navigation bar window: (%d,%d - %d,%d)", |
| 3188 | pf.left, pf.top, pf.right, pf.bottom)); |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3189 | } else if ((attrs.type == TYPE_SECURE_SYSTEM_OVERLAY |
| 3190 | || attrs.type == TYPE_BOOT_PROGRESS) |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 3191 | && ((fl & FLAG_FULLSCREEN) != 0)) { |
| 3192 | // Fullscreen secure system overlays get what they ask for. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3193 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3194 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3195 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3196 | + mOverscanScreenWidth; |
| 3197 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3198 | + mOverscanScreenHeight; |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 3199 | } else if (attrs.type == TYPE_BOOT_PROGRESS |
| 3200 | || attrs.type == TYPE_UNIVERSE_BACKGROUND) { |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3201 | // Boot progress screen always covers entire display. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3202 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3203 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3204 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3205 | + mOverscanScreenWidth; |
| 3206 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3207 | + mOverscanScreenHeight; |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3208 | } else if (attrs.type == TYPE_WALLPAPER) { |
| 3209 | // The wallpaper also has Real Ultimate Power. |
| 3210 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3211 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3212 | pf.right = df.right = of.right = cf.right |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3213 | = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3214 | pf.bottom = df.bottom = of.bottom = cf.bottom |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3215 | = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3216 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3217 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3218 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3219 | // Asking to layout into the overscan region, so give it that pure |
| 3220 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3221 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3222 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3223 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3224 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3225 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3226 | = mOverscanScreenTop + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3227 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3228 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3229 | && (attrs.type == TYPE_TOAST |
| 3230 | || (attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3231 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW))) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3232 | // Asking for layout as if the nav bar is hidden, lets the |
| 3233 | // application extend into the unrestricted screen area. We |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3234 | // only do this for application windows (or toasts) to ensure no window that |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3235 | // can be above the nav bar can do this. |
| 3236 | // XXX This assumes that an app asking for this will also |
| 3237 | // ask for layout in only content. We can't currently figure out |
| 3238 | // 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] | 3239 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3240 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3241 | pf.right = df.right = of.right = cf.right = mUnrestrictedScreenLeft |
| 3242 | + mUnrestrictedScreenWidth; |
| 3243 | pf.bottom = df.bottom = of.bottom = cf.bottom = mUnrestrictedScreenTop |
| 3244 | + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3245 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3246 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3247 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3248 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3249 | + mRestrictedScreenWidth; |
| 3250 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3251 | + mRestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3252 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3253 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3254 | applyStableConstraints(sysUiFl, fl, cf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3255 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3256 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3257 | vf.left = mCurLeft; |
| 3258 | vf.top = mCurTop; |
| 3259 | vf.right = mCurRight; |
| 3260 | vf.bottom = mCurBottom; |
| 3261 | } else { |
| 3262 | vf.set(cf); |
| 3263 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3264 | } else if (attached != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3265 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3266 | "): attached to " + attached); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3267 | // A child window should be placed inside of the same visible |
| 3268 | // frame that its parent had. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3269 | 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] | 3270 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3271 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3272 | "): normal window"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3273 | // Otherwise, a normal window must be placed inside the content |
| 3274 | // of all screen decorations. |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3275 | if (attrs.type == TYPE_STATUS_BAR_PANEL) { |
| 3276 | // Status bar panels are the only windows who can go on top of |
| 3277 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3278 | // permission, so they have the same privileges as the status |
| 3279 | // bar itself. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3280 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3281 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3282 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3283 | + mRestrictedScreenWidth; |
| 3284 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3285 | + mRestrictedScreenHeight; |
John Spurlock | ca4d040 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3286 | } else if (attrs.type == TYPE_TOAST || attrs.type == TYPE_SYSTEM_ALERT |
| 3287 | || attrs.type == TYPE_VOLUME_OVERLAY) { |
| 3288 | // These dialogs are stable to interim decor changes. |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3289 | pf.left = df.left = of.left = cf.left = mStableLeft; |
| 3290 | pf.top = df.top = of.top = cf.top = mStableTop; |
| 3291 | pf.right = df.right = of.right = cf.right = mStableRight; |
| 3292 | pf.bottom = df.bottom = of.bottom = cf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3293 | } else { |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3294 | pf.left = mContentLeft; |
| 3295 | pf.top = mContentTop; |
| 3296 | pf.right = mContentRight; |
| 3297 | pf.bottom = mContentBottom; |
| 3298 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3299 | df.left = of.left = cf.left = mDockLeft; |
| 3300 | df.top = of.top = cf.top = mDockTop; |
| 3301 | df.right = of.right = cf.right = mDockRight; |
| 3302 | df.bottom = of.bottom = cf.bottom = mDockBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3303 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3304 | df.left = of.left = cf.left = mContentLeft; |
| 3305 | df.top = of.top = cf.top = mContentTop; |
| 3306 | df.right = of.right = cf.right = mContentRight; |
| 3307 | df.bottom = of.bottom = cf.bottom = mContentBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3308 | } |
| 3309 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3310 | vf.left = mCurLeft; |
| 3311 | vf.top = mCurTop; |
| 3312 | vf.right = mCurRight; |
| 3313 | vf.bottom = mCurBottom; |
| 3314 | } else { |
| 3315 | vf.set(cf); |
| 3316 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3317 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3318 | } |
| 3319 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3320 | |
Craig Mautner | b816bed | 2013-07-23 10:26:17 -0700 | [diff] [blame] | 3321 | // TYPE_SYSTEM_ERROR is above the NavigationBar so it can't be allowed to extend over it. |
| 3322 | if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0 && attrs.type != TYPE_SYSTEM_ERROR) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3323 | df.left = df.top = of.left = of.top = cf.left = cf.top = vf.left = vf.top = -10000; |
| 3324 | df.right = df.bottom = of.right = of.bottom = cf.right = cf.bottom |
| 3325 | = vf.right = vf.bottom = 10000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3326 | } |
| 3327 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3328 | 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] | 3329 | + ": sim=#" + Integer.toHexString(sim) |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3330 | + " attach=" + attached + " type=" + attrs.type |
| 3331 | + String.format(" flags=0x%08x", fl) |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 3332 | + " pf=" + pf.toShortString() + " df=" + df.toShortString() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3333 | + " of=" + of.toShortString() |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3334 | + " cf=" + cf.toShortString() + " vf=" + vf.toShortString() |
| 3335 | + " dcf=" + dcf.toShortString()); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3336 | |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3337 | win.computeFrameLw(pf, df, of, cf, vf, dcf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3338 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3339 | // Dock windows carve out the bottom of the screen, so normal windows |
| 3340 | // can't appear underneath them. |
Craig Mautner | 8bd206b | 2012-10-03 10:32:02 -0700 | [diff] [blame] | 3341 | if (attrs.type == TYPE_INPUT_METHOD && win.isVisibleOrBehindKeyguardLw() |
| 3342 | && !win.getGivenInsetsPendingLw()) { |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3343 | setLastInputMethodWindowLw(null, null); |
| 3344 | offsetInputMethodWindowLw(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3345 | } |
| 3346 | } |
| 3347 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3348 | private void offsetInputMethodWindowLw(WindowState win) { |
| 3349 | int top = win.getContentFrameLw().top; |
| 3350 | top += win.getGivenContentInsetsLw().top; |
| 3351 | if (mContentBottom > top) { |
| 3352 | mContentBottom = top; |
| 3353 | } |
| 3354 | top = win.getVisibleFrameLw().top; |
| 3355 | top += win.getGivenVisibleInsetsLw().top; |
| 3356 | if (mCurBottom > top) { |
| 3357 | mCurBottom = top; |
| 3358 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3359 | if (DEBUG_LAYOUT) Slog.v(TAG, "Input method: mDockBottom=" |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3360 | + mDockBottom + " mContentBottom=" |
| 3361 | + mContentBottom + " mCurBottom=" + mCurBottom); |
| 3362 | } |
| 3363 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3364 | /** {@inheritDoc} */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 3365 | @Override |
| 3366 | public void finishLayoutLw() { |
| 3367 | return; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3368 | } |
| 3369 | |
| 3370 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3371 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3372 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3373 | mTopFullscreenOpaqueWindowState = null; |
Craig Mautner | 0392442 | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3374 | mAppsToBeHidden.clear(); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3375 | mForceStatusBar = false; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3376 | mForceStatusBarFromKeyguard = false; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3377 | mForcingShowNavBar = false; |
| 3378 | mForcingShowNavBarLayer = -1; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3379 | |
| 3380 | mHideLockScreen = false; |
| 3381 | mAllowLockscreenWhenOn = false; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3382 | mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3383 | mShowingLockscreen = false; |
| 3384 | mShowingDream = false; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3385 | } |
| 3386 | |
| 3387 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3388 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3389 | public void applyPostLayoutPolicyLw(WindowState win, |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3390 | WindowManager.LayoutParams attrs) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3391 | if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw=" |
| 3392 | + win.isVisibleOrBehindKeyguardLw()); |
John Spurlock | ca4d040 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3393 | if (mTopFullscreenOpaqueWindowState == null |
| 3394 | && win.isVisibleLw() && attrs.type == TYPE_INPUT_METHOD) { |
| 3395 | mForcingShowNavBar = true; |
| 3396 | mForcingShowNavBarLayer = win.getSurfaceLayer(); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3397 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3398 | if (mTopFullscreenOpaqueWindowState == null && |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 3399 | win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3400 | if ((attrs.flags & FLAG_FORCE_NOT_FULLSCREEN) != 0) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3401 | if (attrs.type == TYPE_KEYGUARD) { |
| 3402 | mForceStatusBarFromKeyguard = true; |
| 3403 | } else { |
| 3404 | mForceStatusBar = true; |
| 3405 | } |
| 3406 | } |
| 3407 | if (attrs.type == TYPE_KEYGUARD) { |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3408 | mShowingLockscreen = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3409 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3410 | boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3411 | && attrs.type <= LAST_APPLICATION_WINDOW; |
| 3412 | if (attrs.type == TYPE_DREAM) { |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3413 | // If the lockscreen was showing when the dream started then wait |
| 3414 | // for the dream to draw before hiding the lockscreen. |
| 3415 | if (!mDreamingLockscreen |
| 3416 | || (win.isVisibleLw() && win.hasDrawnLw())) { |
| 3417 | mShowingDream = true; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3418 | appWindow = true; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3419 | } |
| 3420 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3421 | |
| 3422 | final boolean showWhenLocked = (attrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0; |
Craig Mautner | 4bdab6b | 2014-04-01 12:05:11 -0700 | [diff] [blame] | 3423 | final boolean dismissKeyguard = (attrs.flags & FLAG_DISMISS_KEYGUARD) != 0; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3424 | if (appWindow) { |
Craig Mautner | 4bdab6b | 2014-04-01 12:05:11 -0700 | [diff] [blame] | 3425 | if (showWhenLocked || (dismissKeyguard && !isKeyguardSecure())) { |
Craig Mautner | 0392442 | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3426 | mAppsToBeHidden.remove(win.getAppToken()); |
| 3427 | } else { |
| 3428 | mAppsToBeHidden.add(win.getAppToken()); |
| 3429 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3430 | if (attrs.x == 0 && attrs.y == 0 |
| 3431 | && attrs.width == WindowManager.LayoutParams.MATCH_PARENT |
| 3432 | && attrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
| 3433 | if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win); |
| 3434 | mTopFullscreenOpaqueWindowState = win; |
Craig Mautner | 0392442 | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3435 | if (mAppsToBeHidden.isEmpty()) { |
Craig Mautner | 1f52437 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3436 | if (showWhenLocked) { |
Craig Mautner | ff89d58 | 2014-03-13 21:09:35 -0700 | [diff] [blame] | 3437 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 3438 | "Setting mHideLockScreen to true by win " + win); |
Craig Mautner | 1f52437 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3439 | mHideLockScreen = true; |
| 3440 | mForceStatusBarFromKeyguard = false; |
| 3441 | } |
Craig Mautner | 4bdab6b | 2014-04-01 12:05:11 -0700 | [diff] [blame] | 3442 | if (dismissKeyguard && mDismissKeyguard == DISMISS_KEYGUARD_NONE) { |
Craig Mautner | 1f52437 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3443 | if (DEBUG_LAYOUT) Slog.v(TAG, "Setting mDismissKeyguard true by win " + win); |
| 3444 | mDismissKeyguard = mWinDismissingKeyguard == win ? |
| 3445 | DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START; |
| 3446 | mWinDismissingKeyguard = win; |
Craig Mautner | ff89d58 | 2014-03-13 21:09:35 -0700 | [diff] [blame] | 3447 | mForceStatusBarFromKeyguard = mShowingLockscreen && isKeyguardSecure(); |
Craig Mautner | 1f52437 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3448 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3449 | } |
| 3450 | if ((attrs.flags & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) { |
| 3451 | mAllowLockscreenWhenOn = true; |
| 3452 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3453 | } |
| 3454 | } |
| 3455 | } |
| 3456 | } |
| 3457 | |
| 3458 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3459 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3460 | public int finishPostLayoutPolicyLw() { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3461 | int changes = 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3462 | boolean topIsFullscreen = false; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3463 | |
| 3464 | final WindowManager.LayoutParams lp = (mTopFullscreenOpaqueWindowState != null) |
| 3465 | ? mTopFullscreenOpaqueWindowState.getAttrs() |
| 3466 | : null; |
| 3467 | |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3468 | // If we are not currently showing a dream then remember the current |
| 3469 | // lockscreen state. We will use this to determine whether the dream |
| 3470 | // started while the lockscreen was showing and remember this state |
| 3471 | // while the dream is showing. |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3472 | if (!mShowingDream) { |
| 3473 | mDreamingLockscreen = mShowingLockscreen; |
| 3474 | } |
| 3475 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3476 | if (mStatusBar != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3477 | if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3478 | + " forcefkg=" + mForceStatusBarFromKeyguard |
Dianne Hackborn | d70bc2f | 2009-10-06 23:25:51 -0700 | [diff] [blame] | 3479 | + " top=" + mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3480 | if (mForceStatusBar || mForceStatusBarFromKeyguard) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3481 | if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3482 | if (mStatusBarController.setBarShowingLw(true)) { |
| 3483 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3484 | } |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 3485 | // Maintain fullscreen layout until incoming animation is complete. |
| 3486 | topIsFullscreen = mTopIsFullscreen && mStatusBar.isAnimatingLw(); |
John Spurlock | f92b616 | 2013-11-11 15:01:16 -0500 | [diff] [blame] | 3487 | // Transient status bar on the lockscreen is not allowed |
| 3488 | if (mForceStatusBarFromKeyguard && mStatusBarController.isTransientShowing()) { |
| 3489 | mStatusBarController.updateVisibilityLw(false /*transientAllowed*/, |
| 3490 | mLastSystemUiFlags, mLastSystemUiFlags); |
| 3491 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3492 | } else if (mTopFullscreenOpaqueWindowState != null) { |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3493 | if (localLOGV) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3494 | Slog.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw() |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3495 | + " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw()); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3496 | Slog.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs() |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3497 | + " lp.flags=0x" + Integer.toHexString(lp.flags)); |
| 3498 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3499 | topIsFullscreen = (lp.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0 |
| 3500 | || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3501 | // The subtle difference between the window for mTopFullscreenOpaqueWindowState |
| 3502 | // and mTopIsFullscreen is that that mTopIsFullscreen is set only if the window |
| 3503 | // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the |
| 3504 | // case though. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3505 | if (mStatusBarController.isTransientShowing()) { |
| 3506 | if (mStatusBarController.setBarShowingLw(true)) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3507 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3508 | } |
| 3509 | } else if (topIsFullscreen) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3510 | if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3511 | if (mStatusBarController.setBarShowingLw(false)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3512 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3513 | } else { |
Craig Mautner | c5a6e44 | 2013-06-05 17:22:35 -0700 | [diff] [blame] | 3514 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar already hiding"); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 3515 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3516 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3517 | if (DEBUG_LAYOUT) Slog.v(TAG, "** SHOWING status bar: top is not fullscreen"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3518 | if (mStatusBarController.setBarShowingLw(true)) { |
| 3519 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3520 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3521 | } |
| 3522 | } |
| 3523 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3524 | |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 3525 | if (mTopIsFullscreen != topIsFullscreen) { |
| 3526 | if (!topIsFullscreen) { |
| 3527 | // Force another layout when status bar becomes fully shown. |
| 3528 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3529 | } |
| 3530 | mTopIsFullscreen = topIsFullscreen; |
| 3531 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3532 | |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3533 | // Hide the key guard if a visible window explicitly specifies that it wants to be |
| 3534 | // displayed when the screen is locked. |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 3535 | if (mKeyguard != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3536 | if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard=" |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3537 | + mHideLockScreen); |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3538 | if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !isKeyguardSecure()) { |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3539 | if (mKeyguard.hideLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3540 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3541 | | FINISH_LAYOUT_REDO_CONFIG |
| 3542 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3543 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3544 | if (mKeyguardDelegate.isShowing()) { |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 3545 | mHandler.post(new Runnable() { |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3546 | @Override |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 3547 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3548 | mKeyguardDelegate.keyguardDone(false, false); |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 3549 | } |
| 3550 | }); |
| 3551 | } |
Dianne Hackborn | 0572658 | 2009-09-22 17:28:24 -0700 | [diff] [blame] | 3552 | } else if (mHideLockScreen) { |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3553 | if (mKeyguard.hideLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3554 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3555 | | FINISH_LAYOUT_REDO_CONFIG |
| 3556 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3557 | } |
Craig Mautner | 2881630 | 2013-10-10 20:31:00 -0700 | [diff] [blame] | 3558 | if (!mShowingDream) { |
| 3559 | mKeyguardDelegate.setHidden(true); |
| 3560 | } |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3561 | } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) { |
| 3562 | // This is the case of keyguard isSecure() and not mHideLockScreen. |
| 3563 | if (mDismissKeyguard == DISMISS_KEYGUARD_START) { |
| 3564 | // Only launch the next keyguard unlock window once per window. |
| 3565 | if (mKeyguard.showLw(true)) { |
| 3566 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3567 | | FINISH_LAYOUT_REDO_CONFIG |
| 3568 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3569 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3570 | mKeyguardDelegate.setHidden(false); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3571 | mHandler.post(new Runnable() { |
| 3572 | @Override |
| 3573 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3574 | mKeyguardDelegate.dismiss(); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3575 | } |
| 3576 | }); |
| 3577 | } |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 3578 | } else { |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3579 | mWinDismissingKeyguard = null; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3580 | if (mKeyguard.showLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3581 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3582 | | FINISH_LAYOUT_REDO_CONFIG |
| 3583 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3584 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3585 | mKeyguardDelegate.setHidden(false); |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 3586 | } |
| 3587 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3588 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3589 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3590 | // If the navigation bar has been hidden or shown, we need to do another |
| 3591 | // layout pass to update that window. |
| 3592 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3593 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3594 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3595 | // update since mAllowLockscreenWhenOn might have changed |
| 3596 | updateLockScreenTimeout(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3597 | return changes; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3598 | } |
| 3599 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3600 | public boolean allowAppAnimationsLw() { |
Craig Mautner | 5800443 | 2013-10-14 12:58:42 -0700 | [diff] [blame] | 3601 | if (mKeyguard != null && mKeyguard.isVisibleLw() && !mKeyguard.isAnimatingLw() |
| 3602 | || mShowingDream) { |
Craig Mautner | 2881630 | 2013-10-10 20:31:00 -0700 | [diff] [blame] | 3603 | // If keyguard or dreams is currently visible, no reason to animate behind it. |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3604 | return false; |
| 3605 | } |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3606 | return true; |
| 3607 | } |
| 3608 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3609 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus) { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3610 | mFocusedWindow = newFocus; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3611 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3612 | // If the navigation bar has been hidden or shown, we need to do another |
| 3613 | // layout pass to update that window. |
| 3614 | return FINISH_LAYOUT_REDO_LAYOUT; |
| 3615 | } |
| 3616 | return 0; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3617 | } |
| 3618 | |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 3619 | /** {@inheritDoc} */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3620 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
| 3621 | // lid changed state |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3622 | final int newLidState = lidOpen ? LID_OPEN : LID_CLOSED; |
| 3623 | if (newLidState == mLidState) { |
| 3624 | return; |
| 3625 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3626 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3627 | mLidState = newLidState; |
| 3628 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3629 | updateRotation(true); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3630 | |
| 3631 | if (lidOpen) { |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 3632 | mPowerManager.wakeUp(SystemClock.uptimeMillis()); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3633 | } else if (!mLidControlsSleep) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3634 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3635 | } |
| 3636 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3637 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3638 | void setHdmiPlugged(boolean plugged) { |
| 3639 | if (mHdmiPlugged != plugged) { |
| 3640 | mHdmiPlugged = plugged; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3641 | updateRotation(true, true); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3642 | Intent intent = new Intent(ACTION_HDMI_PLUGGED); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3643 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3644 | intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 3645 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3646 | } |
| 3647 | } |
| 3648 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3649 | void initializeHdmiState() { |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 3650 | boolean plugged = false; |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3651 | // watch for HDMI plug messages if the hdmi switch exists |
| 3652 | if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) { |
| 3653 | mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi"); |
| 3654 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3655 | final String filename = "/sys/class/switch/hdmi/state"; |
| 3656 | FileReader reader = null; |
| 3657 | try { |
| 3658 | reader = new FileReader(filename); |
| 3659 | char[] buf = new char[15]; |
| 3660 | int n = reader.read(buf); |
| 3661 | if (n > 1) { |
| 3662 | plugged = 0 != Integer.parseInt(new String(buf, 0, n-1)); |
| 3663 | } |
| 3664 | } catch (IOException ex) { |
| 3665 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 3666 | } catch (NumberFormatException ex) { |
| 3667 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 3668 | } finally { |
| 3669 | if (reader != null) { |
| 3670 | try { |
| 3671 | reader.close(); |
| 3672 | } catch (IOException ex) { |
| 3673 | } |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3674 | } |
| 3675 | } |
| 3676 | } |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 3677 | // This dance forces the code in setHdmiPlugged to run. |
| 3678 | // Always do this so the sticky intent is stuck (to false) if there is no hdmi. |
| 3679 | mHdmiPlugged = !plugged; |
| 3680 | setHdmiPlugged(!mHdmiPlugged); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3681 | } |
| 3682 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3683 | /** |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3684 | * @return Whether music is being played right now "locally" (e.g. on the device's speakers |
| 3685 | * or wired headphones) or "remotely" (e.g. on a device using the Cast protocol and |
| 3686 | * controlled by this device, or through remote submix). |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3687 | */ |
| 3688 | boolean isMusicActive() { |
Eric Laurent | 413cb9d | 2009-07-17 11:52:43 -0700 | [diff] [blame] | 3689 | final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); |
| 3690 | if (am == null) { |
| 3691 | Log.w(TAG, "isMusicActive: couldn't get AudioManager reference"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3692 | return false; |
| 3693 | } |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3694 | return am.isLocalOrRemoteMusicActive(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3695 | } |
| 3696 | |
| 3697 | /** |
| 3698 | * Tell the audio service to adjust the volume appropriate to the event. |
| 3699 | * @param keycode |
| 3700 | */ |
Mike Lockwood | a53e381 | 2009-09-25 10:51:39 -0400 | [diff] [blame] | 3701 | void handleVolumeKey(int stream, int keycode) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3702 | IAudioService audioService = getAudioService(); |
| 3703 | if (audioService == null) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3704 | return; |
| 3705 | } |
| 3706 | try { |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3707 | // when audio is playing locally, we shouldn't have to hold a wake lock |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3708 | // during the call, but we do it as a precaution for the rare possibility |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3709 | // that the music stops right before we call this. |
| 3710 | // Otherwise we might also be in a remote playback case. |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 3711 | // TODO: Actually handle MUTE. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3712 | mBroadcastWakeLock.acquire(); |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3713 | if (stream == AudioSystem.STREAM_MUSIC) { |
| 3714 | audioService.adjustLocalOrRemoteStreamVolume(stream, |
| 3715 | keycode == KeyEvent.KEYCODE_VOLUME_UP |
| 3716 | ? AudioManager.ADJUST_RAISE |
| 3717 | : AudioManager.ADJUST_LOWER, |
| 3718 | mContext.getOpPackageName()); |
| 3719 | } else { |
| 3720 | audioService.adjustStreamVolume(stream, |
| 3721 | keycode == KeyEvent.KEYCODE_VOLUME_UP |
| 3722 | ? AudioManager.ADJUST_RAISE |
| 3723 | : AudioManager.ADJUST_LOWER, |
| 3724 | 0, |
| 3725 | mContext.getOpPackageName()); |
| 3726 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3727 | } catch (RemoteException e) { |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3728 | Log.w(TAG, "IAudioService.adjust*StreamVolume() threw RemoteException " + e); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3729 | } finally { |
| 3730 | mBroadcastWakeLock.release(); |
| 3731 | } |
| 3732 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3733 | |
Dianne Hackborn | c0e3f24 | 2011-08-19 14:19:10 -0700 | [diff] [blame] | 3734 | final Object mScreenshotLock = new Object(); |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3735 | ServiceConnection mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3736 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3737 | final Runnable mScreenshotTimeout = new Runnable() { |
| 3738 | @Override public void run() { |
| 3739 | synchronized (mScreenshotLock) { |
| 3740 | if (mScreenshotConnection != null) { |
| 3741 | mContext.unbindService(mScreenshotConnection); |
| 3742 | mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3743 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3744 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3745 | } |
| 3746 | }; |
| 3747 | |
| 3748 | // Assume this is called from the Handler thread. |
| 3749 | private void takeScreenshot() { |
| 3750 | synchronized (mScreenshotLock) { |
| 3751 | if (mScreenshotConnection != null) { |
| 3752 | return; |
| 3753 | } |
| 3754 | ComponentName cn = new ComponentName("com.android.systemui", |
| 3755 | "com.android.systemui.screenshot.TakeScreenshotService"); |
| 3756 | Intent intent = new Intent(); |
| 3757 | intent.setComponent(cn); |
| 3758 | ServiceConnection conn = new ServiceConnection() { |
| 3759 | @Override |
| 3760 | public void onServiceConnected(ComponentName name, IBinder service) { |
| 3761 | synchronized (mScreenshotLock) { |
| 3762 | if (mScreenshotConnection != this) { |
| 3763 | return; |
| 3764 | } |
| 3765 | Messenger messenger = new Messenger(service); |
| 3766 | Message msg = Message.obtain(null, 1); |
| 3767 | final ServiceConnection myConn = this; |
| 3768 | Handler h = new Handler(mHandler.getLooper()) { |
| 3769 | @Override |
| 3770 | public void handleMessage(Message msg) { |
| 3771 | synchronized (mScreenshotLock) { |
| 3772 | if (mScreenshotConnection == myConn) { |
| 3773 | mContext.unbindService(mScreenshotConnection); |
| 3774 | mScreenshotConnection = null; |
| 3775 | mHandler.removeCallbacks(mScreenshotTimeout); |
| 3776 | } |
| 3777 | } |
| 3778 | } |
| 3779 | }; |
| 3780 | msg.replyTo = new Messenger(h); |
Winson Chung | a63bb84 | 2011-10-17 10:26:28 -0700 | [diff] [blame] | 3781 | msg.arg1 = msg.arg2 = 0; |
| 3782 | if (mStatusBar != null && mStatusBar.isVisibleLw()) |
| 3783 | msg.arg1 = 1; |
| 3784 | if (mNavigationBar != null && mNavigationBar.isVisibleLw()) |
| 3785 | msg.arg2 = 1; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3786 | try { |
| 3787 | messenger.send(msg); |
| 3788 | } catch (RemoteException e) { |
| 3789 | } |
| 3790 | } |
| 3791 | } |
| 3792 | @Override |
| 3793 | public void onServiceDisconnected(ComponentName name) {} |
| 3794 | }; |
Amith Yamasani | 27b89e6 | 2013-01-16 12:30:11 -0800 | [diff] [blame] | 3795 | if (mContext.bindServiceAsUser( |
| 3796 | intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3797 | mScreenshotConnection = conn; |
| 3798 | mHandler.postDelayed(mScreenshotTimeout, 10000); |
| 3799 | } |
| 3800 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3801 | } |
| 3802 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3803 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3804 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3805 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3806 | if (!mSystemBooted) { |
| 3807 | // If we have not yet booted, don't let key events do anything. |
| 3808 | return 0; |
| 3809 | } |
| 3810 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3811 | final boolean interactive = (policyFlags & FLAG_INTERACTIVE) != 0; |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 3812 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 3813 | final boolean canceled = event.isCanceled(); |
| 3814 | final int keyCode = event.getKeyCode(); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 3815 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 3816 | final boolean isInjected = (policyFlags & WindowManagerPolicy.FLAG_INJECTED) != 0; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 3817 | |
Mike Lockwood | c72b15f | 2009-11-28 20:58:22 -0500 | [diff] [blame] | 3818 | // If screen is off then we treat the case where the keyguard is open but hidden |
| 3819 | // the same as if it were open and in front. |
| 3820 | // This will prevent any keys other than the power button from waking the screen |
| 3821 | // when the keyguard is hidden by another activity. |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3822 | final boolean keyguardActive = (mKeyguardDelegate == null ? false : |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3823 | (interactive ? |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3824 | mKeyguardDelegate.isShowingAndNotHidden() : |
| 3825 | mKeyguardDelegate.isShowing())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3826 | |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 3827 | if (keyCode == KeyEvent.KEYCODE_POWER |
| 3828 | || keyCode == KeyEvent.KEYCODE_SLEEP |
| 3829 | || keyCode == KeyEvent.KEYCODE_WAKEUP) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3830 | policyFlags |= WindowManagerPolicy.FLAG_WAKE; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 3831 | } |
| 3832 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 3833 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3834 | Log.d(TAG, "interceptKeyTq keycode=" + keyCode |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3835 | + " interactive=" + interactive + " keyguardActive=" + keyguardActive |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 3836 | + " policyFlags=" + Integer.toHexString(policyFlags)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3837 | } |
| 3838 | |
Jeff Brown | 98392ef | 2011-09-12 18:24:59 -0700 | [diff] [blame] | 3839 | if (down && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 |
| 3840 | && event.getRepeatCount() == 0) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3841 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
| 3842 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3843 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3844 | // Basic policy based on interactive state. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3845 | int result; |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 3846 | boolean isWakeKey = (policyFlags & (WindowManagerPolicy.FLAG_WAKE |
| 3847 | | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3848 | if (interactive || (isInjected && !isWakeKey)) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3849 | // When the screen is on or if the key is injected pass the key to the application. |
| 3850 | result = ACTION_PASS_TO_USER; |
| 3851 | } else { |
| 3852 | // When the screen is off and the key is not injected, determine whether |
| 3853 | // to wake the device but don't pass the key to the application. |
| 3854 | result = 0; |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 3855 | if (isWakeKey && (!down || !isWakeKeyWhenScreenOff(keyCode))) { |
| 3856 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3857 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3858 | } |
| 3859 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 3860 | // If the key would be handled globally, just return the result, don't worry about special |
| 3861 | // key processing. |
| 3862 | if (mGlobalKeyManager.shouldHandleGlobalKey(keyCode, event)) { |
| 3863 | return result; |
| 3864 | } |
| 3865 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3866 | // Handle special keys. |
| 3867 | switch (keyCode) { |
| 3868 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 3869 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 3870 | case KeyEvent.KEYCODE_VOLUME_MUTE: { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3871 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { |
| 3872 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3873 | if (interactive && !mVolumeDownKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3874 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 3875 | mVolumeDownKeyTriggered = true; |
| 3876 | mVolumeDownKeyTime = event.getDownTime(); |
| 3877 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 3878 | cancelPendingPowerKeyAction(); |
| 3879 | interceptScreenshotChord(); |
| 3880 | } |
| 3881 | } else { |
| 3882 | mVolumeDownKeyTriggered = false; |
| 3883 | cancelPendingScreenshotChordAction(); |
| 3884 | } |
| 3885 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { |
| 3886 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3887 | if (interactive && !mVolumeUpKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3888 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 3889 | mVolumeUpKeyTriggered = true; |
| 3890 | cancelPendingPowerKeyAction(); |
| 3891 | cancelPendingScreenshotChordAction(); |
| 3892 | } |
| 3893 | } else { |
| 3894 | mVolumeUpKeyTriggered = false; |
| 3895 | cancelPendingScreenshotChordAction(); |
| 3896 | } |
| 3897 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3898 | if (down) { |
| 3899 | ITelephony telephonyService = getTelephonyService(); |
| 3900 | if (telephonyService != null) { |
| 3901 | try { |
| 3902 | if (telephonyService.isRinging()) { |
| 3903 | // If an incoming call is ringing, either VOLUME key means |
| 3904 | // "silence ringer". We handle these keys here, rather than |
| 3905 | // in the InCallScreen, to make sure we'll respond to them |
| 3906 | // even if the InCallScreen hasn't come to the foreground yet. |
| 3907 | // Look for the DOWN event here, to agree with the "fallback" |
| 3908 | // behavior in the InCallScreen. |
| 3909 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 3910 | + " VOLUME key-down while ringing: Silence ringer!"); |
| 3911 | |
| 3912 | // Silence the ringer. (It's safe to call this |
| 3913 | // even if the ringer has already been silenced.) |
| 3914 | telephonyService.silenceRinger(); |
| 3915 | |
| 3916 | // And *don't* pass this key thru to the current activity |
| 3917 | // (which is probably the InCallScreen.) |
| 3918 | result &= ~ACTION_PASS_TO_USER; |
| 3919 | break; |
| 3920 | } |
| 3921 | if (telephonyService.isOffhook() |
| 3922 | && (result & ACTION_PASS_TO_USER) == 0) { |
| 3923 | // If we are in call but we decided not to pass the key to |
| 3924 | // the application, handle the volume change here. |
| 3925 | handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keyCode); |
| 3926 | break; |
| 3927 | } |
| 3928 | } catch (RemoteException ex) { |
| 3929 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
| 3930 | } |
| 3931 | } |
| 3932 | |
| 3933 | if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { |
| 3934 | // If music is playing but we decided not to pass the key to the |
| 3935 | // application, handle the volume change here. |
| 3936 | handleVolumeKey(AudioManager.STREAM_MUSIC, keyCode); |
| 3937 | break; |
| 3938 | } |
| 3939 | } |
| 3940 | break; |
| 3941 | } |
| 3942 | |
| 3943 | case KeyEvent.KEYCODE_ENDCALL: { |
| 3944 | result &= ~ACTION_PASS_TO_USER; |
| 3945 | if (down) { |
| 3946 | ITelephony telephonyService = getTelephonyService(); |
| 3947 | boolean hungUp = false; |
| 3948 | if (telephonyService != null) { |
| 3949 | try { |
| 3950 | hungUp = telephonyService.endCall(); |
| 3951 | } catch (RemoteException ex) { |
| 3952 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
| 3953 | } |
| 3954 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3955 | interceptPowerKeyDown(!interactive || hungUp); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3956 | } else { |
| 3957 | if (interceptPowerKeyUp(canceled)) { |
| 3958 | if ((mEndcallBehavior |
| 3959 | & Settings.System.END_BUTTON_BEHAVIOR_HOME) != 0) { |
| 3960 | if (goHome()) { |
| 3961 | break; |
Dianne Hackborn | 0041e97 | 2009-07-24 17:14:43 -0700 | [diff] [blame] | 3962 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3963 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3964 | if ((mEndcallBehavior |
| 3965 | & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 3966 | mPowerManager.goToSleep(event.getEventTime()); |
| 3967 | isWakeKey = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3968 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3969 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3970 | } |
| 3971 | break; |
| 3972 | } |
| 3973 | |
| 3974 | case KeyEvent.KEYCODE_POWER: { |
| 3975 | result &= ~ACTION_PASS_TO_USER; |
| 3976 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3977 | mImmersiveModeConfirmation.onPowerKeyDown(interactive, event.getDownTime(), |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 3978 | isImmersiveMode(mLastSystemUiFlags)); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 3979 | if (interactive && !mPowerKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3980 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 3981 | mPowerKeyTriggered = true; |
| 3982 | mPowerKeyTime = event.getDownTime(); |
| 3983 | interceptScreenshotChord(); |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3984 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3985 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3986 | ITelephony telephonyService = getTelephonyService(); |
| 3987 | boolean hungUp = false; |
| 3988 | if (telephonyService != null) { |
| 3989 | try { |
| 3990 | if (telephonyService.isRinging()) { |
| 3991 | // Pressing Power while there's a ringing incoming |
| 3992 | // call should silence the ringer. |
| 3993 | telephonyService.silenceRinger(); |
| 3994 | } else if ((mIncallPowerBehavior |
| 3995 | & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 |
| 3996 | && telephonyService.isOffhook()) { |
| 3997 | // Otherwise, if "Power button ends call" is enabled, |
| 3998 | // the Power button will hang up any current active call. |
| 3999 | hungUp = telephonyService.endCall(); |
| 4000 | } |
| 4001 | } catch (RemoteException ex) { |
| 4002 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
| 4003 | } |
| 4004 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 4005 | interceptPowerKeyDown(!interactive || hungUp |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4006 | || mVolumeDownKeyTriggered || mVolumeUpKeyTriggered); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4007 | } else { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4008 | mPowerKeyTriggered = false; |
| 4009 | cancelPendingScreenshotChordAction(); |
| 4010 | if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) { |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4011 | mPowerManager.goToSleep(event.getEventTime()); |
| 4012 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4013 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4014 | mPendingPowerKeyUpCanceled = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4015 | } |
| 4016 | break; |
| 4017 | } |
| 4018 | |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4019 | case KeyEvent.KEYCODE_SLEEP: { |
| 4020 | result &= ~ACTION_PASS_TO_USER; |
| 4021 | mPowerManager.goToSleep(event.getEventTime()); |
| 4022 | isWakeKey = false; |
| 4023 | break; |
| 4024 | } |
| 4025 | |
| 4026 | case KeyEvent.KEYCODE_WAKEUP: { |
| 4027 | result &= ~ACTION_PASS_TO_USER; |
| 4028 | break; |
| 4029 | } |
| 4030 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4031 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4032 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4033 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4034 | if (down) { |
| 4035 | ITelephony telephonyService = getTelephonyService(); |
| 4036 | if (telephonyService != null) { |
| 4037 | try { |
| 4038 | if (!telephonyService.isIdle()) { |
| 4039 | // Suppress PLAY/PAUSE toggle when phone is ringing or in-call |
| 4040 | // to avoid music playback. |
| 4041 | break; |
| 4042 | } |
| 4043 | } catch (RemoteException ex) { |
| 4044 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4045 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4046 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4047 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4048 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4049 | case KeyEvent.KEYCODE_MUTE: |
| 4050 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4051 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4052 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4053 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4054 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4055 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
| 4056 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4057 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 4058 | // Only do this if we would otherwise not pass it to the user. In that |
| 4059 | // case, the PhoneWindow class will do the same thing, except it will |
| 4060 | // 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] | 4061 | // Note that we need to make a copy of the key event here because the |
| 4062 | // original key event will be recycled when we return. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4063 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4064 | Message msg = mHandler.obtainMessage(MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK, |
| 4065 | new KeyEvent(event)); |
| 4066 | msg.setAsynchronous(true); |
| 4067 | msg.sendToTarget(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4068 | } |
| 4069 | break; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4070 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4071 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4072 | case KeyEvent.KEYCODE_CALL: { |
| 4073 | if (down) { |
| 4074 | ITelephony telephonyService = getTelephonyService(); |
| 4075 | if (telephonyService != null) { |
| 4076 | try { |
| 4077 | if (telephonyService.isRinging()) { |
| 4078 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4079 | + " CALL key-down while ringing: Answer the call!"); |
| 4080 | telephonyService.answerRingingCall(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4081 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4082 | // And *don't* pass this key thru to the current activity |
| 4083 | // (which is presumably the InCallScreen.) |
| 4084 | result &= ~ACTION_PASS_TO_USER; |
| 4085 | } |
| 4086 | } catch (RemoteException ex) { |
| 4087 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4088 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4089 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4090 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4091 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4092 | } |
| 4093 | } |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4094 | |
| 4095 | if (isWakeKey) { |
| 4096 | mPowerManager.wakeUp(event.getEventTime()); |
| 4097 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4098 | return result; |
| 4099 | } |
| 4100 | |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4101 | /** |
| 4102 | * When the screen is off we ignore some keys that might otherwise typically |
| 4103 | * be considered wake keys. We filter them out here. |
| 4104 | * |
| 4105 | * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it |
| 4106 | * is always considered a wake key. |
| 4107 | */ |
| 4108 | private boolean isWakeKeyWhenScreenOff(int keyCode) { |
| 4109 | switch (keyCode) { |
| 4110 | // ignore volume keys unless docked |
| 4111 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4112 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 4113 | case KeyEvent.KEYCODE_VOLUME_MUTE: |
| 4114 | return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 4115 | |
| 4116 | // ignore media and camera keys |
| 4117 | case KeyEvent.KEYCODE_MUTE: |
| 4118 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4119 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4120 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4121 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4122 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4123 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4124 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4125 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4126 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
| 4127 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4128 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4129 | case KeyEvent.KEYCODE_CAMERA: |
| 4130 | return false; |
| 4131 | } |
| 4132 | return true; |
| 4133 | } |
| 4134 | |
| 4135 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4136 | /** {@inheritDoc} */ |
| 4137 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame^] | 4138 | public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) { |
| 4139 | // We already know this is a wake motion so just wake up. |
| 4140 | // Note that we would observe policyFlags containing |
| 4141 | // FLAG_WAKE and FLAG_INTERACTIVE here. |
| 4142 | mPowerManager.wakeUp(whenNanos / 1000000); |
| 4143 | return 0; |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4144 | } |
| 4145 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4146 | void dispatchMediaKeyWithWakeLock(KeyEvent event) { |
| 4147 | if (DEBUG_INPUT) { |
| 4148 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: " + event); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4149 | } |
| 4150 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4151 | if (mHavePendingMediaKeyRepeatWithWakeLock) { |
| 4152 | if (DEBUG_INPUT) { |
| 4153 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: canceled repeat"); |
| 4154 | } |
| 4155 | |
| 4156 | mHandler.removeMessages(MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK); |
| 4157 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4158 | mBroadcastWakeLock.release(); // pending repeat was holding onto the wake lock |
| 4159 | } |
| 4160 | |
| 4161 | dispatchMediaKeyWithWakeLockToAudioService(event); |
| 4162 | |
| 4163 | if (event.getAction() == KeyEvent.ACTION_DOWN |
| 4164 | && event.getRepeatCount() == 0) { |
| 4165 | mHavePendingMediaKeyRepeatWithWakeLock = true; |
| 4166 | |
| 4167 | Message msg = mHandler.obtainMessage( |
| 4168 | MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK, event); |
| 4169 | msg.setAsynchronous(true); |
| 4170 | mHandler.sendMessageDelayed(msg, ViewConfiguration.getKeyRepeatTimeout()); |
| 4171 | } else { |
| 4172 | mBroadcastWakeLock.release(); |
| 4173 | } |
| 4174 | } |
| 4175 | |
| 4176 | void dispatchMediaKeyRepeatWithWakeLock(KeyEvent event) { |
| 4177 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4178 | |
| 4179 | KeyEvent repeatEvent = KeyEvent.changeTimeRepeat(event, |
| 4180 | SystemClock.uptimeMillis(), 1, event.getFlags() | KeyEvent.FLAG_LONG_PRESS); |
| 4181 | if (DEBUG_INPUT) { |
| 4182 | Slog.d(TAG, "dispatchMediaKeyRepeatWithWakeLock: " + repeatEvent); |
| 4183 | } |
| 4184 | |
| 4185 | dispatchMediaKeyWithWakeLockToAudioService(repeatEvent); |
| 4186 | mBroadcastWakeLock.release(); |
| 4187 | } |
| 4188 | |
| 4189 | void dispatchMediaKeyWithWakeLockToAudioService(KeyEvent event) { |
| 4190 | if (ActivityManagerNative.isSystemReady()) { |
| 4191 | IAudioService audioService = getAudioService(); |
| 4192 | if (audioService != null) { |
| 4193 | try { |
| 4194 | audioService.dispatchMediaKeyEventUnderWakelock(event); |
| 4195 | } catch (RemoteException e) { |
| 4196 | Log.e(TAG, "dispatchMediaKeyEvent threw exception " + e); |
Jean-Michel Trivi | c680222 | 2012-04-30 11:15:03 -0700 | [diff] [blame] | 4197 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4198 | } |
| 4199 | } |
| 4200 | } |
| 4201 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4202 | BroadcastReceiver mDockReceiver = new BroadcastReceiver() { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4203 | @Override |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4204 | public void onReceive(Context context, Intent intent) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 4205 | if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { |
| 4206 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 4207 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4208 | } else { |
| 4209 | try { |
| 4210 | IUiModeManager uiModeService = IUiModeManager.Stub.asInterface( |
| 4211 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 4212 | mUiMode = uiModeService.getCurrentModeType(); |
| 4213 | } catch (RemoteException e) { |
| 4214 | } |
Dianne Hackborn | 80fa166 | 2009-10-07 14:02:10 -0700 | [diff] [blame] | 4215 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4216 | updateRotation(true); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4217 | synchronized (mLock) { |
| 4218 | updateOrientationListenerLp(); |
| 4219 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4220 | } |
| 4221 | }; |
| 4222 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4223 | BroadcastReceiver mDreamReceiver = new BroadcastReceiver() { |
| 4224 | @Override |
| 4225 | public void onReceive(Context context, Intent intent) { |
| 4226 | if (Intent.ACTION_DREAMING_STARTED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4227 | if (mKeyguardDelegate != null) { |
| 4228 | mKeyguardDelegate.onDreamingStarted(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4229 | } |
| 4230 | } else if (Intent.ACTION_DREAMING_STOPPED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4231 | if (mKeyguardDelegate != null) { |
| 4232 | mKeyguardDelegate.onDreamingStopped(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4233 | } |
| 4234 | } |
| 4235 | } |
| 4236 | }; |
| 4237 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4238 | BroadcastReceiver mMultiuserReceiver = new BroadcastReceiver() { |
| 4239 | @Override |
| 4240 | public void onReceive(Context context, Intent intent) { |
| 4241 | if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { |
| 4242 | // tickle the settings observer: this first ensures that we're |
| 4243 | // observing the relevant settings for the newly-active user, |
| 4244 | // and then updates our own bookkeeping based on the now- |
| 4245 | // current user. |
| 4246 | mSettingsObserver.onChange(false); |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4247 | |
| 4248 | // force a re-application of focused window sysui visibility. |
| 4249 | // the window may never have been shown for this user |
| 4250 | // e.g. the keyguard when going through the new-user setup flow |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4251 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4252 | mLastSystemUiFlags = 0; |
| 4253 | updateSystemUiVisibilityLw(); |
| 4254 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4255 | } |
| 4256 | } |
| 4257 | }; |
| 4258 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 4259 | private void requestTransientBars(WindowState swipeTarget) { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4260 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4261 | boolean sb = mStatusBarController.checkShowTransientBarLw(); |
| 4262 | boolean nb = mNavigationBarController.checkShowTransientBarLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4263 | if (sb || nb) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 4264 | WindowState barTarget = sb ? mStatusBar : mNavigationBar; |
| 4265 | if (sb ^ nb && barTarget != swipeTarget) { |
| 4266 | if (DEBUG) Slog.d(TAG, "Not showing transient bar, wrong swipe target"); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4267 | return; |
| 4268 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4269 | if (sb) mStatusBarController.showTransient(); |
| 4270 | if (nb) mNavigationBarController.showTransient(); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 4271 | mImmersiveModeConfirmation.confirmCurrentPrompt(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4272 | updateSystemUiVisibilityLw(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 4273 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4274 | } |
| 4275 | } |
| 4276 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4277 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4278 | public void screenTurnedOff(int why) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4279 | EventLog.writeEvent(70000, 0); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4280 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4281 | mScreenOnEarly = false; |
| 4282 | mScreenOnFully = false; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4283 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4284 | if (mKeyguardDelegate != null) { |
| 4285 | mKeyguardDelegate.onScreenTurnedOff(why); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4286 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4287 | synchronized (mLock) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4288 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4289 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4290 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4291 | } |
| 4292 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4293 | @Override |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 4294 | public void screenTurningOn(final ScreenOnListener screenOnListener) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4295 | EventLog.writeEvent(70000, 1); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 4296 | if (false) { |
| 4297 | RuntimeException here = new RuntimeException("here"); |
| 4298 | here.fillInStackTrace(); |
| 4299 | Slog.i(TAG, "Screen turning on...", here); |
| 4300 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4301 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4302 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4303 | mScreenOnEarly = true; |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4304 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4305 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4306 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4307 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4308 | waitForKeyguard(screenOnListener); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4309 | } |
| 4310 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4311 | private void waitForKeyguard(final ScreenOnListener screenOnListener) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4312 | if (mKeyguardDelegate != null) { |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4313 | if (screenOnListener != null) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4314 | mKeyguardDelegate.onScreenTurnedOn(new KeyguardServiceDelegate.ShowListener() { |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4315 | @Override |
| 4316 | public void onShown(IBinder windowToken) { |
| 4317 | waitForKeyguardWindowDrawn(windowToken, screenOnListener); |
| 4318 | } |
| 4319 | }); |
| 4320 | return; |
| 4321 | } else { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4322 | mKeyguardDelegate.onScreenTurnedOn(null); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4323 | } |
| 4324 | } else { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4325 | Slog.i(TAG, "No keyguard interface!"); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4326 | } |
| 4327 | finishScreenTurningOn(screenOnListener); |
| 4328 | } |
| 4329 | |
| 4330 | private void waitForKeyguardWindowDrawn(IBinder windowToken, |
| 4331 | final ScreenOnListener screenOnListener) { |
Craig Mautner | 6f29590 | 2013-10-11 21:43:06 -0700 | [diff] [blame] | 4332 | if (windowToken != null && !mHideLockScreen) { |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4333 | try { |
| 4334 | if (mWindowManager.waitForWindowDrawn( |
| 4335 | windowToken, new IRemoteCallback.Stub() { |
| 4336 | @Override |
| 4337 | public void sendResult(Bundle data) { |
| 4338 | Slog.i(TAG, "Lock screen displayed!"); |
| 4339 | finishScreenTurningOn(screenOnListener); |
| 4340 | } |
| 4341 | })) { |
| 4342 | return; |
| 4343 | } |
Craig Mautner | 4e8a19c | 2013-10-08 17:26:08 -0700 | [diff] [blame] | 4344 | Slog.i(TAG, "No lock screen! waitForWindowDrawn false"); |
| 4345 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4346 | } catch (RemoteException ex) { |
| 4347 | // Can't happen in system process. |
| 4348 | } |
| 4349 | } |
| 4350 | |
Craig Mautner | 4e8a19c | 2013-10-08 17:26:08 -0700 | [diff] [blame] | 4351 | Slog.i(TAG, "No lock screen! windowToken=" + windowToken); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4352 | finishScreenTurningOn(screenOnListener); |
| 4353 | } |
| 4354 | |
| 4355 | private void finishScreenTurningOn(ScreenOnListener screenOnListener) { |
| 4356 | synchronized (mLock) { |
| 4357 | mScreenOnFully = true; |
| 4358 | } |
| 4359 | |
Jeff Brown | 4fc4527 | 2012-10-10 18:28:14 -0700 | [diff] [blame] | 4360 | try { |
| 4361 | mWindowManager.setEventDispatching(true); |
| 4362 | } catch (RemoteException unhandled) { |
| 4363 | } |
| 4364 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4365 | if (screenOnListener != null) { |
| 4366 | screenOnListener.onScreenOn(); |
| 4367 | } |
| 4368 | } |
| 4369 | |
| 4370 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4371 | public boolean isScreenOnEarly() { |
| 4372 | return mScreenOnEarly; |
| 4373 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4374 | |
| 4375 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4376 | public boolean isScreenOnFully() { |
| 4377 | return mScreenOnFully; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4378 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4379 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4380 | /** {@inheritDoc} */ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4381 | public void enableKeyguard(boolean enabled) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4382 | if (mKeyguardDelegate != null) { |
| 4383 | mKeyguardDelegate.setKeyguardEnabled(enabled); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4384 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4385 | } |
| 4386 | |
| 4387 | /** {@inheritDoc} */ |
| 4388 | public void exitKeyguardSecurely(OnKeyguardExitResult callback) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4389 | if (mKeyguardDelegate != null) { |
| 4390 | mKeyguardDelegate.verifyUnlock(callback); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4391 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4392 | } |
| 4393 | |
Mike Lockwood | f791330 | 2009-11-28 22:27:10 -0500 | [diff] [blame] | 4394 | private boolean keyguardIsShowingTq() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4395 | if (mKeyguardDelegate == null) return false; |
| 4396 | return mKeyguardDelegate.isShowingAndNotHidden(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4397 | } |
| 4398 | |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4399 | |
| 4400 | /** {@inheritDoc} */ |
| 4401 | public boolean isKeyguardLocked() { |
| 4402 | return keyguardOn(); |
| 4403 | } |
| 4404 | |
| 4405 | /** {@inheritDoc} */ |
| 4406 | public boolean isKeyguardSecure() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4407 | if (mKeyguardDelegate == null) return false; |
| 4408 | return mKeyguardDelegate.isSecure(); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4409 | } |
| 4410 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4411 | /** {@inheritDoc} */ |
| 4412 | public boolean inKeyguardRestrictedKeyInputMode() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4413 | if (mKeyguardDelegate == null) return false; |
| 4414 | return mKeyguardDelegate.isInputRestricted(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4415 | } |
| 4416 | |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4417 | public void dismissKeyguardLw() { |
Jim Miller | 195b551 | 2013-02-28 03:35:57 -0800 | [diff] [blame] | 4418 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4419 | mHandler.post(new Runnable() { |
| 4420 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4421 | if (mKeyguardDelegate.isDismissable()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4422 | // Can we just finish the keyguard straight away? |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4423 | mKeyguardDelegate.keyguardDone(false, true); |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4424 | } else { |
| 4425 | // ask the keyguard to prompt the user to authenticate if necessary |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4426 | mKeyguardDelegate.dismiss(); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4427 | } |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4428 | } |
| 4429 | }); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4430 | } |
| 4431 | } |
| 4432 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4433 | void sendCloseSystemWindows() { |
| 4434 | sendCloseSystemWindows(mContext, null); |
| 4435 | } |
| 4436 | |
| 4437 | void sendCloseSystemWindows(String reason) { |
| 4438 | sendCloseSystemWindows(mContext, reason); |
| 4439 | } |
| 4440 | |
| 4441 | static void sendCloseSystemWindows(Context context, String reason) { |
| 4442 | if (ActivityManagerNative.isSystemReady()) { |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 4443 | try { |
| 4444 | ActivityManagerNative.getDefault().closeSystemDialogs(reason); |
| 4445 | } catch (RemoteException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4446 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4447 | } |
| 4448 | } |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 4449 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4450 | @Override |
| 4451 | public int rotationForOrientationLw(int orientation, int lastRotation) { |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4452 | if (false) { |
| 4453 | Slog.v(TAG, "rotationForOrientationLw(orient=" |
| 4454 | + orientation + ", last=" + lastRotation |
| 4455 | + "); user=" + mUserRotation + " " |
| 4456 | + ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) |
| 4457 | ? "USER_ROTATION_LOCKED" : "") |
| 4458 | ); |
| 4459 | } |
| 4460 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 4461 | if (mForceDefaultOrientation) { |
| 4462 | return Surface.ROTATION_0; |
| 4463 | } |
| 4464 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4465 | synchronized (mLock) { |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4466 | int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 |
| 4467 | if (sensorRotation < 0) { |
Jeff Brown | 0f862b4 | 2012-09-27 21:11:01 -0700 | [diff] [blame] | 4468 | sensorRotation = lastRotation; |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4469 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4470 | |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4471 | final int preferredRotation; |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 4472 | if (mLidState == LID_OPEN && mLidOpenRotation >= 0) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4473 | // Ignore sensor when lid switch is open and rotation is forced. |
| 4474 | preferredRotation = mLidOpenRotation; |
| 4475 | } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4476 | && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4477 | // Ignore sensor when in car dock unless explicitly enabled. |
| 4478 | // This case can override the behavior of NOSENSOR, and can also |
| 4479 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4480 | preferredRotation = mCarDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4481 | ? sensorRotation : mCarDockRotation; |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 4482 | } else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 4483 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 4484 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4485 | && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4486 | // Ignore sensor when in desk dock unless explicitly enabled. |
| 4487 | // This case can override the behavior of NOSENSOR, and can also |
| 4488 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4489 | preferredRotation = mDeskDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4490 | ? sensorRotation : mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4491 | } else if (mHdmiPlugged && mDemoHdmiRotationLock) { |
| 4492 | // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled. |
Jeff Brown | eb3e4b9 | 2011-12-06 19:54:24 -0800 | [diff] [blame] | 4493 | // Note that the dock orientation overrides the HDMI orientation. |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4494 | preferredRotation = mDemoHdmiRotation; |
| 4495 | } else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED |
| 4496 | && mUndockedHdmiRotation >= 0) { |
| 4497 | // Ignore sensor when plugged into HDMI and an undocked orientation has |
| 4498 | // been specified in the configuration (only for legacy devices without |
| 4499 | // full multi-display support). |
| 4500 | // Note that the dock orientation overrides the HDMI orientation. |
| 4501 | preferredRotation = mUndockedHdmiRotation; |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4502 | } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { |
| 4503 | // Application just wants to remain locked in the last rotation. |
| 4504 | preferredRotation = lastRotation; |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 4505 | } else if (!mSupportAutoRotation) { |
| 4506 | // If we don't support auto-rotation then bail out here and ignore |
| 4507 | // the sensor and any rotation lock settings. |
| 4508 | preferredRotation = -1; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4509 | } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4510 | && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4511 | || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED |
| 4512 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE |
| 4513 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT |
| 4514 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER)) |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4515 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 4516 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4517 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 4518 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { |
| 4519 | // Otherwise, use sensor only if requested by the application or enabled |
| 4520 | // by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR. |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4521 | if (mAllowAllRotations < 0) { |
| 4522 | // Can't read this during init() because the context doesn't |
| 4523 | // have display metrics at that time so we cannot determine |
| 4524 | // tablet vs. phone then. |
| 4525 | mAllowAllRotations = mContext.getResources().getBoolean( |
| 4526 | com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; |
| 4527 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4528 | if (sensorRotation != Surface.ROTATION_180 |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4529 | || mAllowAllRotations == 1 |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4530 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4531 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4532 | preferredRotation = sensorRotation; |
| 4533 | } else { |
| 4534 | preferredRotation = lastRotation; |
| 4535 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4536 | } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED |
| 4537 | && orientation != ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { |
| 4538 | // Apply rotation lock. Does not apply to NOSENSOR. |
| 4539 | // The idea is that the user rotation expresses a weak preference for the direction |
| 4540 | // of gravity and as NOSENSOR is never affected by gravity, then neither should |
| 4541 | // 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] | 4542 | preferredRotation = mUserRotation; |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4543 | } else { |
| 4544 | // No overriding preference. |
| 4545 | // We will do exactly what the application asked us to do. |
| 4546 | preferredRotation = -1; |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4547 | } |
| 4548 | |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4549 | switch (orientation) { |
| 4550 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4551 | // Return portrait unless overridden. |
| 4552 | if (isAnyPortrait(preferredRotation)) { |
| 4553 | return preferredRotation; |
| 4554 | } |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4555 | return mPortraitRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4556 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4557 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4558 | // Return landscape unless overridden. |
| 4559 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4560 | return preferredRotation; |
| 4561 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4562 | return mLandscapeRotation; |
| 4563 | |
| 4564 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4565 | // Return reverse portrait unless overridden. |
| 4566 | if (isAnyPortrait(preferredRotation)) { |
| 4567 | return preferredRotation; |
| 4568 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4569 | return mUpsideDownRotation; |
| 4570 | |
| 4571 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4572 | // Return seascape unless overridden. |
| 4573 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4574 | return preferredRotation; |
| 4575 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4576 | return mSeascapeRotation; |
| 4577 | |
| 4578 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4579 | case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4580 | // Return either landscape rotation. |
| 4581 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4582 | return preferredRotation; |
| 4583 | } |
| 4584 | if (isLandscapeOrSeascape(lastRotation)) { |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 4585 | return lastRotation; |
| 4586 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4587 | return mLandscapeRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4588 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4589 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4590 | case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4591 | // Return either portrait rotation. |
| 4592 | if (isAnyPortrait(preferredRotation)) { |
| 4593 | return preferredRotation; |
| 4594 | } |
| 4595 | if (isAnyPortrait(lastRotation)) { |
| 4596 | return lastRotation; |
| 4597 | } |
| 4598 | return mPortraitRotation; |
| 4599 | |
| 4600 | default: |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 4601 | // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, |
| 4602 | // just return the preferred orientation we already calculated. |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4603 | if (preferredRotation >= 0) { |
| 4604 | return preferredRotation; |
| 4605 | } |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 4606 | return Surface.ROTATION_0; |
Daniel Sandler | e7e5ac2 | 2011-02-22 16:10:21 -0500 | [diff] [blame] | 4607 | } |
| 4608 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4609 | } |
| 4610 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4611 | @Override |
| 4612 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation) { |
| 4613 | switch (orientation) { |
| 4614 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
| 4615 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
| 4616 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
| 4617 | return isAnyPortrait(rotation); |
| 4618 | |
| 4619 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
| 4620 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
| 4621 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
| 4622 | return isLandscapeOrSeascape(rotation); |
| 4623 | |
| 4624 | default: |
| 4625 | return true; |
| 4626 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4627 | } |
| 4628 | |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4629 | @Override |
| 4630 | public void setRotationLw(int rotation) { |
| 4631 | mOrientationListener.setCurrentRotation(rotation); |
| 4632 | } |
| 4633 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4634 | private boolean isLandscapeOrSeascape(int rotation) { |
| 4635 | return rotation == mLandscapeRotation || rotation == mSeascapeRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4636 | } |
| 4637 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4638 | private boolean isAnyPortrait(int rotation) { |
| 4639 | return rotation == mPortraitRotation || rotation == mUpsideDownRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4640 | } |
| 4641 | |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4642 | public int getUserRotationMode() { |
| 4643 | return Settings.System.getIntForUser(mContext.getContentResolver(), |
Brett Chabot | 7e55c40 | 2013-05-16 19:38:08 -0700 | [diff] [blame] | 4644 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
| 4645 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 4646 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4647 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4648 | |
| 4649 | // User rotation: to be used when all else fails in assigning an orientation to the device |
| 4650 | public void setUserRotationMode(int mode, int rot) { |
| 4651 | ContentResolver res = mContext.getContentResolver(); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4652 | |
| 4653 | // mUserRotationMode and mUserRotation will be assigned by the content observer |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4654 | if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4655 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4656 | Settings.System.USER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4657 | rot, |
| 4658 | UserHandle.USER_CURRENT); |
| 4659 | Settings.System.putIntForUser(res, |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4660 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4661 | 0, |
| 4662 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4663 | } else { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4664 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4665 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4666 | 1, |
| 4667 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4668 | } |
| 4669 | } |
| 4670 | |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 4671 | public void setSafeMode(boolean safeMode) { |
| 4672 | mSafeMode = safeMode; |
| 4673 | performHapticFeedbackLw(null, safeMode |
| 4674 | ? HapticFeedbackConstants.SAFE_MODE_ENABLED |
| 4675 | : HapticFeedbackConstants.SAFE_MODE_DISABLED, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4676 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4677 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 4678 | static long[] getLongIntArray(Resources r, int resid) { |
| 4679 | int[] ar = r.getIntArray(resid); |
| 4680 | if (ar == null) { |
| 4681 | return null; |
| 4682 | } |
| 4683 | long[] out = new long[ar.length]; |
| 4684 | for (int i=0; i<ar.length; i++) { |
| 4685 | out[i] = ar[i]; |
| 4686 | } |
| 4687 | return out; |
| 4688 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4689 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4690 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4691 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4692 | public void systemReady() { |
Mike Lockwood | e63f6f7 | 2013-11-15 11:01:47 -0800 | [diff] [blame] | 4693 | mKeyguardDelegate = new KeyguardServiceDelegate(mContext, null); |
| 4694 | mKeyguardDelegate.onSystemReady(); |
| 4695 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 4696 | synchronized (mLock) { |
| 4697 | updateOrientationListenerLp(); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 4698 | mSystemReady = true; |
| 4699 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4700 | @Override |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 4701 | public void run() { |
| 4702 | updateSettings(); |
| 4703 | } |
| 4704 | }); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4705 | } |
| 4706 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4707 | |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 4708 | /** {@inheritDoc} */ |
| 4709 | public void systemBooted() { |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 4710 | if (mKeyguardDelegate != null) { |
| 4711 | mKeyguardDelegate.onBootCompleted(); |
| 4712 | } |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 4713 | synchronized (mLock) { |
| 4714 | mSystemBooted = true; |
| 4715 | } |
| 4716 | } |
| 4717 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4718 | ProgressDialog mBootMsgDialog = null; |
| 4719 | |
| 4720 | /** {@inheritDoc} */ |
| 4721 | public void showBootMessage(final CharSequence msg, final boolean always) { |
| 4722 | mHandler.post(new Runnable() { |
| 4723 | @Override public void run() { |
| 4724 | if (mBootMsgDialog == null) { |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 4725 | mBootMsgDialog = new ProgressDialog(mContext) { |
| 4726 | // This dialog will consume all events coming in to |
| 4727 | // it, to avoid it trying to do things too early in boot. |
| 4728 | @Override public boolean dispatchKeyEvent(KeyEvent event) { |
| 4729 | return true; |
| 4730 | } |
| 4731 | @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 4732 | return true; |
| 4733 | } |
| 4734 | @Override public boolean dispatchTouchEvent(MotionEvent ev) { |
| 4735 | return true; |
| 4736 | } |
| 4737 | @Override public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 4738 | return true; |
| 4739 | } |
| 4740 | @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 4741 | return true; |
| 4742 | } |
| 4743 | @Override public boolean dispatchPopulateAccessibilityEvent( |
| 4744 | AccessibilityEvent event) { |
| 4745 | return true; |
| 4746 | } |
| 4747 | }; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4748 | mBootMsgDialog.setTitle(R.string.android_upgrading_title); |
| 4749 | mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); |
| 4750 | mBootMsgDialog.setIndeterminate(true); |
| 4751 | mBootMsgDialog.getWindow().setType( |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4752 | WindowManager.LayoutParams.TYPE_BOOT_PROGRESS); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4753 | mBootMsgDialog.getWindow().addFlags( |
| 4754 | WindowManager.LayoutParams.FLAG_DIM_BEHIND |
| 4755 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); |
| 4756 | mBootMsgDialog.getWindow().setDimAmount(1); |
Dianne Hackborn | d9efb95 | 2011-12-07 14:56:51 -0800 | [diff] [blame] | 4757 | WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes(); |
| 4758 | lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 4759 | mBootMsgDialog.getWindow().setAttributes(lp); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4760 | mBootMsgDialog.setCancelable(false); |
| 4761 | mBootMsgDialog.show(); |
| 4762 | } |
| 4763 | mBootMsgDialog.setMessage(msg); |
| 4764 | } |
| 4765 | }); |
| 4766 | } |
| 4767 | |
| 4768 | /** {@inheritDoc} */ |
| 4769 | public void hideBootMessages() { |
| 4770 | mHandler.post(new Runnable() { |
| 4771 | @Override public void run() { |
| 4772 | if (mBootMsgDialog != null) { |
| 4773 | mBootMsgDialog.dismiss(); |
| 4774 | mBootMsgDialog = null; |
| 4775 | } |
| 4776 | } |
| 4777 | }); |
| 4778 | } |
| 4779 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4780 | /** {@inheritDoc} */ |
| 4781 | public void userActivity() { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4782 | // *************************************** |
| 4783 | // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE |
| 4784 | // *************************************** |
| 4785 | // THIS IS CALLED FROM DEEP IN THE POWER MANAGER |
| 4786 | // WITH ITS LOCKS HELD. |
| 4787 | // |
| 4788 | // This code must be VERY careful about the locks |
| 4789 | // it acquires. |
| 4790 | // In fact, the current code acquires way too many, |
| 4791 | // and probably has lurking deadlocks. |
| 4792 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4793 | synchronized (mScreenLockTimeout) { |
| 4794 | if (mLockScreenTimerActive) { |
| 4795 | // reset the timer |
| 4796 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 4797 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 4798 | } |
| 4799 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 4800 | } |
| 4801 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4802 | class ScreenLockTimeout implements Runnable { |
| 4803 | Bundle options; |
| 4804 | |
| 4805 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4806 | public void run() { |
| 4807 | synchronized (this) { |
| 4808 | if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4809 | if (mKeyguardDelegate != null) { |
| 4810 | mKeyguardDelegate.doKeyguardTimeout(options); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4811 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4812 | mLockScreenTimerActive = false; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4813 | options = null; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4814 | } |
| 4815 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4816 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4817 | public void setLockOptions(Bundle options) { |
| 4818 | this.options = options; |
| 4819 | } |
| 4820 | } |
| 4821 | |
| 4822 | ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout(); |
| 4823 | |
| 4824 | public void lockNow(Bundle options) { |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 4825 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); |
| 4826 | mHandler.removeCallbacks(mScreenLockTimeout); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4827 | if (options != null) { |
| 4828 | // In case multiple calls are made to lockNow, we don't wipe out the options |
| 4829 | // until the runnable actually executes. |
| 4830 | mScreenLockTimeout.setLockOptions(options); |
| 4831 | } |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 4832 | mHandler.post(mScreenLockTimeout); |
| 4833 | } |
| 4834 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4835 | private void updateLockScreenTimeout() { |
| 4836 | synchronized (mScreenLockTimeout) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4837 | boolean enable = (mAllowLockscreenWhenOn && mScreenOnEarly && |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4838 | mKeyguardDelegate != null && mKeyguardDelegate.isSecure()); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4839 | if (mLockScreenTimerActive != enable) { |
| 4840 | if (enable) { |
| 4841 | if (localLOGV) Log.v(TAG, "setting lockscreen timer"); |
| 4842 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 4843 | } else { |
| 4844 | if (localLOGV) Log.v(TAG, "clearing lockscreen timer"); |
| 4845 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 4846 | } |
| 4847 | mLockScreenTimerActive = enable; |
| 4848 | } |
| 4849 | } |
| 4850 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4851 | |
| 4852 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4853 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4854 | public void enableScreenAfterBoot() { |
| 4855 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4856 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4857 | updateRotation(true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4858 | } |
Dianne Hackborn | f54c8f9 | 2009-09-19 14:03:57 -0700 | [diff] [blame] | 4859 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4860 | private void applyLidSwitchState() { |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4861 | if (mLidState == LID_CLOSED && mLidControlsSleep) { |
| 4862 | mPowerManager.goToSleep(SystemClock.uptimeMillis()); |
| 4863 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4864 | } |
| 4865 | |
| 4866 | void updateRotation(boolean alwaysSendConfiguration) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4867 | try { |
| 4868 | //set orientation on WindowManager |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 4869 | mWindowManager.updateRotation(alwaysSendConfiguration, false); |
| 4870 | } catch (RemoteException e) { |
| 4871 | // Ignore |
| 4872 | } |
| 4873 | } |
| 4874 | |
| 4875 | void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout) { |
| 4876 | try { |
| 4877 | //set orientation on WindowManager |
| 4878 | mWindowManager.updateRotation(alwaysSendConfiguration, forceRelayout); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4879 | } catch (RemoteException e) { |
| 4880 | // Ignore |
| 4881 | } |
| 4882 | } |
| 4883 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4884 | /** |
| 4885 | * Return an Intent to launch the currently active dock app as home. Returns |
| 4886 | * null if the standard home should be launched, which is the case if any of the following is |
| 4887 | * true: |
| 4888 | * <ul> |
| 4889 | * <li>The device is not in either car mode or desk mode |
| 4890 | * <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false |
| 4891 | * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false |
| 4892 | * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME |
| 4893 | * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME |
| 4894 | * </ul> |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4895 | * @return A dock intent. |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4896 | */ |
| 4897 | Intent createHomeDockIntent() { |
| 4898 | Intent intent = null; |
| 4899 | |
| 4900 | // What home does is based on the mode, not the dock state. That |
| 4901 | // is, when in car mode you should be taken to car home regardless |
| 4902 | // of whether we are actually in a car dock. |
| 4903 | if (mUiMode == Configuration.UI_MODE_TYPE_CAR) { |
| 4904 | if (ENABLE_CAR_DOCK_HOME_CAPTURE) { |
| 4905 | intent = mCarDockIntent; |
| 4906 | } |
| 4907 | } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { |
| 4908 | if (ENABLE_DESK_DOCK_HOME_CAPTURE) { |
| 4909 | intent = mDeskDockIntent; |
| 4910 | } |
| 4911 | } |
| 4912 | |
| 4913 | if (intent == null) { |
| 4914 | return null; |
| 4915 | } |
| 4916 | |
| 4917 | ActivityInfo ai = null; |
| 4918 | ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser( |
| 4919 | intent, |
John Spurlock | f56bef1 | 2013-07-09 09:51:46 -0400 | [diff] [blame] | 4920 | PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 4921 | mCurrentUserId); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4922 | if (info != null) { |
| 4923 | ai = info.activityInfo; |
| 4924 | } |
| 4925 | if (ai != null |
| 4926 | && ai.metaData != null |
| 4927 | && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { |
| 4928 | intent = new Intent(intent); |
| 4929 | intent.setClassName(ai.packageName, ai.name); |
| 4930 | return intent; |
| 4931 | } |
| 4932 | |
| 4933 | return null; |
| 4934 | } |
| 4935 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4936 | void startDockOrHome() { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 4937 | awakenDreams(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4938 | |
| 4939 | Intent dock = createHomeDockIntent(); |
| 4940 | if (dock != null) { |
| 4941 | try { |
| 4942 | mContext.startActivityAsUser(dock, UserHandle.CURRENT); |
| 4943 | return; |
| 4944 | } catch (ActivityNotFoundException e) { |
| 4945 | } |
| 4946 | } |
| 4947 | |
Dianne Hackborn | d888399 | 2012-09-07 15:58:52 -0700 | [diff] [blame] | 4948 | mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4949 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4950 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4951 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4952 | * goes to the home screen |
| 4953 | * @return whether it did anything |
| 4954 | */ |
| 4955 | boolean goHome() { |
| 4956 | if (false) { |
| 4957 | // This code always brings home to the front. |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 4958 | try { |
| 4959 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 4960 | } catch (RemoteException e) { |
| 4961 | } |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 4962 | sendCloseSystemWindows(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4963 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4964 | } else { |
| 4965 | // This code brings home to the front or, if it is already |
| 4966 | // at the front, puts the device to sleep. |
| 4967 | try { |
Wink Saville | d2e6a33 | 2010-02-12 12:12:06 -0800 | [diff] [blame] | 4968 | if (SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1) { |
| 4969 | /// Roll back EndcallBehavior as the cupcake design to pass P1 lab entry. |
| 4970 | Log.d(TAG, "UTS-TEST-MODE"); |
| 4971 | } else { |
| 4972 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 4973 | sendCloseSystemWindows(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4974 | Intent dock = createHomeDockIntent(); |
| 4975 | if (dock != null) { |
| 4976 | int result = ActivityManagerNative.getDefault() |
| 4977 | .startActivityAsUser(null, null, dock, |
| 4978 | dock.resolveTypeIfNeeded(mContext.getContentResolver()), |
| 4979 | null, null, 0, |
| 4980 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
| 4981 | null, null, null, UserHandle.USER_CURRENT); |
| 4982 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
| 4983 | return false; |
| 4984 | } |
| 4985 | } |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4986 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4987 | int result = ActivityManagerNative.getDefault() |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 4988 | .startActivityAsUser(null, null, mHomeIntent, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4989 | mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 4990 | null, null, 0, |
| 4991 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
Dianne Hackborn | 5e03e2c | 2012-09-06 14:21:19 -0700 | [diff] [blame] | 4992 | null, null, null, UserHandle.USER_CURRENT); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 4993 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4994 | return false; |
| 4995 | } |
| 4996 | } catch (RemoteException ex) { |
| 4997 | // bummer, the activity manager, which is in this process, is dead |
| 4998 | } |
| 4999 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5000 | return true; |
| 5001 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5002 | |
| 5003 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5004 | public void setCurrentOrientationLw(int newOrientation) { |
| 5005 | synchronized (mLock) { |
| 5006 | if (newOrientation != mCurrentAppOrientation) { |
| 5007 | mCurrentAppOrientation = newOrientation; |
| 5008 | updateOrientationListenerLp(); |
| 5009 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5010 | } |
| 5011 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5012 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5013 | private void performAuditoryFeedbackForAccessibilityIfNeed() { |
| 5014 | if (!isGlobalAccessibilityGestureEnabled()) { |
| 5015 | return; |
| 5016 | } |
| 5017 | AudioManager audioManager = (AudioManager) mContext.getSystemService( |
| 5018 | Context.AUDIO_SERVICE); |
| 5019 | if (audioManager.isSilentMode()) { |
| 5020 | return; |
| 5021 | } |
| 5022 | Ringtone ringTone = RingtoneManager.getRingtone(mContext, |
| 5023 | Settings.System.DEFAULT_NOTIFICATION_URI); |
| 5024 | ringTone.setStreamType(AudioManager.STREAM_MUSIC); |
| 5025 | ringTone.play(); |
| 5026 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5027 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5028 | private boolean isGlobalAccessibilityGestureEnabled() { |
| 5029 | return Settings.Global.getInt(mContext.getContentResolver(), |
| 5030 | Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1; |
| 5031 | } |
| 5032 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5033 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5034 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { |
Svetoslav Ganov | 9617921 | 2012-10-10 14:17:45 -0700 | [diff] [blame] | 5035 | if (!mVibrator.hasVibrator()) { |
| 5036 | return false; |
| 5037 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5038 | final boolean hapticsDisabled = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 5039 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) == 0; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5040 | if (!always && (hapticsDisabled || mKeyguardDelegate.isShowingAndNotHidden())) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5041 | return false; |
| 5042 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5043 | long[] pattern = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5044 | switch (effectId) { |
| 5045 | case HapticFeedbackConstants.LONG_PRESS: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5046 | pattern = mLongPressVibePattern; |
| 5047 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5048 | case HapticFeedbackConstants.VIRTUAL_KEY: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5049 | pattern = mVirtualKeyVibePattern; |
| 5050 | break; |
| 5051 | case HapticFeedbackConstants.KEYBOARD_TAP: |
| 5052 | pattern = mKeyboardTapVibePattern; |
| 5053 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5054 | case HapticFeedbackConstants.SAFE_MODE_DISABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5055 | pattern = mSafeModeDisabledVibePattern; |
| 5056 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5057 | case HapticFeedbackConstants.SAFE_MODE_ENABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5058 | pattern = mSafeModeEnabledVibePattern; |
| 5059 | break; |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5060 | default: |
| 5061 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5062 | } |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5063 | int owningUid; |
| 5064 | String owningPackage; |
| 5065 | if (win != null) { |
| 5066 | owningUid = win.getOwningUid(); |
| 5067 | owningPackage = win.getOwningPackage(); |
| 5068 | } else { |
| 5069 | owningUid = android.os.Process.myUid(); |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 5070 | owningPackage = mContext.getOpPackageName(); |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5071 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5072 | if (pattern.length == 1) { |
| 5073 | // One-shot vibration |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5074 | mVibrator.vibrate(owningUid, owningPackage, pattern[0]); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5075 | } else { |
| 5076 | // Pattern vibration |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5077 | mVibrator.vibrate(owningUid, owningPackage, pattern, -1); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5078 | } |
| 5079 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5080 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5081 | |
| 5082 | @Override |
| 5083 | public void keepScreenOnStartedLw() { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 5084 | } |
| 5085 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5086 | @Override |
| 5087 | public void keepScreenOnStoppedLw() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5088 | if (mKeyguardDelegate != null && !mKeyguardDelegate.isShowingAndNotHidden()) { |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5089 | long curTime = SystemClock.uptimeMillis(); |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 5090 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5091 | } |
| 5092 | } |
Mike Lockwood | fcb3924 | 2009-10-21 23:01:07 -0400 | [diff] [blame] | 5093 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5094 | private int updateSystemUiVisibilityLw() { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5095 | // If there is no window focused, there will be nobody to handle the events |
| 5096 | // anyway, so just hang on in whatever state we're in until things settle down. |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5097 | WindowState win = mFocusedWindow != null ? mFocusedWindow : mTopFullscreenOpaqueWindowState; |
| 5098 | if (win == null) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5099 | return 0; |
| 5100 | } |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5101 | if (win.getAttrs().type == TYPE_KEYGUARD && mHideLockScreen == true) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5102 | // We are updating at a point where the keyguard has gotten |
| 5103 | // focus, but we were last in a state where the top window is |
| 5104 | // hiding it. This is probably because the keyguard as been |
| 5105 | // shown while the top window was displayed, so we want to ignore |
| 5106 | // it here because this is just a very transient change and it |
| 5107 | // will quickly lose focus once it correctly gets hidden. |
| 5108 | return 0; |
| 5109 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 5110 | |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5111 | int tmpVisibility = win.getSystemUiVisibility() |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5112 | & ~mResettingSystemUiFlags |
| 5113 | & ~mForceClearedSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5114 | if (mForcingShowNavBar && win.getSurfaceLayer() < mForcingShowNavBarLayer) { |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5115 | tmpVisibility &= ~View.SYSTEM_UI_CLEARABLE_FLAGS; |
| 5116 | } |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5117 | final int visibility = updateSystemBarsLw(win, mLastSystemUiFlags, tmpVisibility); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5118 | final int diff = visibility ^ mLastSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5119 | final boolean needsMenu = win.getNeedsMenuLw(mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 5120 | if (diff == 0 && mLastFocusNeedsMenu == needsMenu |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5121 | && mFocusedApp == win.getAppToken()) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5122 | return 0; |
| 5123 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5124 | mLastSystemUiFlags = visibility; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5125 | mLastFocusNeedsMenu = needsMenu; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5126 | mFocusedApp = win.getAppToken(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5127 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5128 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5129 | public void run() { |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5130 | try { |
| 5131 | IStatusBarService statusbar = getStatusBarService(); |
| 5132 | if (statusbar != null) { |
| 5133 | statusbar.setSystemUiVisibility(visibility, 0xffffffff); |
| 5134 | statusbar.topAppWindowChanged(needsMenu); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5135 | } |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5136 | } catch (RemoteException e) { |
| 5137 | // re-acquire status bar service next time it is needed. |
| 5138 | mStatusBarService = null; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5139 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5140 | } |
| 5141 | }); |
| 5142 | return diff; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5143 | } |
| 5144 | |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5145 | private int updateSystemBarsLw(WindowState win, int oldVis, int vis) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5146 | // apply translucent bar vis flags |
| 5147 | WindowState transWin = mKeyguard != null && mKeyguard.isVisibleLw() && !mHideLockScreen |
| 5148 | ? mKeyguard |
| 5149 | : mTopFullscreenOpaqueWindowState; |
| 5150 | vis = mStatusBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 5151 | vis = mNavigationBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 5152 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5153 | // prevent status bar interaction from clearing certain flags |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5154 | boolean statusBarHasFocus = win.getAttrs().type == TYPE_STATUS_BAR; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5155 | if (statusBarHasFocus) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5156 | int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
| 5157 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 5158 | | View.SYSTEM_UI_FLAG_IMMERSIVE |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5159 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5160 | | View.STATUS_BAR_TRANSLUCENT |
| 5161 | | View.NAVIGATION_BAR_TRANSLUCENT; |
| 5162 | vis = (vis & ~flags) | (oldVis & flags); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5163 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5164 | |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5165 | if (!areTranslucentBarsAllowed()) { |
| 5166 | vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5167 | } |
| 5168 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5169 | // update status bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5170 | boolean immersiveSticky = |
| 5171 | (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5172 | boolean hideStatusBarWM = |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5173 | mTopFullscreenOpaqueWindowState != null && |
| 5174 | (mTopFullscreenOpaqueWindowState.getAttrs().flags |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5175 | & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; |
| 5176 | boolean hideStatusBarSysui = |
| 5177 | (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5178 | boolean hideNavBarSysui = |
| 5179 | (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5180 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5181 | boolean transientStatusBarAllowed = |
| 5182 | mStatusBar != null && ( |
| 5183 | hideStatusBarWM |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5184 | || (hideStatusBarSysui && immersiveSticky) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5185 | || statusBarHasFocus); |
| 5186 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5187 | boolean transientNavBarAllowed = |
| 5188 | mNavigationBar != null && |
| 5189 | hideNavBarSysui && immersiveSticky; |
| 5190 | |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 5191 | boolean denyTransientStatus = mStatusBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5192 | && !transientStatusBarAllowed && hideStatusBarSysui; |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 5193 | boolean denyTransientNav = mNavigationBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5194 | && !transientNavBarAllowed; |
| 5195 | if (denyTransientStatus || denyTransientNav) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5196 | // clear the clearable flags instead |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5197 | clearClearableFlagsLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5198 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5199 | |
| 5200 | vis = mStatusBarController.updateVisibilityLw(transientStatusBarAllowed, oldVis, vis); |
| 5201 | |
| 5202 | // update navigation bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5203 | boolean oldImmersiveMode = isImmersiveMode(oldVis); |
| 5204 | boolean newImmersiveMode = isImmersiveMode(vis); |
| 5205 | if (win != null && oldImmersiveMode != newImmersiveMode) { |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5206 | final String pkg = win.getOwningPackage(); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5207 | mImmersiveModeConfirmation.immersiveModeChanged(pkg, newImmersiveMode); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5208 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5209 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5210 | vis = mNavigationBarController.updateVisibilityLw(transientNavBarAllowed, oldVis, vis); |
| 5211 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 5212 | return vis; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5213 | } |
| 5214 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5215 | private void clearClearableFlagsLw() { |
| 5216 | int newVal = mResettingSystemUiFlags | View.SYSTEM_UI_CLEARABLE_FLAGS; |
| 5217 | if (newVal != mResettingSystemUiFlags) { |
| 5218 | mResettingSystemUiFlags = newVal; |
| 5219 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 5220 | } |
| 5221 | } |
| 5222 | |
| 5223 | private boolean isImmersiveMode(int vis) { |
| 5224 | final int flags = View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5225 | return mNavigationBar != null |
| 5226 | && (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0 |
Daniel Sandler | 900ece5 | 2013-10-18 15:53:27 -0400 | [diff] [blame] | 5227 | && (vis & flags) != 0 |
| 5228 | && canHideNavigationBar(); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5229 | } |
| 5230 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5231 | /** |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5232 | * @return whether the navigation or status bar can be made translucent |
| 5233 | * |
| 5234 | * This should return true unless touch exploration is not enabled or |
| 5235 | * R.boolean.config_enableTranslucentDecor is false. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5236 | */ |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5237 | private boolean areTranslucentBarsAllowed() { |
| 5238 | return mTranslucentDecorEnabled && !mTouchExplorationEnabled; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5239 | } |
| 5240 | |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5241 | // Use this instead of checking config_showNavigationBar so that it can be consistently |
| 5242 | // overridden by qemu.hw.mainkeys in the emulator. |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5243 | @Override |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5244 | public boolean hasNavigationBar() { |
| 5245 | return mHasNavigationBar; |
| 5246 | } |
| 5247 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 5248 | @Override |
| 5249 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target) { |
| 5250 | mLastInputMethodWindow = ime; |
| 5251 | mLastInputMethodTargetWindow = target; |
| 5252 | } |
| 5253 | |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5254 | @Override |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5255 | public void setCurrentUserLw(int newUserId) { |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 5256 | mCurrentUserId = newUserId; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5257 | if (mKeyguardDelegate != null) { |
| 5258 | mKeyguardDelegate.setCurrentUser(newUserId); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5259 | } |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 5260 | if (mStatusBarService != null) { |
| 5261 | try { |
| 5262 | mStatusBarService.setCurrentUser(newUserId); |
| 5263 | } catch (RemoteException e) { |
| 5264 | // oh well |
| 5265 | } |
| 5266 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5267 | setLastInputMethodWindowLw(null, null); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5268 | } |
| 5269 | |
| 5270 | @Override |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 5271 | public boolean canMagnifyWindow(int windowType) { |
| 5272 | switch (windowType) { |
| 5273 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD: |
| 5274 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG: |
| 5275 | case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR: |
| 5276 | case WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY: { |
| 5277 | return false; |
| 5278 | } |
| 5279 | } |
| 5280 | return true; |
| 5281 | } |
| 5282 | |
| 5283 | @Override |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5284 | public void setTouchExplorationEnabled(boolean enabled) { |
| 5285 | mTouchExplorationEnabled = enabled; |
| 5286 | } |
| 5287 | |
| 5288 | @Override |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 5289 | public boolean isTopLevelWindow(int windowType) { |
| 5290 | if (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW |
| 5291 | && windowType <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 5292 | return (windowType == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG); |
| 5293 | } |
| 5294 | return true; |
| 5295 | } |
| 5296 | |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 5297 | @Override |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 5298 | public void dump(String prefix, PrintWriter pw, String[] args) { |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5299 | pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5300 | pw.print(" mSystemReady="); pw.print(mSystemReady); |
| 5301 | pw.print(" mSystemBooted="); pw.println(mSystemBooted); |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 5302 | pw.print(prefix); pw.print("mLidState="); pw.print(mLidState); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5303 | pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); |
| 5304 | pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5305 | if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 |
| 5306 | || mForceClearedSystemUiFlags != 0) { |
| 5307 | pw.print(prefix); pw.print("mLastSystemUiFlags=0x"); |
| 5308 | pw.print(Integer.toHexString(mLastSystemUiFlags)); |
| 5309 | pw.print(" mResettingSystemUiFlags=0x"); |
| 5310 | pw.print(Integer.toHexString(mResettingSystemUiFlags)); |
| 5311 | pw.print(" mForceClearedSystemUiFlags=0x"); |
| 5312 | pw.println(Integer.toHexString(mForceClearedSystemUiFlags)); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5313 | } |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5314 | if (mLastFocusNeedsMenu) { |
| 5315 | pw.print(prefix); pw.print("mLastFocusNeedsMenu="); |
| 5316 | pw.println(mLastFocusNeedsMenu); |
| 5317 | } |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 5318 | pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5319 | pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); |
| 5320 | pw.print(" mDockMode="); pw.print(mDockMode); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5321 | pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); |
| 5322 | pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); |
| 5323 | pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); |
| 5324 | pw.print(" mUserRotation="); pw.print(mUserRotation); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 5325 | pw.print(" mAllowAllRotations="); pw.println(mAllowAllRotations); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5326 | pw.print(prefix); pw.print("mCurrentAppOrientation="); pw.println(mCurrentAppOrientation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5327 | pw.print(prefix); pw.print("mCarDockEnablesAccelerometer="); |
| 5328 | pw.print(mCarDockEnablesAccelerometer); |
| 5329 | pw.print(" mDeskDockEnablesAccelerometer="); |
| 5330 | pw.println(mDeskDockEnablesAccelerometer); |
| 5331 | pw.print(prefix); pw.print("mLidKeyboardAccessibility="); |
| 5332 | pw.print(mLidKeyboardAccessibility); |
| 5333 | pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5334 | pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep); |
| 5335 | pw.print(prefix); pw.print("mLongPressOnPowerBehavior="); |
| 5336 | pw.print(mLongPressOnPowerBehavior); |
| 5337 | pw.print(" mHasSoftInput="); pw.println(mHasSoftInput); |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 5338 | pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly); |
| 5339 | pw.print(" mScreenOnFully="); pw.print(mScreenOnFully); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5340 | pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 5341 | pw.print(prefix); pw.print("mOverscanScreen=("); pw.print(mOverscanScreenLeft); |
| 5342 | pw.print(","); pw.print(mOverscanScreenTop); |
| 5343 | pw.print(") "); pw.print(mOverscanScreenWidth); |
| 5344 | pw.print("x"); pw.println(mOverscanScreenHeight); |
| 5345 | if (mOverscanLeft != 0 || mOverscanTop != 0 |
| 5346 | || mOverscanRight != 0 || mOverscanBottom != 0) { |
| 5347 | pw.print(prefix); pw.print("mOverscan left="); pw.print(mOverscanLeft); |
| 5348 | pw.print(" top="); pw.print(mOverscanTop); |
| 5349 | pw.print(" right="); pw.print(mOverscanRight); |
| 5350 | pw.print(" bottom="); pw.println(mOverscanBottom); |
| 5351 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 5352 | pw.print(prefix); pw.print("mRestrictedOverscanScreen=("); |
| 5353 | pw.print(mRestrictedOverscanScreenLeft); |
| 5354 | pw.print(","); pw.print(mRestrictedOverscanScreenTop); |
| 5355 | pw.print(") "); pw.print(mRestrictedOverscanScreenWidth); |
| 5356 | pw.print("x"); pw.println(mRestrictedOverscanScreenHeight); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5357 | pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft); |
| 5358 | pw.print(","); pw.print(mUnrestrictedScreenTop); |
| 5359 | pw.print(") "); pw.print(mUnrestrictedScreenWidth); |
| 5360 | pw.print("x"); pw.println(mUnrestrictedScreenHeight); |
| 5361 | pw.print(prefix); pw.print("mRestrictedScreen=("); pw.print(mRestrictedScreenLeft); |
| 5362 | pw.print(","); pw.print(mRestrictedScreenTop); |
| 5363 | pw.print(") "); pw.print(mRestrictedScreenWidth); |
| 5364 | pw.print("x"); pw.println(mRestrictedScreenHeight); |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 5365 | pw.print(prefix); pw.print("mStableFullscreen=("); pw.print(mStableFullscreenLeft); |
| 5366 | pw.print(","); pw.print(mStableFullscreenTop); |
| 5367 | pw.print(")-("); pw.print(mStableFullscreenRight); |
| 5368 | pw.print(","); pw.print(mStableFullscreenBottom); pw.println(")"); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 5369 | pw.print(prefix); pw.print("mStable=("); pw.print(mStableLeft); |
| 5370 | pw.print(","); pw.print(mStableTop); |
| 5371 | pw.print(")-("); pw.print(mStableRight); |
| 5372 | pw.print(","); pw.print(mStableBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5373 | pw.print(prefix); pw.print("mSystem=("); pw.print(mSystemLeft); |
| 5374 | pw.print(","); pw.print(mSystemTop); |
| 5375 | pw.print(")-("); pw.print(mSystemRight); |
| 5376 | pw.print(","); pw.print(mSystemBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5377 | pw.print(prefix); pw.print("mCur=("); pw.print(mCurLeft); |
| 5378 | pw.print(","); pw.print(mCurTop); |
| 5379 | pw.print(")-("); pw.print(mCurRight); |
| 5380 | pw.print(","); pw.print(mCurBottom); pw.println(")"); |
| 5381 | pw.print(prefix); pw.print("mContent=("); pw.print(mContentLeft); |
| 5382 | pw.print(","); pw.print(mContentTop); |
| 5383 | pw.print(")-("); pw.print(mContentRight); |
| 5384 | pw.print(","); pw.print(mContentBottom); pw.println(")"); |
| 5385 | pw.print(prefix); pw.print("mDock=("); pw.print(mDockLeft); |
| 5386 | pw.print(","); pw.print(mDockTop); |
| 5387 | pw.print(")-("); pw.print(mDockRight); |
| 5388 | pw.print(","); pw.print(mDockBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5389 | pw.print(prefix); pw.print("mDockLayer="); pw.print(mDockLayer); |
| 5390 | pw.print(" mStatusBarLayer="); pw.println(mStatusBarLayer); |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5391 | pw.print(prefix); pw.print("mShowingLockscreen="); pw.print(mShowingLockscreen); |
| 5392 | pw.print(" mShowingDream="); pw.print(mShowingDream); |
| 5393 | pw.print(" mDreamingLockscreen="); pw.println(mDreamingLockscreen); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5394 | if (mLastInputMethodWindow != null) { |
| 5395 | pw.print(prefix); pw.print("mLastInputMethodWindow="); |
| 5396 | pw.println(mLastInputMethodWindow); |
| 5397 | } |
| 5398 | if (mLastInputMethodTargetWindow != null) { |
| 5399 | pw.print(prefix); pw.print("mLastInputMethodTargetWindow="); |
| 5400 | pw.println(mLastInputMethodTargetWindow); |
| 5401 | } |
| 5402 | if (mStatusBar != null) { |
| 5403 | pw.print(prefix); pw.print("mStatusBar="); |
| 5404 | pw.println(mStatusBar); |
| 5405 | } |
| 5406 | if (mNavigationBar != null) { |
| 5407 | pw.print(prefix); pw.print("mNavigationBar="); |
| 5408 | pw.println(mNavigationBar); |
| 5409 | } |
| 5410 | if (mKeyguard != null) { |
| 5411 | pw.print(prefix); pw.print("mKeyguard="); |
| 5412 | pw.println(mKeyguard); |
| 5413 | } |
| 5414 | if (mFocusedWindow != null) { |
| 5415 | pw.print(prefix); pw.print("mFocusedWindow="); |
| 5416 | pw.println(mFocusedWindow); |
| 5417 | } |
| 5418 | if (mFocusedApp != null) { |
| 5419 | pw.print(prefix); pw.print("mFocusedApp="); |
| 5420 | pw.println(mFocusedApp); |
| 5421 | } |
| 5422 | if (mWinDismissingKeyguard != null) { |
| 5423 | pw.print(prefix); pw.print("mWinDismissingKeyguard="); |
| 5424 | pw.println(mWinDismissingKeyguard); |
| 5425 | } |
| 5426 | if (mTopFullscreenOpaqueWindowState != null) { |
| 5427 | pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); |
| 5428 | pw.println(mTopFullscreenOpaqueWindowState); |
| 5429 | } |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5430 | if (mForcingShowNavBar) { |
| 5431 | pw.print(prefix); pw.print("mForcingShowNavBar="); |
| 5432 | pw.println(mForcingShowNavBar); pw.print( "mForcingShowNavBarLayer="); |
| 5433 | pw.println(mForcingShowNavBarLayer); |
| 5434 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5435 | pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5436 | pw.print(" mHideLockScreen="); pw.println(mHideLockScreen); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5437 | pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); |
| 5438 | pw.print(" mForceStatusBarFromKeyguard="); |
| 5439 | pw.println(mForceStatusBarFromKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5440 | pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 5441 | pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5442 | pw.print(" mHomePressed="); pw.println(mHomePressed); |
| 5443 | pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); |
| 5444 | pw.print(" mLockScreenTimeout="); pw.print(mLockScreenTimeout); |
| 5445 | pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive); |
| 5446 | pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior); |
| 5447 | pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior); |
| 5448 | pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior); |
| 5449 | pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation); |
| 5450 | pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); |
| 5451 | pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); |
| 5452 | pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 5453 | pw.print(prefix); pw.print("mDemoHdmiRotation="); pw.print(mDemoHdmiRotation); |
| 5454 | pw.print(" mDemoHdmiRotationLock="); pw.println(mDemoHdmiRotationLock); |
| 5455 | pw.print(prefix); pw.print("mUndockedHdmiRotation="); pw.println(mUndockedHdmiRotation); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5456 | mStatusBarController.dump(pw, prefix); |
| 5457 | mNavigationBarController.dump(pw, prefix); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5458 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5459 | } |