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; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 49 | import android.media.session.MediaSessionLegacyHelper; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 50 | import android.os.Bundle; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 51 | import android.os.FactoryTest; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 52 | import android.os.Handler; |
| 53 | import android.os.IBinder; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 54 | import android.os.IRemoteCallback; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 55 | import android.os.Looper; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 56 | import android.os.Message; |
| 57 | import android.os.Messenger; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 58 | import android.os.PowerManager; |
| 59 | import android.os.RemoteException; |
| 60 | import android.os.ServiceManager; |
| 61 | import android.os.SystemClock; |
| 62 | import android.os.SystemProperties; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 63 | import android.os.UEventObserver; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 64 | import android.os.UserHandle; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 65 | import android.os.Vibrator; |
| 66 | import android.provider.Settings; |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 67 | import android.service.dreams.DreamService; |
| 68 | import android.service.dreams.IDreamManager; |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 69 | import android.telephony.TelephonyManager; |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 70 | import android.util.DisplayMetrics; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 71 | import android.util.EventLog; |
| 72 | import android.util.Log; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 73 | import android.util.Slog; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 74 | import android.util.SparseArray; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 75 | import android.view.Display; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 76 | import android.view.Gravity; |
| 77 | import android.view.HapticFeedbackConstants; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 78 | import android.view.IApplicationToken; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 79 | import android.view.IWindowManager; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 80 | import android.view.InputChannel; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 81 | import android.view.InputDevice; |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 82 | import android.view.InputEvent; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 83 | import android.view.InputEventReceiver; |
Jeff Brown | 6b53e8d | 2010-11-10 16:03:06 -0800 | [diff] [blame] | 84 | import android.view.KeyCharacterMap; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 85 | import android.view.KeyCharacterMap.FallbackAction; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 86 | import android.view.KeyEvent; |
| 87 | import android.view.MotionEvent; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 88 | import android.view.Surface; |
| 89 | import android.view.View; |
| 90 | import android.view.ViewConfiguration; |
| 91 | import android.view.Window; |
| 92 | import android.view.WindowManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 93 | import android.view.WindowManagerGlobal; |
| 94 | import android.view.WindowManagerPolicy; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 95 | import android.view.accessibility.AccessibilityEvent; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 96 | import android.view.accessibility.AccessibilityManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 97 | import android.view.animation.Animation; |
| 98 | import android.view.animation.AnimationUtils; |
| 99 | |
| 100 | import com.android.internal.R; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 101 | import com.android.internal.policy.IKeyguardService; |
| 102 | import com.android.internal.policy.IKeyguardServiceConstants; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 103 | import com.android.internal.policy.PolicyManager; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 104 | import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 105 | import com.android.internal.statusbar.IStatusBarService; |
| 106 | import com.android.internal.telephony.ITelephony; |
| 107 | import com.android.internal.widget.PointerLocationView; |
| 108 | |
| 109 | import java.io.File; |
| 110 | import java.io.FileReader; |
| 111 | import java.io.IOException; |
| 112 | import java.io.PrintWriter; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 113 | import java.util.HashSet; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 114 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 115 | import static android.view.WindowManager.LayoutParams.*; |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 116 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; |
| 117 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; |
| 118 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 119 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 120 | /** |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 121 | * WindowManagerPolicy implementation for the Android phone UI. This |
| 122 | * introduces a new method suffix, Lp, for an internal lock of the |
| 123 | * PhoneWindowManager. This is used to protect some internal state, and |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 124 | * 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] | 125 | * of both of those when held. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 126 | */ |
| 127 | public class PhoneWindowManager implements WindowManagerPolicy { |
| 128 | static final String TAG = "WindowManager"; |
| 129 | static final boolean DEBUG = false; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 130 | static final boolean localLOGV = false; |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 131 | static final boolean DEBUG_LAYOUT = false; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 132 | static final boolean DEBUG_INPUT = false; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 133 | static final boolean DEBUG_STARTING_WINDOW = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 134 | static final boolean SHOW_STARTING_ANIMATIONS = true; |
| 135 | static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 136 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 137 | // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. |
| 138 | // No longer recommended for desk docks; still useful in car docks. |
| 139 | static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; |
| 140 | static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; |
| 141 | |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 142 | // Whether to use the new Session APIs |
| 143 | static final boolean USE_SESSIONS = true; |
| 144 | |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 145 | static final int SHORT_PRESS_POWER_NOTHING = 0; |
| 146 | static final int SHORT_PRESS_POWER_GO_TO_SLEEP = 1; |
| 147 | static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP = 2; |
| 148 | static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME = 3; |
| 149 | |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 150 | static final int LONG_PRESS_POWER_NOTHING = 0; |
| 151 | static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; |
| 152 | static final int LONG_PRESS_POWER_SHUT_OFF = 2; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 153 | static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 154 | |
| 155 | // These need to match the documentation/constant in |
| 156 | // core/res/res/values/config.xml |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 157 | static final int LONG_PRESS_HOME_NOTHING = 0; |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 158 | static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 159 | static final int LONG_PRESS_HOME_ASSIST = 2; |
| 160 | |
| 161 | static final int DOUBLE_TAP_HOME_NOTHING = 0; |
| 162 | static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 163 | |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 164 | static final int APPLICATION_MEDIA_SUBLAYER = -2; |
| 165 | static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 166 | static final int APPLICATION_PANEL_SUBLAYER = 1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 167 | static final int APPLICATION_SUB_PANEL_SUBLAYER = 2; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 168 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 169 | static public final String SYSTEM_DIALOG_REASON_KEY = "reason"; |
| 170 | static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions"; |
| 171 | static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 172 | static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 173 | static public final String SYSTEM_DIALOG_REASON_ASSIST = "assist"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 174 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 175 | /** |
| 176 | * These are the system UI flags that, when changing, can cause the layout |
| 177 | * of the screen to change. |
| 178 | */ |
| 179 | static final int SYSTEM_UI_CHANGING_LAYOUT = |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 180 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | 7f4820a | 2013-10-08 12:54:35 -0400 | [diff] [blame] | 181 | | View.SYSTEM_UI_FLAG_FULLSCREEN |
| 182 | | View.STATUS_BAR_TRANSLUCENT |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 183 | | View.NAVIGATION_BAR_TRANSLUCENT |
| 184 | | View.SYSTEM_UI_TRANSPARENT; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 185 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 186 | /** |
| 187 | * Keyguard stuff |
| 188 | */ |
| 189 | private WindowState mKeyguardScrim; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 190 | private boolean mKeyguardHidden; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 191 | private boolean mKeyguardDrawn; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 192 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 193 | /* Table of Application Launch keys. Maps from key codes to intent categories. |
| 194 | * |
| 195 | * These are special keys that are used to launch particular kinds of applications, |
| 196 | * such as a web browser. HID defines nearly a hundred of them in the Consumer (0x0C) |
| 197 | * usage page. We don't support quite that many yet... |
| 198 | */ |
| 199 | static SparseArray<String> sApplicationLaunchKeyCategories; |
| 200 | static { |
| 201 | sApplicationLaunchKeyCategories = new SparseArray<String>(); |
| 202 | sApplicationLaunchKeyCategories.append( |
| 203 | KeyEvent.KEYCODE_EXPLORER, Intent.CATEGORY_APP_BROWSER); |
| 204 | sApplicationLaunchKeyCategories.append( |
| 205 | KeyEvent.KEYCODE_ENVELOPE, Intent.CATEGORY_APP_EMAIL); |
| 206 | sApplicationLaunchKeyCategories.append( |
| 207 | KeyEvent.KEYCODE_CONTACTS, Intent.CATEGORY_APP_CONTACTS); |
| 208 | sApplicationLaunchKeyCategories.append( |
| 209 | KeyEvent.KEYCODE_CALENDAR, Intent.CATEGORY_APP_CALENDAR); |
| 210 | sApplicationLaunchKeyCategories.append( |
| 211 | KeyEvent.KEYCODE_MUSIC, Intent.CATEGORY_APP_MUSIC); |
| 212 | sApplicationLaunchKeyCategories.append( |
| 213 | KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); |
| 214 | } |
| 215 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 216 | /** |
| 217 | * Lock protecting internal state. Must not call out into window |
| 218 | * manager with lock held. (This lock will be acquired in places |
| 219 | * where the window manager is calling in with its own lock held.) |
| 220 | */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 221 | private final Object mLock = new Object(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 222 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 223 | Context mContext; |
| 224 | IWindowManager mWindowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 225 | WindowManagerFuncs mWindowManagerFuncs; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 226 | PowerManager mPowerManager; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 227 | IStatusBarService mStatusBarService; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 228 | boolean mPreloadedRecentApps; |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 229 | final Object mServiceAquireLock = new Object(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 230 | Vibrator mVibrator; // Vibrator for giving feedback of orientation changes |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 231 | SearchManager mSearchManager; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 232 | AccessibilityManager mAccessibilityManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 233 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 234 | // Vibrator pattern for haptic feedback of a long press. |
| 235 | long[] mLongPressVibePattern; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 236 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 237 | // Vibrator pattern for haptic feedback of virtual key press. |
| 238 | long[] mVirtualKeyVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 239 | |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 240 | // Vibrator pattern for a short vibration. |
| 241 | long[] mKeyboardTapVibePattern; |
| 242 | |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 243 | // Vibrator pattern for a short vibration when tapping on an hour/minute tick of a Clock. |
| 244 | long[] mClockTickVibePattern; |
| 245 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 246 | // Vibrator pattern for haptic feedback during boot when safe mode is disabled. |
| 247 | long[] mSafeModeDisabledVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 248 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 249 | // Vibrator pattern for haptic feedback during boot when safe mode is enabled. |
| 250 | long[] mSafeModeEnabledVibePattern; |
Romain Guy | 8154cd3 | 2010-03-29 14:41:15 -0700 | [diff] [blame] | 251 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 252 | /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */ |
| 253 | boolean mEnableShiftMenuBugReports = false; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 254 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 255 | boolean mSafeMode; |
| 256 | WindowState mStatusBar = null; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 257 | int mStatusBarHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 258 | WindowState mNavigationBar = null; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 259 | boolean mHasNavigationBar = false; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 260 | boolean mCanHideNavigationBar = false; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 261 | boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side? |
| 262 | boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*? |
| 263 | int[] mNavigationBarHeightForRotation = new int[4]; |
| 264 | int[] mNavigationBarWidthForRotation = new int[4]; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 265 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 266 | KeyguardServiceDelegate mKeyguardDelegate; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 267 | GlobalActions mGlobalActions; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 268 | volatile boolean mPowerKeyHandled; // accessed from input reader and handler thread |
| 269 | boolean mPendingPowerKeyUpCanceled; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 270 | Handler mHandler; |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 271 | WindowState mLastInputMethodWindow = null; |
| 272 | WindowState mLastInputMethodTargetWindow = null; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 273 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 274 | int mRecentAppsHeldModifiers; |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 275 | boolean mLanguageSwitchKeyPressed; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 276 | |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 277 | int mLidState = LID_ABSENT; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 278 | boolean mHaveBuiltInKeyboard; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 279 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 280 | boolean mSystemReady; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 281 | boolean mSystemBooted; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 282 | boolean mHdmiPlugged; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 283 | int mUiMode; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 284 | int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 285 | int mLidOpenRotation; |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 286 | int mCarDockRotation; |
| 287 | int mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 288 | int mUndockedHdmiRotation; |
| 289 | int mDemoHdmiRotation; |
| 290 | boolean mDemoHdmiRotationLock; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 291 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 292 | // Default display does not rotate, apps that require non-default orientation will have to |
| 293 | // have the orientation emulated. |
| 294 | private boolean mForceDefaultOrientation = false; |
| 295 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 296 | int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; |
| 297 | int mUserRotation = Surface.ROTATION_0; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 298 | boolean mAccelerometerDefault; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 299 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 300 | boolean mSupportAutoRotation; |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 301 | int mAllowAllRotations = -1; |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 302 | boolean mCarDockEnablesAccelerometer; |
| 303 | boolean mDeskDockEnablesAccelerometer; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 304 | int mLidKeyboardAccessibility; |
| 305 | int mLidNavigationAccessibility; |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 306 | boolean mLidControlsSleep; |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 307 | int mShortPressOnPowerBehavior = -1; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 308 | int mLongPressOnPowerBehavior = -1; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 309 | boolean mScreenOnEarly = false; |
| 310 | boolean mScreenOnFully = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 311 | boolean mOrientationSensorEnabled = false; |
| 312 | int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 313 | boolean mHasSoftInput = false; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 314 | boolean mTranslucentDecorEnabled = true; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 315 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 316 | int mPointerLocationMode = 0; // guarded by mLock |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 317 | |
| 318 | // The last window we were told about in focusChanged. |
| 319 | WindowState mFocusedWindow; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 320 | IApplicationToken mFocusedApp; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 321 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 322 | PointerLocationView mPointerLocationView; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 323 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 324 | // The current size of the screen; really; extends into the overscan area of |
| 325 | // the screen and doesn't account for any system elements like the status bar. |
| 326 | int mOverscanScreenLeft, mOverscanScreenTop; |
| 327 | int mOverscanScreenWidth, mOverscanScreenHeight; |
| 328 | // The current visible size of the screen; really; (ir)regardless of whether the status |
| 329 | // bar can be hidden but not extending into the overscan area. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 330 | int mUnrestrictedScreenLeft, mUnrestrictedScreenTop; |
| 331 | int mUnrestrictedScreenWidth, mUnrestrictedScreenHeight; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 332 | // Like mOverscanScreen*, but allowed to move into the overscan region where appropriate. |
| 333 | int mRestrictedOverscanScreenLeft, mRestrictedOverscanScreenTop; |
| 334 | int mRestrictedOverscanScreenWidth, mRestrictedOverscanScreenHeight; |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 335 | // The current size of the screen; these may be different than (0,0)-(dw,dh) |
| 336 | // if the status bar can't be hidden; in that case it effectively carves out |
| 337 | // that area of the display from all other windows. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 338 | int mRestrictedScreenLeft, mRestrictedScreenTop; |
| 339 | int mRestrictedScreenWidth, mRestrictedScreenHeight; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 340 | // During layout, the current screen borders accounting for any currently |
| 341 | // visible system UI elements. |
| 342 | int mSystemLeft, mSystemTop, mSystemRight, mSystemBottom; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 343 | // For applications requesting stable content insets, these are them. |
| 344 | int mStableLeft, mStableTop, mStableRight, mStableBottom; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 345 | // For applications requesting stable content insets but have also set the |
| 346 | // fullscreen window flag, these are the stable dimensions without the status bar. |
| 347 | int mStableFullscreenLeft, mStableFullscreenTop; |
| 348 | int mStableFullscreenRight, mStableFullscreenBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 349 | // During layout, the current screen borders with all outer decoration |
| 350 | // (status bar, input method dock) accounted for. |
| 351 | int mCurLeft, mCurTop, mCurRight, mCurBottom; |
| 352 | // During layout, the frame in which content should be displayed |
| 353 | // to the user, accounting for all screen decoration except for any |
| 354 | // space they deem as available for other content. This is usually |
| 355 | // the same as mCur*, but may be larger if the screen decor has supplied |
| 356 | // content insets. |
| 357 | int mContentLeft, mContentTop, mContentRight, mContentBottom; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 358 | // During layout, the frame in which voice content should be displayed |
| 359 | // to the user, accounting for all screen decoration except for any |
| 360 | // space they deem as available for other content. |
| 361 | int mVoiceContentLeft, mVoiceContentTop, mVoiceContentRight, mVoiceContentBottom; |
Dianne Hackborn | 8e11ef0 | 2010-11-18 19:47:42 -0800 | [diff] [blame] | 362 | // 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] | 363 | // windows are placed. |
| 364 | int mDockLeft, mDockTop, mDockRight, mDockBottom; |
| 365 | // During layout, the layer at which the doc window is placed. |
| 366 | int mDockLayer; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 367 | // During layout, this is the layer of the status bar. |
| 368 | int mStatusBarLayer; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 369 | int mLastSystemUiFlags; |
| 370 | // Bits that we are in the process of clearing, so we want to prevent |
| 371 | // them from being set by applications until everything has been updated |
| 372 | // to have them clear. |
| 373 | int mResettingSystemUiFlags = 0; |
| 374 | // Bits that we are currently always keeping cleared. |
| 375 | int mForceClearedSystemUiFlags = 0; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 376 | // What we last reported to system UI about whether the compatibility |
| 377 | // menu needs to be displayed. |
| 378 | boolean mLastFocusNeedsMenu = false; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 379 | |
| 380 | FakeWindow mHideNavFakeWindow = null; |
| 381 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 382 | static final Rect mTmpParentFrame = new Rect(); |
| 383 | static final Rect mTmpDisplayFrame = new Rect(); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 384 | static final Rect mTmpOverscanFrame = new Rect(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 385 | static final Rect mTmpContentFrame = new Rect(); |
| 386 | static final Rect mTmpVisibleFrame = new Rect(); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 387 | static final Rect mTmpDecorFrame = new Rect(); |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 388 | static final Rect mTmpNavigationFrame = new Rect(); |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 389 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 390 | WindowState mTopFullscreenOpaqueWindowState; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 391 | HashSet<IApplicationToken> mAppsToBeHidden = new HashSet<IApplicationToken>(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 392 | boolean mTopIsFullscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 393 | boolean mForceStatusBar; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 394 | boolean mForceStatusBarFromKeyguard; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 395 | boolean mHideLockScreen; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 396 | boolean mForcingShowNavBar; |
| 397 | int mForcingShowNavBarLayer; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 398 | |
| 399 | // States of keyguard dismiss. |
| 400 | private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed. |
| 401 | private static final int DISMISS_KEYGUARD_START = 1; // Keyguard needs to be dismissed. |
| 402 | private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed. |
| 403 | int mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
| 404 | |
| 405 | /** The window that is currently dismissing the keyguard. Dismissing the keyguard must only |
| 406 | * be done once per window. */ |
| 407 | private WindowState mWinDismissingKeyguard; |
| 408 | |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 409 | boolean mShowingLockscreen; |
| 410 | boolean mShowingDream; |
| 411 | boolean mDreamingLockscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 412 | boolean mHomePressed; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 413 | boolean mHomeConsumed; |
| 414 | boolean mHomeDoubleTapPending; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 415 | Intent mHomeIntent; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 416 | Intent mCarDockIntent; |
| 417 | Intent mDeskDockIntent; |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 418 | boolean mSearchKeyShortcutPending; |
| 419 | boolean mConsumeSearchKeyUp; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 420 | boolean mAssistKeyLongPressed; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 421 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 422 | // support for activating the lock screen while the screen is on |
| 423 | boolean mAllowLockscreenWhenOn; |
| 424 | int mLockScreenTimeout; |
| 425 | boolean mLockScreenTimerActive; |
| 426 | |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 427 | // 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] | 428 | int mEndcallBehavior; |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 429 | |
| 430 | // Behavior of POWER button while in-call and screen on. |
| 431 | // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) |
| 432 | int mIncallPowerBehavior; |
| 433 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 434 | Display mDisplay; |
| 435 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 436 | int mLandscapeRotation = 0; // default landscape rotation |
| 437 | int mSeascapeRotation = 0; // "other" landscape rotation, 180 degrees from mLandscapeRotation |
| 438 | int mPortraitRotation = 0; // default portrait rotation |
| 439 | int mUpsideDownRotation = 0; // "other" portrait rotation |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 440 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 441 | int mOverscanLeft = 0; |
| 442 | int mOverscanTop = 0; |
| 443 | int mOverscanRight = 0; |
| 444 | int mOverscanBottom = 0; |
| 445 | |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 446 | // What we do when the user long presses on home |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 447 | private int mLongPressOnHomeBehavior; |
| 448 | |
| 449 | // What we do when the user double-taps on home |
| 450 | private int mDoubleTapOnHomeBehavior; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 451 | |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 452 | // Screenshot trigger states |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 453 | // Time to volume and power must be pressed within this interval of each other. |
| 454 | private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150; |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 455 | // Increase the chord delay when taking a screenshot from the keyguard |
| 456 | private static final float KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER = 2.5f; |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 457 | private boolean mScreenshotChordEnabled; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 458 | private boolean mVolumeDownKeyTriggered; |
| 459 | private long mVolumeDownKeyTime; |
| 460 | private boolean mVolumeDownKeyConsumedByScreenshotChord; |
| 461 | private boolean mVolumeUpKeyTriggered; |
| 462 | private boolean mPowerKeyTriggered; |
| 463 | private long mPowerKeyTime; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 464 | |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 465 | /* The number of steps between min and max brightness */ |
| 466 | private static final int BRIGHTNESS_STEPS = 10; |
| 467 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 468 | SettingsObserver mSettingsObserver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 469 | ShortcutManager mShortcutManager; |
| 470 | PowerManager.WakeLock mBroadcastWakeLock; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 471 | boolean mHavePendingMediaKeyRepeatWithWakeLock; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 472 | |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 473 | private int mCurrentUserId; |
| 474 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 475 | // Maps global key codes to the components that will handle them. |
| 476 | private GlobalKeyManager mGlobalKeyManager; |
| 477 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 478 | // Fallback actions by key code. |
| 479 | private final SparseArray<KeyCharacterMap.FallbackAction> mFallbackActions = |
| 480 | new SparseArray<KeyCharacterMap.FallbackAction>(); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 481 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 482 | private static final int MSG_ENABLE_POINTER_LOCATION = 1; |
| 483 | private static final int MSG_DISABLE_POINTER_LOCATION = 2; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 484 | private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; |
| 485 | 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] | 486 | |
| 487 | private class PolicyHandler extends Handler { |
| 488 | @Override |
| 489 | public void handleMessage(Message msg) { |
| 490 | switch (msg.what) { |
| 491 | case MSG_ENABLE_POINTER_LOCATION: |
| 492 | enablePointerLocation(); |
| 493 | break; |
| 494 | case MSG_DISABLE_POINTER_LOCATION: |
| 495 | disablePointerLocation(); |
| 496 | break; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 497 | case MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK: |
| 498 | dispatchMediaKeyWithWakeLock((KeyEvent)msg.obj); |
| 499 | break; |
| 500 | case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK: |
| 501 | dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj); |
| 502 | break; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 503 | } |
| 504 | } |
| 505 | } |
| 506 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 507 | private UEventObserver mHDMIObserver = new UEventObserver() { |
| 508 | @Override |
| 509 | public void onUEvent(UEventObserver.UEvent event) { |
| 510 | setHdmiPlugged("1".equals(event.get("SWITCH_STATE"))); |
| 511 | } |
| 512 | }; |
| 513 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 514 | class SettingsObserver extends ContentObserver { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 515 | SettingsObserver(Handler handler) { |
| 516 | super(handler); |
| 517 | } |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 518 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 519 | void observe() { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 520 | // Observe all users' changes |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 521 | ContentResolver resolver = mContext.getContentResolver(); |
| 522 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 523 | Settings.System.END_BUTTON_BEHAVIOR), false, this, |
| 524 | UserHandle.USER_ALL); |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 525 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 526 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this, |
| 527 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 528 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 529 | Settings.System.ACCELEROMETER_ROTATION), false, this, |
| 530 | UserHandle.USER_ALL); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 531 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 532 | Settings.System.USER_ROTATION), false, this, |
| 533 | UserHandle.USER_ALL); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 534 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 535 | Settings.System.SCREEN_OFF_TIMEOUT), false, this, |
| 536 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 537 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 538 | Settings.System.POINTER_LOCATION), false, this, |
| 539 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 540 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 541 | Settings.Secure.DEFAULT_INPUT_METHOD), false, this, |
| 542 | UserHandle.USER_ALL); |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 543 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 544 | Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS), false, this, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 545 | UserHandle.USER_ALL); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 546 | resolver.registerContentObserver(Settings.Global.getUriFor( |
| 547 | Settings.Global.POLICY_CONTROL), false, this, |
| 548 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 549 | updateSettings(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | @Override public void onChange(boolean selfChange) { |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 553 | updateSettings(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 554 | updateRotation(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 555 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 556 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 557 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 558 | class MyOrientationListener extends WindowOrientationListener { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 559 | MyOrientationListener(Context context, Handler handler) { |
| 560 | super(context, handler); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 561 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 562 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 563 | @Override |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 564 | public void onProposedRotationChanged(int rotation) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 565 | if (localLOGV) Slog.v(TAG, "onProposedRotationChanged, rotation=" + rotation); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 566 | updateRotation(false); |
| 567 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 568 | } |
| 569 | MyOrientationListener mOrientationListener; |
| 570 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 571 | private final BarController mStatusBarController = new BarController("StatusBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 572 | View.STATUS_BAR_TRANSIENT, |
| 573 | View.STATUS_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 574 | View.STATUS_BAR_TRANSLUCENT, |
| 575 | StatusBarManager.WINDOW_STATUS_BAR, |
| 576 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 577 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 578 | private final BarController mNavigationBarController = new BarController("NavigationBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 579 | View.NAVIGATION_BAR_TRANSIENT, |
| 580 | View.NAVIGATION_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 581 | View.NAVIGATION_BAR_TRANSLUCENT, |
| 582 | StatusBarManager.WINDOW_NAVIGATION_BAR, |
| 583 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 584 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 585 | private ImmersiveModeConfirmation mImmersiveModeConfirmation; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 586 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 587 | private SystemGesturesPointerEventListener mSystemGestures; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 588 | |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 589 | IStatusBarService getStatusBarService() { |
| 590 | synchronized (mServiceAquireLock) { |
| 591 | if (mStatusBarService == null) { |
| 592 | mStatusBarService = IStatusBarService.Stub.asInterface( |
| 593 | ServiceManager.getService("statusbar")); |
| 594 | } |
| 595 | return mStatusBarService; |
| 596 | } |
| 597 | } |
| 598 | |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 599 | /* |
| 600 | * We always let the sensor be switched on by default except when |
| 601 | * the user has explicitly disabled sensor based rotation or when the |
| 602 | * screen is switched off. |
| 603 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 604 | boolean needSensorRunningLp() { |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 605 | if (mSupportAutoRotation) { |
| 606 | if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 607 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 608 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT |
| 609 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { |
| 610 | // If the application has explicitly requested to follow the |
| 611 | // orientation, then we need to turn the sensor on. |
| 612 | return true; |
| 613 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 614 | } |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 615 | if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 616 | (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 617 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 618 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK))) { |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 619 | // enable accelerometer if we are docked in a dock that enables accelerometer |
| 620 | // orientation management, |
| 621 | return true; |
| 622 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 623 | if (mUserRotationMode == USER_ROTATION_LOCKED) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 624 | // If the setting for using the sensor by default is enabled, then |
| 625 | // we will always leave it on. Note that the user could go to |
| 626 | // a window that forces an orientation that does not use the |
| 627 | // sensor and in theory we could turn it off... however, when next |
| 628 | // turning it on we won't have a good value for the current |
| 629 | // orientation for a little bit, which can cause orientation |
| 630 | // changes to lag, so we'd like to keep it always on. (It will |
| 631 | // still be turned off when the screen is off.) |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 632 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 633 | } |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 634 | return mSupportAutoRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 635 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 636 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 637 | /* |
| 638 | * Various use cases for invoking this function |
| 639 | * screen turning off, should always disable listeners if already enabled |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 640 | * 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] | 641 | * if not already enabled |
| 642 | * screen turned on and current app does not have sensor orientation, disable listeners if |
| 643 | * already enabled |
| 644 | * screen turning on and current app has sensor based orientation, enable listeners if needed |
| 645 | * screen turning on and current app has nosensor based orientation, do nothing |
| 646 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 647 | void updateOrientationListenerLp() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 648 | if (!mOrientationListener.canDetectOrientation()) { |
| 649 | // If sensor is turned off or nonexistent for some reason |
| 650 | return; |
| 651 | } |
| 652 | //Could have been invoked due to screen turning on or off or |
| 653 | //change of the currently visible window's orientation |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 654 | if (localLOGV) Slog.v(TAG, "Screen status="+mScreenOnEarly+ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 655 | ", current orientation="+mCurrentAppOrientation+ |
| 656 | ", SensorEnabled="+mOrientationSensorEnabled); |
| 657 | boolean disable = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 658 | if (mScreenOnEarly) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 659 | if (needSensorRunningLp()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 660 | disable = false; |
| 661 | //enable listener if not already enabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 662 | if (!mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 663 | mOrientationListener.enable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 664 | if(localLOGV) Slog.v(TAG, "Enabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 665 | mOrientationSensorEnabled = true; |
| 666 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 667 | } |
| 668 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 669 | //check if sensors need to be disabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 670 | if (disable && mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 671 | mOrientationListener.disable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 672 | if(localLOGV) Slog.v(TAG, "Disabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 673 | mOrientationSensorEnabled = false; |
| 674 | } |
| 675 | } |
| 676 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 677 | private void interceptPowerKeyDown(boolean handled) { |
| 678 | mPowerKeyHandled = handled; |
| 679 | if (!handled) { |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 680 | mHandler.postDelayed(mPowerLongPress, |
| 681 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 682 | } |
| 683 | } |
| 684 | |
| 685 | private boolean interceptPowerKeyUp(boolean canceled) { |
| 686 | if (!mPowerKeyHandled) { |
| 687 | mHandler.removeCallbacks(mPowerLongPress); |
| 688 | return !canceled; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 689 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 690 | return false; |
| 691 | } |
| 692 | |
| 693 | private void cancelPendingPowerKeyAction() { |
| 694 | if (!mPowerKeyHandled) { |
| 695 | mHandler.removeCallbacks(mPowerLongPress); |
| 696 | } |
Jeff Brown | ff20471 | 2011-10-25 21:27:54 -0700 | [diff] [blame] | 697 | if (mPowerKeyTriggered) { |
| 698 | mPendingPowerKeyUpCanceled = true; |
| 699 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | private void interceptScreenshotChord() { |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 703 | if (mScreenshotChordEnabled |
| 704 | && mVolumeDownKeyTriggered && mPowerKeyTriggered && !mVolumeUpKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 705 | final long now = SystemClock.uptimeMillis(); |
| 706 | if (now <= mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS |
| 707 | && now <= mPowerKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) { |
| 708 | mVolumeDownKeyConsumedByScreenshotChord = true; |
| 709 | cancelPendingPowerKeyAction(); |
| 710 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 711 | mHandler.postDelayed(mScreenshotRunnable, getScreenshotChordLongPressDelay()); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 712 | } |
| 713 | } |
| 714 | } |
| 715 | |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 716 | private long getScreenshotChordLongPressDelay() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 717 | if (mKeyguardDelegate.isShowing()) { |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 718 | // Double the time it takes to take a screenshot from the keyguard |
| 719 | return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER * |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 720 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 721 | } |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 722 | return ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout(); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 723 | } |
| 724 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 725 | private void cancelPendingScreenshotChordAction() { |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 726 | mHandler.removeCallbacks(mScreenshotRunnable); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 727 | } |
| 728 | |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 729 | private void powerShortPress(long eventTime) { |
| 730 | if (mShortPressOnPowerBehavior < 0) { |
| 731 | mShortPressOnPowerBehavior = mContext.getResources().getInteger( |
| 732 | com.android.internal.R.integer.config_shortPressOnPowerBehavior); |
| 733 | } |
| 734 | |
| 735 | switch (mShortPressOnPowerBehavior) { |
| 736 | case SHORT_PRESS_POWER_NOTHING: |
| 737 | break; |
| 738 | case SHORT_PRESS_POWER_GO_TO_SLEEP: |
| 739 | mPowerManager.goToSleep(eventTime, |
| 740 | PowerManager.GO_TO_SLEEP_REASON_USER, 0); |
| 741 | break; |
| 742 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP: |
| 743 | mPowerManager.goToSleep(eventTime, |
| 744 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 745 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 746 | break; |
| 747 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME: |
| 748 | mPowerManager.goToSleep(eventTime, |
| 749 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 750 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 751 | launchHomeFromHotKey(); |
| 752 | break; |
| 753 | } |
| 754 | } |
| 755 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 756 | private final Runnable mPowerLongPress = new Runnable() { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 757 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 758 | public void run() { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 759 | // The context isn't read |
| 760 | if (mLongPressOnPowerBehavior < 0) { |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 761 | mLongPressOnPowerBehavior = mContext.getResources().getInteger( |
| 762 | com.android.internal.R.integer.config_longPressOnPowerBehavior); |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 763 | } |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 764 | int resolvedBehavior = mLongPressOnPowerBehavior; |
| 765 | if (FactoryTest.isLongPressOnPowerOffEnabled()) { |
| 766 | resolvedBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM; |
| 767 | } |
| 768 | |
| 769 | switch (resolvedBehavior) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 770 | case LONG_PRESS_POWER_NOTHING: |
| 771 | break; |
| 772 | case LONG_PRESS_POWER_GLOBAL_ACTIONS: |
| 773 | mPowerKeyHandled = true; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 774 | if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) { |
| 775 | performAuditoryFeedbackForAccessibilityIfNeed(); |
| 776 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 777 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
| 778 | showGlobalActionsDialog(); |
| 779 | break; |
| 780 | case LONG_PRESS_POWER_SHUT_OFF: |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 781 | case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM: |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 782 | mPowerKeyHandled = true; |
| 783 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 784 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 785 | mWindowManagerFuncs.shutdown(resolvedBehavior == LONG_PRESS_POWER_SHUT_OFF); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 786 | break; |
| 787 | } |
| 788 | } |
| 789 | }; |
| 790 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 791 | private final Runnable mScreenshotRunnable = new Runnable() { |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 792 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 793 | public void run() { |
| 794 | takeScreenshot(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 795 | } |
| 796 | }; |
| 797 | |
| 798 | void showGlobalActionsDialog() { |
| 799 | if (mGlobalActions == null) { |
Jeff Brown | 7304c34 | 2012-05-11 18:42:42 -0700 | [diff] [blame] | 800 | mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 801 | } |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 802 | final boolean keyguardShowing = keyguardIsShowingTq(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 803 | mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); |
| 804 | if (keyguardShowing) { |
| 805 | // since it took two seconds of long press to bring this up, |
| 806 | // 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] | 807 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 808 | } |
| 809 | } |
| 810 | |
| 811 | boolean isDeviceProvisioned() { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 812 | return Settings.Global.getInt( |
| 813 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 814 | } |
| 815 | |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 816 | boolean isUserSetupComplete() { |
| 817 | return Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 818 | Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; |
| 819 | } |
| 820 | |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 821 | private void handleLongPressOnHome() { |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 822 | if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 823 | mHomeConsumed = true; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 824 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 825 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 826 | if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) { |
| 827 | toggleRecentApps(); |
| 828 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_ASSIST) { |
| 829 | launchAssistAction(); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 830 | } |
| 831 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 832 | } |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 833 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 834 | private void handleDoubleTapOnHome() { |
| 835 | if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 836 | mHomeConsumed = true; |
| 837 | toggleRecentApps(); |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable() { |
| 842 | @Override |
| 843 | public void run() { |
| 844 | if (mHomeDoubleTapPending) { |
| 845 | mHomeDoubleTapPending = false; |
| 846 | launchHomeFromHotKey(); |
| 847 | } |
| 848 | } |
| 849 | }; |
| 850 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 851 | /** {@inheritDoc} */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 852 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 853 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 854 | WindowManagerFuncs windowManagerFuncs) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 855 | mContext = context; |
| 856 | mWindowManager = windowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 857 | mWindowManagerFuncs = windowManagerFuncs; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 858 | mHandler = new PolicyHandler(); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 859 | mOrientationListener = new MyOrientationListener(mContext, mHandler); |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 860 | try { |
| 861 | mOrientationListener.setCurrentRotation(windowManager.getRotation()); |
| 862 | } catch (RemoteException ex) { } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 863 | mSettingsObserver = new SettingsObserver(mHandler); |
| 864 | mSettingsObserver.observe(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 865 | mShortcutManager = new ShortcutManager(context, mHandler); |
| 866 | mShortcutManager.observe(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 867 | mUiMode = context.getResources().getInteger( |
| 868 | com.android.internal.R.integer.config_defaultUiModeType); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 869 | mHomeIntent = new Intent(Intent.ACTION_MAIN, null); |
| 870 | mHomeIntent.addCategory(Intent.CATEGORY_HOME); |
| 871 | mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 872 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 873 | mCarDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 874 | mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK); |
| 875 | mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 876 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 877 | mDeskDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 878 | mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK); |
| 879 | mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 880 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 881 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 882 | mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 883 | mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 884 | "PhoneWindowManager.mBroadcastWakeLock"); |
| 885 | mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 886 | mSupportAutoRotation = mContext.getResources().getBoolean( |
| 887 | com.android.internal.R.bool.config_supportAutoRotation); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 888 | mLidOpenRotation = readRotation( |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 889 | com.android.internal.R.integer.config_lidOpenRotation); |
| 890 | mCarDockRotation = readRotation( |
| 891 | com.android.internal.R.integer.config_carDockRotation); |
| 892 | mDeskDockRotation = readRotation( |
| 893 | com.android.internal.R.integer.config_deskDockRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 894 | mUndockedHdmiRotation = readRotation( |
| 895 | com.android.internal.R.integer.config_undockedHdmiRotation); |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 896 | mCarDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 897 | com.android.internal.R.bool.config_carDockEnablesAccelerometer); |
| 898 | mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 899 | com.android.internal.R.bool.config_deskDockEnablesAccelerometer); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 900 | mLidKeyboardAccessibility = mContext.getResources().getInteger( |
| 901 | com.android.internal.R.integer.config_lidKeyboardAccessibility); |
| 902 | mLidNavigationAccessibility = mContext.getResources().getInteger( |
| 903 | com.android.internal.R.integer.config_lidNavigationAccessibility); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 904 | mLidControlsSleep = mContext.getResources().getBoolean( |
| 905 | com.android.internal.R.bool.config_lidControlsSleep); |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 906 | mTranslucentDecorEnabled = mContext.getResources().getBoolean( |
| 907 | com.android.internal.R.bool.config_enableTranslucentDecor); |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 908 | readConfigurationDependentBehaviors(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 909 | |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 910 | mAccessibilityManager = (AccessibilityManager) context.getSystemService( |
| 911 | Context.ACCESSIBILITY_SERVICE); |
| 912 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 913 | // register for dock events |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 914 | IntentFilter filter = new IntentFilter(); |
| 915 | filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); |
| 916 | filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE); |
| 917 | filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); |
| 918 | filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 919 | filter.addAction(Intent.ACTION_DOCK_EVENT); |
| 920 | Intent intent = context.registerReceiver(mDockReceiver, filter); |
| 921 | if (intent != null) { |
| 922 | // Retrieve current sticky dock event broadcast. |
| 923 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 924 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 925 | } |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 926 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 927 | // register for dream-related broadcasts |
| 928 | filter = new IntentFilter(); |
| 929 | filter.addAction(Intent.ACTION_DREAMING_STARTED); |
| 930 | filter.addAction(Intent.ACTION_DREAMING_STOPPED); |
| 931 | context.registerReceiver(mDreamReceiver, filter); |
| 932 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 933 | // register for multiuser-relevant broadcasts |
| 934 | filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); |
| 935 | context.registerReceiver(mMultiuserReceiver, filter); |
| 936 | |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 937 | // monitor for system gestures |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 938 | mSystemGestures = new SystemGesturesPointerEventListener(context, |
| 939 | new SystemGesturesPointerEventListener.Callbacks() { |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 940 | @Override |
| 941 | public void onSwipeFromTop() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 942 | if (mStatusBar != null) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 943 | requestTransientBars(mStatusBar); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 944 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 945 | } |
| 946 | @Override |
| 947 | public void onSwipeFromBottom() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 948 | if (mNavigationBar != null && mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 949 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 950 | } |
| 951 | } |
| 952 | @Override |
| 953 | public void onSwipeFromRight() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 954 | if (mNavigationBar != null && !mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 955 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 956 | } |
| 957 | } |
| 958 | @Override |
| 959 | public void onDebug() { |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 960 | // no-op |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 961 | } |
| 962 | }); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 963 | mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 964 | mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 965 | |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 966 | mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 967 | mLongPressVibePattern = getLongIntArray(mContext.getResources(), |
| 968 | com.android.internal.R.array.config_longPressVibePattern); |
| 969 | mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(), |
| 970 | com.android.internal.R.array.config_virtualKeyVibePattern); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 971 | mKeyboardTapVibePattern = getLongIntArray(mContext.getResources(), |
| 972 | com.android.internal.R.array.config_keyboardTapVibePattern); |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 973 | mClockTickVibePattern = getLongIntArray(mContext.getResources(), |
| 974 | com.android.internal.R.array.config_clockTickVibePattern); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 975 | mSafeModeDisabledVibePattern = getLongIntArray(mContext.getResources(), |
| 976 | com.android.internal.R.array.config_safeModeDisabledVibePattern); |
| 977 | mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), |
| 978 | com.android.internal.R.array.config_safeModeEnabledVibePattern); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 979 | |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 980 | mScreenshotChordEnabled = mContext.getResources().getBoolean( |
| 981 | com.android.internal.R.bool.config_enableScreenshotChord); |
| 982 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 983 | mGlobalKeyManager = new GlobalKeyManager(mContext); |
| 984 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 985 | // Controls rotation and the like. |
| 986 | initializeHdmiState(); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 987 | |
| 988 | // Match current screen state. |
Jeff Brown | 26c6a50 | 2014-04-11 02:15:54 -0700 | [diff] [blame] | 989 | if (mPowerManager.isInteractive()) { |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 990 | wakingUp(null); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 991 | } else { |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 992 | goingToSleep(WindowManagerPolicy.OFF_BECAUSE_OF_USER); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 993 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 994 | } |
| 995 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 996 | /** |
| 997 | * Read values from config.xml that may be overridden depending on |
| 998 | * the configuration of the device. |
| 999 | * eg. Disable long press on home goes to recents on sw600dp. |
| 1000 | */ |
| 1001 | private void readConfigurationDependentBehaviors() { |
| 1002 | mLongPressOnHomeBehavior = mContext.getResources().getInteger( |
| 1003 | com.android.internal.R.integer.config_longPressOnHomeBehavior); |
| 1004 | if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING || |
| 1005 | mLongPressOnHomeBehavior > LONG_PRESS_HOME_ASSIST) { |
| 1006 | mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1007 | } |
| 1008 | |
| 1009 | mDoubleTapOnHomeBehavior = mContext.getResources().getInteger( |
| 1010 | com.android.internal.R.integer.config_doubleTapOnHomeBehavior); |
| 1011 | if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING || |
| 1012 | mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 1013 | mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1014 | } |
| 1015 | } |
| 1016 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1017 | @Override |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1018 | public void setInitialDisplaySize(Display display, int width, int height, int density) { |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 1019 | // This method might be called before the policy has been fully initialized |
| 1020 | // or for other displays we don't care about. |
| 1021 | if (mContext == null || display.getDisplayId() != Display.DEFAULT_DISPLAY) { |
| 1022 | return; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1023 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1024 | mDisplay = display; |
| 1025 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1026 | final Resources res = mContext.getResources(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1027 | int shortSize, longSize; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1028 | if (width > height) { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1029 | shortSize = height; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1030 | longSize = width; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1031 | mLandscapeRotation = Surface.ROTATION_0; |
| 1032 | mSeascapeRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1033 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1034 | mPortraitRotation = Surface.ROTATION_90; |
| 1035 | mUpsideDownRotation = Surface.ROTATION_270; |
| 1036 | } else { |
| 1037 | mPortraitRotation = Surface.ROTATION_270; |
| 1038 | mUpsideDownRotation = Surface.ROTATION_90; |
| 1039 | } |
| 1040 | } else { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1041 | shortSize = width; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1042 | longSize = height; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1043 | mPortraitRotation = Surface.ROTATION_0; |
| 1044 | mUpsideDownRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1045 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1046 | mLandscapeRotation = Surface.ROTATION_270; |
| 1047 | mSeascapeRotation = Surface.ROTATION_90; |
| 1048 | } else { |
| 1049 | mLandscapeRotation = Surface.ROTATION_90; |
| 1050 | mSeascapeRotation = Surface.ROTATION_270; |
| 1051 | } |
| 1052 | } |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1053 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1054 | mStatusBarHeight = |
| 1055 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1056 | |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1057 | // Height of the navigation bar when presented horizontally at bottom |
| 1058 | mNavigationBarHeightForRotation[mPortraitRotation] = |
| 1059 | mNavigationBarHeightForRotation[mUpsideDownRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1060 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1061 | mNavigationBarHeightForRotation[mLandscapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1062 | mNavigationBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize( |
| 1063 | com.android.internal.R.dimen.navigation_bar_height_landscape); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1064 | |
| 1065 | // Width of the navigation bar when presented vertically along one side |
| 1066 | mNavigationBarWidthForRotation[mPortraitRotation] = |
| 1067 | mNavigationBarWidthForRotation[mUpsideDownRotation] = |
| 1068 | mNavigationBarWidthForRotation[mLandscapeRotation] = |
| 1069 | mNavigationBarWidthForRotation[mSeascapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1070 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1071 | |
| 1072 | // SystemUI (status bar) layout policy |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1073 | int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1074 | int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1075 | |
Craig Mautner | d4ec3324 | 2013-07-22 10:37:43 -0700 | [diff] [blame] | 1076 | // Allow the navigation bar to move on small devices (phones). |
| 1077 | mNavigationBarCanMove = shortSizeDp < 600; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1078 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1079 | mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1080 | // Allow a system property to override this. Used by the emulator. |
| 1081 | // See also hasNavigationBar(). |
| 1082 | String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); |
| 1083 | if ("1".equals(navBarOverride)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1084 | mHasNavigationBar = false; |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1085 | } else if ("0".equals(navBarOverride)) { |
| 1086 | mHasNavigationBar = true; |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1087 | } |
| 1088 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 1089 | // For demo purposes, allow the rotation of the HDMI display to be controlled. |
| 1090 | // By default, HDMI locks rotation to landscape. |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1091 | if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1092 | mDemoHdmiRotation = mPortraitRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1093 | } else { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1094 | mDemoHdmiRotation = mLandscapeRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1095 | } |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1096 | mDemoHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1097 | |
| 1098 | // Only force the default orientation if the screen is xlarge, at least 960dp x 720dp, per |
| 1099 | // http://developer.android.com/guide/practices/screens_support.html#range |
| 1100 | mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 && |
| 1101 | res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) && |
| 1102 | // For debug purposes the next line turns this feature off with: |
| 1103 | // $ adb shell setprop config.override_forced_orient true |
| 1104 | // $ adb shell wm size reset |
| 1105 | !"true".equals(SystemProperties.get("config.override_forced_orient")); |
| 1106 | } |
| 1107 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1108 | /** |
| 1109 | * @return whether the navigation bar can be hidden, e.g. the device has a |
| 1110 | * navigation bar and touch exploration is not enabled |
| 1111 | */ |
| 1112 | private boolean canHideNavigationBar() { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 1113 | return mHasNavigationBar |
| 1114 | && !mAccessibilityManager.isTouchExplorationEnabled(); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1115 | } |
| 1116 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1117 | @Override |
| 1118 | public boolean isDefaultOrientationForced() { |
| 1119 | return mForceDefaultOrientation; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1120 | } |
| 1121 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1122 | @Override |
| 1123 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom) { |
| 1124 | if (display.getDisplayId() == Display.DEFAULT_DISPLAY) { |
| 1125 | mOverscanLeft = left; |
| 1126 | mOverscanTop = top; |
| 1127 | mOverscanRight = right; |
| 1128 | mOverscanBottom = bottom; |
| 1129 | } |
| 1130 | } |
| 1131 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1132 | public void updateSettings() { |
| 1133 | ContentResolver resolver = mContext.getContentResolver(); |
| 1134 | boolean updateRotation = false; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1135 | synchronized (mLock) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1136 | mEndcallBehavior = Settings.System.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1137 | Settings.System.END_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1138 | Settings.System.END_BUTTON_BEHAVIOR_DEFAULT, |
| 1139 | UserHandle.USER_CURRENT); |
| 1140 | mIncallPowerBehavior = Settings.Secure.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1141 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1142 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT, |
| 1143 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1144 | |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1145 | // Configure rotation lock. |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1146 | int userRotation = Settings.System.getIntForUser(resolver, |
| 1147 | Settings.System.USER_ROTATION, Surface.ROTATION_0, |
| 1148 | UserHandle.USER_CURRENT); |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1149 | if (mUserRotation != userRotation) { |
| 1150 | mUserRotation = userRotation; |
| 1151 | updateRotation = true; |
| 1152 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1153 | int userRotationMode = Settings.System.getIntForUser(resolver, |
| 1154 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1155 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 1156 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
| 1157 | if (mUserRotationMode != userRotationMode) { |
| 1158 | mUserRotationMode = userRotationMode; |
| 1159 | updateRotation = true; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1160 | updateOrientationListenerLp(); |
| 1161 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1162 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1163 | if (mSystemReady) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1164 | int pointerLocation = Settings.System.getIntForUser(resolver, |
| 1165 | Settings.System.POINTER_LOCATION, 0, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1166 | if (mPointerLocationMode != pointerLocation) { |
| 1167 | mPointerLocationMode = pointerLocation; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1168 | mHandler.sendEmptyMessage(pointerLocation != 0 ? |
| 1169 | MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1170 | } |
| 1171 | } |
| 1172 | // use screen off timeout setting as the timeout for the lockscreen |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1173 | mLockScreenTimeout = Settings.System.getIntForUser(resolver, |
| 1174 | Settings.System.SCREEN_OFF_TIMEOUT, 0, UserHandle.USER_CURRENT); |
| 1175 | String imId = Settings.Secure.getStringForUser(resolver, |
| 1176 | Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1177 | boolean hasSoftInput = imId != null && imId.length() > 0; |
| 1178 | if (mHasSoftInput != hasSoftInput) { |
| 1179 | mHasSoftInput = hasSoftInput; |
| 1180 | updateRotation = true; |
| 1181 | } |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1182 | if (mImmersiveModeConfirmation != null) { |
John Spurlock | 4355a53 | 2014-02-19 09:49:25 -0500 | [diff] [blame] | 1183 | mImmersiveModeConfirmation.loadSetting(mCurrentUserId); |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1184 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 1185 | PolicyControl.reloadFromSetting(mContext); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1186 | } |
| 1187 | if (updateRotation) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1188 | updateRotation(true); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1189 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1190 | } |
| 1191 | |
| 1192 | private void enablePointerLocation() { |
| 1193 | if (mPointerLocationView == null) { |
| 1194 | mPointerLocationView = new PointerLocationView(mContext); |
| 1195 | mPointerLocationView.setPrintCoords(false); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1196 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 1197 | WindowManager.LayoutParams.MATCH_PARENT, |
| 1198 | WindowManager.LayoutParams.MATCH_PARENT); |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1199 | lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1200 | lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
| 1201 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
| 1202 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1203 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
Jeff Brown | 90fc905 | 2012-10-01 14:44:24 -0700 | [diff] [blame] | 1204 | if (ActivityManager.isHighEndGfx()) { |
| 1205 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1206 | lp.privateFlags |= |
| 1207 | WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; |
| 1208 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1209 | lp.format = PixelFormat.TRANSLUCENT; |
| 1210 | lp.setTitle("PointerLocation"); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1211 | WindowManager wm = (WindowManager) |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1212 | mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1213 | lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1214 | wm.addView(mPointerLocationView, lp); |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1215 | mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView); |
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() { |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1220 | if (mPointerLocationView != null) { |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1221 | mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView); |
| 1222 | WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1223 | wm.removeView(mPointerLocationView); |
| 1224 | mPointerLocationView = null; |
| 1225 | } |
| 1226 | } |
| 1227 | |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1228 | private int readRotation(int resID) { |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1229 | try { |
| 1230 | int rotation = mContext.getResources().getInteger(resID); |
| 1231 | switch (rotation) { |
| 1232 | case 0: |
| 1233 | return Surface.ROTATION_0; |
| 1234 | case 90: |
| 1235 | return Surface.ROTATION_90; |
| 1236 | case 180: |
| 1237 | return Surface.ROTATION_180; |
| 1238 | case 270: |
| 1239 | return Surface.ROTATION_270; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1240 | } |
| 1241 | } catch (Resources.NotFoundException e) { |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1242 | // fall through |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1243 | } |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1244 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1245 | } |
| 1246 | |
| 1247 | /** {@inheritDoc} */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1248 | @Override |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1249 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1250 | int type = attrs.type; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1251 | |
| 1252 | outAppOp[0] = AppOpsManager.OP_NONE; |
| 1253 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1254 | if (type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW |
| 1255 | || type > WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1256 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1257 | } |
| 1258 | String permission = null; |
| 1259 | switch (type) { |
| 1260 | case TYPE_TOAST: |
| 1261 | // XXX right now the app process has complete control over |
| 1262 | // this... should introduce a token to let the system |
| 1263 | // monitor/control what they are doing. |
| 1264 | break; |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 1265 | case TYPE_DREAM: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1266 | case TYPE_INPUT_METHOD: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1267 | case TYPE_WALLPAPER: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1268 | case TYPE_PRIVATE_PRESENTATION: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1269 | case TYPE_VOICE_INTERACTION: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1270 | // The window manager will check these. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1271 | break; |
| 1272 | case TYPE_PHONE: |
| 1273 | case TYPE_PRIORITY_PHONE: |
| 1274 | case TYPE_SYSTEM_ALERT: |
| 1275 | case TYPE_SYSTEM_ERROR: |
| 1276 | case TYPE_SYSTEM_OVERLAY: |
| 1277 | permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1278 | outAppOp[0] = AppOpsManager.OP_SYSTEM_ALERT_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1279 | break; |
| 1280 | default: |
| 1281 | permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; |
| 1282 | } |
| 1283 | if (permission != null) { |
| 1284 | if (mContext.checkCallingOrSelfPermission(permission) |
| 1285 | != PackageManager.PERMISSION_GRANTED) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1286 | return WindowManagerGlobal.ADD_PERMISSION_DENIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1287 | } |
| 1288 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1289 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1290 | } |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1291 | |
| 1292 | @Override |
| 1293 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs) { |
| 1294 | |
| 1295 | // If this switch statement is modified, modify the comment in the declarations of |
| 1296 | // the type in {@link WindowManager.LayoutParams} as well. |
| 1297 | switch (attrs.type) { |
| 1298 | default: |
| 1299 | // These are the windows that by default are shown only to the user that created |
| 1300 | // them. If this needs to be overridden, set |
| 1301 | // {@link WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS} in |
| 1302 | // {@link WindowManager.LayoutParams}. Note that permission |
| 1303 | // {@link android.Manifest.permission.INTERNAL_SYSTEM_WINDOW} is required as well. |
| 1304 | if ((attrs.privateFlags & PRIVATE_FLAG_SHOW_FOR_ALL_USERS) == 0) { |
| 1305 | return true; |
| 1306 | } |
| 1307 | break; |
| 1308 | |
| 1309 | // These are the windows that by default are shown to all users. However, to |
| 1310 | // protect against spoofing, check permissions below. |
| 1311 | case TYPE_APPLICATION_STARTING: |
| 1312 | case TYPE_BOOT_PROGRESS: |
| 1313 | case TYPE_DISPLAY_OVERLAY: |
| 1314 | case TYPE_HIDDEN_NAV_CONSUMER: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1315 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1316 | case TYPE_KEYGUARD_DIALOG: |
| 1317 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1318 | case TYPE_NAVIGATION_BAR: |
| 1319 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1320 | case TYPE_PHONE: |
| 1321 | case TYPE_POINTER: |
| 1322 | case TYPE_PRIORITY_PHONE: |
| 1323 | case TYPE_RECENTS_OVERLAY: |
| 1324 | case TYPE_SEARCH_BAR: |
| 1325 | case TYPE_STATUS_BAR: |
| 1326 | case TYPE_STATUS_BAR_PANEL: |
| 1327 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1328 | case TYPE_SYSTEM_DIALOG: |
| 1329 | case TYPE_UNIVERSE_BACKGROUND: |
| 1330 | case TYPE_VOLUME_OVERLAY: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1331 | case TYPE_PRIVATE_PRESENTATION: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1332 | break; |
| 1333 | } |
| 1334 | |
| 1335 | // Check if third party app has set window to system window type. |
| 1336 | return mContext.checkCallingOrSelfPermission( |
| 1337 | android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) |
| 1338 | != PackageManager.PERMISSION_GRANTED; |
| 1339 | } |
| 1340 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1341 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1342 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) { |
| 1343 | switch (attrs.type) { |
| 1344 | case TYPE_SYSTEM_OVERLAY: |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1345 | case TYPE_SECURE_SYSTEM_OVERLAY: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1346 | // These types of windows can't receive input events. |
| 1347 | attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1348 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1349 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1350 | break; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1351 | case TYPE_STATUS_BAR: |
| 1352 | |
| 1353 | // If the Keyguard is in a hidden state (occluded by another window), we force to |
| 1354 | // remove the wallpaper and keyguard flag so that any change in-flight after setting |
| 1355 | // the keyguard as occluded wouldn't set these flags again. |
| 1356 | // See {@link #processKeyguardSetHiddenResultLw}. |
| 1357 | if (mKeyguardHidden) { |
| 1358 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 1359 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 1360 | } |
| 1361 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1362 | } |
Adrian Roos | 3850211 | 2014-04-09 21:04:11 +0200 | [diff] [blame] | 1363 | |
| 1364 | if (attrs.type != TYPE_STATUS_BAR) { |
| 1365 | // The status bar is the only window allowed to exhibit keyguard behavior. |
| 1366 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 1367 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1368 | |
| 1369 | if (ActivityManager.isHighEndGfx() |
| 1370 | && (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) { |
| 1371 | attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
| 1372 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 1373 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; |
| 1374 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1375 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1376 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1377 | void readLidState() { |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 1378 | mLidState = mWindowManagerFuncs.getLidState(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1379 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1380 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1381 | private boolean isHidden(int accessibilityMode) { |
| 1382 | switch (accessibilityMode) { |
| 1383 | case 1: |
| 1384 | return mLidState == LID_CLOSED; |
| 1385 | case 2: |
| 1386 | return mLidState == LID_OPEN; |
| 1387 | default: |
| 1388 | return false; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1389 | } |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1390 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1391 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1392 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1393 | @Override |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1394 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 1395 | int navigationPresence) { |
| 1396 | mHaveBuiltInKeyboard = (keyboardPresence & PRESENCE_INTERNAL) != 0; |
| 1397 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1398 | readConfigurationDependentBehaviors(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1399 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1400 | applyLidSwitchState(); |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1401 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1402 | if (config.keyboard == Configuration.KEYBOARD_NOKEYS |
| 1403 | || (keyboardPresence == PRESENCE_INTERNAL |
| 1404 | && isHidden(mLidKeyboardAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1405 | config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1406 | if (!mHasSoftInput) { |
| 1407 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; |
| 1408 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1409 | } |
| 1410 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1411 | if (config.navigation == Configuration.NAVIGATION_NONAV |
| 1412 | || (navigationPresence == PRESENCE_INTERNAL |
| 1413 | && isHidden(mLidNavigationAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1414 | config.navigationHidden = Configuration.NAVIGATIONHIDDEN_YES; |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1415 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1416 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1417 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1418 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1419 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1420 | public int windowTypeToLayerLw(int type) { |
| 1421 | if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1422 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1423 | } |
| 1424 | switch (type) { |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1425 | case TYPE_UNIVERSE_BACKGROUND: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1426 | return 1; |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1427 | case TYPE_PRIVATE_PRESENTATION: |
| 1428 | return 2; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1429 | case TYPE_WALLPAPER: |
| 1430 | // wallpaper is at the bottom, though the window manager may move it. |
| 1431 | return 2; |
| 1432 | case TYPE_PHONE: |
| 1433 | return 3; |
| 1434 | case TYPE_SEARCH_BAR: |
| 1435 | return 4; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1436 | case TYPE_VOICE_INTERACTION: |
| 1437 | // voice interaction layer is almost immediately above apps. |
| 1438 | return 5; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1439 | case TYPE_RECENTS_OVERLAY: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1440 | case TYPE_SYSTEM_DIALOG: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1441 | return 6; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1442 | case TYPE_TOAST: |
| 1443 | // toasts and the plugged-in battery thing |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1444 | return 7; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1445 | case TYPE_PRIORITY_PHONE: |
| 1446 | // SIM errors and unlock. Not sure if this really should be in a high layer. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1447 | return 8; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1448 | case TYPE_DREAM: |
| 1449 | // used for Dreams (screensavers with TYPE_DREAM windows) |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1450 | return 9; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1451 | case TYPE_SYSTEM_ALERT: |
| 1452 | // like the ANR / app crashed dialogs |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1453 | return 10; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1454 | case TYPE_INPUT_METHOD: |
| 1455 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1456 | return 11; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1457 | case TYPE_INPUT_METHOD_DIALOG: |
| 1458 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1459 | return 12; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1460 | case TYPE_KEYGUARD_SCRIM: |
| 1461 | // the safety window that shows behind keyguard while keyguard is starting |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1462 | return 13; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1463 | case TYPE_STATUS_BAR_SUB_PANEL: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1464 | return 14; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1465 | case TYPE_STATUS_BAR: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1466 | return 15; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1467 | case TYPE_STATUS_BAR_PANEL: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1468 | return 16; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1469 | case TYPE_KEYGUARD_DIALOG: |
| 1470 | return 17; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1471 | case TYPE_VOLUME_OVERLAY: |
| 1472 | // the on-screen volume indicator and controller shown when the user |
| 1473 | // changes the device volume |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1474 | return 18; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1475 | case TYPE_SYSTEM_OVERLAY: |
| 1476 | // the on-screen volume indicator and controller shown when the user |
| 1477 | // changes the device volume |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1478 | return 19; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1479 | case TYPE_NAVIGATION_BAR: |
| 1480 | // the navigation bar, if available, shows atop most things |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1481 | return 20; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1482 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1483 | // some panels (e.g. search) need to show on top of the navigation bar |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1484 | return 21; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1485 | case TYPE_SYSTEM_ERROR: |
| 1486 | // system-level error dialogs |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1487 | return 22; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1488 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1489 | // used to highlight the magnified portion of a display |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1490 | return 23; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1491 | case TYPE_DISPLAY_OVERLAY: |
| 1492 | // used to simulate secondary display devices |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1493 | return 24; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1494 | case TYPE_DRAG: |
| 1495 | // the drag layer: input for drag-and-drop is associated with this window, |
| 1496 | // which sits above all other focusable windows |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1497 | return 25; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1498 | case TYPE_SECURE_SYSTEM_OVERLAY: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1499 | return 26; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1500 | case TYPE_BOOT_PROGRESS: |
| 1501 | return 27; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1502 | case TYPE_POINTER: |
| 1503 | // the (mouse) pointer layer |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1504 | return 28; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1505 | case TYPE_HIDDEN_NAV_CONSUMER: |
| 1506 | return 29; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1507 | } |
| 1508 | Log.e(TAG, "Unknown window type: " + type); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1509 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1510 | } |
| 1511 | |
| 1512 | /** {@inheritDoc} */ |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1513 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1514 | public int subWindowTypeToLayerLw(int type) { |
| 1515 | switch (type) { |
| 1516 | case TYPE_APPLICATION_PANEL: |
| 1517 | case TYPE_APPLICATION_ATTACHED_DIALOG: |
| 1518 | return APPLICATION_PANEL_SUBLAYER; |
| 1519 | case TYPE_APPLICATION_MEDIA: |
| 1520 | return APPLICATION_MEDIA_SUBLAYER; |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 1521 | case TYPE_APPLICATION_MEDIA_OVERLAY: |
| 1522 | return APPLICATION_MEDIA_OVERLAY_SUBLAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1523 | case TYPE_APPLICATION_SUB_PANEL: |
| 1524 | return APPLICATION_SUB_PANEL_SUBLAYER; |
| 1525 | } |
| 1526 | Log.e(TAG, "Unknown sub-window type: " + type); |
| 1527 | return 0; |
| 1528 | } |
| 1529 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1530 | @Override |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1531 | public int getMaxWallpaperLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1532 | return windowTypeToLayerLw(TYPE_STATUS_BAR); |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1533 | } |
| 1534 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1535 | @Override |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1536 | public int getAboveUniverseLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1537 | return windowTypeToLayerLw(TYPE_SYSTEM_ERROR); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1538 | } |
| 1539 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1540 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1541 | if (mHasNavigationBar) { |
| 1542 | // For a basic navigation bar, when we are in landscape mode we place |
| 1543 | // the navigation bar to the side. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1544 | if (mNavigationBarCanMove && fullWidth > fullHeight) { |
| 1545 | return fullWidth - mNavigationBarWidthForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1546 | } |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1547 | } |
| 1548 | return fullWidth; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1549 | } |
| 1550 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1551 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1552 | if (mHasNavigationBar) { |
| 1553 | // For a basic navigation bar, when we are in portrait mode we place |
| 1554 | // the navigation bar to the bottom. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1555 | if (!mNavigationBarCanMove || fullWidth < fullHeight) { |
| 1556 | return fullHeight - mNavigationBarHeightForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1557 | } |
| 1558 | } |
| 1559 | return fullHeight; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1560 | } |
| 1561 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1562 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
| 1563 | return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1564 | } |
| 1565 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1566 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1567 | // There is a separate status bar at the top of the display. We don't count that as part |
| 1568 | // 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] | 1569 | // we do want to exclude it since applications can't generally use that part |
| 1570 | // of the screen. |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1571 | return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation) - mStatusBarHeight; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1572 | } |
| 1573 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1574 | @Override |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1575 | public boolean doesForceHide(WindowManager.LayoutParams attrs) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1576 | return (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1577 | } |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1578 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1579 | @Override |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1580 | public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs) { |
| 1581 | return attrs.type == TYPE_STATUS_BAR; |
| 1582 | } |
| 1583 | |
| 1584 | @Override |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1585 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs) { |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1586 | switch (attrs.type) { |
| 1587 | case TYPE_STATUS_BAR: |
| 1588 | case TYPE_NAVIGATION_BAR: |
| 1589 | case TYPE_WALLPAPER: |
| 1590 | case TYPE_DREAM: |
| 1591 | case TYPE_UNIVERSE_BACKGROUND: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1592 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1593 | return false; |
| 1594 | default: |
| 1595 | return true; |
| 1596 | } |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1597 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1598 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1599 | /** {@inheritDoc} */ |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1600 | @Override |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1601 | public View addStartingWindow(IBinder appToken, String packageName, int theme, |
| 1602 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1603 | int icon, int logo, int windowFlags) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1604 | if (!SHOW_STARTING_ANIMATIONS) { |
| 1605 | return null; |
| 1606 | } |
| 1607 | if (packageName == null) { |
| 1608 | return null; |
| 1609 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1610 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1611 | WindowManager wm = null; |
| 1612 | View view = null; |
| 1613 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1614 | try { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1615 | Context context = mContext; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1616 | if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow " + packageName |
| 1617 | + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" |
| 1618 | + Integer.toHexString(theme)); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1619 | if (theme != context.getThemeResId() || labelRes != 0) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1620 | try { |
| 1621 | context = context.createPackageContext(packageName, 0); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1622 | context.setTheme(theme); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1623 | } catch (PackageManager.NameNotFoundException e) { |
| 1624 | // Ignore |
| 1625 | } |
| 1626 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1627 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1628 | Window win = PolicyManager.makeNewWindow(context); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1629 | final TypedArray ta = win.getWindowStyle(); |
| 1630 | if (ta.getBoolean( |
| 1631 | com.android.internal.R.styleable.Window_windowDisablePreview, false) |
| 1632 | || ta.getBoolean( |
| 1633 | com.android.internal.R.styleable.Window_windowShowWallpaper,false)) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1634 | return null; |
| 1635 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1636 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1637 | Resources r = context.getResources(); |
| 1638 | win.setTitle(r.getText(labelRes, nonLocalizedLabel)); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1639 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1640 | win.setType( |
| 1641 | WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); |
| 1642 | // Force the window flags: this is a fake window, so it is not really |
| 1643 | // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM |
| 1644 | // flag because we do know that the next window will take input |
| 1645 | // focus, so we want to get the IME window up on top of us right away. |
| 1646 | win.setFlags( |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1647 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1648 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1649 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1650 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1651 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1652 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1653 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1654 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1655 | |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1656 | win.setDefaultIcon(icon); |
| 1657 | win.setDefaultLogo(logo); |
| 1658 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1659 | win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1660 | WindowManager.LayoutParams.MATCH_PARENT); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1661 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1662 | final WindowManager.LayoutParams params = win.getAttributes(); |
| 1663 | params.token = appToken; |
| 1664 | params.packageName = packageName; |
| 1665 | params.windowAnimations = win.getWindowStyle().getResourceId( |
| 1666 | com.android.internal.R.styleable.Window_windowAnimationStyle, 0); |
Dianne Hackborn | 5d927c2 | 2011-09-02 12:22:18 -0700 | [diff] [blame] | 1667 | params.privateFlags |= |
| 1668 | WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1669 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1670 | |
| 1671 | if (!compatInfo.supportsScreen()) { |
| 1672 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; |
| 1673 | } |
| 1674 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1675 | params.setTitle("Starting " + packageName); |
| 1676 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1677 | wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
| 1678 | view = win.getDecorView(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1679 | |
| 1680 | if (win.isFloating()) { |
| 1681 | // Whoops, there is no way to display an animation/preview |
| 1682 | // of such a thing! After all that work... let's skip it. |
| 1683 | // (Note that we must do this here because it is in |
| 1684 | // getDecorView() where the theme is evaluated... maybe |
| 1685 | // we should peek the floating attribute from the theme |
| 1686 | // earlier.) |
| 1687 | return null; |
| 1688 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1689 | |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1690 | if (DEBUG_STARTING_WINDOW) Slog.d( |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1691 | TAG, "Adding starting window for " + packageName |
| 1692 | + " / " + appToken + ": " |
| 1693 | + (view.getParent() != null ? view : null)); |
| 1694 | |
| 1695 | wm.addView(view, params); |
| 1696 | |
| 1697 | // Only return the view if it was successfully added to the |
| 1698 | // window manager... which we can tell by it having a parent. |
| 1699 | return view.getParent() != null ? view : null; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1700 | } catch (WindowManager.BadTokenException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1701 | // ignore |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 1702 | Log.w(TAG, appToken + " already running, starting window not displayed. " + |
| 1703 | e.getMessage()); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1704 | } catch (RuntimeException e) { |
| 1705 | // don't crash if something else bad happens, for example a |
| 1706 | // failure loading resources because we are loading from an app |
| 1707 | // on external storage that has been unmounted. |
| 1708 | Log.w(TAG, appToken + " failed creating starting window", e); |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1709 | } finally { |
| 1710 | if (view != null && view.getParent() == null) { |
| 1711 | Log.w(TAG, "view not successfully added to wm, removing view"); |
| 1712 | wm.removeViewImmediate(view); |
| 1713 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1714 | } |
| 1715 | |
| 1716 | return null; |
| 1717 | } |
| 1718 | |
| 1719 | /** {@inheritDoc} */ |
| 1720 | public void removeStartingWindow(IBinder appToken, View window) { |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1721 | if (DEBUG_STARTING_WINDOW) { |
| 1722 | RuntimeException e = new RuntimeException("here"); |
| 1723 | e.fillInStackTrace(); |
| 1724 | Log.v(TAG, "Removing starting window for " + appToken + ": " + window, e); |
| 1725 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1726 | |
| 1727 | if (window != null) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1728 | WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1729 | wm.removeView(window); |
| 1730 | } |
| 1731 | } |
| 1732 | |
| 1733 | /** |
| 1734 | * Preflight adding a window to the system. |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1735 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1736 | * Currently enforces that three window types are singletons: |
| 1737 | * <ul> |
| 1738 | * <li>STATUS_BAR_TYPE</li> |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1739 | * <li>KEYGUARD_TYPE</li> |
| 1740 | * </ul> |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1741 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1742 | * @param win The window to be added |
| 1743 | * @param attrs Information about the window to be added |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1744 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1745 | * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, |
| 1746 | * WindowManagerImpl.ADD_MULTIPLE_SINGLETON |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1747 | */ |
| 1748 | public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) { |
| 1749 | switch (attrs.type) { |
| 1750 | case TYPE_STATUS_BAR: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1751 | mContext.enforceCallingOrSelfPermission( |
| 1752 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1753 | "PhoneWindowManager"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1754 | if (mStatusBar != null) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1755 | if (mStatusBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1756 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1757 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1758 | } |
| 1759 | mStatusBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1760 | mStatusBarController.setWindow(win); |
John Spurlock | 8fdfe62 | 2014-05-21 17:10:10 -0400 | [diff] [blame] | 1761 | mKeyguardDelegate.hideScrim(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1762 | break; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1763 | case TYPE_NAVIGATION_BAR: |
| 1764 | mContext.enforceCallingOrSelfPermission( |
| 1765 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1766 | "PhoneWindowManager"); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1767 | if (mNavigationBar != null) { |
| 1768 | if (mNavigationBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1769 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1770 | } |
| 1771 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1772 | mNavigationBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1773 | mNavigationBarController.setWindow(win); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 1774 | if (DEBUG_LAYOUT) Slog.i(TAG, "NAVIGATION BAR: " + mNavigationBar); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1775 | break; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1776 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1777 | mContext.enforceCallingOrSelfPermission( |
| 1778 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1779 | "PhoneWindowManager"); |
| 1780 | break; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1781 | case TYPE_STATUS_BAR_PANEL: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1782 | mContext.enforceCallingOrSelfPermission( |
| 1783 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1784 | "PhoneWindowManager"); |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1785 | break; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1786 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1787 | mContext.enforceCallingOrSelfPermission( |
| 1788 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1789 | "PhoneWindowManager"); |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1790 | break; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1791 | case TYPE_KEYGUARD_SCRIM: |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1792 | if (mKeyguardScrim != null) { |
| 1793 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
| 1794 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1795 | mKeyguardScrim = win; |
| 1796 | break; |
| 1797 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1798 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1799 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1800 | } |
| 1801 | |
| 1802 | /** {@inheritDoc} */ |
| 1803 | public void removeWindowLw(WindowState win) { |
| 1804 | if (mStatusBar == win) { |
| 1805 | mStatusBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1806 | mStatusBarController.setWindow(null); |
Jim Miller | c0b676d | 2013-03-22 16:11:08 -0700 | [diff] [blame] | 1807 | mKeyguardDelegate.showScrim(); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1808 | } else if (mKeyguardScrim == win) { |
| 1809 | Log.v(TAG, "Removing keyguard scrim"); |
| 1810 | mKeyguardScrim = null; |
| 1811 | } if (mNavigationBar == win) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1812 | mNavigationBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1813 | mNavigationBarController.setWindow(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1814 | } |
| 1815 | } |
| 1816 | |
| 1817 | static final boolean PRINT_ANIM = false; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1818 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1819 | /** {@inheritDoc} */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1820 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1821 | public int selectAnimationLw(WindowState win, int transit) { |
| 1822 | if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win |
| 1823 | + ": transit=" + transit); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1824 | if (win == mStatusBar) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1825 | boolean isKeyguard = (win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1826 | if (transit == TRANSIT_EXIT |
| 1827 | || transit == TRANSIT_HIDE) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1828 | return isKeyguard ? -1 : R.anim.dock_top_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1829 | } else if (transit == TRANSIT_ENTER |
| 1830 | || transit == TRANSIT_SHOW) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1831 | return isKeyguard ? -1 : R.anim.dock_top_enter; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1832 | } |
| 1833 | } else if (win == mNavigationBar) { |
| 1834 | // This can be on either the bottom or the right. |
| 1835 | if (mNavigationBarOnBottom) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1836 | if (transit == TRANSIT_EXIT |
| 1837 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1838 | return R.anim.dock_bottom_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1839 | } else if (transit == TRANSIT_ENTER |
| 1840 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1841 | return R.anim.dock_bottom_enter; |
| 1842 | } |
| 1843 | } else { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1844 | if (transit == TRANSIT_EXIT |
| 1845 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1846 | return R.anim.dock_right_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1847 | } else if (transit == TRANSIT_ENTER |
| 1848 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1849 | return R.anim.dock_right_enter; |
| 1850 | } |
| 1851 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1852 | } |
| 1853 | |
| 1854 | if (transit == TRANSIT_PREVIEW_DONE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1855 | if (win.hasAppShownWindows()) { |
| 1856 | if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT"); |
| 1857 | return com.android.internal.R.anim.app_starting_exit; |
| 1858 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 1859 | } else if (win.getAttrs().type == TYPE_DREAM && mDreamingLockscreen |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1860 | && transit == TRANSIT_ENTER) { |
| 1861 | // Special case: we are animating in a dream, while the keyguard |
| 1862 | // is shown. We don't want an animation on the dream, because |
| 1863 | // we need it shown immediately with the keyguard animating away |
| 1864 | // to reveal it. |
| 1865 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1866 | } |
| 1867 | |
| 1868 | return 0; |
| 1869 | } |
| 1870 | |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1871 | @Override |
| 1872 | public void selectRotationAnimationLw(int anim[]) { |
| 1873 | if (PRINT_ANIM) Slog.i(TAG, "selectRotationAnimation mTopFullscreen=" |
| 1874 | + mTopFullscreenOpaqueWindowState + " rotationAnimation=" |
| 1875 | + (mTopFullscreenOpaqueWindowState == null ? |
| 1876 | "0" : mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation)); |
| 1877 | if (mTopFullscreenOpaqueWindowState != null && mTopIsFullscreen) { |
| 1878 | switch (mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation) { |
| 1879 | case ROTATION_ANIMATION_CROSSFADE: |
| 1880 | anim[0] = R.anim.rotation_animation_xfade_exit; |
| 1881 | anim[1] = R.anim.rotation_animation_enter; |
| 1882 | break; |
| 1883 | case ROTATION_ANIMATION_JUMPCUT: |
| 1884 | anim[0] = R.anim.rotation_animation_jump_exit; |
| 1885 | anim[1] = R.anim.rotation_animation_enter; |
| 1886 | break; |
| 1887 | case ROTATION_ANIMATION_ROTATE: |
| 1888 | default: |
| 1889 | anim[0] = anim[1] = 0; |
| 1890 | break; |
| 1891 | } |
| 1892 | } else { |
| 1893 | anim[0] = anim[1] = 0; |
| 1894 | } |
| 1895 | } |
| 1896 | |
| 1897 | @Override |
| 1898 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 1899 | boolean forceDefault) { |
| 1900 | switch (exitAnimId) { |
| 1901 | case R.anim.rotation_animation_xfade_exit: |
| 1902 | case R.anim.rotation_animation_jump_exit: |
| 1903 | // These are the only cases that matter. |
| 1904 | if (forceDefault) { |
| 1905 | return false; |
| 1906 | } |
| 1907 | int anim[] = new int[2]; |
| 1908 | selectRotationAnimationLw(anim); |
| 1909 | return (exitAnimId == anim[0] && enterAnimId == anim[1]); |
| 1910 | default: |
| 1911 | return true; |
| 1912 | } |
| 1913 | } |
| 1914 | |
| 1915 | @Override |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 1916 | public Animation createForceHideEnterAnimation(boolean onWallpaper) { |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1917 | return AnimationUtils.loadAnimation(mContext, |
| 1918 | com.android.internal.R.anim.lock_screen_behind_enter); |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1919 | } |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 1920 | |
| 1921 | private static void awakenDreams() { |
| 1922 | IDreamManager dreamManager = getDreamManager(); |
| 1923 | if (dreamManager != null) { |
| 1924 | try { |
| 1925 | dreamManager.awaken(); |
| 1926 | } catch (RemoteException e) { |
| 1927 | // fine, stay asleep then |
| 1928 | } |
| 1929 | } |
| 1930 | } |
| 1931 | |
| 1932 | static IDreamManager getDreamManager() { |
| 1933 | return IDreamManager.Stub.asInterface( |
| 1934 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
| 1935 | } |
| 1936 | |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 1937 | TelephonyManager getTelephonyService() { |
| 1938 | return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1939 | } |
| 1940 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1941 | static IAudioService getAudioService() { |
| 1942 | IAudioService audioService = IAudioService.Stub.asInterface( |
| 1943 | ServiceManager.checkService(Context.AUDIO_SERVICE)); |
| 1944 | if (audioService == null) { |
| 1945 | Log.w(TAG, "Unable to find IAudioService interface."); |
| 1946 | } |
| 1947 | return audioService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1948 | } |
| 1949 | |
| 1950 | boolean keyguardOn() { |
| 1951 | return keyguardIsShowingTq() || inKeyguardRestrictedKeyInputMode(); |
| 1952 | } |
| 1953 | |
| 1954 | private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { |
| 1955 | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, |
| 1956 | WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, |
| 1957 | }; |
| 1958 | |
| 1959 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1960 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1961 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1962 | final boolean keyguardOn = keyguardOn(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1963 | final int keyCode = event.getKeyCode(); |
| 1964 | final int repeatCount = event.getRepeatCount(); |
| 1965 | final int metaState = event.getMetaState(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1966 | final int flags = event.getFlags(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1967 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 1968 | final boolean canceled = event.isCanceled(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1969 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 1970 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1971 | Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount=" |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 1972 | + repeatCount + " keyguardOn=" + keyguardOn + " mHomePressed=" + mHomePressed |
| 1973 | + " canceled=" + canceled); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1974 | } |
| 1975 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1976 | // If we think we might have a volume down & power key chord on the way |
| 1977 | // but we're not sure, then tell the dispatcher to wait a little while and |
| 1978 | // try again later before dispatching. |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1979 | if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1980 | if (mVolumeDownKeyTriggered && !mPowerKeyTriggered) { |
| 1981 | final long now = SystemClock.uptimeMillis(); |
| 1982 | final long timeoutTime = mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS; |
| 1983 | if (now < timeoutTime) { |
| 1984 | return timeoutTime - now; |
| 1985 | } |
| 1986 | } |
| 1987 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN |
| 1988 | && mVolumeDownKeyConsumedByScreenshotChord) { |
| 1989 | if (!down) { |
| 1990 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 1991 | } |
| 1992 | return -1; |
| 1993 | } |
| 1994 | } |
| 1995 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1996 | // First we always handle the home key here, so applications |
| 1997 | // can never break it, although if keyguard is on, we do let |
| 1998 | // it handle it, because that gives us the correct 5 second |
| 1999 | // timeout. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2000 | if (keyCode == KeyEvent.KEYCODE_HOME) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2001 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2002 | // If we have released the home key, and didn't do anything else |
| 2003 | // while it was pressed, then it is time to go home! |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2004 | if (!down) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2005 | cancelPreloadRecentApps(); |
| 2006 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2007 | mHomePressed = false; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2008 | if (mHomeConsumed) { |
| 2009 | mHomeConsumed = false; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2010 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2011 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2012 | |
| 2013 | if (canceled) { |
| 2014 | Log.i(TAG, "Ignoring HOME; event canceled."); |
| 2015 | return -1; |
| 2016 | } |
| 2017 | |
| 2018 | // If an incoming call is ringing, HOME is totally disabled. |
| 2019 | // (The user is already on the InCallScreen at this point, |
| 2020 | // and his ONLY options are to answer or reject the call.) |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 2021 | TelephonyManager telephonyManager = getTelephonyService(); |
| 2022 | if (telephonyManager != null && telephonyManager.isRinging()) { |
| 2023 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); |
| 2024 | return -1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2025 | } |
| 2026 | |
| 2027 | // Delay handling home if a double-tap is possible. |
| 2028 | if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) { |
| 2029 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case |
| 2030 | mHomeDoubleTapPending = true; |
| 2031 | mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable, |
| 2032 | ViewConfiguration.getDoubleTapTimeout()); |
| 2033 | return -1; |
| 2034 | } |
| 2035 | |
| 2036 | // Go home! |
| 2037 | launchHomeFromHotKey(); |
| 2038 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2039 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2040 | |
| 2041 | // If a system window has focus, then it doesn't make sense |
| 2042 | // right now to interact with applications. |
| 2043 | WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null; |
| 2044 | if (attrs != null) { |
| 2045 | final int type = attrs.type; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2046 | if (type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM |
| 2047 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG |
| 2048 | || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2049 | // the "app" is keyguard, so give it the key |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2050 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2051 | } |
| 2052 | final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length; |
| 2053 | for (int i=0; i<typeCount; i++) { |
| 2054 | if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) { |
| 2055 | // 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] | 2056 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2057 | } |
| 2058 | } |
| 2059 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2060 | |
| 2061 | // Remember that home is pressed and handle special actions. |
| 2062 | if (repeatCount == 0) { |
| 2063 | mHomePressed = true; |
| 2064 | if (mHomeDoubleTapPending) { |
| 2065 | mHomeDoubleTapPending = false; |
| 2066 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); |
| 2067 | handleDoubleTapOnHome(); |
| 2068 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI |
| 2069 | || mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 2070 | preloadRecentApps(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2071 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2072 | } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { |
| 2073 | if (!keyguardOn) { |
| 2074 | handleLongPressOnHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2075 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2076 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2077 | return -1; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2078 | } else if (keyCode == KeyEvent.KEYCODE_MENU) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2079 | // Hijack modified menu keys for debugging features |
| 2080 | final int chordBug = KeyEvent.META_SHIFT_ON; |
| 2081 | |
| 2082 | if (down && repeatCount == 0) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2083 | if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2084 | Intent intent = new Intent(Intent.ACTION_BUG_REPORT); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2085 | mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, |
| 2086 | null, null, null, 0, null, null); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2087 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2088 | } else if (SHOW_PROCESSES_ON_ALT_MENU && |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2089 | (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2090 | Intent service = new Intent(); |
| 2091 | service.setClassName(mContext, "com.android.server.LoadAverageService"); |
| 2092 | ContentResolver res = mContext.getContentResolver(); |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2093 | boolean shown = Settings.Global.getInt( |
| 2094 | res, Settings.Global.SHOW_PROCESSES, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2095 | if (!shown) { |
| 2096 | mContext.startService(service); |
| 2097 | } else { |
| 2098 | mContext.stopService(service); |
| 2099 | } |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2100 | Settings.Global.putInt( |
| 2101 | res, Settings.Global.SHOW_PROCESSES, shown ? 0 : 1); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2102 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2103 | } |
| 2104 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2105 | } else if (keyCode == KeyEvent.KEYCODE_SEARCH) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2106 | if (down) { |
| 2107 | if (repeatCount == 0) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2108 | mSearchKeyShortcutPending = true; |
| 2109 | mConsumeSearchKeyUp = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2110 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2111 | } else { |
| 2112 | mSearchKeyShortcutPending = false; |
| 2113 | if (mConsumeSearchKeyUp) { |
| 2114 | mConsumeSearchKeyUp = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2115 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2116 | } |
| 2117 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2118 | return 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2119 | } else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) { |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2120 | if (!keyguardOn) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2121 | if (down && repeatCount == 0) { |
| 2122 | preloadRecentApps(); |
| 2123 | } else if (!down) { |
| 2124 | toggleRecentApps(); |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2125 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2126 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2127 | return -1; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2128 | } else if (keyCode == KeyEvent.KEYCODE_ASSIST) { |
| 2129 | if (down) { |
| 2130 | if (repeatCount == 0) { |
| 2131 | mAssistKeyLongPressed = false; |
| 2132 | } else if (repeatCount == 1) { |
| 2133 | mAssistKeyLongPressed = true; |
| 2134 | if (!keyguardOn) { |
| 2135 | launchAssistLongPressAction(); |
| 2136 | } |
| 2137 | } |
| 2138 | } else { |
| 2139 | if (mAssistKeyLongPressed) { |
| 2140 | mAssistKeyLongPressed = false; |
| 2141 | } else { |
| 2142 | if (!keyguardOn) { |
| 2143 | launchAssistAction(); |
| 2144 | } |
| 2145 | } |
| 2146 | } |
| 2147 | return -1; |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 2148 | } else if (keyCode == KeyEvent.KEYCODE_SYSRQ) { |
| 2149 | if (down && repeatCount == 0) { |
| 2150 | mHandler.post(mScreenshotRunnable); |
| 2151 | } |
| 2152 | return -1; |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 2153 | } else if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP |
| 2154 | || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) { |
| 2155 | if (down) { |
| 2156 | int direction = keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP ? 1 : -1; |
| 2157 | |
| 2158 | // Disable autobrightness if it's on |
| 2159 | int auto = Settings.System.getIntForUser( |
| 2160 | mContext.getContentResolver(), |
| 2161 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2162 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2163 | UserHandle.USER_CURRENT_OR_SELF); |
| 2164 | if (auto != 0) { |
| 2165 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2166 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2167 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2168 | UserHandle.USER_CURRENT_OR_SELF); |
| 2169 | } |
| 2170 | |
| 2171 | int min = mPowerManager.getMinimumScreenBrightnessSetting(); |
| 2172 | int max = mPowerManager.getMaximumScreenBrightnessSetting(); |
| 2173 | int step = (max - min + BRIGHTNESS_STEPS - 1) / BRIGHTNESS_STEPS * direction; |
| 2174 | int brightness = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 2175 | Settings.System.SCREEN_BRIGHTNESS, |
| 2176 | mPowerManager.getDefaultScreenBrightnessSetting(), |
| 2177 | UserHandle.USER_CURRENT_OR_SELF); |
| 2178 | brightness += step; |
| 2179 | // Make sure we don't go beyond the limits. |
| 2180 | brightness = Math.min(max, brightness); |
| 2181 | brightness = Math.max(min, brightness); |
| 2182 | |
| 2183 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2184 | Settings.System.SCREEN_BRIGHTNESS, brightness, |
| 2185 | UserHandle.USER_CURRENT_OR_SELF); |
| 2186 | Intent intent = new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG); |
| 2187 | mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF); |
| 2188 | } |
| 2189 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2190 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2191 | |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2192 | // Shortcuts are invoked through Search+key, so intercept those here |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2193 | // Any printing key that is chorded with Search should be consumed |
| 2194 | // even if no shortcut was invoked. This prevents text from being |
| 2195 | // inadvertently inserted when using a keyboard that has built-in macro |
| 2196 | // 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] | 2197 | if (mSearchKeyShortcutPending) { |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2198 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
| 2199 | if (kcm.isPrintingKey(keyCode)) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2200 | mConsumeSearchKeyUp = true; |
| 2201 | mSearchKeyShortcutPending = false; |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2202 | if (down && repeatCount == 0 && !keyguardOn) { |
| 2203 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState); |
| 2204 | if (shortcutIntent != null) { |
| 2205 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2206 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2207 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2208 | } catch (ActivityNotFoundException ex) { |
| 2209 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2210 | + "the activity to which it is registered was not found: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2211 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode), ex); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2212 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2213 | } else { |
| 2214 | Slog.i(TAG, "Dropping unregistered shortcut key combination: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2215 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2216 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2217 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2218 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2219 | } |
| 2220 | } |
| 2221 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2222 | // Invoke shortcuts using Meta. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2223 | if (down && repeatCount == 0 && !keyguardOn |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2224 | && (metaState & KeyEvent.META_META_ON) != 0) { |
| 2225 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2226 | if (kcm.isPrintingKey(keyCode)) { |
| 2227 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, |
| 2228 | metaState & ~(KeyEvent.META_META_ON |
| 2229 | | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON)); |
| 2230 | if (shortcutIntent != null) { |
| 2231 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2232 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2233 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2234 | } catch (ActivityNotFoundException ex) { |
| 2235 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2236 | + "the activity to which it is registered was not found: " |
| 2237 | + "META+" + KeyEvent.keyCodeToString(keyCode), ex); |
| 2238 | } |
| 2239 | return -1; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2240 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2241 | } |
| 2242 | } |
| 2243 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2244 | // Handle application launch keys. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2245 | if (down && repeatCount == 0 && !keyguardOn) { |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2246 | String category = sApplicationLaunchKeyCategories.get(keyCode); |
| 2247 | if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 2248 | Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2249 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2250 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2251 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2252 | } catch (ActivityNotFoundException ex) { |
| 2253 | Slog.w(TAG, "Dropping application launch key because " |
| 2254 | + "the activity to which it is registered was not found: " |
| 2255 | + "keyCode=" + keyCode + ", category=" + category, ex); |
| 2256 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2257 | return -1; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2258 | } |
| 2259 | } |
| 2260 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2261 | // Display task switcher for ALT-TAB or Meta-TAB. |
| 2262 | if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2263 | if (mRecentAppsHeldModifiers == 0 && !keyguardOn) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2264 | final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK; |
| 2265 | if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON) |
| 2266 | || KeyEvent.metaStateHasModifiers( |
| 2267 | shiftlessModifiers, KeyEvent.META_META_ON)) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2268 | mRecentAppsHeldModifiers = shiftlessModifiers; |
| 2269 | showRecentApps(true); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2270 | return -1; |
| 2271 | } |
| 2272 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2273 | } else if (!down && mRecentAppsHeldModifiers != 0 |
| 2274 | && (metaState & mRecentAppsHeldModifiers) == 0) { |
| 2275 | mRecentAppsHeldModifiers = 0; |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 2276 | hideRecentApps(true); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2277 | } |
| 2278 | |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 2279 | // Handle keyboard language switching. |
| 2280 | if (down && repeatCount == 0 |
| 2281 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2282 | || (keyCode == KeyEvent.KEYCODE_SPACE |
| 2283 | && (metaState & KeyEvent.META_CTRL_MASK) != 0))) { |
| 2284 | int direction = (metaState & KeyEvent.META_SHIFT_MASK) != 0 ? -1 : 1; |
| 2285 | mWindowManagerFuncs.switchKeyboardLayout(event.getDeviceId(), direction); |
| 2286 | return -1; |
| 2287 | } |
| 2288 | if (mLanguageSwitchKeyPressed && !down |
| 2289 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2290 | || keyCode == KeyEvent.KEYCODE_SPACE)) { |
| 2291 | mLanguageSwitchKeyPressed = false; |
| 2292 | return -1; |
| 2293 | } |
| 2294 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 2295 | if (mGlobalKeyManager.handleGlobalKey(mContext, keyCode, event)) { |
| 2296 | return -1; |
| 2297 | } |
| 2298 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2299 | // Let the application handle the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2300 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2301 | } |
| 2302 | |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2303 | /** {@inheritDoc} */ |
| 2304 | @Override |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2305 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2306 | // Note: This method is only called if the initial down was unhandled. |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2307 | if (DEBUG_INPUT) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2308 | Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction() |
| 2309 | + ", flags=" + event.getFlags() |
| 2310 | + ", keyCode=" + event.getKeyCode() |
| 2311 | + ", scanCode=" + event.getScanCode() |
| 2312 | + ", metaState=" + event.getMetaState() |
| 2313 | + ", repeatCount=" + event.getRepeatCount() |
| 2314 | + ", policyFlags=" + policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2315 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2316 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2317 | KeyEvent fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2318 | if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 2319 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2320 | final int keyCode = event.getKeyCode(); |
| 2321 | final int metaState = event.getMetaState(); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2322 | final boolean initialDown = event.getAction() == KeyEvent.ACTION_DOWN |
| 2323 | && event.getRepeatCount() == 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2324 | |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2325 | // Check for fallback actions specified by the key character map. |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2326 | final FallbackAction fallbackAction; |
| 2327 | if (initialDown) { |
| 2328 | fallbackAction = kcm.getFallbackAction(keyCode, metaState); |
| 2329 | } else { |
| 2330 | fallbackAction = mFallbackActions.get(keyCode); |
| 2331 | } |
| 2332 | |
| 2333 | if (fallbackAction != null) { |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2334 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2335 | Slog.d(TAG, "Fallback: keyCode=" + fallbackAction.keyCode |
| 2336 | + " metaState=" + Integer.toHexString(fallbackAction.metaState)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2337 | } |
| 2338 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2339 | final int flags = event.getFlags() | KeyEvent.FLAG_FALLBACK; |
| 2340 | fallbackEvent = KeyEvent.obtain( |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2341 | event.getDownTime(), event.getEventTime(), |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2342 | event.getAction(), fallbackAction.keyCode, |
| 2343 | event.getRepeatCount(), fallbackAction.metaState, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2344 | event.getDeviceId(), event.getScanCode(), |
| 2345 | flags, event.getSource(), null); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2346 | |
| 2347 | if (!interceptFallback(win, fallbackEvent, policyFlags)) { |
| 2348 | fallbackEvent.recycle(); |
| 2349 | fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2350 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2351 | |
| 2352 | if (initialDown) { |
| 2353 | mFallbackActions.put(keyCode, fallbackAction); |
| 2354 | } else if (event.getAction() == KeyEvent.ACTION_UP) { |
| 2355 | mFallbackActions.remove(keyCode); |
| 2356 | fallbackAction.recycle(); |
| 2357 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2358 | } |
| 2359 | } |
| 2360 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2361 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2362 | if (fallbackEvent == null) { |
| 2363 | Slog.d(TAG, "No fallback."); |
| 2364 | } else { |
| 2365 | Slog.d(TAG, "Performing fallback: " + fallbackEvent); |
| 2366 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2367 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2368 | return fallbackEvent; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2369 | } |
| 2370 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2371 | private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2372 | int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2373 | if ((actions & ACTION_PASS_TO_USER) != 0) { |
| 2374 | long delayMillis = interceptKeyBeforeDispatching( |
| 2375 | win, fallbackEvent, policyFlags); |
| 2376 | if (delayMillis == 0) { |
| 2377 | return true; |
| 2378 | } |
| 2379 | } |
| 2380 | return false; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 2381 | } |
| 2382 | |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2383 | private void launchAssistLongPressAction() { |
| 2384 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 2385 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
| 2386 | |
| 2387 | // launch the search activity |
| 2388 | Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); |
| 2389 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2390 | try { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2391 | // TODO: This only stops the factory-installed search manager. |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2392 | // Need to formalize an API to handle others |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2393 | SearchManager searchManager = getSearchManager(); |
| 2394 | if (searchManager != null) { |
| 2395 | searchManager.stopSearch(); |
| 2396 | } |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2397 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2398 | } catch (ActivityNotFoundException e) { |
| 2399 | Slog.w(TAG, "No activity to handle assist long press action.", e); |
| 2400 | } |
| 2401 | } |
| 2402 | |
| 2403 | private void launchAssistAction() { |
| 2404 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 2405 | Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 2406 | .getAssistIntent(mContext, true, UserHandle.USER_CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2407 | if (intent != null) { |
| 2408 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 2409 | | Intent.FLAG_ACTIVITY_SINGLE_TOP |
| 2410 | | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 2411 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2412 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2413 | } catch (ActivityNotFoundException e) { |
| 2414 | Slog.w(TAG, "No activity to handle assist action.", e); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2415 | } |
| 2416 | } |
| 2417 | } |
| 2418 | |
| 2419 | private SearchManager getSearchManager() { |
| 2420 | if (mSearchManager == null) { |
| 2421 | mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); |
| 2422 | } |
| 2423 | return mSearchManager; |
| 2424 | } |
| 2425 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2426 | private void preloadRecentApps() { |
| 2427 | mPreloadedRecentApps = true; |
| 2428 | try { |
| 2429 | IStatusBarService statusbar = getStatusBarService(); |
| 2430 | if (statusbar != null) { |
| 2431 | statusbar.preloadRecentApps(); |
| 2432 | } |
| 2433 | } catch (RemoteException e) { |
| 2434 | Slog.e(TAG, "RemoteException when preloading recent apps", e); |
| 2435 | // re-acquire status bar service next time it is needed. |
| 2436 | mStatusBarService = null; |
| 2437 | } |
| 2438 | } |
| 2439 | |
| 2440 | private void cancelPreloadRecentApps() { |
| 2441 | if (mPreloadedRecentApps) { |
| 2442 | mPreloadedRecentApps = false; |
| 2443 | try { |
| 2444 | IStatusBarService statusbar = getStatusBarService(); |
| 2445 | if (statusbar != null) { |
| 2446 | statusbar.cancelPreloadRecentApps(); |
| 2447 | } |
| 2448 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2449 | Slog.e(TAG, "RemoteException when cancelling recent apps preload", e); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2450 | // re-acquire status bar service next time it is needed. |
| 2451 | mStatusBarService = null; |
| 2452 | } |
| 2453 | } |
| 2454 | } |
| 2455 | |
| 2456 | private void toggleRecentApps() { |
| 2457 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2458 | try { |
| 2459 | IStatusBarService statusbar = getStatusBarService(); |
| 2460 | if (statusbar != null) { |
| 2461 | statusbar.toggleRecentApps(); |
| 2462 | } |
| 2463 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2464 | Slog.e(TAG, "RemoteException when toggling recent apps", e); |
| 2465 | // re-acquire status bar service next time it is needed. |
| 2466 | mStatusBarService = null; |
| 2467 | } |
| 2468 | } |
| 2469 | |
| 2470 | private void showRecentApps(boolean triggeredFromAltTab) { |
| 2471 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2472 | try { |
| 2473 | IStatusBarService statusbar = getStatusBarService(); |
| 2474 | if (statusbar != null) { |
| 2475 | statusbar.showRecentApps(triggeredFromAltTab); |
| 2476 | } |
| 2477 | } catch (RemoteException e) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2478 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
| 2479 | // re-acquire status bar service next time it is needed. |
| 2480 | mStatusBarService = null; |
| 2481 | } |
| 2482 | } |
| 2483 | |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 2484 | private void hideRecentApps(boolean triggeredFromAltTab) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2485 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2486 | try { |
| 2487 | IStatusBarService statusbar = getStatusBarService(); |
| 2488 | if (statusbar != null) { |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 2489 | statusbar.hideRecentApps(triggeredFromAltTab); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2490 | } |
| 2491 | } catch (RemoteException e) { |
| 2492 | Slog.e(TAG, "RemoteException when closing recent apps", e); |
| 2493 | // re-acquire status bar service next time it is needed. |
| 2494 | mStatusBarService = null; |
| 2495 | } |
| 2496 | } |
| 2497 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2498 | /** |
| 2499 | * A home key -> launch home action was detected. Take the appropriate action |
| 2500 | * given the situation with the keyguard. |
| 2501 | */ |
| 2502 | void launchHomeFromHotKey() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2503 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowingAndNotOccluded()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2504 | // don't launch home if keyguard showing |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2505 | } else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2506 | // when in keyguard restricted mode, must first verify unlock |
| 2507 | // before launching home |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2508 | mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2509 | public void onKeyguardExitResult(boolean success) { |
| 2510 | if (success) { |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2511 | try { |
| 2512 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2513 | } catch (RemoteException e) { |
| 2514 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2515 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2516 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2517 | } |
| 2518 | } |
| 2519 | }); |
| 2520 | } else { |
| 2521 | // no keyguard stuff to worry about, just launch home! |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2522 | try { |
| 2523 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2524 | } catch (RemoteException e) { |
| 2525 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2526 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2527 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2528 | } |
| 2529 | } |
| 2530 | |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2531 | private final Runnable mClearHideNavigationFlag = new Runnable() { |
| 2532 | @Override |
| 2533 | public void run() { |
| 2534 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
| 2535 | // Clear flags. |
| 2536 | mForceClearedSystemUiFlags &= |
| 2537 | ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 2538 | } |
| 2539 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2540 | } |
| 2541 | }; |
| 2542 | |
| 2543 | /** |
| 2544 | * Input handler used while nav bar is hidden. Captures any touch on the screen, |
| 2545 | * to determine when the nav bar should be shown and prevent applications from |
| 2546 | * receiving those touches. |
| 2547 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2548 | final class HideNavInputEventReceiver extends InputEventReceiver { |
| 2549 | public HideNavInputEventReceiver(InputChannel inputChannel, Looper looper) { |
| 2550 | super(inputChannel, looper); |
| 2551 | } |
| 2552 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2553 | @Override |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2554 | public void onInputEvent(InputEvent event) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2555 | boolean handled = false; |
| 2556 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 2557 | if (event instanceof MotionEvent |
| 2558 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 2559 | final MotionEvent motionEvent = (MotionEvent)event; |
| 2560 | if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2561 | // When the user taps down, we re-show the nav bar. |
| 2562 | boolean changed = false; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2563 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2564 | // Any user activity always causes us to show the |
| 2565 | // navigation controls, if they had been hidden. |
| 2566 | // We also clear the low profile and only content |
| 2567 | // flags so that tapping on the screen will atomically |
| 2568 | // restore all currently hidden screen decorations. |
| 2569 | int newVal = mResettingSystemUiFlags | |
| 2570 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| 2571 | View.SYSTEM_UI_FLAG_LOW_PROFILE | |
| 2572 | View.SYSTEM_UI_FLAG_FULLSCREEN; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2573 | if (mResettingSystemUiFlags != newVal) { |
| 2574 | mResettingSystemUiFlags = newVal; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2575 | changed = true; |
| 2576 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2577 | // We don't allow the system's nav bar to be hidden |
| 2578 | // again for 1 second, to prevent applications from |
| 2579 | // spamming us and keeping it from being shown. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2580 | newVal = mForceClearedSystemUiFlags | |
| 2581 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2582 | if (mForceClearedSystemUiFlags != newVal) { |
| 2583 | mForceClearedSystemUiFlags = newVal; |
| 2584 | changed = true; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2585 | mHandler.postDelayed(mClearHideNavigationFlag, 1000); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2586 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2587 | } |
| 2588 | if (changed) { |
| 2589 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 2590 | } |
| 2591 | } |
| 2592 | } |
| 2593 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2594 | finishInputEvent(event, handled); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2595 | } |
| 2596 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2597 | } |
| 2598 | final InputEventReceiver.Factory mHideNavInputEventReceiverFactory = |
| 2599 | new InputEventReceiver.Factory() { |
| 2600 | @Override |
| 2601 | public InputEventReceiver createInputEventReceiver( |
| 2602 | InputChannel inputChannel, Looper looper) { |
| 2603 | return new HideNavInputEventReceiver(inputChannel, looper); |
| 2604 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2605 | }; |
| 2606 | |
| 2607 | @Override |
| 2608 | public int adjustSystemUiVisibilityLw(int visibility) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2609 | mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
| 2610 | mNavigationBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2611 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2612 | // Reset any bits in mForceClearingStatusBarVisibility that |
| 2613 | // are now clear. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2614 | mResettingSystemUiFlags &= visibility; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2615 | // Clear any bits in the new visibility that are currently being |
| 2616 | // force cleared, before reporting it. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2617 | return visibility & ~mResettingSystemUiFlags |
| 2618 | & ~mForceClearedSystemUiFlags; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2619 | } |
| 2620 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2621 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2622 | public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 2623 | final int fl = PolicyControl.getWindowFlags(null, attrs); |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 2624 | final int sysuiVis = PolicyControl.getSystemUiVisibility(null, attrs); |
| 2625 | final int systemUiVisibility = (sysuiVis | attrs.subtreeSystemUiVisibility); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2626 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2627 | 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] | 2628 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2629 | int availRight, availBottom; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 2630 | if (canHideNavigationBar() && |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2631 | (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2632 | availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 2633 | availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
| 2634 | } else { |
| 2635 | availRight = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 2636 | availBottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
| 2637 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2638 | if ((systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2639 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 2640 | contentInset.set(mStableFullscreenLeft, mStableFullscreenTop, |
| 2641 | availRight - mStableFullscreenRight, |
| 2642 | availBottom - mStableFullscreenBottom); |
| 2643 | } else { |
| 2644 | contentInset.set(mStableLeft, mStableTop, |
| 2645 | availRight - mStableRight, availBottom - mStableBottom); |
| 2646 | } |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2647 | } else if ((fl & FLAG_FULLSCREEN) != 0 || (fl & FLAG_LAYOUT_IN_OVERSCAN) != 0) { |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2648 | contentInset.setEmpty(); |
| 2649 | } else if ((systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2650 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) { |
| 2651 | contentInset.set(mCurLeft, mCurTop, |
| 2652 | availRight - mCurRight, availBottom - mCurBottom); |
| 2653 | } else { |
| 2654 | contentInset.set(mCurLeft, mCurTop, |
| 2655 | availRight - mCurRight, availBottom - mCurBottom); |
| 2656 | } |
| 2657 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2658 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2659 | contentInset.setEmpty(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2660 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2661 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2662 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2663 | @Override |
| 2664 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
| 2665 | int displayRotation) { |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2666 | final int overscanLeft, overscanTop, overscanRight, overscanBottom; |
| 2667 | if (isDefaultDisplay) { |
| 2668 | switch (displayRotation) { |
| 2669 | case Surface.ROTATION_90: |
| 2670 | overscanLeft = mOverscanTop; |
| 2671 | overscanTop = mOverscanRight; |
| 2672 | overscanRight = mOverscanBottom; |
| 2673 | overscanBottom = mOverscanLeft; |
| 2674 | break; |
| 2675 | case Surface.ROTATION_180: |
| 2676 | overscanLeft = mOverscanRight; |
| 2677 | overscanTop = mOverscanBottom; |
| 2678 | overscanRight = mOverscanLeft; |
| 2679 | overscanBottom = mOverscanTop; |
| 2680 | break; |
| 2681 | case Surface.ROTATION_270: |
| 2682 | overscanLeft = mOverscanBottom; |
| 2683 | overscanTop = mOverscanLeft; |
| 2684 | overscanRight = mOverscanTop; |
| 2685 | overscanBottom = mOverscanRight; |
| 2686 | break; |
| 2687 | default: |
| 2688 | overscanLeft = mOverscanLeft; |
| 2689 | overscanTop = mOverscanTop; |
| 2690 | overscanRight = mOverscanRight; |
| 2691 | overscanBottom = mOverscanBottom; |
| 2692 | break; |
| 2693 | } |
| 2694 | } else { |
| 2695 | overscanLeft = 0; |
| 2696 | overscanTop = 0; |
| 2697 | overscanRight = 0; |
| 2698 | overscanBottom = 0; |
| 2699 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2700 | mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0; |
| 2701 | mOverscanScreenTop = mRestrictedOverscanScreenTop = 0; |
| 2702 | mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth; |
| 2703 | mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2704 | mSystemLeft = 0; |
| 2705 | mSystemTop = 0; |
| 2706 | mSystemRight = displayWidth; |
| 2707 | mSystemBottom = displayHeight; |
| 2708 | mUnrestrictedScreenLeft = overscanLeft; |
| 2709 | mUnrestrictedScreenTop = overscanTop; |
| 2710 | mUnrestrictedScreenWidth = displayWidth - overscanLeft - overscanRight; |
| 2711 | mUnrestrictedScreenHeight = displayHeight - overscanTop - overscanBottom; |
| 2712 | mRestrictedScreenLeft = mUnrestrictedScreenLeft; |
| 2713 | mRestrictedScreenTop = mUnrestrictedScreenTop; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2714 | mRestrictedScreenWidth = mSystemGestures.screenWidth = mUnrestrictedScreenWidth; |
| 2715 | mRestrictedScreenHeight = mSystemGestures.screenHeight = mUnrestrictedScreenHeight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2716 | mDockLeft = mContentLeft = mVoiceContentLeft = mStableLeft = mStableFullscreenLeft |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2717 | = mCurLeft = mUnrestrictedScreenLeft; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2718 | mDockTop = mContentTop = mVoiceContentTop = mStableTop = mStableFullscreenTop |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2719 | = mCurTop = mUnrestrictedScreenTop; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2720 | mDockRight = mContentRight = mVoiceContentRight = mStableRight = mStableFullscreenRight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2721 | = mCurRight = displayWidth - overscanRight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2722 | mDockBottom = mContentBottom = mVoiceContentBottom = mStableBottom = mStableFullscreenBottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2723 | = mCurBottom = displayHeight - overscanBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2724 | mDockLayer = 0x10000000; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 2725 | mStatusBarLayer = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2726 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2727 | // start with the current dock rect, which will be (0,0,displayWidth,displayHeight) |
| 2728 | final Rect pf = mTmpParentFrame; |
| 2729 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2730 | final Rect of = mTmpOverscanFrame; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2731 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2732 | final Rect dcf = mTmpDecorFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2733 | pf.left = df.left = of.left = vf.left = mDockLeft; |
| 2734 | pf.top = df.top = of.top = vf.top = mDockTop; |
| 2735 | pf.right = df.right = of.right = vf.right = mDockRight; |
| 2736 | pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2737 | dcf.setEmpty(); // Decor frame N/A for system bars. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2738 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2739 | if (isDefaultDisplay) { |
| 2740 | // For purposes of putting out fake window up to steal focus, we will |
| 2741 | // drive nav being hidden only by whether it is requested. |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2742 | final int sysui = mLastSystemUiFlags; |
| 2743 | boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 2744 | boolean navTranslucent = (sysui |
| 2745 | & (View.NAVIGATION_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 2746 | boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0; |
| 2747 | boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
| 2748 | boolean navAllowedHidden = immersive || immersiveSticky; |
| 2749 | navTranslucent &= !immersiveSticky; // transient trumps translucent |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 2750 | navTranslucent &= areTranslucentBarsAllowed(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2751 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2752 | // When the navigation bar isn't visible, we put up a fake |
| 2753 | // input window to catch all touch events. This way we can |
| 2754 | // detect when the user presses anywhere to bring back the nav |
| 2755 | // bar and ensure the application doesn't see the event. |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 2756 | if (navVisible || navAllowedHidden) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2757 | if (mHideNavFakeWindow != null) { |
| 2758 | mHideNavFakeWindow.dismiss(); |
| 2759 | mHideNavFakeWindow = null; |
| 2760 | } |
| 2761 | } else if (mHideNavFakeWindow == null) { |
| 2762 | mHideNavFakeWindow = mWindowManagerFuncs.addFakeWindow( |
| 2763 | mHandler.getLooper(), mHideNavInputEventReceiverFactory, |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 2764 | "hidden nav", WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER, 0, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2765 | 0, false, false, true); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2766 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2767 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2768 | // For purposes of positioning and showing the nav bar, if we have |
| 2769 | // decided that it can't be hidden (because of the screen aspect ratio), |
| 2770 | // then take that into account. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 2771 | navVisible |= !canHideNavigationBar(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2772 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2773 | boolean updateSysUiVisibility = false; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2774 | if (mNavigationBar != null) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2775 | boolean transientNavBarShowing = mNavigationBarController.isTransientShowing(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2776 | // Force the navigation bar to its appropriate place and |
| 2777 | // size. We need to do this directly, instead of relying on |
| 2778 | // it to bubble up from the nav bar, because this needs to |
| 2779 | // change atomically with screen rotations. |
| 2780 | mNavigationBarOnBottom = (!mNavigationBarCanMove || displayWidth < displayHeight); |
| 2781 | if (mNavigationBarOnBottom) { |
| 2782 | // 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] | 2783 | int top = displayHeight - overscanBottom |
| 2784 | - mNavigationBarHeightForRotation[displayRotation]; |
| 2785 | mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2786 | mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 2787 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2788 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2789 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2790 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2791 | mDockBottom = mTmpNavigationFrame.top; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2792 | mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop; |
| 2793 | mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2794 | } else { |
| 2795 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2796 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2797 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 2798 | if (navVisible && !navTranslucent && !navAllowedHidden |
| 2799 | && !mNavigationBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2800 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2801 | // If the opaque nav bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2802 | // and not in the process of animating on or off, then |
| 2803 | // we can tell the app that it is covered by it. |
| 2804 | mSystemBottom = mTmpNavigationFrame.top; |
| 2805 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2806 | } else { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2807 | // Landscape screen; nav bar goes to the right. |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2808 | int left = displayWidth - overscanRight |
| 2809 | - mNavigationBarWidthForRotation[displayRotation]; |
| 2810 | mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2811 | mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 2812 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2813 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2814 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2815 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2816 | mDockRight = mTmpNavigationFrame.left; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2817 | mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft; |
| 2818 | mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2819 | } else { |
| 2820 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2821 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2822 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2823 | if (navVisible && !navTranslucent && !mNavigationBar.isAnimatingLw() |
| 2824 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2825 | // If the nav bar is currently requested to be visible, |
| 2826 | // and not in the process of animating on or off, then |
| 2827 | // we can tell the app that it is covered by it. |
| 2828 | mSystemRight = mTmpNavigationFrame.left; |
| 2829 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2830 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2831 | // Make sure the content and current rectangles are updated to |
| 2832 | // account for the restrictions from the navigation bar. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2833 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 2834 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 2835 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 2836 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2837 | mStatusBarLayer = mNavigationBar.getSurfaceLayer(); |
| 2838 | // And compute the final frame. |
| 2839 | mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2840 | mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2841 | if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2842 | if (mNavigationBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2843 | updateSysUiVisibility = true; |
| 2844 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2845 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2846 | 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] | 2847 | mDockLeft, mDockTop, mDockRight, mDockBottom)); |
| 2848 | |
| 2849 | // decide where the status bar goes ahead of time |
| 2850 | if (mStatusBar != null) { |
| 2851 | // apply any navigation bar insets |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2852 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 2853 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 2854 | pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft; |
| 2855 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight |
| 2856 | + mUnrestrictedScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2857 | vf.left = mStableLeft; |
| 2858 | vf.top = mStableTop; |
| 2859 | vf.right = mStableRight; |
| 2860 | vf.bottom = mStableBottom; |
| 2861 | |
| 2862 | mStatusBarLayer = mStatusBar.getSurfaceLayer(); |
| 2863 | |
| 2864 | // Let the status bar determine its size. |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2865 | mStatusBar.computeFrameLw(pf, df, vf, vf, vf, dcf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2866 | |
| 2867 | // For layout, the status bar is always at the top with our fixed height. |
| 2868 | mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 2869 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2870 | boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 2871 | boolean statusBarTranslucent = (sysui |
| 2872 | & (View.STATUS_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 2873 | statusBarTranslucent &= areTranslucentBarsAllowed(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2874 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2875 | // If the status bar is hidden, we don't want to cause |
| 2876 | // windows behind it to scroll. |
John Spurlock | eda1f69 | 2013-09-16 11:38:44 -0400 | [diff] [blame] | 2877 | if (mStatusBar.isVisibleLw() && !statusBarTransient) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2878 | // Status bar may go away, so the screen area it occupies |
| 2879 | // is available to apps but just covering them when the |
| 2880 | // status bar is visible. |
| 2881 | mDockTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 2882 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2883 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 2884 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 2885 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 2886 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2887 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2888 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar: " + |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2889 | String.format( |
| 2890 | "dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]", |
| 2891 | mDockLeft, mDockTop, mDockRight, mDockBottom, |
| 2892 | mContentLeft, mContentTop, mContentRight, mContentBottom, |
| 2893 | mCurLeft, mCurTop, mCurRight, mCurBottom)); |
| 2894 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2895 | if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2896 | && !statusBarTransient && !statusBarTranslucent |
| 2897 | && !mStatusBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2898 | // If the opaque status bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2899 | // and not in the process of animating on or off, then |
| 2900 | // we can tell the app that it is covered by it. |
| 2901 | mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 2902 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2903 | if (mStatusBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2904 | updateSysUiVisibility = true; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2905 | } |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 2906 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2907 | if (updateSysUiVisibility) { |
| 2908 | updateSystemUiVisibilityLw(); |
| 2909 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2910 | } |
| 2911 | } |
| 2912 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 2913 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 2914 | @Override |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2915 | public int getSystemDecorLayerLw() { |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 2916 | if (mStatusBar != null) return mStatusBar.getSurfaceLayer(); |
| 2917 | if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer(); |
| 2918 | return 0; |
| 2919 | } |
| 2920 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 2921 | @Override |
| 2922 | public void getContentRectLw(Rect r) { |
| 2923 | r.set(mContentLeft, mContentTop, mContentRight, mContentBottom); |
| 2924 | } |
| 2925 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2926 | void setAttachedWindowFrames(WindowState win, int fl, int adjust, WindowState attached, |
| 2927 | 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] | 2928 | if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) { |
| 2929 | // Here's a special case: if this attached window is a panel that is |
| 2930 | // above the dock window, and the window it is attached to is below |
| 2931 | // the dock window, then the frames we computed for the window it is |
| 2932 | // attached to can not be used because the dock is effectively part |
| 2933 | // of the underlying window and the attached window is floating on top |
| 2934 | // of the whole thing. So, we ignore the attached window and explicitly |
| 2935 | // compute the frames that would be appropriate without the dock. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2936 | df.left = of.left = cf.left = vf.left = mDockLeft; |
| 2937 | df.top = of.top = cf.top = vf.top = mDockTop; |
| 2938 | df.right = of.right = cf.right = vf.right = mDockRight; |
| 2939 | df.bottom = of.bottom = cf.bottom = vf.bottom = mDockBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2940 | } else { |
| 2941 | // The effective display frame of the attached window depends on |
| 2942 | // whether it is taking care of insetting its content. If not, |
| 2943 | // we need to use the parent's content frame so that the entire |
| 2944 | // window is positioned within that content. Otherwise we can use |
| 2945 | // the display frame and let the attached window take care of |
| 2946 | // positioning its content appropriately. |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2947 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2948 | cf.set(attached.getOverscanFrameLw()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2949 | } else { |
| 2950 | // If the window is resizing, then we want to base the content |
| 2951 | // frame on our attached content frame to resize... however, |
| 2952 | // things can be tricky if the attached window is NOT in resize |
| 2953 | // mode, in which case its content frame will be larger. |
| 2954 | // Ungh. So to deal with that, make sure the content frame |
| 2955 | // we end up using is not covering the IM dock. |
| 2956 | cf.set(attached.getContentFrameLw()); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2957 | if (attached.isVoiceInteraction()) { |
| 2958 | if (cf.left < mVoiceContentLeft) cf.left = mVoiceContentLeft; |
| 2959 | if (cf.top < mVoiceContentTop) cf.top = mVoiceContentTop; |
| 2960 | if (cf.right > mVoiceContentRight) cf.right = mVoiceContentRight; |
| 2961 | if (cf.bottom > mVoiceContentBottom) cf.bottom = mVoiceContentBottom; |
| 2962 | } else if (attached.getSurfaceLayer() < mDockLayer) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2963 | if (cf.left < mContentLeft) cf.left = mContentLeft; |
| 2964 | if (cf.top < mContentTop) cf.top = mContentTop; |
| 2965 | if (cf.right > mContentRight) cf.right = mContentRight; |
| 2966 | if (cf.bottom > mContentBottom) cf.bottom = mContentBottom; |
| 2967 | } |
| 2968 | } |
| 2969 | df.set(insetDecors ? attached.getDisplayFrameLw() : cf); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2970 | of.set(insetDecors ? attached.getOverscanFrameLw() : cf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2971 | vf.set(attached.getVisibleFrameLw()); |
| 2972 | } |
| 2973 | // The LAYOUT_IN_SCREEN flag is used to determine whether the attached |
| 2974 | // window should be positioned relative to its parent or the entire |
| 2975 | // screen. |
| 2976 | pf.set((fl & FLAG_LAYOUT_IN_SCREEN) == 0 |
| 2977 | ? attached.getFrameLw() : df); |
| 2978 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2979 | |
| 2980 | private void applyStableConstraints(int sysui, int fl, Rect r) { |
| 2981 | if ((sysui & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2982 | // If app is requesting a stable layout, don't let the |
| 2983 | // content insets go below the stable values. |
| 2984 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 2985 | if (r.left < mStableFullscreenLeft) r.left = mStableFullscreenLeft; |
| 2986 | if (r.top < mStableFullscreenTop) r.top = mStableFullscreenTop; |
| 2987 | if (r.right > mStableFullscreenRight) r.right = mStableFullscreenRight; |
| 2988 | if (r.bottom > mStableFullscreenBottom) r.bottom = mStableFullscreenBottom; |
| 2989 | } else { |
| 2990 | if (r.left < mStableLeft) r.left = mStableLeft; |
| 2991 | if (r.top < mStableTop) r.top = mStableTop; |
| 2992 | if (r.right > mStableRight) r.right = mStableRight; |
| 2993 | if (r.bottom > mStableBottom) r.bottom = mStableBottom; |
| 2994 | } |
| 2995 | } |
| 2996 | } |
| 2997 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2998 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2999 | @Override |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 3000 | public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs, |
| 3001 | WindowState attached) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3002 | // we've already done the status bar |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 3003 | if (win == mStatusBar || win == mNavigationBar) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3004 | return; |
| 3005 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3006 | final boolean isDefaultDisplay = win.isDefaultDisplay(); |
| 3007 | final boolean needsToOffsetInputMethodTarget = isDefaultDisplay && |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3008 | (win == mLastInputMethodTargetWindow && mLastInputMethodWindow != null); |
| 3009 | if (needsToOffsetInputMethodTarget) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3010 | 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] | 3011 | offsetInputMethodWindowLw(mLastInputMethodWindow); |
| 3012 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3013 | |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3014 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3015 | final int sim = attrs.softInputMode; |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 3016 | final int sysUiFl = PolicyControl.getSystemUiVisibility(win, null); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3017 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3018 | final Rect pf = mTmpParentFrame; |
| 3019 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3020 | final Rect of = mTmpOverscanFrame; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3021 | final Rect cf = mTmpContentFrame; |
| 3022 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3023 | final Rect dcf = mTmpDecorFrame; |
| 3024 | dcf.setEmpty(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3025 | |
| 3026 | final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3027 | && mNavigationBar != null && mNavigationBar.isVisibleLw()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3028 | |
Craig Mautner | f683b56 | 2012-10-02 11:10:57 -0700 | [diff] [blame] | 3029 | final int adjust = sim & SOFT_INPUT_MASK_ADJUST; |
| 3030 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3031 | if (!isDefaultDisplay) { |
| 3032 | if (attached != null) { |
| 3033 | // If this window is attached to another, our display |
| 3034 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3035 | setAttachedWindowFrames(win, fl, adjust, attached, true, pf, df, of, cf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3036 | } else { |
| 3037 | // Give the window full screen. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3038 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3039 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3040 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3041 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3042 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3043 | = mOverscanScreenTop + mOverscanScreenHeight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3044 | } |
| 3045 | } else if (attrs.type == TYPE_INPUT_METHOD) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3046 | pf.left = df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3047 | pf.top = df.top = of.top = cf.top = vf.top = mDockTop; |
| 3048 | pf.right = df.right = of.right = cf.right = vf.right = mDockRight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3049 | // IM dock windows layout below the nav bar... |
John Spurlock | 57beb3b | 2013-10-10 10:27:44 -0400 | [diff] [blame] | 3050 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3051 | // ...with content insets above the nav bar |
| 3052 | cf.bottom = vf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3053 | // IM dock windows always go to the bottom of the screen. |
| 3054 | attrs.gravity = Gravity.BOTTOM; |
| 3055 | mDockLayer = win.getSurfaceLayer(); |
| 3056 | } else { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3057 | |
| 3058 | // Default policy decor for the default display |
| 3059 | dcf.left = mSystemLeft; |
| 3060 | dcf.top = mSystemTop; |
| 3061 | dcf.right = mSystemRight; |
| 3062 | dcf.bottom = mSystemBottom; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3063 | final boolean inheritTranslucentDecor = (attrs.privateFlags |
| 3064 | & WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR) != 0; |
John Spurlock | 65567d4 | 2013-10-08 10:08:32 -0400 | [diff] [blame] | 3065 | final boolean isAppWindow = |
| 3066 | attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW && |
| 3067 | attrs.type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 3068 | final boolean topAtRest = |
| 3069 | win == mTopFullscreenOpaqueWindowState && !win.isAnimatingLw(); |
| 3070 | if (isAppWindow && !inheritTranslucentDecor && !topAtRest) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3071 | if ((sysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 |
| 3072 | && (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3073 | && (fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == 0 |
| 3074 | && (fl & WindowManager.LayoutParams. |
| 3075 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3076 | // Ensure policy decor includes status bar |
| 3077 | dcf.top = mStableTop; |
| 3078 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3079 | if ((fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3080 | && (sysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0 |
| 3081 | && (fl & WindowManager.LayoutParams. |
| 3082 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3083 | // Ensure policy decor includes navigation bar |
| 3084 | dcf.bottom = mStableBottom; |
| 3085 | dcf.right = mStableRight; |
| 3086 | } |
| 3087 | } |
| 3088 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3089 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) |
| 3090 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3091 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3092 | + "): IN_SCREEN, INSET_DECOR"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3093 | // This is the case for a normal activity window: we want it |
| 3094 | // to cover all of the screen space, and it can take care of |
| 3095 | // moving its contents to account for screen decorations that |
| 3096 | // intrude into that space. |
| 3097 | if (attached != null) { |
| 3098 | // If this window is attached to another, our display |
| 3099 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3100 | 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] | 3101 | } else { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3102 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3103 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3104 | // Status bar panels are the only windows who can go on top of |
| 3105 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3106 | // permission, so they have the same privileges as the status |
| 3107 | // bar itself. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3108 | // |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3109 | // However, they should still dodge the navigation bar if it exists. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3110 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3111 | pf.left = df.left = of.left = hasNavBar |
| 3112 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3113 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3114 | pf.right = df.right = of.right = hasNavBar |
| 3115 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
| 3116 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3117 | pf.bottom = df.bottom = of.bottom = hasNavBar |
| 3118 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
| 3119 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3120 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3121 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3122 | "Laying out status bar window: (%d,%d - %d,%d)", |
| 3123 | pf.left, pf.top, pf.right, pf.bottom)); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3124 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3125 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3126 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3127 | // Asking to layout into the overscan region, so give it that pure |
| 3128 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3129 | pf.left = df.left = of.left = mOverscanScreenLeft; |
| 3130 | pf.top = df.top = of.top = mOverscanScreenTop; |
| 3131 | pf.right = df.right = of.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3132 | pf.bottom = df.bottom = of.bottom = mOverscanScreenTop |
| 3133 | + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3134 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3135 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3136 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3137 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3138 | // Asking for layout as if the nav bar is hidden, lets the |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3139 | // application extend into the unrestricted overscan screen area. We |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3140 | // only do this for application windows to ensure no window that |
| 3141 | // can be above the nav bar can do this. |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3142 | pf.left = df.left = mOverscanScreenLeft; |
| 3143 | pf.top = df.top = mOverscanScreenTop; |
| 3144 | pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3145 | pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3146 | // We need to tell the app about where the frame inside the overscan |
| 3147 | // is, so it can inset its content by that amount -- it didn't ask |
| 3148 | // to actually extend itself into the overscan region. |
| 3149 | of.left = mUnrestrictedScreenLeft; |
| 3150 | of.top = mUnrestrictedScreenTop; |
| 3151 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3152 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3153 | } else { |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3154 | pf.left = df.left = mRestrictedOverscanScreenLeft; |
| 3155 | pf.top = df.top = mRestrictedOverscanScreenTop; |
| 3156 | pf.right = df.right = mRestrictedOverscanScreenLeft |
| 3157 | + mRestrictedOverscanScreenWidth; |
| 3158 | pf.bottom = df.bottom = mRestrictedOverscanScreenTop |
| 3159 | + mRestrictedOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3160 | // We need to tell the app about where the frame inside the overscan |
| 3161 | // is, so it can inset its content by that amount -- it didn't ask |
| 3162 | // to actually extend itself into the overscan region. |
| 3163 | of.left = mUnrestrictedScreenLeft; |
| 3164 | of.top = mUnrestrictedScreenTop; |
| 3165 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3166 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3167 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3168 | |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3169 | if ((fl & FLAG_FULLSCREEN) == 0) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3170 | if (win.isVoiceInteraction()) { |
| 3171 | cf.left = mVoiceContentLeft; |
| 3172 | cf.top = mVoiceContentTop; |
| 3173 | cf.right = mVoiceContentRight; |
| 3174 | cf.bottom = mVoiceContentBottom; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3175 | } else { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3176 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
| 3177 | cf.left = mDockLeft; |
| 3178 | cf.top = mDockTop; |
| 3179 | cf.right = mDockRight; |
| 3180 | cf.bottom = mDockBottom; |
| 3181 | } else { |
| 3182 | cf.left = mContentLeft; |
| 3183 | cf.top = mContentTop; |
| 3184 | cf.right = mContentRight; |
| 3185 | cf.bottom = mContentBottom; |
| 3186 | } |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3187 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3188 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3189 | // Full screen windows are always given a layout that is as if the |
| 3190 | // status bar and other transient decors are gone. This is to avoid |
| 3191 | // bad states when moving from a window that is not hding the |
| 3192 | // status bar to one that is. |
| 3193 | cf.left = mRestrictedScreenLeft; |
| 3194 | cf.top = mRestrictedScreenTop; |
| 3195 | cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 3196 | cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3197 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3198 | applyStableConstraints(sysUiFl, fl, cf); |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3199 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3200 | vf.left = mCurLeft; |
| 3201 | vf.top = mCurTop; |
| 3202 | vf.right = mCurRight; |
| 3203 | vf.bottom = mCurBottom; |
| 3204 | } else { |
| 3205 | vf.set(cf); |
| 3206 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3207 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3208 | } else if ((fl & FLAG_LAYOUT_IN_SCREEN) != 0 || (sysUiFl |
| 3209 | & (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 3210 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3211 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3212 | "): IN_SCREEN"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3213 | // A window that has requested to fill the entire screen just |
| 3214 | // gets everything, period. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3215 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3216 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3217 | pf.left = df.left = of.left = cf.left = hasNavBar |
| 3218 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3219 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3220 | pf.right = df.right = of.right = cf.right = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3221 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3222 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3223 | pf.bottom = df.bottom = of.bottom = cf.bottom = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3224 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3225 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3226 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3227 | "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)", |
| 3228 | pf.left, pf.top, pf.right, pf.bottom)); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 3229 | } else if (attrs.type == TYPE_NAVIGATION_BAR |
| 3230 | || attrs.type == TYPE_NAVIGATION_BAR_PANEL) { |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3231 | // The navigation bar has Real Ultimate Power. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3232 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3233 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3234 | pf.right = df.right = of.right = mUnrestrictedScreenLeft |
| 3235 | + mUnrestrictedScreenWidth; |
| 3236 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop |
| 3237 | + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3238 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3239 | "Laying out navigation bar window: (%d,%d - %d,%d)", |
| 3240 | pf.left, pf.top, pf.right, pf.bottom)); |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3241 | } else if ((attrs.type == TYPE_SECURE_SYSTEM_OVERLAY |
| 3242 | || attrs.type == TYPE_BOOT_PROGRESS) |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 3243 | && ((fl & FLAG_FULLSCREEN) != 0)) { |
| 3244 | // Fullscreen secure system overlays get what they ask for. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3245 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3246 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3247 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3248 | + mOverscanScreenWidth; |
| 3249 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3250 | + mOverscanScreenHeight; |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 3251 | } else if (attrs.type == TYPE_BOOT_PROGRESS |
| 3252 | || attrs.type == TYPE_UNIVERSE_BACKGROUND) { |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3253 | // Boot progress screen always covers entire display. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3254 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3255 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3256 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3257 | + mOverscanScreenWidth; |
| 3258 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3259 | + mOverscanScreenHeight; |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3260 | } else if (attrs.type == TYPE_WALLPAPER) { |
| 3261 | // The wallpaper also has Real Ultimate Power. |
| 3262 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3263 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3264 | pf.right = df.right = of.right = cf.right |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3265 | = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3266 | pf.bottom = df.bottom = of.bottom = cf.bottom |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3267 | = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3268 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3269 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3270 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3271 | // Asking to layout into the overscan region, so give it that pure |
| 3272 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3273 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3274 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3275 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3276 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3277 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3278 | = mOverscanScreenTop + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3279 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3280 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3281 | && (attrs.type == TYPE_TOAST |
| 3282 | || (attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3283 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW))) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3284 | // Asking for layout as if the nav bar is hidden, lets the |
| 3285 | // application extend into the unrestricted screen area. We |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3286 | // 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] | 3287 | // can be above the nav bar can do this. |
| 3288 | // XXX This assumes that an app asking for this will also |
| 3289 | // ask for layout in only content. We can't currently figure out |
| 3290 | // 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] | 3291 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3292 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3293 | pf.right = df.right = of.right = cf.right = mUnrestrictedScreenLeft |
| 3294 | + mUnrestrictedScreenWidth; |
| 3295 | pf.bottom = df.bottom = of.bottom = cf.bottom = mUnrestrictedScreenTop |
| 3296 | + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3297 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3298 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3299 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3300 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3301 | + mRestrictedScreenWidth; |
| 3302 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3303 | + mRestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3304 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3305 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3306 | applyStableConstraints(sysUiFl, fl, cf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3307 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3308 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3309 | vf.left = mCurLeft; |
| 3310 | vf.top = mCurTop; |
| 3311 | vf.right = mCurRight; |
| 3312 | vf.bottom = mCurBottom; |
| 3313 | } else { |
| 3314 | vf.set(cf); |
| 3315 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3316 | } else if (attached != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3317 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3318 | "): attached to " + attached); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3319 | // A child window should be placed inside of the same visible |
| 3320 | // frame that its parent had. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3321 | 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] | 3322 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3323 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3324 | "): normal window"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3325 | // Otherwise, a normal window must be placed inside the content |
| 3326 | // of all screen decorations. |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3327 | if (attrs.type == TYPE_STATUS_BAR_PANEL) { |
| 3328 | // Status bar panels are the only windows who can go on top of |
| 3329 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3330 | // permission, so they have the same privileges as the status |
| 3331 | // bar itself. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3332 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3333 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3334 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3335 | + mRestrictedScreenWidth; |
| 3336 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3337 | + mRestrictedScreenHeight; |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3338 | } else if (attrs.type == TYPE_TOAST || attrs.type == TYPE_SYSTEM_ALERT |
| 3339 | || attrs.type == TYPE_VOLUME_OVERLAY) { |
| 3340 | // These dialogs are stable to interim decor changes. |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3341 | pf.left = df.left = of.left = cf.left = mStableLeft; |
| 3342 | pf.top = df.top = of.top = cf.top = mStableTop; |
| 3343 | pf.right = df.right = of.right = cf.right = mStableRight; |
| 3344 | pf.bottom = df.bottom = of.bottom = cf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3345 | } else { |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3346 | pf.left = mContentLeft; |
| 3347 | pf.top = mContentTop; |
| 3348 | pf.right = mContentRight; |
| 3349 | pf.bottom = mContentBottom; |
Dianne Hackborn | 20d9474 | 2014-05-29 18:35:45 -0700 | [diff] [blame] | 3350 | if (win.isVoiceInteraction()) { |
| 3351 | df.left = of.left = cf.left = mVoiceContentLeft; |
| 3352 | df.top = of.top = cf.top = mVoiceContentTop; |
| 3353 | df.right = of.right = cf.right = mVoiceContentRight; |
| 3354 | df.bottom = of.bottom = cf.bottom = mVoiceContentBottom; |
| 3355 | } else if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3356 | df.left = of.left = cf.left = mDockLeft; |
| 3357 | df.top = of.top = cf.top = mDockTop; |
| 3358 | df.right = of.right = cf.right = mDockRight; |
| 3359 | df.bottom = of.bottom = cf.bottom = mDockBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3360 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3361 | df.left = of.left = cf.left = mContentLeft; |
| 3362 | df.top = of.top = cf.top = mContentTop; |
| 3363 | df.right = of.right = cf.right = mContentRight; |
| 3364 | df.bottom = of.bottom = cf.bottom = mContentBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3365 | } |
| 3366 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3367 | vf.left = mCurLeft; |
| 3368 | vf.top = mCurTop; |
| 3369 | vf.right = mCurRight; |
| 3370 | vf.bottom = mCurBottom; |
| 3371 | } else { |
| 3372 | vf.set(cf); |
| 3373 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3374 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3375 | } |
| 3376 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3377 | |
Craig Mautner | b816bed | 2013-07-23 10:26:17 -0700 | [diff] [blame] | 3378 | // TYPE_SYSTEM_ERROR is above the NavigationBar so it can't be allowed to extend over it. |
| 3379 | if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0 && attrs.type != TYPE_SYSTEM_ERROR) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3380 | df.left = df.top = of.left = of.top = cf.left = cf.top = vf.left = vf.top = -10000; |
| 3381 | df.right = df.bottom = of.right = of.bottom = cf.right = cf.bottom |
| 3382 | = vf.right = vf.bottom = 10000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3383 | } |
| 3384 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3385 | 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] | 3386 | + ": sim=#" + Integer.toHexString(sim) |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3387 | + " attach=" + attached + " type=" + attrs.type |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3388 | + String.format(" flags=0x%08x", fl) |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 3389 | + " pf=" + pf.toShortString() + " df=" + df.toShortString() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3390 | + " of=" + of.toShortString() |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3391 | + " cf=" + cf.toShortString() + " vf=" + vf.toShortString() |
| 3392 | + " dcf=" + dcf.toShortString()); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3393 | |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3394 | win.computeFrameLw(pf, df, of, cf, vf, dcf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3395 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3396 | // Dock windows carve out the bottom of the screen, so normal windows |
| 3397 | // can't appear underneath them. |
Craig Mautner | 8bd206b | 2012-10-03 10:32:02 -0700 | [diff] [blame] | 3398 | if (attrs.type == TYPE_INPUT_METHOD && win.isVisibleOrBehindKeyguardLw() |
| 3399 | && !win.getGivenInsetsPendingLw()) { |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3400 | setLastInputMethodWindowLw(null, null); |
| 3401 | offsetInputMethodWindowLw(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3402 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3403 | if (attrs.type == TYPE_VOICE_INTERACTION && win.isVisibleOrBehindKeyguardLw() |
| 3404 | && !win.getGivenInsetsPendingLw()) { |
| 3405 | offsetVoiceInputWindowLw(win); |
| 3406 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3407 | } |
| 3408 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3409 | private void offsetInputMethodWindowLw(WindowState win) { |
| 3410 | int top = win.getContentFrameLw().top; |
| 3411 | top += win.getGivenContentInsetsLw().top; |
| 3412 | if (mContentBottom > top) { |
| 3413 | mContentBottom = top; |
| 3414 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3415 | if (mVoiceContentBottom > top) { |
| 3416 | mVoiceContentBottom = top; |
| 3417 | } |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3418 | top = win.getVisibleFrameLw().top; |
| 3419 | top += win.getGivenVisibleInsetsLw().top; |
| 3420 | if (mCurBottom > top) { |
| 3421 | mCurBottom = top; |
| 3422 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3423 | if (DEBUG_LAYOUT) Slog.v(TAG, "Input method: mDockBottom=" |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3424 | + mDockBottom + " mContentBottom=" |
| 3425 | + mContentBottom + " mCurBottom=" + mCurBottom); |
| 3426 | } |
| 3427 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3428 | private void offsetVoiceInputWindowLw(WindowState win) { |
| 3429 | final int gravity = win.getAttrs().gravity; |
| 3430 | switch (gravity&((Gravity.AXIS_PULL_BEFORE|Gravity.AXIS_PULL_AFTER) |
| 3431 | << Gravity.AXIS_X_SHIFT)) { |
| 3432 | case Gravity.AXIS_PULL_BEFORE<<Gravity.AXIS_X_SHIFT: { |
| 3433 | int right = win.getContentFrameLw().right - win.getGivenContentInsetsLw().right; |
| 3434 | if (mVoiceContentLeft < right) { |
| 3435 | mVoiceContentLeft = right; |
| 3436 | } |
| 3437 | } break; |
| 3438 | case Gravity.AXIS_PULL_AFTER<<Gravity.AXIS_X_SHIFT: { |
| 3439 | int left = win.getContentFrameLw().left - win.getGivenContentInsetsLw().left; |
| 3440 | if (mVoiceContentRight < left) { |
| 3441 | mVoiceContentRight = left; |
| 3442 | } |
| 3443 | } break; |
| 3444 | } |
| 3445 | switch (gravity&((Gravity.AXIS_PULL_BEFORE|Gravity.AXIS_PULL_AFTER) |
| 3446 | << Gravity.AXIS_Y_SHIFT)) { |
| 3447 | case Gravity.AXIS_PULL_BEFORE<<Gravity.AXIS_Y_SHIFT: { |
| 3448 | int bottom = win.getContentFrameLw().bottom - win.getGivenContentInsetsLw().bottom; |
| 3449 | if (mVoiceContentTop < bottom) { |
| 3450 | mVoiceContentTop = bottom; |
| 3451 | } |
| 3452 | } break; |
| 3453 | case Gravity.AXIS_PULL_AFTER<<Gravity.AXIS_Y_SHIFT: { |
| 3454 | int top = win.getContentFrameLw().top - win.getGivenContentInsetsLw().top; |
| 3455 | if (mVoiceContentBottom < top) { |
| 3456 | mVoiceContentBottom = top; |
| 3457 | } |
| 3458 | } break; |
| 3459 | } |
| 3460 | } |
| 3461 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3462 | /** {@inheritDoc} */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 3463 | @Override |
| 3464 | public void finishLayoutLw() { |
| 3465 | return; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3466 | } |
| 3467 | |
| 3468 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3469 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3470 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3471 | mTopFullscreenOpaqueWindowState = null; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3472 | mAppsToBeHidden.clear(); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3473 | mForceStatusBar = false; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3474 | mForceStatusBarFromKeyguard = false; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3475 | mForcingShowNavBar = false; |
| 3476 | mForcingShowNavBarLayer = -1; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3477 | |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3478 | mHideLockScreen = false; |
| 3479 | mAllowLockscreenWhenOn = false; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3480 | mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3481 | mShowingLockscreen = false; |
| 3482 | mShowingDream = false; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3483 | } |
| 3484 | |
| 3485 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3486 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3487 | public void applyPostLayoutPolicyLw(WindowState win, |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3488 | WindowManager.LayoutParams attrs) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3489 | if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw=" |
| 3490 | + win.isVisibleOrBehindKeyguardLw()); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3491 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3492 | if (mTopFullscreenOpaqueWindowState == null |
| 3493 | && win.isVisibleLw() && attrs.type == TYPE_INPUT_METHOD) { |
| 3494 | mForcingShowNavBar = true; |
| 3495 | mForcingShowNavBarLayer = win.getSurfaceLayer(); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3496 | } |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 3497 | if (attrs.type == TYPE_STATUS_BAR && (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 3498 | mForceStatusBarFromKeyguard = true; |
| 3499 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3500 | if (mTopFullscreenOpaqueWindowState == null && |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 3501 | win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3502 | if ((fl & FLAG_FORCE_NOT_FULLSCREEN) != 0) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3503 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3504 | mForceStatusBarFromKeyguard = true; |
| 3505 | } else { |
| 3506 | mForceStatusBar = true; |
| 3507 | } |
| 3508 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3509 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3510 | mShowingLockscreen = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3511 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3512 | boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3513 | && attrs.type <= LAST_APPLICATION_WINDOW; |
| 3514 | if (attrs.type == TYPE_DREAM) { |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3515 | // If the lockscreen was showing when the dream started then wait |
| 3516 | // for the dream to draw before hiding the lockscreen. |
| 3517 | if (!mDreamingLockscreen |
| 3518 | || (win.isVisibleLw() && win.hasDrawnLw())) { |
| 3519 | mShowingDream = true; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3520 | appWindow = true; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3521 | } |
| 3522 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3523 | |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 3524 | final boolean showWhenLocked = (fl & FLAG_SHOW_WHEN_LOCKED) != 0; |
Craig Mautner | 74ee938 | 2014-04-01 15:20:16 -0700 | [diff] [blame] | 3525 | final boolean dismissKeyguard = (fl & FLAG_DISMISS_KEYGUARD) != 0; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3526 | if (appWindow) { |
Craig Mautner | 4bdab6b | 2014-04-01 12:05:11 -0700 | [diff] [blame] | 3527 | if (showWhenLocked || (dismissKeyguard && !isKeyguardSecure())) { |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3528 | mAppsToBeHidden.remove(win.getAppToken()); |
| 3529 | } else { |
| 3530 | mAppsToBeHidden.add(win.getAppToken()); |
| 3531 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3532 | if (attrs.x == 0 && attrs.y == 0 |
| 3533 | && attrs.width == WindowManager.LayoutParams.MATCH_PARENT |
| 3534 | && attrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
| 3535 | if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win); |
| 3536 | mTopFullscreenOpaqueWindowState = win; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3537 | if (mAppsToBeHidden.isEmpty()) { |
Craig Mautner | da09ae3 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3538 | if (showWhenLocked) { |
| 3539 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 3540 | "Setting mHideLockScreen to true by win " + win); |
| 3541 | mHideLockScreen = true; |
| 3542 | mForceStatusBarFromKeyguard = false; |
| 3543 | } |
Craig Mautner | 4bdab6b | 2014-04-01 12:05:11 -0700 | [diff] [blame] | 3544 | if (dismissKeyguard && mDismissKeyguard == DISMISS_KEYGUARD_NONE) { |
Craig Mautner | da09ae3 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3545 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 3546 | "Setting mDismissKeyguard true by win " + win); |
| 3547 | mDismissKeyguard = mWinDismissingKeyguard == win ? |
| 3548 | DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START; |
| 3549 | mWinDismissingKeyguard = win; |
| 3550 | mForceStatusBarFromKeyguard = mShowingLockscreen && isKeyguardSecure(); |
| 3551 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3552 | } |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 3553 | if ((fl & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) { |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3554 | mAllowLockscreenWhenOn = true; |
| 3555 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3556 | } |
| 3557 | } |
| 3558 | } |
| 3559 | } |
| 3560 | |
| 3561 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3562 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3563 | public int finishPostLayoutPolicyLw() { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3564 | int changes = 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3565 | boolean topIsFullscreen = false; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3566 | |
| 3567 | final WindowManager.LayoutParams lp = (mTopFullscreenOpaqueWindowState != null) |
| 3568 | ? mTopFullscreenOpaqueWindowState.getAttrs() |
| 3569 | : null; |
| 3570 | |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3571 | // If we are not currently showing a dream then remember the current |
| 3572 | // lockscreen state. We will use this to determine whether the dream |
| 3573 | // started while the lockscreen was showing and remember this state |
| 3574 | // while the dream is showing. |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3575 | if (!mShowingDream) { |
| 3576 | mDreamingLockscreen = mShowingLockscreen; |
| 3577 | } |
| 3578 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3579 | if (mStatusBar != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3580 | if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3581 | + " forcefkg=" + mForceStatusBarFromKeyguard |
Dianne Hackborn | d70bc2f | 2009-10-06 23:25:51 -0700 | [diff] [blame] | 3582 | + " top=" + mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3583 | if (mForceStatusBar || mForceStatusBarFromKeyguard) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3584 | if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3585 | if (mStatusBarController.setBarShowingLw(true)) { |
| 3586 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3587 | } |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 3588 | // Maintain fullscreen layout until incoming animation is complete. |
| 3589 | topIsFullscreen = mTopIsFullscreen && mStatusBar.isAnimatingLw(); |
John Spurlock | f92b616 | 2013-11-11 15:01:16 -0500 | [diff] [blame] | 3590 | // Transient status bar on the lockscreen is not allowed |
| 3591 | if (mForceStatusBarFromKeyguard && mStatusBarController.isTransientShowing()) { |
| 3592 | mStatusBarController.updateVisibilityLw(false /*transientAllowed*/, |
| 3593 | mLastSystemUiFlags, mLastSystemUiFlags); |
| 3594 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3595 | } else if (mTopFullscreenOpaqueWindowState != null) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3596 | final int fl = PolicyControl.getWindowFlags(null, lp); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3597 | if (localLOGV) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3598 | Slog.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw() |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3599 | + " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw()); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3600 | Slog.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs() |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3601 | + " lp.flags=0x" + Integer.toHexString(fl)); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3602 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3603 | topIsFullscreen = (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0 |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3604 | || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3605 | // The subtle difference between the window for mTopFullscreenOpaqueWindowState |
| 3606 | // and mTopIsFullscreen is that that mTopIsFullscreen is set only if the window |
| 3607 | // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the |
| 3608 | // case though. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3609 | if (mStatusBarController.isTransientShowing()) { |
| 3610 | if (mStatusBarController.setBarShowingLw(true)) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3611 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3612 | } |
| 3613 | } else if (topIsFullscreen) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3614 | if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3615 | if (mStatusBarController.setBarShowingLw(false)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3616 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3617 | } else { |
Craig Mautner | c5a6e44 | 2013-06-05 17:22:35 -0700 | [diff] [blame] | 3618 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar already hiding"); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 3619 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3620 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3621 | 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] | 3622 | if (mStatusBarController.setBarShowingLw(true)) { |
| 3623 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3624 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3625 | } |
| 3626 | } |
| 3627 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3628 | |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 3629 | if (mTopIsFullscreen != topIsFullscreen) { |
| 3630 | if (!topIsFullscreen) { |
| 3631 | // Force another layout when status bar becomes fully shown. |
| 3632 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3633 | } |
| 3634 | mTopIsFullscreen = topIsFullscreen; |
| 3635 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3636 | |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3637 | // Hide the key guard if a visible window explicitly specifies that it wants to be |
| 3638 | // displayed when the screen is locked. |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3639 | if (mKeyguardDelegate != null && mStatusBar != null) { |
| 3640 | if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard=" |
| 3641 | + mHideLockScreen); |
| 3642 | if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !isKeyguardSecure()) { |
| 3643 | mKeyguardHidden = true; |
| 3644 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(true))) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3645 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3646 | | FINISH_LAYOUT_REDO_CONFIG |
| 3647 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3648 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3649 | if (mKeyguardDelegate.isShowing()) { |
| 3650 | mHandler.post(new Runnable() { |
| 3651 | @Override |
| 3652 | public void run() { |
| 3653 | mKeyguardDelegate.keyguardDone(false, false); |
| 3654 | } |
| 3655 | }); |
| 3656 | } |
| 3657 | } else if (mHideLockScreen) { |
| 3658 | mKeyguardHidden = true; |
| 3659 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(true))) { |
| 3660 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3661 | | FINISH_LAYOUT_REDO_CONFIG |
| 3662 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3663 | } |
| 3664 | } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) { |
| 3665 | // This is the case of keyguard isSecure() and not mHideLockScreen. |
| 3666 | if (mDismissKeyguard == DISMISS_KEYGUARD_START) { |
| 3667 | // Only launch the next keyguard unlock window once per window. |
| 3668 | mKeyguardHidden = false; |
| 3669 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(false))) { |
| 3670 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3671 | | FINISH_LAYOUT_REDO_CONFIG |
| 3672 | | FINISH_LAYOUT_REDO_WALLPAPER; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3673 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3674 | mHandler.post(new Runnable() { |
| 3675 | @Override |
| 3676 | public void run() { |
| 3677 | mKeyguardDelegate.dismiss(); |
| 3678 | } |
| 3679 | }); |
| 3680 | } |
| 3681 | } else { |
| 3682 | mWinDismissingKeyguard = null; |
| 3683 | mKeyguardHidden = false; |
| 3684 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(false))) { |
| 3685 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3686 | | FINISH_LAYOUT_REDO_CONFIG |
| 3687 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3688 | } |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 3689 | } |
| 3690 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3691 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3692 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3693 | // If the navigation bar has been hidden or shown, we need to do another |
| 3694 | // layout pass to update that window. |
| 3695 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3696 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3697 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3698 | // update since mAllowLockscreenWhenOn might have changed |
| 3699 | updateLockScreenTimeout(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3700 | return changes; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3701 | } |
| 3702 | |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3703 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3704 | * Processes the result code of {@link IKeyguardService#setOccluded}. This is needed because we |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3705 | * immediately need to put the wallpaper directly behind the Keyguard when a window with flag |
| 3706 | * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED} gets dismissed. If we |
| 3707 | * would wait for Keyguard to change the flags, that would be running asynchronously and thus be |
| 3708 | * too late so the user might see the window behind. |
| 3709 | * |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3710 | * @param setHiddenResult The result code from {@link IKeyguardService#setOccluded}. |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3711 | * @return Whether the flags have changed and we have to redo the layout. |
| 3712 | */ |
| 3713 | private boolean processKeyguardSetHiddenResultLw(int setHiddenResult) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3714 | if (setHiddenResult |
| 3715 | == IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_SET_FLAGS) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3716 | mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD; |
| 3717 | mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 3718 | return true; |
| 3719 | } else if (setHiddenResult |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3720 | == IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_UNSET_FLAGS) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3721 | mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD; |
| 3722 | mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER; |
| 3723 | return true; |
| 3724 | } else { |
| 3725 | return false; |
| 3726 | } |
| 3727 | } |
| 3728 | |
| 3729 | private boolean isStatusBarKeyguard() { |
| 3730 | return mStatusBar != null |
| 3731 | && (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
| 3732 | } |
| 3733 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3734 | public boolean allowAppAnimationsLw() { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3735 | if (isStatusBarKeyguard() || mShowingDream) { |
Craig Mautner | 2881630 | 2013-10-10 20:31:00 -0700 | [diff] [blame] | 3736 | // 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] | 3737 | return false; |
| 3738 | } |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3739 | return true; |
| 3740 | } |
| 3741 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3742 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus) { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3743 | mFocusedWindow = newFocus; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3744 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3745 | // If the navigation bar has been hidden or shown, we need to do another |
| 3746 | // layout pass to update that window. |
| 3747 | return FINISH_LAYOUT_REDO_LAYOUT; |
| 3748 | } |
| 3749 | return 0; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3750 | } |
| 3751 | |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 3752 | /** {@inheritDoc} */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3753 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
| 3754 | // lid changed state |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3755 | final int newLidState = lidOpen ? LID_OPEN : LID_CLOSED; |
| 3756 | if (newLidState == mLidState) { |
| 3757 | return; |
| 3758 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3759 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3760 | mLidState = newLidState; |
| 3761 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3762 | updateRotation(true); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3763 | |
| 3764 | if (lidOpen) { |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 3765 | mPowerManager.wakeUp(SystemClock.uptimeMillis()); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3766 | } else if (!mLidControlsSleep) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3767 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3768 | } |
| 3769 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3770 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3771 | void setHdmiPlugged(boolean plugged) { |
| 3772 | if (mHdmiPlugged != plugged) { |
| 3773 | mHdmiPlugged = plugged; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3774 | updateRotation(true, true); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3775 | Intent intent = new Intent(ACTION_HDMI_PLUGGED); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3776 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3777 | intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 3778 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3779 | } |
| 3780 | } |
| 3781 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3782 | void initializeHdmiState() { |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 3783 | boolean plugged = false; |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3784 | // watch for HDMI plug messages if the hdmi switch exists |
| 3785 | if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) { |
| 3786 | mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi"); |
| 3787 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3788 | final String filename = "/sys/class/switch/hdmi/state"; |
| 3789 | FileReader reader = null; |
| 3790 | try { |
| 3791 | reader = new FileReader(filename); |
| 3792 | char[] buf = new char[15]; |
| 3793 | int n = reader.read(buf); |
| 3794 | if (n > 1) { |
| 3795 | plugged = 0 != Integer.parseInt(new String(buf, 0, n-1)); |
| 3796 | } |
| 3797 | } catch (IOException ex) { |
| 3798 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 3799 | } catch (NumberFormatException ex) { |
| 3800 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 3801 | } finally { |
| 3802 | if (reader != null) { |
| 3803 | try { |
| 3804 | reader.close(); |
| 3805 | } catch (IOException ex) { |
| 3806 | } |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3807 | } |
| 3808 | } |
| 3809 | } |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 3810 | // This dance forces the code in setHdmiPlugged to run. |
| 3811 | // Always do this so the sticky intent is stuck (to false) if there is no hdmi. |
| 3812 | mHdmiPlugged = !plugged; |
| 3813 | setHdmiPlugged(!mHdmiPlugged); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3814 | } |
| 3815 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3816 | /** |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3817 | * @return Whether music is being played right now "locally" (e.g. on the device's speakers |
| 3818 | * or wired headphones) or "remotely" (e.g. on a device using the Cast protocol and |
| 3819 | * controlled by this device, or through remote submix). |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3820 | */ |
| 3821 | boolean isMusicActive() { |
Eric Laurent | 413cb9d | 2009-07-17 11:52:43 -0700 | [diff] [blame] | 3822 | final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); |
| 3823 | if (am == null) { |
| 3824 | Log.w(TAG, "isMusicActive: couldn't get AudioManager reference"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3825 | return false; |
| 3826 | } |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3827 | return am.isLocalOrRemoteMusicActive(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3828 | } |
| 3829 | |
| 3830 | /** |
| 3831 | * Tell the audio service to adjust the volume appropriate to the event. |
| 3832 | * @param keycode |
| 3833 | */ |
Mike Lockwood | a53e381 | 2009-09-25 10:51:39 -0400 | [diff] [blame] | 3834 | void handleVolumeKey(int stream, int keycode) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3835 | IAudioService audioService = getAudioService(); |
| 3836 | if (audioService == null) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3837 | return; |
| 3838 | } |
| 3839 | try { |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3840 | // 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] | 3841 | // 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] | 3842 | // that the music stops right before we call this. |
| 3843 | // Otherwise we might also be in a remote playback case. |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 3844 | // TODO: Actually handle MUTE. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3845 | mBroadcastWakeLock.acquire(); |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3846 | if (stream == AudioSystem.STREAM_MUSIC) { |
| 3847 | audioService.adjustLocalOrRemoteStreamVolume(stream, |
| 3848 | keycode == KeyEvent.KEYCODE_VOLUME_UP |
| 3849 | ? AudioManager.ADJUST_RAISE |
| 3850 | : AudioManager.ADJUST_LOWER, |
| 3851 | mContext.getOpPackageName()); |
| 3852 | } else { |
| 3853 | audioService.adjustStreamVolume(stream, |
| 3854 | keycode == KeyEvent.KEYCODE_VOLUME_UP |
| 3855 | ? AudioManager.ADJUST_RAISE |
| 3856 | : AudioManager.ADJUST_LOWER, |
| 3857 | 0, |
| 3858 | mContext.getOpPackageName()); |
| 3859 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3860 | } catch (RemoteException e) { |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3861 | Log.w(TAG, "IAudioService.adjust*StreamVolume() threw RemoteException " + e); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3862 | } finally { |
| 3863 | mBroadcastWakeLock.release(); |
| 3864 | } |
| 3865 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3866 | |
Dianne Hackborn | c0e3f24 | 2011-08-19 14:19:10 -0700 | [diff] [blame] | 3867 | final Object mScreenshotLock = new Object(); |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3868 | ServiceConnection mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3869 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3870 | final Runnable mScreenshotTimeout = new Runnable() { |
| 3871 | @Override public void run() { |
| 3872 | synchronized (mScreenshotLock) { |
| 3873 | if (mScreenshotConnection != null) { |
| 3874 | mContext.unbindService(mScreenshotConnection); |
| 3875 | mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3876 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3877 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3878 | } |
| 3879 | }; |
| 3880 | |
| 3881 | // Assume this is called from the Handler thread. |
| 3882 | private void takeScreenshot() { |
| 3883 | synchronized (mScreenshotLock) { |
| 3884 | if (mScreenshotConnection != null) { |
| 3885 | return; |
| 3886 | } |
| 3887 | ComponentName cn = new ComponentName("com.android.systemui", |
| 3888 | "com.android.systemui.screenshot.TakeScreenshotService"); |
| 3889 | Intent intent = new Intent(); |
| 3890 | intent.setComponent(cn); |
| 3891 | ServiceConnection conn = new ServiceConnection() { |
| 3892 | @Override |
| 3893 | public void onServiceConnected(ComponentName name, IBinder service) { |
| 3894 | synchronized (mScreenshotLock) { |
| 3895 | if (mScreenshotConnection != this) { |
| 3896 | return; |
| 3897 | } |
| 3898 | Messenger messenger = new Messenger(service); |
| 3899 | Message msg = Message.obtain(null, 1); |
| 3900 | final ServiceConnection myConn = this; |
| 3901 | Handler h = new Handler(mHandler.getLooper()) { |
| 3902 | @Override |
| 3903 | public void handleMessage(Message msg) { |
| 3904 | synchronized (mScreenshotLock) { |
| 3905 | if (mScreenshotConnection == myConn) { |
| 3906 | mContext.unbindService(mScreenshotConnection); |
| 3907 | mScreenshotConnection = null; |
| 3908 | mHandler.removeCallbacks(mScreenshotTimeout); |
| 3909 | } |
| 3910 | } |
| 3911 | } |
| 3912 | }; |
| 3913 | msg.replyTo = new Messenger(h); |
Winson Chung | a63bb84 | 2011-10-17 10:26:28 -0700 | [diff] [blame] | 3914 | msg.arg1 = msg.arg2 = 0; |
| 3915 | if (mStatusBar != null && mStatusBar.isVisibleLw()) |
| 3916 | msg.arg1 = 1; |
| 3917 | if (mNavigationBar != null && mNavigationBar.isVisibleLw()) |
| 3918 | msg.arg2 = 1; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3919 | try { |
| 3920 | messenger.send(msg); |
| 3921 | } catch (RemoteException e) { |
| 3922 | } |
| 3923 | } |
| 3924 | } |
| 3925 | @Override |
| 3926 | public void onServiceDisconnected(ComponentName name) {} |
| 3927 | }; |
Amith Yamasani | 27b89e6 | 2013-01-16 12:30:11 -0800 | [diff] [blame] | 3928 | if (mContext.bindServiceAsUser( |
| 3929 | intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3930 | mScreenshotConnection = conn; |
| 3931 | mHandler.postDelayed(mScreenshotTimeout, 10000); |
| 3932 | } |
| 3933 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3934 | } |
| 3935 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3936 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3937 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 3938 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3939 | if (!mSystemBooted) { |
| 3940 | // If we have not yet booted, don't let key events do anything. |
| 3941 | return 0; |
| 3942 | } |
| 3943 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 3944 | final boolean interactive = (policyFlags & FLAG_INTERACTIVE) != 0; |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 3945 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 3946 | final boolean canceled = event.isCanceled(); |
| 3947 | final int keyCode = event.getKeyCode(); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 3948 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 3949 | final boolean isInjected = (policyFlags & WindowManagerPolicy.FLAG_INJECTED) != 0; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 3950 | |
Mike Lockwood | c72b15f | 2009-11-28 20:58:22 -0500 | [diff] [blame] | 3951 | // If screen is off then we treat the case where the keyguard is open but hidden |
| 3952 | // the same as if it were open and in front. |
| 3953 | // This will prevent any keys other than the power button from waking the screen |
| 3954 | // when the keyguard is hidden by another activity. |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3955 | final boolean keyguardActive = (mKeyguardDelegate == null ? false : |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 3956 | (interactive ? |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3957 | mKeyguardDelegate.isShowingAndNotOccluded() : |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 3958 | mKeyguardDelegate.isShowing())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3959 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 3960 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3961 | Log.d(TAG, "interceptKeyTq keycode=" + keyCode |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 3962 | + " interactive=" + interactive + " keyguardActive=" + keyguardActive |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 3963 | + " policyFlags=" + Integer.toHexString(policyFlags)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3964 | } |
| 3965 | |
Jeff Brown | 98392ef | 2011-09-12 18:24:59 -0700 | [diff] [blame] | 3966 | if (down && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 |
| 3967 | && event.getRepeatCount() == 0) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3968 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
| 3969 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3970 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 3971 | // Basic policy based on interactive state. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3972 | int result; |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 3973 | boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0 |
| 3974 | || event.isWakeKey(); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 3975 | if (interactive || (isInjected && !isWakeKey)) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3976 | // When the screen is on or if the key is injected pass the key to the application. |
| 3977 | result = ACTION_PASS_TO_USER; |
| 3978 | } else { |
| 3979 | // When the screen is off and the key is not injected, determine whether |
| 3980 | // to wake the device but don't pass the key to the application. |
| 3981 | result = 0; |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 3982 | if (isWakeKey && (!down || !isWakeKeyWhenScreenOff(keyCode))) { |
| 3983 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3984 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3985 | } |
| 3986 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 3987 | // If the key would be handled globally, just return the result, don't worry about special |
| 3988 | // key processing. |
| 3989 | if (mGlobalKeyManager.shouldHandleGlobalKey(keyCode, event)) { |
| 3990 | return result; |
| 3991 | } |
| 3992 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3993 | // Handle special keys. |
| 3994 | switch (keyCode) { |
| 3995 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 3996 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 3997 | case KeyEvent.KEYCODE_VOLUME_MUTE: { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3998 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { |
| 3999 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4000 | if (interactive && !mVolumeDownKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4001 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4002 | mVolumeDownKeyTriggered = true; |
| 4003 | mVolumeDownKeyTime = event.getDownTime(); |
| 4004 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 4005 | cancelPendingPowerKeyAction(); |
| 4006 | interceptScreenshotChord(); |
| 4007 | } |
| 4008 | } else { |
| 4009 | mVolumeDownKeyTriggered = false; |
| 4010 | cancelPendingScreenshotChordAction(); |
| 4011 | } |
| 4012 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { |
| 4013 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4014 | if (interactive && !mVolumeUpKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4015 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4016 | mVolumeUpKeyTriggered = true; |
| 4017 | cancelPendingPowerKeyAction(); |
| 4018 | cancelPendingScreenshotChordAction(); |
| 4019 | } |
| 4020 | } else { |
| 4021 | mVolumeUpKeyTriggered = false; |
| 4022 | cancelPendingScreenshotChordAction(); |
| 4023 | } |
| 4024 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4025 | if (down) { |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4026 | TelephonyManager telephonyManager = getTelephonyService(); |
| 4027 | if (telephonyManager != null) { |
| 4028 | if (telephonyManager.isRinging()) { |
| 4029 | // If an incoming call is ringing, either VOLUME key means |
| 4030 | // "silence ringer". We handle these keys here, rather than |
| 4031 | // in the InCallScreen, to make sure we'll respond to them |
| 4032 | // even if the InCallScreen hasn't come to the foreground yet. |
| 4033 | // Look for the DOWN event here, to agree with the "fallback" |
| 4034 | // behavior in the InCallScreen. |
| 4035 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4036 | + " VOLUME key-down while ringing: Silence ringer!"); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4037 | |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4038 | // Silence the ringer. (It's safe to call this |
| 4039 | // even if the ringer has already been silenced.) |
| 4040 | telephonyManager.silenceRinger(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4041 | |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4042 | // And *don't* pass this key thru to the current activity |
| 4043 | // (which is probably the InCallScreen.) |
| 4044 | result &= ~ACTION_PASS_TO_USER; |
| 4045 | break; |
| 4046 | } |
| 4047 | if (telephonyManager.isOffhook() |
| 4048 | && (result & ACTION_PASS_TO_USER) == 0) { |
| 4049 | // If we are in call but we decided not to pass the key to |
| 4050 | // the application, handle the volume change here. |
| 4051 | handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keyCode); |
| 4052 | break; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4053 | } |
| 4054 | } |
| 4055 | |
| 4056 | if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { |
| 4057 | // If music is playing but we decided not to pass the key to the |
| 4058 | // application, handle the volume change here. |
| 4059 | handleVolumeKey(AudioManager.STREAM_MUSIC, keyCode); |
| 4060 | break; |
| 4061 | } |
| 4062 | } |
| 4063 | break; |
| 4064 | } |
| 4065 | |
| 4066 | case KeyEvent.KEYCODE_ENDCALL: { |
| 4067 | result &= ~ACTION_PASS_TO_USER; |
| 4068 | if (down) { |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4069 | TelephonyManager telephonyManager = getTelephonyService(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4070 | boolean hungUp = false; |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4071 | if (telephonyManager != null) { |
| 4072 | hungUp = telephonyManager.endCall(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4073 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4074 | interceptPowerKeyDown(!interactive || hungUp); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4075 | } else { |
| 4076 | if (interceptPowerKeyUp(canceled)) { |
| 4077 | if ((mEndcallBehavior |
| 4078 | & Settings.System.END_BUTTON_BEHAVIOR_HOME) != 0) { |
| 4079 | if (goHome()) { |
| 4080 | break; |
Dianne Hackborn | 0041e97 | 2009-07-24 17:14:43 -0700 | [diff] [blame] | 4081 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4082 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4083 | if ((mEndcallBehavior |
| 4084 | & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4085 | mPowerManager.goToSleep(event.getEventTime()); |
| 4086 | isWakeKey = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4087 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4088 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4089 | } |
| 4090 | break; |
| 4091 | } |
| 4092 | |
| 4093 | case KeyEvent.KEYCODE_POWER: { |
| 4094 | result &= ~ACTION_PASS_TO_USER; |
| 4095 | if (down) { |
Jeff Brown | 26c6a50 | 2014-04-11 02:15:54 -0700 | [diff] [blame] | 4096 | boolean panic = mImmersiveModeConfirmation.onPowerKeyDown(interactive, |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 4097 | event.getDownTime(), isImmersiveMode(mLastSystemUiFlags)); |
| 4098 | if (panic) { |
| 4099 | mHandler.post(mRequestTransientNav); |
| 4100 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4101 | if (interactive && !mPowerKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4102 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4103 | mPowerKeyTriggered = true; |
| 4104 | mPowerKeyTime = event.getDownTime(); |
| 4105 | interceptScreenshotChord(); |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4106 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4107 | |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4108 | TelephonyManager telephonyManager = getTelephonyService(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4109 | boolean hungUp = false; |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4110 | if (telephonyManager != null) { |
| 4111 | if (telephonyManager.isRinging()) { |
| 4112 | // Pressing Power while there's a ringing incoming |
| 4113 | // call should silence the ringer. |
| 4114 | telephonyManager.silenceRinger(); |
| 4115 | } else if ((mIncallPowerBehavior |
| 4116 | & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 |
| 4117 | && telephonyManager.isOffhook() && interactive) { |
| 4118 | // Otherwise, if "Power button ends call" is enabled, |
| 4119 | // the Power button will hang up any current active call. |
| 4120 | hungUp = telephonyManager.endCall(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4121 | } |
| 4122 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4123 | interceptPowerKeyDown(!interactive || hungUp |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4124 | || mVolumeDownKeyTriggered || mVolumeUpKeyTriggered); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4125 | } else { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4126 | mPowerKeyTriggered = false; |
| 4127 | cancelPendingScreenshotChordAction(); |
| 4128 | if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) { |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 4129 | powerShortPress(event.getEventTime()); |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4130 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4131 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4132 | mPendingPowerKeyUpCanceled = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4133 | } |
| 4134 | break; |
| 4135 | } |
| 4136 | |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4137 | case KeyEvent.KEYCODE_SLEEP: { |
| 4138 | result &= ~ACTION_PASS_TO_USER; |
| 4139 | mPowerManager.goToSleep(event.getEventTime()); |
| 4140 | isWakeKey = false; |
| 4141 | break; |
| 4142 | } |
| 4143 | |
| 4144 | case KeyEvent.KEYCODE_WAKEUP: { |
| 4145 | result &= ~ACTION_PASS_TO_USER; |
| 4146 | break; |
| 4147 | } |
| 4148 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4149 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4150 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4151 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4152 | if (down) { |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4153 | TelephonyManager telephonyManager = getTelephonyService(); |
| 4154 | if (telephonyManager != null) { |
| 4155 | if (!telephonyManager.isIdle()) { |
| 4156 | // Suppress PLAY/PAUSE toggle when phone is ringing or in-call |
| 4157 | // to avoid music playback. |
| 4158 | break; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4159 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4160 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4161 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4162 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4163 | case KeyEvent.KEYCODE_MUTE: |
| 4164 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4165 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4166 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4167 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4168 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4169 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
| 4170 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4171 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 4172 | // Only do this if we would otherwise not pass it to the user. In that |
| 4173 | // case, the PhoneWindow class will do the same thing, except it will |
| 4174 | // 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] | 4175 | // Note that we need to make a copy of the key event here because the |
| 4176 | // original key event will be recycled when we return. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4177 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4178 | Message msg = mHandler.obtainMessage(MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK, |
| 4179 | new KeyEvent(event)); |
| 4180 | msg.setAsynchronous(true); |
| 4181 | msg.sendToTarget(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4182 | } |
| 4183 | break; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4184 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4185 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4186 | case KeyEvent.KEYCODE_CALL: { |
| 4187 | if (down) { |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4188 | TelephonyManager telephonyManager = getTelephonyService(); |
| 4189 | if (telephonyManager != null) { |
| 4190 | if (telephonyManager.isRinging()) { |
| 4191 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4192 | + " CALL key-down while ringing: Answer the call!"); |
| 4193 | telephonyManager.answerRingingCall(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4194 | |
Santos Cordon | 3afed57 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4195 | // And *don't* pass this key thru to the current activity |
| 4196 | // (which is presumably the InCallScreen.) |
| 4197 | result &= ~ACTION_PASS_TO_USER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4198 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4199 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4200 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4201 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4202 | } |
| 4203 | } |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4204 | |
| 4205 | if (isWakeKey) { |
| 4206 | mPowerManager.wakeUp(event.getEventTime()); |
| 4207 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4208 | return result; |
| 4209 | } |
| 4210 | |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4211 | /** |
| 4212 | * When the screen is off we ignore some keys that might otherwise typically |
| 4213 | * be considered wake keys. We filter them out here. |
| 4214 | * |
| 4215 | * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it |
| 4216 | * is always considered a wake key. |
| 4217 | */ |
| 4218 | private boolean isWakeKeyWhenScreenOff(int keyCode) { |
| 4219 | switch (keyCode) { |
| 4220 | // ignore volume keys unless docked |
| 4221 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4222 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 4223 | case KeyEvent.KEYCODE_VOLUME_MUTE: |
| 4224 | return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 4225 | |
| 4226 | // ignore media and camera keys |
| 4227 | case KeyEvent.KEYCODE_MUTE: |
| 4228 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4229 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4230 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4231 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4232 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4233 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4234 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4235 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4236 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
| 4237 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4238 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4239 | case KeyEvent.KEYCODE_CAMERA: |
| 4240 | return false; |
| 4241 | } |
| 4242 | return true; |
| 4243 | } |
| 4244 | |
| 4245 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4246 | /** {@inheritDoc} */ |
| 4247 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4248 | public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) { |
| 4249 | // We already know this is a wake motion so just wake up. |
| 4250 | // Note that we would observe policyFlags containing |
| 4251 | // FLAG_WAKE and FLAG_INTERACTIVE here. |
| 4252 | mPowerManager.wakeUp(whenNanos / 1000000); |
| 4253 | return 0; |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4254 | } |
| 4255 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4256 | void dispatchMediaKeyWithWakeLock(KeyEvent event) { |
| 4257 | if (DEBUG_INPUT) { |
| 4258 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: " + event); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4259 | } |
| 4260 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4261 | if (mHavePendingMediaKeyRepeatWithWakeLock) { |
| 4262 | if (DEBUG_INPUT) { |
| 4263 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: canceled repeat"); |
| 4264 | } |
| 4265 | |
| 4266 | mHandler.removeMessages(MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK); |
| 4267 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4268 | mBroadcastWakeLock.release(); // pending repeat was holding onto the wake lock |
| 4269 | } |
| 4270 | |
| 4271 | dispatchMediaKeyWithWakeLockToAudioService(event); |
| 4272 | |
| 4273 | if (event.getAction() == KeyEvent.ACTION_DOWN |
| 4274 | && event.getRepeatCount() == 0) { |
| 4275 | mHavePendingMediaKeyRepeatWithWakeLock = true; |
| 4276 | |
| 4277 | Message msg = mHandler.obtainMessage( |
| 4278 | MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK, event); |
| 4279 | msg.setAsynchronous(true); |
| 4280 | mHandler.sendMessageDelayed(msg, ViewConfiguration.getKeyRepeatTimeout()); |
| 4281 | } else { |
| 4282 | mBroadcastWakeLock.release(); |
| 4283 | } |
| 4284 | } |
| 4285 | |
| 4286 | void dispatchMediaKeyRepeatWithWakeLock(KeyEvent event) { |
| 4287 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4288 | |
| 4289 | KeyEvent repeatEvent = KeyEvent.changeTimeRepeat(event, |
| 4290 | SystemClock.uptimeMillis(), 1, event.getFlags() | KeyEvent.FLAG_LONG_PRESS); |
| 4291 | if (DEBUG_INPUT) { |
| 4292 | Slog.d(TAG, "dispatchMediaKeyRepeatWithWakeLock: " + repeatEvent); |
| 4293 | } |
| 4294 | |
| 4295 | dispatchMediaKeyWithWakeLockToAudioService(repeatEvent); |
| 4296 | mBroadcastWakeLock.release(); |
| 4297 | } |
| 4298 | |
| 4299 | void dispatchMediaKeyWithWakeLockToAudioService(KeyEvent event) { |
| 4300 | if (ActivityManagerNative.isSystemReady()) { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 4301 | if (USE_SESSIONS) { |
| 4302 | MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(event, true); |
| 4303 | } else { |
| 4304 | IAudioService audioService = getAudioService(); |
| 4305 | if (audioService != null) { |
| 4306 | try { |
| 4307 | audioService.dispatchMediaKeyEventUnderWakelock(event); |
| 4308 | } catch (RemoteException e) { |
| 4309 | Log.e(TAG, "dispatchMediaKeyEvent threw exception " + e); |
| 4310 | } |
Jean-Michel Trivi | c680222 | 2012-04-30 11:15:03 -0700 | [diff] [blame] | 4311 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4312 | } |
| 4313 | } |
| 4314 | } |
| 4315 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4316 | BroadcastReceiver mDockReceiver = new BroadcastReceiver() { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4317 | @Override |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4318 | public void onReceive(Context context, Intent intent) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 4319 | if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { |
| 4320 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 4321 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4322 | } else { |
| 4323 | try { |
| 4324 | IUiModeManager uiModeService = IUiModeManager.Stub.asInterface( |
| 4325 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 4326 | mUiMode = uiModeService.getCurrentModeType(); |
| 4327 | } catch (RemoteException e) { |
| 4328 | } |
Dianne Hackborn | 80fa166 | 2009-10-07 14:02:10 -0700 | [diff] [blame] | 4329 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4330 | updateRotation(true); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4331 | synchronized (mLock) { |
| 4332 | updateOrientationListenerLp(); |
| 4333 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4334 | } |
| 4335 | }; |
| 4336 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4337 | BroadcastReceiver mDreamReceiver = new BroadcastReceiver() { |
| 4338 | @Override |
| 4339 | public void onReceive(Context context, Intent intent) { |
| 4340 | if (Intent.ACTION_DREAMING_STARTED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4341 | if (mKeyguardDelegate != null) { |
| 4342 | mKeyguardDelegate.onDreamingStarted(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4343 | } |
| 4344 | } else if (Intent.ACTION_DREAMING_STOPPED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4345 | if (mKeyguardDelegate != null) { |
| 4346 | mKeyguardDelegate.onDreamingStopped(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4347 | } |
| 4348 | } |
| 4349 | } |
| 4350 | }; |
| 4351 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4352 | BroadcastReceiver mMultiuserReceiver = new BroadcastReceiver() { |
| 4353 | @Override |
| 4354 | public void onReceive(Context context, Intent intent) { |
| 4355 | if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { |
| 4356 | // tickle the settings observer: this first ensures that we're |
| 4357 | // observing the relevant settings for the newly-active user, |
| 4358 | // and then updates our own bookkeeping based on the now- |
| 4359 | // current user. |
| 4360 | mSettingsObserver.onChange(false); |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4361 | |
| 4362 | // force a re-application of focused window sysui visibility. |
| 4363 | // the window may never have been shown for this user |
| 4364 | // e.g. the keyguard when going through the new-user setup flow |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4365 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4366 | mLastSystemUiFlags = 0; |
| 4367 | updateSystemUiVisibilityLw(); |
| 4368 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4369 | } |
| 4370 | } |
| 4371 | }; |
| 4372 | |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 4373 | private final Runnable mRequestTransientNav = new Runnable() { |
| 4374 | @Override |
| 4375 | public void run() { |
| 4376 | requestTransientBars(mNavigationBar); |
| 4377 | } |
| 4378 | }; |
| 4379 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 4380 | private void requestTransientBars(WindowState swipeTarget) { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4381 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 4382 | if (!isUserSetupComplete()) { |
| 4383 | // Swipe-up for navigation bar is disabled during setup |
| 4384 | return; |
| 4385 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4386 | boolean sb = mStatusBarController.checkShowTransientBarLw(); |
| 4387 | boolean nb = mNavigationBarController.checkShowTransientBarLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4388 | if (sb || nb) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 4389 | WindowState barTarget = sb ? mStatusBar : mNavigationBar; |
| 4390 | if (sb ^ nb && barTarget != swipeTarget) { |
| 4391 | if (DEBUG) Slog.d(TAG, "Not showing transient bar, wrong swipe target"); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4392 | return; |
| 4393 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4394 | if (sb) mStatusBarController.showTransient(); |
| 4395 | if (nb) mNavigationBarController.showTransient(); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 4396 | mImmersiveModeConfirmation.confirmCurrentPrompt(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4397 | updateSystemUiVisibilityLw(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 4398 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4399 | } |
| 4400 | } |
| 4401 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4402 | @Override |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 4403 | public void goingToSleep(int why) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4404 | EventLog.writeEvent(70000, 0); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4405 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4406 | mScreenOnEarly = false; |
| 4407 | mScreenOnFully = false; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4408 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4409 | if (mKeyguardDelegate != null) { |
| 4410 | mKeyguardDelegate.onScreenTurnedOff(why); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4411 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4412 | synchronized (mLock) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4413 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4414 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4415 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4416 | } |
| 4417 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4418 | @Override |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 4419 | public void wakingUp(final ScreenOnListener screenOnListener) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4420 | EventLog.writeEvent(70000, 1); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 4421 | if (false) { |
| 4422 | RuntimeException here = new RuntimeException("here"); |
| 4423 | here.fillInStackTrace(); |
| 4424 | Slog.i(TAG, "Screen turning on...", here); |
| 4425 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4426 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4427 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4428 | mScreenOnEarly = true; |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4429 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4430 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4431 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4432 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4433 | waitForKeyguard(screenOnListener); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4434 | } |
| 4435 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4436 | private void waitForKeyguard(final ScreenOnListener screenOnListener) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4437 | if (mKeyguardDelegate != null) { |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 4438 | mKeyguardDelegate.onScreenTurnedOn(new KeyguardServiceDelegate.ShowListener() { |
| 4439 | @Override |
| 4440 | public void onShown(IBinder windowToken) { |
| 4441 | waitForKeyguardWindowDrawn(windowToken, screenOnListener); |
| 4442 | } |
| 4443 | }); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4444 | } else { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4445 | Slog.i(TAG, "No keyguard interface!"); |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 4446 | finishScreenTurningOn(screenOnListener); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4447 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4448 | } |
| 4449 | |
| 4450 | private void waitForKeyguardWindowDrawn(IBinder windowToken, |
| 4451 | final ScreenOnListener screenOnListener) { |
Craig Mautner | 6f29590 | 2013-10-11 21:43:06 -0700 | [diff] [blame] | 4452 | if (windowToken != null && !mHideLockScreen) { |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4453 | try { |
| 4454 | if (mWindowManager.waitForWindowDrawn( |
| 4455 | windowToken, new IRemoteCallback.Stub() { |
| 4456 | @Override |
| 4457 | public void sendResult(Bundle data) { |
| 4458 | Slog.i(TAG, "Lock screen displayed!"); |
| 4459 | finishScreenTurningOn(screenOnListener); |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 4460 | setKeyguardDrawn(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4461 | } |
| 4462 | })) { |
| 4463 | return; |
| 4464 | } |
Craig Mautner | 4e8a19c | 2013-10-08 17:26:08 -0700 | [diff] [blame] | 4465 | Slog.i(TAG, "No lock screen! waitForWindowDrawn false"); |
| 4466 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4467 | } catch (RemoteException ex) { |
| 4468 | // Can't happen in system process. |
| 4469 | } |
| 4470 | } |
| 4471 | |
Craig Mautner | 4e8a19c | 2013-10-08 17:26:08 -0700 | [diff] [blame] | 4472 | Slog.i(TAG, "No lock screen! windowToken=" + windowToken); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4473 | finishScreenTurningOn(screenOnListener); |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 4474 | setKeyguardDrawn(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4475 | } |
| 4476 | |
| 4477 | private void finishScreenTurningOn(ScreenOnListener screenOnListener) { |
| 4478 | synchronized (mLock) { |
| 4479 | mScreenOnFully = true; |
| 4480 | } |
| 4481 | |
Jeff Brown | 4fc4527 | 2012-10-10 18:28:14 -0700 | [diff] [blame] | 4482 | try { |
| 4483 | mWindowManager.setEventDispatching(true); |
| 4484 | } catch (RemoteException unhandled) { |
| 4485 | } |
| 4486 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4487 | if (screenOnListener != null) { |
| 4488 | screenOnListener.onScreenOn(); |
| 4489 | } |
| 4490 | } |
| 4491 | |
| 4492 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4493 | public boolean isScreenOnEarly() { |
| 4494 | return mScreenOnEarly; |
| 4495 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4496 | |
| 4497 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4498 | public boolean isScreenOnFully() { |
| 4499 | return mScreenOnFully; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4500 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4501 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4502 | /** {@inheritDoc} */ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4503 | public void enableKeyguard(boolean enabled) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4504 | if (mKeyguardDelegate != null) { |
| 4505 | mKeyguardDelegate.setKeyguardEnabled(enabled); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4506 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4507 | } |
| 4508 | |
| 4509 | /** {@inheritDoc} */ |
| 4510 | public void exitKeyguardSecurely(OnKeyguardExitResult callback) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4511 | if (mKeyguardDelegate != null) { |
| 4512 | mKeyguardDelegate.verifyUnlock(callback); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4513 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4514 | } |
| 4515 | |
Mike Lockwood | f791330 | 2009-11-28 22:27:10 -0500 | [diff] [blame] | 4516 | private boolean keyguardIsShowingTq() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4517 | if (mKeyguardDelegate == null) return false; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4518 | return mKeyguardDelegate.isShowingAndNotOccluded(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4519 | } |
| 4520 | |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4521 | |
| 4522 | /** {@inheritDoc} */ |
| 4523 | public boolean isKeyguardLocked() { |
| 4524 | return keyguardOn(); |
| 4525 | } |
| 4526 | |
| 4527 | /** {@inheritDoc} */ |
| 4528 | public boolean isKeyguardSecure() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4529 | if (mKeyguardDelegate == null) return false; |
| 4530 | return mKeyguardDelegate.isSecure(); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4531 | } |
| 4532 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4533 | /** {@inheritDoc} */ |
| 4534 | public boolean inKeyguardRestrictedKeyInputMode() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4535 | if (mKeyguardDelegate == null) return false; |
| 4536 | return mKeyguardDelegate.isInputRestricted(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4537 | } |
| 4538 | |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4539 | public void dismissKeyguardLw() { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 4540 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4541 | mHandler.post(new Runnable() { |
| 4542 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4543 | if (mKeyguardDelegate.isDismissable()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4544 | // Can we just finish the keyguard straight away? |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4545 | mKeyguardDelegate.keyguardDone(false, true); |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4546 | } else { |
| 4547 | // ask the keyguard to prompt the user to authenticate if necessary |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4548 | mKeyguardDelegate.dismiss(); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4549 | } |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4550 | } |
| 4551 | }); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4552 | } |
| 4553 | } |
| 4554 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 4555 | private void setKeyguardDrawn() { |
| 4556 | synchronized (mLock) { |
| 4557 | mKeyguardDrawn = true; |
| 4558 | } |
| 4559 | try { |
| 4560 | mWindowManager.enableScreenIfNeeded(); |
| 4561 | } catch (RemoteException unhandled) { |
| 4562 | } |
| 4563 | } |
| 4564 | |
| 4565 | @Override |
| 4566 | public boolean isKeyguardDrawnLw() { |
| 4567 | synchronized (mLock) { |
| 4568 | return mKeyguardDrawn; |
| 4569 | } |
| 4570 | } |
| 4571 | |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4572 | @Override |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 4573 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4574 | if (mKeyguardDelegate != null) { |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 4575 | mKeyguardDelegate.startKeyguardExitAnimation(startTime, fadeoutDuration); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4576 | } |
| 4577 | } |
| 4578 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4579 | void sendCloseSystemWindows() { |
| 4580 | sendCloseSystemWindows(mContext, null); |
| 4581 | } |
| 4582 | |
| 4583 | void sendCloseSystemWindows(String reason) { |
| 4584 | sendCloseSystemWindows(mContext, reason); |
| 4585 | } |
| 4586 | |
| 4587 | static void sendCloseSystemWindows(Context context, String reason) { |
| 4588 | if (ActivityManagerNative.isSystemReady()) { |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 4589 | try { |
| 4590 | ActivityManagerNative.getDefault().closeSystemDialogs(reason); |
| 4591 | } catch (RemoteException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4592 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4593 | } |
| 4594 | } |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 4595 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4596 | @Override |
| 4597 | public int rotationForOrientationLw(int orientation, int lastRotation) { |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4598 | if (false) { |
| 4599 | Slog.v(TAG, "rotationForOrientationLw(orient=" |
| 4600 | + orientation + ", last=" + lastRotation |
| 4601 | + "); user=" + mUserRotation + " " |
| 4602 | + ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) |
| 4603 | ? "USER_ROTATION_LOCKED" : "") |
| 4604 | ); |
| 4605 | } |
| 4606 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 4607 | if (mForceDefaultOrientation) { |
| 4608 | return Surface.ROTATION_0; |
| 4609 | } |
| 4610 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4611 | synchronized (mLock) { |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4612 | int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 |
| 4613 | if (sensorRotation < 0) { |
Jeff Brown | 0f862b4 | 2012-09-27 21:11:01 -0700 | [diff] [blame] | 4614 | sensorRotation = lastRotation; |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4615 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4616 | |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4617 | final int preferredRotation; |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 4618 | if (mLidState == LID_OPEN && mLidOpenRotation >= 0) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4619 | // Ignore sensor when lid switch is open and rotation is forced. |
| 4620 | preferredRotation = mLidOpenRotation; |
| 4621 | } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4622 | && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4623 | // Ignore sensor when in car dock unless explicitly enabled. |
| 4624 | // This case can override the behavior of NOSENSOR, and can also |
| 4625 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4626 | preferredRotation = mCarDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4627 | ? sensorRotation : mCarDockRotation; |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 4628 | } else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 4629 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 4630 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4631 | && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4632 | // Ignore sensor when in desk dock unless explicitly enabled. |
| 4633 | // This case can override the behavior of NOSENSOR, and can also |
| 4634 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4635 | preferredRotation = mDeskDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4636 | ? sensorRotation : mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4637 | } else if (mHdmiPlugged && mDemoHdmiRotationLock) { |
| 4638 | // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled. |
Jeff Brown | eb3e4b9 | 2011-12-06 19:54:24 -0800 | [diff] [blame] | 4639 | // Note that the dock orientation overrides the HDMI orientation. |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4640 | preferredRotation = mDemoHdmiRotation; |
| 4641 | } else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED |
| 4642 | && mUndockedHdmiRotation >= 0) { |
| 4643 | // Ignore sensor when plugged into HDMI and an undocked orientation has |
| 4644 | // been specified in the configuration (only for legacy devices without |
| 4645 | // full multi-display support). |
| 4646 | // Note that the dock orientation overrides the HDMI orientation. |
| 4647 | preferredRotation = mUndockedHdmiRotation; |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4648 | } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { |
| 4649 | // Application just wants to remain locked in the last rotation. |
| 4650 | preferredRotation = lastRotation; |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 4651 | } else if (!mSupportAutoRotation) { |
| 4652 | // If we don't support auto-rotation then bail out here and ignore |
| 4653 | // the sensor and any rotation lock settings. |
| 4654 | preferredRotation = -1; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4655 | } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4656 | && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4657 | || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED |
| 4658 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE |
| 4659 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT |
| 4660 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER)) |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4661 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 4662 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4663 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 4664 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { |
| 4665 | // Otherwise, use sensor only if requested by the application or enabled |
| 4666 | // by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR. |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4667 | if (mAllowAllRotations < 0) { |
| 4668 | // Can't read this during init() because the context doesn't |
| 4669 | // have display metrics at that time so we cannot determine |
| 4670 | // tablet vs. phone then. |
| 4671 | mAllowAllRotations = mContext.getResources().getBoolean( |
| 4672 | com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; |
| 4673 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4674 | if (sensorRotation != Surface.ROTATION_180 |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4675 | || mAllowAllRotations == 1 |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4676 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4677 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4678 | preferredRotation = sensorRotation; |
| 4679 | } else { |
| 4680 | preferredRotation = lastRotation; |
| 4681 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4682 | } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED |
| 4683 | && orientation != ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { |
| 4684 | // Apply rotation lock. Does not apply to NOSENSOR. |
| 4685 | // The idea is that the user rotation expresses a weak preference for the direction |
| 4686 | // of gravity and as NOSENSOR is never affected by gravity, then neither should |
| 4687 | // 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] | 4688 | preferredRotation = mUserRotation; |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4689 | } else { |
| 4690 | // No overriding preference. |
| 4691 | // We will do exactly what the application asked us to do. |
| 4692 | preferredRotation = -1; |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4693 | } |
| 4694 | |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4695 | switch (orientation) { |
| 4696 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4697 | // Return portrait unless overridden. |
| 4698 | if (isAnyPortrait(preferredRotation)) { |
| 4699 | return preferredRotation; |
| 4700 | } |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4701 | return mPortraitRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4702 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4703 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4704 | // Return landscape unless overridden. |
| 4705 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4706 | return preferredRotation; |
| 4707 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4708 | return mLandscapeRotation; |
| 4709 | |
| 4710 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4711 | // Return reverse portrait unless overridden. |
| 4712 | if (isAnyPortrait(preferredRotation)) { |
| 4713 | return preferredRotation; |
| 4714 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4715 | return mUpsideDownRotation; |
| 4716 | |
| 4717 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4718 | // Return seascape unless overridden. |
| 4719 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4720 | return preferredRotation; |
| 4721 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4722 | return mSeascapeRotation; |
| 4723 | |
| 4724 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4725 | case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4726 | // Return either landscape rotation. |
| 4727 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4728 | return preferredRotation; |
| 4729 | } |
| 4730 | if (isLandscapeOrSeascape(lastRotation)) { |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 4731 | return lastRotation; |
| 4732 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4733 | return mLandscapeRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4734 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4735 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4736 | case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4737 | // Return either portrait rotation. |
| 4738 | if (isAnyPortrait(preferredRotation)) { |
| 4739 | return preferredRotation; |
| 4740 | } |
| 4741 | if (isAnyPortrait(lastRotation)) { |
| 4742 | return lastRotation; |
| 4743 | } |
| 4744 | return mPortraitRotation; |
| 4745 | |
| 4746 | default: |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 4747 | // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, |
| 4748 | // just return the preferred orientation we already calculated. |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4749 | if (preferredRotation >= 0) { |
| 4750 | return preferredRotation; |
| 4751 | } |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 4752 | return Surface.ROTATION_0; |
Daniel Sandler | e7e5ac2 | 2011-02-22 16:10:21 -0500 | [diff] [blame] | 4753 | } |
| 4754 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4755 | } |
| 4756 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4757 | @Override |
| 4758 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation) { |
| 4759 | switch (orientation) { |
| 4760 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
| 4761 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
| 4762 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
| 4763 | return isAnyPortrait(rotation); |
| 4764 | |
| 4765 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
| 4766 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
| 4767 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
| 4768 | return isLandscapeOrSeascape(rotation); |
| 4769 | |
| 4770 | default: |
| 4771 | return true; |
| 4772 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4773 | } |
| 4774 | |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4775 | @Override |
| 4776 | public void setRotationLw(int rotation) { |
| 4777 | mOrientationListener.setCurrentRotation(rotation); |
| 4778 | } |
| 4779 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4780 | private boolean isLandscapeOrSeascape(int rotation) { |
| 4781 | return rotation == mLandscapeRotation || rotation == mSeascapeRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4782 | } |
| 4783 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4784 | private boolean isAnyPortrait(int rotation) { |
| 4785 | return rotation == mPortraitRotation || rotation == mUpsideDownRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4786 | } |
| 4787 | |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4788 | public int getUserRotationMode() { |
| 4789 | return Settings.System.getIntForUser(mContext.getContentResolver(), |
Brett Chabot | 7e55c40 | 2013-05-16 19:38:08 -0700 | [diff] [blame] | 4790 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
| 4791 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 4792 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4793 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4794 | |
| 4795 | // User rotation: to be used when all else fails in assigning an orientation to the device |
| 4796 | public void setUserRotationMode(int mode, int rot) { |
| 4797 | ContentResolver res = mContext.getContentResolver(); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4798 | |
| 4799 | // mUserRotationMode and mUserRotation will be assigned by the content observer |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4800 | if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4801 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4802 | Settings.System.USER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4803 | rot, |
| 4804 | UserHandle.USER_CURRENT); |
| 4805 | Settings.System.putIntForUser(res, |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4806 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4807 | 0, |
| 4808 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4809 | } else { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4810 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4811 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4812 | 1, |
| 4813 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4814 | } |
| 4815 | } |
| 4816 | |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 4817 | public void setSafeMode(boolean safeMode) { |
| 4818 | mSafeMode = safeMode; |
| 4819 | performHapticFeedbackLw(null, safeMode |
| 4820 | ? HapticFeedbackConstants.SAFE_MODE_ENABLED |
| 4821 | : HapticFeedbackConstants.SAFE_MODE_DISABLED, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4822 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4823 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 4824 | static long[] getLongIntArray(Resources r, int resid) { |
| 4825 | int[] ar = r.getIntArray(resid); |
| 4826 | if (ar == null) { |
| 4827 | return null; |
| 4828 | } |
| 4829 | long[] out = new long[ar.length]; |
| 4830 | for (int i=0; i<ar.length; i++) { |
| 4831 | out[i] = ar[i]; |
| 4832 | } |
| 4833 | return out; |
| 4834 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4835 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4836 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4837 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4838 | public void systemReady() { |
Mike Lockwood | ed8902d | 2013-11-15 11:01:47 -0800 | [diff] [blame] | 4839 | mKeyguardDelegate = new KeyguardServiceDelegate(mContext, null); |
| 4840 | mKeyguardDelegate.onSystemReady(); |
| 4841 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 4842 | synchronized (mLock) { |
| 4843 | updateOrientationListenerLp(); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 4844 | mSystemReady = true; |
| 4845 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4846 | @Override |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 4847 | public void run() { |
| 4848 | updateSettings(); |
| 4849 | } |
| 4850 | }); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4851 | } |
| 4852 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4853 | |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 4854 | /** {@inheritDoc} */ |
| 4855 | public void systemBooted() { |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 4856 | if (mKeyguardDelegate != null) { |
| 4857 | mKeyguardDelegate.onBootCompleted(); |
| 4858 | } |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 4859 | synchronized (mLock) { |
| 4860 | mSystemBooted = true; |
| 4861 | } |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 4862 | waitForKeyguard(null); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 4863 | } |
| 4864 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4865 | ProgressDialog mBootMsgDialog = null; |
| 4866 | |
| 4867 | /** {@inheritDoc} */ |
| 4868 | public void showBootMessage(final CharSequence msg, final boolean always) { |
| 4869 | mHandler.post(new Runnable() { |
| 4870 | @Override public void run() { |
| 4871 | if (mBootMsgDialog == null) { |
Craig Stout | 4c0cb8a | 2014-04-04 13:03:10 -0700 | [diff] [blame] | 4872 | int theme; |
| 4873 | if (mContext.getPackageManager().hasSystemFeature( |
| 4874 | PackageManager.FEATURE_WATCH)) { |
| 4875 | theme = com.android.internal.R.style.Theme_Micro_Dialog_Alert; |
| 4876 | } else if (mContext.getPackageManager().hasSystemFeature( |
| 4877 | PackageManager.FEATURE_TELEVISION)) { |
| 4878 | theme = com.android.internal.R.style.Theme_Leanback_Dialog_Alert; |
| 4879 | } else { |
| 4880 | theme = 0; |
| 4881 | } |
Vinod Krishnan | fa8fc41 | 2014-04-18 14:35:53 -0700 | [diff] [blame] | 4882 | |
| 4883 | mBootMsgDialog = new ProgressDialog(mContext, theme) { |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 4884 | // This dialog will consume all events coming in to |
| 4885 | // it, to avoid it trying to do things too early in boot. |
| 4886 | @Override public boolean dispatchKeyEvent(KeyEvent event) { |
| 4887 | return true; |
| 4888 | } |
| 4889 | @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 4890 | return true; |
| 4891 | } |
| 4892 | @Override public boolean dispatchTouchEvent(MotionEvent ev) { |
| 4893 | return true; |
| 4894 | } |
| 4895 | @Override public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 4896 | return true; |
| 4897 | } |
| 4898 | @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 4899 | return true; |
| 4900 | } |
| 4901 | @Override public boolean dispatchPopulateAccessibilityEvent( |
| 4902 | AccessibilityEvent event) { |
| 4903 | return true; |
| 4904 | } |
| 4905 | }; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4906 | mBootMsgDialog.setTitle(R.string.android_upgrading_title); |
| 4907 | mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); |
| 4908 | mBootMsgDialog.setIndeterminate(true); |
| 4909 | mBootMsgDialog.getWindow().setType( |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4910 | WindowManager.LayoutParams.TYPE_BOOT_PROGRESS); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4911 | mBootMsgDialog.getWindow().addFlags( |
| 4912 | WindowManager.LayoutParams.FLAG_DIM_BEHIND |
| 4913 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); |
| 4914 | mBootMsgDialog.getWindow().setDimAmount(1); |
Dianne Hackborn | d9efb95 | 2011-12-07 14:56:51 -0800 | [diff] [blame] | 4915 | WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes(); |
| 4916 | lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 4917 | mBootMsgDialog.getWindow().setAttributes(lp); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4918 | mBootMsgDialog.setCancelable(false); |
| 4919 | mBootMsgDialog.show(); |
| 4920 | } |
| 4921 | mBootMsgDialog.setMessage(msg); |
| 4922 | } |
| 4923 | }); |
| 4924 | } |
| 4925 | |
| 4926 | /** {@inheritDoc} */ |
| 4927 | public void hideBootMessages() { |
| 4928 | mHandler.post(new Runnable() { |
| 4929 | @Override public void run() { |
| 4930 | if (mBootMsgDialog != null) { |
| 4931 | mBootMsgDialog.dismiss(); |
| 4932 | mBootMsgDialog = null; |
| 4933 | } |
| 4934 | } |
| 4935 | }); |
| 4936 | } |
| 4937 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4938 | /** {@inheritDoc} */ |
| 4939 | public void userActivity() { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4940 | // *************************************** |
| 4941 | // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE |
| 4942 | // *************************************** |
| 4943 | // THIS IS CALLED FROM DEEP IN THE POWER MANAGER |
| 4944 | // WITH ITS LOCKS HELD. |
| 4945 | // |
| 4946 | // This code must be VERY careful about the locks |
| 4947 | // it acquires. |
| 4948 | // In fact, the current code acquires way too many, |
| 4949 | // and probably has lurking deadlocks. |
| 4950 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4951 | synchronized (mScreenLockTimeout) { |
| 4952 | if (mLockScreenTimerActive) { |
| 4953 | // reset the timer |
| 4954 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 4955 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 4956 | } |
| 4957 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 4958 | } |
| 4959 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4960 | class ScreenLockTimeout implements Runnable { |
| 4961 | Bundle options; |
| 4962 | |
| 4963 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4964 | public void run() { |
| 4965 | synchronized (this) { |
| 4966 | if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4967 | if (mKeyguardDelegate != null) { |
| 4968 | mKeyguardDelegate.doKeyguardTimeout(options); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4969 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4970 | mLockScreenTimerActive = false; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4971 | options = null; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4972 | } |
| 4973 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4974 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4975 | public void setLockOptions(Bundle options) { |
| 4976 | this.options = options; |
| 4977 | } |
| 4978 | } |
| 4979 | |
| 4980 | ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout(); |
| 4981 | |
| 4982 | public void lockNow(Bundle options) { |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 4983 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); |
| 4984 | mHandler.removeCallbacks(mScreenLockTimeout); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 4985 | if (options != null) { |
| 4986 | // In case multiple calls are made to lockNow, we don't wipe out the options |
| 4987 | // until the runnable actually executes. |
| 4988 | mScreenLockTimeout.setLockOptions(options); |
| 4989 | } |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 4990 | mHandler.post(mScreenLockTimeout); |
| 4991 | } |
| 4992 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4993 | private void updateLockScreenTimeout() { |
| 4994 | synchronized (mScreenLockTimeout) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4995 | boolean enable = (mAllowLockscreenWhenOn && mScreenOnEarly && |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4996 | mKeyguardDelegate != null && mKeyguardDelegate.isSecure()); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4997 | if (mLockScreenTimerActive != enable) { |
| 4998 | if (enable) { |
| 4999 | if (localLOGV) Log.v(TAG, "setting lockscreen timer"); |
| 5000 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 5001 | } else { |
| 5002 | if (localLOGV) Log.v(TAG, "clearing lockscreen timer"); |
| 5003 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 5004 | } |
| 5005 | mLockScreenTimerActive = enable; |
| 5006 | } |
| 5007 | } |
| 5008 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5009 | |
| 5010 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5011 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5012 | public void enableScreenAfterBoot() { |
| 5013 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5014 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5015 | updateRotation(true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5016 | } |
Dianne Hackborn | f54c8f9 | 2009-09-19 14:03:57 -0700 | [diff] [blame] | 5017 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5018 | private void applyLidSwitchState() { |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5019 | if (mLidState == LID_CLOSED && mLidControlsSleep) { |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 5020 | mPowerManager.goToSleep(SystemClock.uptimeMillis(), |
| 5021 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 5022 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5023 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5024 | } |
| 5025 | |
| 5026 | void updateRotation(boolean alwaysSendConfiguration) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5027 | try { |
| 5028 | //set orientation on WindowManager |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 5029 | mWindowManager.updateRotation(alwaysSendConfiguration, false); |
| 5030 | } catch (RemoteException e) { |
| 5031 | // Ignore |
| 5032 | } |
| 5033 | } |
| 5034 | |
| 5035 | void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout) { |
| 5036 | try { |
| 5037 | //set orientation on WindowManager |
| 5038 | mWindowManager.updateRotation(alwaysSendConfiguration, forceRelayout); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5039 | } catch (RemoteException e) { |
| 5040 | // Ignore |
| 5041 | } |
| 5042 | } |
| 5043 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5044 | /** |
| 5045 | * Return an Intent to launch the currently active dock app as home. Returns |
| 5046 | * null if the standard home should be launched, which is the case if any of the following is |
| 5047 | * true: |
| 5048 | * <ul> |
| 5049 | * <li>The device is not in either car mode or desk mode |
| 5050 | * <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false |
| 5051 | * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false |
| 5052 | * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME |
| 5053 | * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME |
| 5054 | * </ul> |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5055 | * @return A dock intent. |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5056 | */ |
| 5057 | Intent createHomeDockIntent() { |
| 5058 | Intent intent = null; |
| 5059 | |
| 5060 | // What home does is based on the mode, not the dock state. That |
| 5061 | // is, when in car mode you should be taken to car home regardless |
| 5062 | // of whether we are actually in a car dock. |
| 5063 | if (mUiMode == Configuration.UI_MODE_TYPE_CAR) { |
| 5064 | if (ENABLE_CAR_DOCK_HOME_CAPTURE) { |
| 5065 | intent = mCarDockIntent; |
| 5066 | } |
| 5067 | } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { |
| 5068 | if (ENABLE_DESK_DOCK_HOME_CAPTURE) { |
| 5069 | intent = mDeskDockIntent; |
| 5070 | } |
| 5071 | } |
| 5072 | |
| 5073 | if (intent == null) { |
| 5074 | return null; |
| 5075 | } |
| 5076 | |
| 5077 | ActivityInfo ai = null; |
| 5078 | ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser( |
| 5079 | intent, |
John Spurlock | f56bef1 | 2013-07-09 09:51:46 -0400 | [diff] [blame] | 5080 | PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 5081 | mCurrentUserId); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5082 | if (info != null) { |
| 5083 | ai = info.activityInfo; |
| 5084 | } |
| 5085 | if (ai != null |
| 5086 | && ai.metaData != null |
| 5087 | && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { |
| 5088 | intent = new Intent(intent); |
| 5089 | intent.setClassName(ai.packageName, ai.name); |
| 5090 | return intent; |
| 5091 | } |
| 5092 | |
| 5093 | return null; |
| 5094 | } |
| 5095 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5096 | void startDockOrHome() { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 5097 | awakenDreams(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5098 | |
| 5099 | Intent dock = createHomeDockIntent(); |
| 5100 | if (dock != null) { |
| 5101 | try { |
| 5102 | mContext.startActivityAsUser(dock, UserHandle.CURRENT); |
| 5103 | return; |
| 5104 | } catch (ActivityNotFoundException e) { |
| 5105 | } |
| 5106 | } |
| 5107 | |
Dianne Hackborn | d888399 | 2012-09-07 15:58:52 -0700 | [diff] [blame] | 5108 | mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5109 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5110 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5111 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5112 | * goes to the home screen |
| 5113 | * @return whether it did anything |
| 5114 | */ |
| 5115 | boolean goHome() { |
| 5116 | if (false) { |
| 5117 | // This code always brings home to the front. |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 5118 | try { |
| 5119 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 5120 | } catch (RemoteException e) { |
| 5121 | } |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 5122 | sendCloseSystemWindows(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5123 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5124 | } else { |
| 5125 | // This code brings home to the front or, if it is already |
| 5126 | // at the front, puts the device to sleep. |
| 5127 | try { |
Wink Saville | d2e6a33 | 2010-02-12 12:12:06 -0800 | [diff] [blame] | 5128 | if (SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1) { |
| 5129 | /// Roll back EndcallBehavior as the cupcake design to pass P1 lab entry. |
| 5130 | Log.d(TAG, "UTS-TEST-MODE"); |
| 5131 | } else { |
| 5132 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 5133 | sendCloseSystemWindows(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5134 | Intent dock = createHomeDockIntent(); |
| 5135 | if (dock != null) { |
| 5136 | int result = ActivityManagerNative.getDefault() |
| 5137 | .startActivityAsUser(null, null, dock, |
| 5138 | dock.resolveTypeIfNeeded(mContext.getContentResolver()), |
| 5139 | null, null, 0, |
| 5140 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
| 5141 | null, null, null, UserHandle.USER_CURRENT); |
| 5142 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
| 5143 | return false; |
| 5144 | } |
| 5145 | } |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5146 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5147 | int result = ActivityManagerNative.getDefault() |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5148 | .startActivityAsUser(null, null, mHomeIntent, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5149 | mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 5150 | null, null, 0, |
| 5151 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
Dianne Hackborn | 5e03e2c | 2012-09-06 14:21:19 -0700 | [diff] [blame] | 5152 | null, null, null, UserHandle.USER_CURRENT); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 5153 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5154 | return false; |
| 5155 | } |
| 5156 | } catch (RemoteException ex) { |
| 5157 | // bummer, the activity manager, which is in this process, is dead |
| 5158 | } |
| 5159 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5160 | return true; |
| 5161 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5162 | |
| 5163 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5164 | public void setCurrentOrientationLw(int newOrientation) { |
| 5165 | synchronized (mLock) { |
| 5166 | if (newOrientation != mCurrentAppOrientation) { |
| 5167 | mCurrentAppOrientation = newOrientation; |
| 5168 | updateOrientationListenerLp(); |
| 5169 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5170 | } |
| 5171 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5172 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5173 | private void performAuditoryFeedbackForAccessibilityIfNeed() { |
| 5174 | if (!isGlobalAccessibilityGestureEnabled()) { |
| 5175 | return; |
| 5176 | } |
| 5177 | AudioManager audioManager = (AudioManager) mContext.getSystemService( |
| 5178 | Context.AUDIO_SERVICE); |
| 5179 | if (audioManager.isSilentMode()) { |
| 5180 | return; |
| 5181 | } |
| 5182 | Ringtone ringTone = RingtoneManager.getRingtone(mContext, |
| 5183 | Settings.System.DEFAULT_NOTIFICATION_URI); |
| 5184 | ringTone.setStreamType(AudioManager.STREAM_MUSIC); |
| 5185 | ringTone.play(); |
| 5186 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5187 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5188 | private boolean isGlobalAccessibilityGestureEnabled() { |
| 5189 | return Settings.Global.getInt(mContext.getContentResolver(), |
| 5190 | Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1; |
| 5191 | } |
| 5192 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5193 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5194 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { |
Svetoslav Ganov | 9617921 | 2012-10-10 14:17:45 -0700 | [diff] [blame] | 5195 | if (!mVibrator.hasVibrator()) { |
| 5196 | return false; |
| 5197 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5198 | final boolean hapticsDisabled = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 5199 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) == 0; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5200 | if (!always && (hapticsDisabled || mKeyguardDelegate.isShowingAndNotOccluded())) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5201 | return false; |
| 5202 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5203 | long[] pattern = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5204 | switch (effectId) { |
| 5205 | case HapticFeedbackConstants.LONG_PRESS: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5206 | pattern = mLongPressVibePattern; |
| 5207 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5208 | case HapticFeedbackConstants.VIRTUAL_KEY: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5209 | pattern = mVirtualKeyVibePattern; |
| 5210 | break; |
| 5211 | case HapticFeedbackConstants.KEYBOARD_TAP: |
| 5212 | pattern = mKeyboardTapVibePattern; |
| 5213 | break; |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 5214 | case HapticFeedbackConstants.CLOCK_TICK: |
| 5215 | pattern = mClockTickVibePattern; |
| 5216 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5217 | case HapticFeedbackConstants.SAFE_MODE_DISABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5218 | pattern = mSafeModeDisabledVibePattern; |
| 5219 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5220 | case HapticFeedbackConstants.SAFE_MODE_ENABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5221 | pattern = mSafeModeEnabledVibePattern; |
| 5222 | break; |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5223 | default: |
| 5224 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5225 | } |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5226 | int owningUid; |
| 5227 | String owningPackage; |
| 5228 | if (win != null) { |
| 5229 | owningUid = win.getOwningUid(); |
| 5230 | owningPackage = win.getOwningPackage(); |
| 5231 | } else { |
| 5232 | owningUid = android.os.Process.myUid(); |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 5233 | owningPackage = mContext.getOpPackageName(); |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5234 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5235 | if (pattern.length == 1) { |
| 5236 | // One-shot vibration |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 5237 | mVibrator.vibrate(owningUid, owningPackage, pattern[0], AudioManager.STREAM_SYSTEM); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5238 | } else { |
| 5239 | // Pattern vibration |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 5240 | mVibrator.vibrate(owningUid, owningPackage, pattern, -1, AudioManager.STREAM_SYSTEM); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5241 | } |
| 5242 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5243 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5244 | |
| 5245 | @Override |
| 5246 | public void keepScreenOnStartedLw() { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 5247 | } |
| 5248 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5249 | @Override |
| 5250 | public void keepScreenOnStoppedLw() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5251 | if (mKeyguardDelegate != null && !mKeyguardDelegate.isShowingAndNotOccluded()) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 5252 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5253 | } |
| 5254 | } |
Mike Lockwood | fcb3924 | 2009-10-21 23:01:07 -0400 | [diff] [blame] | 5255 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5256 | private int updateSystemUiVisibilityLw() { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5257 | // If there is no window focused, there will be nobody to handle the events |
| 5258 | // 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] | 5259 | WindowState win = mFocusedWindow != null ? mFocusedWindow : mTopFullscreenOpaqueWindowState; |
| 5260 | if (win == null) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5261 | return 0; |
| 5262 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5263 | if ((win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 && mHideLockScreen == true) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5264 | // We are updating at a point where the keyguard has gotten |
| 5265 | // focus, but we were last in a state where the top window is |
| 5266 | // hiding it. This is probably because the keyguard as been |
| 5267 | // shown while the top window was displayed, so we want to ignore |
| 5268 | // it here because this is just a very transient change and it |
| 5269 | // will quickly lose focus once it correctly gets hidden. |
| 5270 | return 0; |
| 5271 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 5272 | |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 5273 | int tmpVisibility = PolicyControl.getSystemUiVisibility(win, null) |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5274 | & ~mResettingSystemUiFlags |
| 5275 | & ~mForceClearedSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5276 | if (mForcingShowNavBar && win.getSurfaceLayer() < mForcingShowNavBarLayer) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5277 | tmpVisibility &= ~PolicyControl.adjustClearableFlags(win, View.SYSTEM_UI_CLEARABLE_FLAGS); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5278 | } |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5279 | final int visibility = updateSystemBarsLw(win, mLastSystemUiFlags, tmpVisibility); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5280 | final int diff = visibility ^ mLastSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5281 | final boolean needsMenu = win.getNeedsMenuLw(mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 5282 | if (diff == 0 && mLastFocusNeedsMenu == needsMenu |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5283 | && mFocusedApp == win.getAppToken()) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5284 | return 0; |
| 5285 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5286 | mLastSystemUiFlags = visibility; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5287 | mLastFocusNeedsMenu = needsMenu; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5288 | mFocusedApp = win.getAppToken(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5289 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5290 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5291 | public void run() { |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5292 | try { |
| 5293 | IStatusBarService statusbar = getStatusBarService(); |
| 5294 | if (statusbar != null) { |
| 5295 | statusbar.setSystemUiVisibility(visibility, 0xffffffff); |
| 5296 | statusbar.topAppWindowChanged(needsMenu); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5297 | } |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5298 | } catch (RemoteException e) { |
| 5299 | // re-acquire status bar service next time it is needed. |
| 5300 | mStatusBarService = null; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5301 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5302 | } |
| 5303 | }); |
| 5304 | return diff; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5305 | } |
| 5306 | |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5307 | private int updateSystemBarsLw(WindowState win, int oldVis, int vis) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5308 | // apply translucent bar vis flags |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5309 | WindowState transWin = isStatusBarKeyguard() && !mHideLockScreen |
| 5310 | ? mStatusBar |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5311 | : mTopFullscreenOpaqueWindowState; |
| 5312 | vis = mStatusBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 5313 | vis = mNavigationBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 5314 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5315 | // prevent status bar interaction from clearing certain flags |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5316 | boolean statusBarHasFocus = win.getAttrs().type == TYPE_STATUS_BAR; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5317 | if (statusBarHasFocus) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5318 | int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
| 5319 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 5320 | | View.SYSTEM_UI_FLAG_IMMERSIVE |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5321 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
| 5322 | if (!isStatusBarKeyguard() || mHideLockScreen) { |
| 5323 | flags |= View.STATUS_BAR_TRANSLUCENT | View.NAVIGATION_BAR_TRANSLUCENT; |
| 5324 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5325 | vis = (vis & ~flags) | (oldVis & flags); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5326 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5327 | |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5328 | if (!areTranslucentBarsAllowed()) { |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 5329 | vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT |
| 5330 | | View.SYSTEM_UI_TRANSPARENT); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5331 | } |
| 5332 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5333 | // update status bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5334 | boolean immersiveSticky = |
| 5335 | (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5336 | boolean hideStatusBarWM = |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5337 | mTopFullscreenOpaqueWindowState != null && |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5338 | (PolicyControl.getWindowFlags(mTopFullscreenOpaqueWindowState, null) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5339 | & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; |
| 5340 | boolean hideStatusBarSysui = |
| 5341 | (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5342 | boolean hideNavBarSysui = |
| 5343 | (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5344 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5345 | boolean transientStatusBarAllowed = |
| 5346 | mStatusBar != null && ( |
| 5347 | hideStatusBarWM |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5348 | || (hideStatusBarSysui && immersiveSticky) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5349 | || statusBarHasFocus); |
| 5350 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5351 | boolean transientNavBarAllowed = |
| 5352 | mNavigationBar != null && |
| 5353 | hideNavBarSysui && immersiveSticky; |
| 5354 | |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 5355 | boolean denyTransientStatus = mStatusBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5356 | && !transientStatusBarAllowed && hideStatusBarSysui; |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 5357 | boolean denyTransientNav = mNavigationBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5358 | && !transientNavBarAllowed; |
| 5359 | if (denyTransientStatus || denyTransientNav) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5360 | // clear the clearable flags instead |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5361 | clearClearableFlagsLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5362 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5363 | |
| 5364 | vis = mStatusBarController.updateVisibilityLw(transientStatusBarAllowed, oldVis, vis); |
| 5365 | |
| 5366 | // update navigation bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5367 | boolean oldImmersiveMode = isImmersiveMode(oldVis); |
| 5368 | boolean newImmersiveMode = isImmersiveMode(vis); |
| 5369 | if (win != null && oldImmersiveMode != newImmersiveMode) { |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5370 | final String pkg = win.getOwningPackage(); |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 5371 | mImmersiveModeConfirmation.immersiveModeChanged(pkg, newImmersiveMode, |
| 5372 | isUserSetupComplete()); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5373 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5374 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5375 | vis = mNavigationBarController.updateVisibilityLw(transientNavBarAllowed, oldVis, vis); |
| 5376 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 5377 | return vis; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5378 | } |
| 5379 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5380 | private void clearClearableFlagsLw() { |
| 5381 | int newVal = mResettingSystemUiFlags | View.SYSTEM_UI_CLEARABLE_FLAGS; |
| 5382 | if (newVal != mResettingSystemUiFlags) { |
| 5383 | mResettingSystemUiFlags = newVal; |
| 5384 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 5385 | } |
| 5386 | } |
| 5387 | |
| 5388 | private boolean isImmersiveMode(int vis) { |
| 5389 | 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] | 5390 | return mNavigationBar != null |
| 5391 | && (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0 |
Daniel Sandler | 900ece5 | 2013-10-18 15:53:27 -0400 | [diff] [blame] | 5392 | && (vis & flags) != 0 |
| 5393 | && canHideNavigationBar(); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5394 | } |
| 5395 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5396 | /** |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5397 | * @return whether the navigation or status bar can be made translucent |
| 5398 | * |
| 5399 | * This should return true unless touch exploration is not enabled or |
| 5400 | * R.boolean.config_enableTranslucentDecor is false. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5401 | */ |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5402 | private boolean areTranslucentBarsAllowed() { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 5403 | return mTranslucentDecorEnabled |
| 5404 | && !mAccessibilityManager.isTouchExplorationEnabled(); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5405 | } |
| 5406 | |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5407 | // Use this instead of checking config_showNavigationBar so that it can be consistently |
| 5408 | // overridden by qemu.hw.mainkeys in the emulator. |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5409 | @Override |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5410 | public boolean hasNavigationBar() { |
| 5411 | return mHasNavigationBar; |
| 5412 | } |
| 5413 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 5414 | @Override |
| 5415 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target) { |
| 5416 | mLastInputMethodWindow = ime; |
| 5417 | mLastInputMethodTargetWindow = target; |
| 5418 | } |
| 5419 | |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5420 | @Override |
Satoshi Kataoka | 658c7b8 | 2013-10-10 17:03:51 +0900 | [diff] [blame] | 5421 | public int getInputMethodWindowVisibleHeightLw() { |
| 5422 | return mDockBottom - mCurBottom; |
| 5423 | } |
| 5424 | |
| 5425 | @Override |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5426 | public void setCurrentUserLw(int newUserId) { |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 5427 | mCurrentUserId = newUserId; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5428 | if (mKeyguardDelegate != null) { |
| 5429 | mKeyguardDelegate.setCurrentUser(newUserId); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5430 | } |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 5431 | if (mStatusBarService != null) { |
| 5432 | try { |
| 5433 | mStatusBarService.setCurrentUser(newUserId); |
| 5434 | } catch (RemoteException e) { |
| 5435 | // oh well |
| 5436 | } |
| 5437 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5438 | setLastInputMethodWindowLw(null, null); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5439 | } |
| 5440 | |
| 5441 | @Override |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 5442 | public boolean canMagnifyWindow(int windowType) { |
| 5443 | switch (windowType) { |
| 5444 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD: |
| 5445 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG: |
| 5446 | case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR: |
| 5447 | case WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY: { |
| 5448 | return false; |
| 5449 | } |
| 5450 | } |
| 5451 | return true; |
| 5452 | } |
| 5453 | |
| 5454 | @Override |
| 5455 | public boolean isTopLevelWindow(int windowType) { |
| 5456 | if (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW |
| 5457 | && windowType <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 5458 | return (windowType == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG); |
| 5459 | } |
| 5460 | return true; |
| 5461 | } |
| 5462 | |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 5463 | @Override |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 5464 | public void dump(String prefix, PrintWriter pw, String[] args) { |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5465 | pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5466 | pw.print(" mSystemReady="); pw.print(mSystemReady); |
| 5467 | pw.print(" mSystemBooted="); pw.println(mSystemBooted); |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 5468 | pw.print(prefix); pw.print("mLidState="); pw.print(mLidState); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5469 | pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); |
| 5470 | pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5471 | if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 |
| 5472 | || mForceClearedSystemUiFlags != 0) { |
| 5473 | pw.print(prefix); pw.print("mLastSystemUiFlags=0x"); |
| 5474 | pw.print(Integer.toHexString(mLastSystemUiFlags)); |
| 5475 | pw.print(" mResettingSystemUiFlags=0x"); |
| 5476 | pw.print(Integer.toHexString(mResettingSystemUiFlags)); |
| 5477 | pw.print(" mForceClearedSystemUiFlags=0x"); |
| 5478 | pw.println(Integer.toHexString(mForceClearedSystemUiFlags)); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5479 | } |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5480 | if (mLastFocusNeedsMenu) { |
| 5481 | pw.print(prefix); pw.print("mLastFocusNeedsMenu="); |
| 5482 | pw.println(mLastFocusNeedsMenu); |
| 5483 | } |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 5484 | pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5485 | pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); |
| 5486 | pw.print(" mDockMode="); pw.print(mDockMode); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5487 | pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); |
| 5488 | pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); |
| 5489 | pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); |
| 5490 | pw.print(" mUserRotation="); pw.print(mUserRotation); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 5491 | pw.print(" mAllowAllRotations="); pw.println(mAllowAllRotations); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5492 | pw.print(prefix); pw.print("mCurrentAppOrientation="); pw.println(mCurrentAppOrientation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5493 | pw.print(prefix); pw.print("mCarDockEnablesAccelerometer="); |
| 5494 | pw.print(mCarDockEnablesAccelerometer); |
| 5495 | pw.print(" mDeskDockEnablesAccelerometer="); |
| 5496 | pw.println(mDeskDockEnablesAccelerometer); |
| 5497 | pw.print(prefix); pw.print("mLidKeyboardAccessibility="); |
| 5498 | pw.print(mLidKeyboardAccessibility); |
| 5499 | pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5500 | pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep); |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 5501 | pw.print(prefix); |
| 5502 | pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior); |
| 5503 | pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior); |
| 5504 | pw.print(prefix); pw.print("mHasSoftInput="); pw.println(mHasSoftInput); |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 5505 | pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly); |
| 5506 | pw.print(" mScreenOnFully="); pw.print(mScreenOnFully); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5507 | pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 5508 | pw.print(prefix); pw.print("mOverscanScreen=("); pw.print(mOverscanScreenLeft); |
| 5509 | pw.print(","); pw.print(mOverscanScreenTop); |
| 5510 | pw.print(") "); pw.print(mOverscanScreenWidth); |
| 5511 | pw.print("x"); pw.println(mOverscanScreenHeight); |
| 5512 | if (mOverscanLeft != 0 || mOverscanTop != 0 |
| 5513 | || mOverscanRight != 0 || mOverscanBottom != 0) { |
| 5514 | pw.print(prefix); pw.print("mOverscan left="); pw.print(mOverscanLeft); |
| 5515 | pw.print(" top="); pw.print(mOverscanTop); |
| 5516 | pw.print(" right="); pw.print(mOverscanRight); |
| 5517 | pw.print(" bottom="); pw.println(mOverscanBottom); |
| 5518 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 5519 | pw.print(prefix); pw.print("mRestrictedOverscanScreen=("); |
| 5520 | pw.print(mRestrictedOverscanScreenLeft); |
| 5521 | pw.print(","); pw.print(mRestrictedOverscanScreenTop); |
| 5522 | pw.print(") "); pw.print(mRestrictedOverscanScreenWidth); |
| 5523 | pw.print("x"); pw.println(mRestrictedOverscanScreenHeight); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5524 | pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft); |
| 5525 | pw.print(","); pw.print(mUnrestrictedScreenTop); |
| 5526 | pw.print(") "); pw.print(mUnrestrictedScreenWidth); |
| 5527 | pw.print("x"); pw.println(mUnrestrictedScreenHeight); |
| 5528 | pw.print(prefix); pw.print("mRestrictedScreen=("); pw.print(mRestrictedScreenLeft); |
| 5529 | pw.print(","); pw.print(mRestrictedScreenTop); |
| 5530 | pw.print(") "); pw.print(mRestrictedScreenWidth); |
| 5531 | pw.print("x"); pw.println(mRestrictedScreenHeight); |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 5532 | pw.print(prefix); pw.print("mStableFullscreen=("); pw.print(mStableFullscreenLeft); |
| 5533 | pw.print(","); pw.print(mStableFullscreenTop); |
| 5534 | pw.print(")-("); pw.print(mStableFullscreenRight); |
| 5535 | pw.print(","); pw.print(mStableFullscreenBottom); pw.println(")"); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 5536 | pw.print(prefix); pw.print("mStable=("); pw.print(mStableLeft); |
| 5537 | pw.print(","); pw.print(mStableTop); |
| 5538 | pw.print(")-("); pw.print(mStableRight); |
| 5539 | pw.print(","); pw.print(mStableBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5540 | pw.print(prefix); pw.print("mSystem=("); pw.print(mSystemLeft); |
| 5541 | pw.print(","); pw.print(mSystemTop); |
| 5542 | pw.print(")-("); pw.print(mSystemRight); |
| 5543 | pw.print(","); pw.print(mSystemBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5544 | pw.print(prefix); pw.print("mCur=("); pw.print(mCurLeft); |
| 5545 | pw.print(","); pw.print(mCurTop); |
| 5546 | pw.print(")-("); pw.print(mCurRight); |
| 5547 | pw.print(","); pw.print(mCurBottom); pw.println(")"); |
| 5548 | pw.print(prefix); pw.print("mContent=("); pw.print(mContentLeft); |
| 5549 | pw.print(","); pw.print(mContentTop); |
| 5550 | pw.print(")-("); pw.print(mContentRight); |
| 5551 | pw.print(","); pw.print(mContentBottom); pw.println(")"); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 5552 | pw.print(prefix); pw.print("mVoiceContent=("); pw.print(mVoiceContentLeft); |
| 5553 | pw.print(","); pw.print(mVoiceContentTop); |
| 5554 | pw.print(")-("); pw.print(mVoiceContentRight); |
| 5555 | pw.print(","); pw.print(mVoiceContentBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5556 | pw.print(prefix); pw.print("mDock=("); pw.print(mDockLeft); |
| 5557 | pw.print(","); pw.print(mDockTop); |
| 5558 | pw.print(")-("); pw.print(mDockRight); |
| 5559 | pw.print(","); pw.print(mDockBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5560 | pw.print(prefix); pw.print("mDockLayer="); pw.print(mDockLayer); |
| 5561 | pw.print(" mStatusBarLayer="); pw.println(mStatusBarLayer); |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5562 | pw.print(prefix); pw.print("mShowingLockscreen="); pw.print(mShowingLockscreen); |
| 5563 | pw.print(" mShowingDream="); pw.print(mShowingDream); |
| 5564 | pw.print(" mDreamingLockscreen="); pw.println(mDreamingLockscreen); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5565 | if (mLastInputMethodWindow != null) { |
| 5566 | pw.print(prefix); pw.print("mLastInputMethodWindow="); |
| 5567 | pw.println(mLastInputMethodWindow); |
| 5568 | } |
| 5569 | if (mLastInputMethodTargetWindow != null) { |
| 5570 | pw.print(prefix); pw.print("mLastInputMethodTargetWindow="); |
| 5571 | pw.println(mLastInputMethodTargetWindow); |
| 5572 | } |
| 5573 | if (mStatusBar != null) { |
| 5574 | pw.print(prefix); pw.print("mStatusBar="); |
| 5575 | pw.println(mStatusBar); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5576 | pw.print(prefix); pw.print("isStatusBarKeyguard="); |
| 5577 | pw.print(isStatusBarKeyguard()); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5578 | } |
| 5579 | if (mNavigationBar != null) { |
| 5580 | pw.print(prefix); pw.print("mNavigationBar="); |
| 5581 | pw.println(mNavigationBar); |
| 5582 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5583 | if (mFocusedWindow != null) { |
| 5584 | pw.print(prefix); pw.print("mFocusedWindow="); |
| 5585 | pw.println(mFocusedWindow); |
| 5586 | } |
| 5587 | if (mFocusedApp != null) { |
| 5588 | pw.print(prefix); pw.print("mFocusedApp="); |
| 5589 | pw.println(mFocusedApp); |
| 5590 | } |
| 5591 | if (mWinDismissingKeyguard != null) { |
| 5592 | pw.print(prefix); pw.print("mWinDismissingKeyguard="); |
| 5593 | pw.println(mWinDismissingKeyguard); |
| 5594 | } |
| 5595 | if (mTopFullscreenOpaqueWindowState != null) { |
| 5596 | pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); |
| 5597 | pw.println(mTopFullscreenOpaqueWindowState); |
| 5598 | } |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5599 | if (mForcingShowNavBar) { |
| 5600 | pw.print(prefix); pw.print("mForcingShowNavBar="); |
| 5601 | pw.println(mForcingShowNavBar); pw.print( "mForcingShowNavBarLayer="); |
| 5602 | pw.println(mForcingShowNavBarLayer); |
| 5603 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5604 | pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5605 | pw.print(" mHideLockScreen="); pw.println(mHideLockScreen); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5606 | pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); |
| 5607 | pw.print(" mForceStatusBarFromKeyguard="); |
| 5608 | pw.println(mForceStatusBarFromKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5609 | pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 5610 | pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5611 | pw.print(" mHomePressed="); pw.println(mHomePressed); |
| 5612 | pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); |
| 5613 | pw.print(" mLockScreenTimeout="); pw.print(mLockScreenTimeout); |
| 5614 | pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive); |
| 5615 | pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior); |
| 5616 | pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior); |
| 5617 | pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior); |
| 5618 | pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation); |
| 5619 | pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); |
| 5620 | pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); |
| 5621 | pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 5622 | pw.print(prefix); pw.print("mDemoHdmiRotation="); pw.print(mDemoHdmiRotation); |
| 5623 | pw.print(" mDemoHdmiRotationLock="); pw.println(mDemoHdmiRotationLock); |
| 5624 | pw.print(prefix); pw.print("mUndockedHdmiRotation="); pw.println(mUndockedHdmiRotation); |
Tim Kilbourn | d7c0c2e | 2014-05-29 16:08:10 -0700 | [diff] [blame] | 5625 | mGlobalKeyManager.dump(prefix, pw); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5626 | mStatusBarController.dump(pw, prefix); |
| 5627 | mNavigationBarController.dump(pw, prefix); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5628 | PolicyControl.dump(prefix, pw); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5629 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5630 | } |