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 | 6848f72 | 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; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 94 | import android.view.WindowManagerInternal; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 95 | import android.view.WindowManagerPolicy; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 96 | import android.view.accessibility.AccessibilityEvent; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 97 | import android.view.accessibility.AccessibilityManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 98 | import android.view.animation.Animation; |
| 99 | import android.view.animation.AnimationUtils; |
| 100 | |
| 101 | import com.android.internal.R; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 102 | import com.android.internal.policy.IKeyguardService; |
| 103 | import com.android.internal.policy.IKeyguardServiceConstants; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 104 | import com.android.internal.policy.PolicyManager; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 105 | import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 106 | import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate.ShowListener; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 107 | import com.android.internal.statusbar.IStatusBarService; |
| 108 | import com.android.internal.telephony.ITelephony; |
| 109 | import com.android.internal.widget.PointerLocationView; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 110 | import com.android.server.LocalServices; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 111 | |
| 112 | import java.io.File; |
| 113 | import java.io.FileReader; |
| 114 | import java.io.IOException; |
| 115 | import java.io.PrintWriter; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 116 | import java.util.ArrayList; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 117 | import java.util.HashSet; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 118 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 119 | import static android.view.WindowManager.LayoutParams.*; |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 120 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; |
| 121 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; |
| 122 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 123 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 124 | /** |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 125 | * WindowManagerPolicy implementation for the Android phone UI. This |
| 126 | * introduces a new method suffix, Lp, for an internal lock of the |
| 127 | * PhoneWindowManager. This is used to protect some internal state, and |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 128 | * 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] | 129 | * of both of those when held. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 130 | */ |
| 131 | public class PhoneWindowManager implements WindowManagerPolicy { |
| 132 | static final String TAG = "WindowManager"; |
| 133 | static final boolean DEBUG = false; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 134 | static final boolean localLOGV = false; |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 135 | static final boolean DEBUG_LAYOUT = false; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 136 | static final boolean DEBUG_INPUT = false; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 137 | static final boolean DEBUG_STARTING_WINDOW = false; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 138 | static final boolean DEBUG_WAKEUP = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 139 | static final boolean SHOW_STARTING_ANIMATIONS = true; |
| 140 | static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 141 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 142 | // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. |
| 143 | // No longer recommended for desk docks; still useful in car docks. |
| 144 | static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; |
| 145 | static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; |
| 146 | |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 147 | // Whether to use the new Session APIs |
| 148 | static final boolean USE_SESSIONS = true; |
| 149 | |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 150 | static final int SHORT_PRESS_POWER_NOTHING = 0; |
| 151 | static final int SHORT_PRESS_POWER_GO_TO_SLEEP = 1; |
| 152 | static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP = 2; |
| 153 | static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME = 3; |
| 154 | |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 155 | static final int LONG_PRESS_POWER_NOTHING = 0; |
| 156 | static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; |
| 157 | static final int LONG_PRESS_POWER_SHUT_OFF = 2; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 158 | static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 159 | |
| 160 | // These need to match the documentation/constant in |
| 161 | // core/res/res/values/config.xml |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 162 | static final int LONG_PRESS_HOME_NOTHING = 0; |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 163 | static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 164 | static final int LONG_PRESS_HOME_ASSIST = 2; |
| 165 | |
| 166 | static final int DOUBLE_TAP_HOME_NOTHING = 0; |
| 167 | static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 168 | |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 169 | static final int APPLICATION_MEDIA_SUBLAYER = -2; |
| 170 | static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 171 | static final int APPLICATION_PANEL_SUBLAYER = 1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 172 | static final int APPLICATION_SUB_PANEL_SUBLAYER = 2; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 173 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 174 | static public final String SYSTEM_DIALOG_REASON_KEY = "reason"; |
| 175 | static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions"; |
| 176 | static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 177 | static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 178 | static public final String SYSTEM_DIALOG_REASON_ASSIST = "assist"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 179 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 180 | /** |
| 181 | * These are the system UI flags that, when changing, can cause the layout |
| 182 | * of the screen to change. |
| 183 | */ |
| 184 | static final int SYSTEM_UI_CHANGING_LAYOUT = |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 185 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | 7f4820a | 2013-10-08 12:54:35 -0400 | [diff] [blame] | 186 | | View.SYSTEM_UI_FLAG_FULLSCREEN |
| 187 | | View.STATUS_BAR_TRANSLUCENT |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 188 | | View.NAVIGATION_BAR_TRANSLUCENT |
| 189 | | View.SYSTEM_UI_TRANSPARENT; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 190 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 191 | /** |
| 192 | * Keyguard stuff |
| 193 | */ |
| 194 | private WindowState mKeyguardScrim; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 195 | private boolean mKeyguardHidden; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 196 | private boolean mKeyguardDrawn; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 197 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 198 | /* Table of Application Launch keys. Maps from key codes to intent categories. |
| 199 | * |
| 200 | * These are special keys that are used to launch particular kinds of applications, |
| 201 | * such as a web browser. HID defines nearly a hundred of them in the Consumer (0x0C) |
| 202 | * usage page. We don't support quite that many yet... |
| 203 | */ |
| 204 | static SparseArray<String> sApplicationLaunchKeyCategories; |
| 205 | static { |
| 206 | sApplicationLaunchKeyCategories = new SparseArray<String>(); |
| 207 | sApplicationLaunchKeyCategories.append( |
| 208 | KeyEvent.KEYCODE_EXPLORER, Intent.CATEGORY_APP_BROWSER); |
| 209 | sApplicationLaunchKeyCategories.append( |
| 210 | KeyEvent.KEYCODE_ENVELOPE, Intent.CATEGORY_APP_EMAIL); |
| 211 | sApplicationLaunchKeyCategories.append( |
| 212 | KeyEvent.KEYCODE_CONTACTS, Intent.CATEGORY_APP_CONTACTS); |
| 213 | sApplicationLaunchKeyCategories.append( |
| 214 | KeyEvent.KEYCODE_CALENDAR, Intent.CATEGORY_APP_CALENDAR); |
| 215 | sApplicationLaunchKeyCategories.append( |
| 216 | KeyEvent.KEYCODE_MUSIC, Intent.CATEGORY_APP_MUSIC); |
| 217 | sApplicationLaunchKeyCategories.append( |
| 218 | KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); |
| 219 | } |
| 220 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 221 | /** |
| 222 | * Lock protecting internal state. Must not call out into window |
| 223 | * manager with lock held. (This lock will be acquired in places |
| 224 | * where the window manager is calling in with its own lock held.) |
| 225 | */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 226 | private final Object mLock = new Object(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 227 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 228 | Context mContext; |
| 229 | IWindowManager mWindowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 230 | WindowManagerFuncs mWindowManagerFuncs; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 231 | WindowManagerInternal mWindowManagerInternal; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 232 | PowerManager mPowerManager; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 233 | IStatusBarService mStatusBarService; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 234 | boolean mPreloadedRecentApps; |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 235 | final Object mServiceAquireLock = new Object(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 236 | Vibrator mVibrator; // Vibrator for giving feedback of orientation changes |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 237 | SearchManager mSearchManager; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 238 | AccessibilityManager mAccessibilityManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 239 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 240 | // Vibrator pattern for haptic feedback of a long press. |
| 241 | long[] mLongPressVibePattern; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 242 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 243 | // Vibrator pattern for haptic feedback of virtual key press. |
| 244 | long[] mVirtualKeyVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 245 | |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 246 | // Vibrator pattern for a short vibration. |
| 247 | long[] mKeyboardTapVibePattern; |
| 248 | |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 249 | // Vibrator pattern for a short vibration when tapping on an hour/minute tick of a Clock. |
| 250 | long[] mClockTickVibePattern; |
| 251 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 252 | // Vibrator pattern for haptic feedback during boot when safe mode is disabled. |
| 253 | long[] mSafeModeDisabledVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 254 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 255 | // Vibrator pattern for haptic feedback during boot when safe mode is enabled. |
| 256 | long[] mSafeModeEnabledVibePattern; |
Romain Guy | 8154cd3 | 2010-03-29 14:41:15 -0700 | [diff] [blame] | 257 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 258 | /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */ |
| 259 | boolean mEnableShiftMenuBugReports = false; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 260 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 261 | boolean mSafeMode; |
| 262 | WindowState mStatusBar = null; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 263 | int mStatusBarHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 264 | WindowState mNavigationBar = null; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 265 | boolean mHasNavigationBar = false; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 266 | boolean mCanHideNavigationBar = false; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 267 | boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side? |
| 268 | boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*? |
| 269 | int[] mNavigationBarHeightForRotation = new int[4]; |
| 270 | int[] mNavigationBarWidthForRotation = new int[4]; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 271 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 272 | KeyguardServiceDelegate mKeyguardDelegate; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 273 | // The following are only accessed on the mHandler thread. |
| 274 | boolean mKeyguardDrawComplete; |
| 275 | boolean mWindowManagerDrawComplete; |
| 276 | ArrayList<ScreenOnListener> mScreenOnListeners = new ArrayList<ScreenOnListener>(); |
| 277 | final IRemoteCallback mWindowManagerDrawCallback = new IRemoteCallback.Stub() { |
| 278 | @Override |
| 279 | public void sendResult(Bundle data) { |
| 280 | if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for display!"); |
| 281 | mHandler.sendEmptyMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE); |
| 282 | } |
| 283 | }; |
| 284 | final ShowListener mKeyguardDelegateCallback = new ShowListener() { |
| 285 | @Override |
| 286 | public void onShown(IBinder windowToken) { |
| 287 | if (DEBUG_WAKEUP) Slog.d(TAG, "mKeyguardDelegate.ShowListener.onShown."); |
| 288 | mHandler.sendEmptyMessage(MSG_KEYGUARD_DRAWN_COMPLETE); |
| 289 | } |
| 290 | }; |
| 291 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 292 | GlobalActions mGlobalActions; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 293 | volatile boolean mPowerKeyHandled; // accessed from input reader and handler thread |
| 294 | boolean mPendingPowerKeyUpCanceled; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 295 | Handler mHandler; |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 296 | WindowState mLastInputMethodWindow = null; |
| 297 | WindowState mLastInputMethodTargetWindow = null; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 298 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame^] | 299 | boolean mRecentsVisible; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 300 | int mRecentAppsHeldModifiers; |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 301 | boolean mLanguageSwitchKeyPressed; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 302 | |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 303 | int mLidState = LID_ABSENT; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 304 | boolean mHaveBuiltInKeyboard; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 305 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 306 | boolean mSystemReady; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 307 | boolean mSystemBooted; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 308 | boolean mHdmiPlugged; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 309 | int mUiMode; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 310 | int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 311 | int mLidOpenRotation; |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 312 | int mCarDockRotation; |
| 313 | int mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 314 | int mUndockedHdmiRotation; |
| 315 | int mDemoHdmiRotation; |
| 316 | boolean mDemoHdmiRotationLock; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 317 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 318 | boolean mWakeGestureEnabledSetting; |
| 319 | MyWakeGestureListener mWakeGestureListener; |
| 320 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 321 | // Default display does not rotate, apps that require non-default orientation will have to |
| 322 | // have the orientation emulated. |
| 323 | private boolean mForceDefaultOrientation = false; |
| 324 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 325 | int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; |
| 326 | int mUserRotation = Surface.ROTATION_0; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 327 | boolean mAccelerometerDefault; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 328 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 329 | boolean mSupportAutoRotation; |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 330 | int mAllowAllRotations = -1; |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 331 | boolean mCarDockEnablesAccelerometer; |
| 332 | boolean mDeskDockEnablesAccelerometer; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 333 | int mLidKeyboardAccessibility; |
| 334 | int mLidNavigationAccessibility; |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 335 | boolean mLidControlsSleep; |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 336 | int mShortPressOnPowerBehavior = -1; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 337 | int mLongPressOnPowerBehavior = -1; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 338 | boolean mScreenOnEarly = false; |
| 339 | boolean mScreenOnFully = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 340 | boolean mOrientationSensorEnabled = false; |
| 341 | int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 342 | boolean mHasSoftInput = false; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 343 | boolean mTranslucentDecorEnabled = true; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 344 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 345 | int mPointerLocationMode = 0; // guarded by mLock |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 346 | |
| 347 | // The last window we were told about in focusChanged. |
| 348 | WindowState mFocusedWindow; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 349 | IApplicationToken mFocusedApp; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 350 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 351 | PointerLocationView mPointerLocationView; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 352 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 353 | // The current size of the screen; really; extends into the overscan area of |
| 354 | // the screen and doesn't account for any system elements like the status bar. |
| 355 | int mOverscanScreenLeft, mOverscanScreenTop; |
| 356 | int mOverscanScreenWidth, mOverscanScreenHeight; |
| 357 | // The current visible size of the screen; really; (ir)regardless of whether the status |
| 358 | // bar can be hidden but not extending into the overscan area. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 359 | int mUnrestrictedScreenLeft, mUnrestrictedScreenTop; |
| 360 | int mUnrestrictedScreenWidth, mUnrestrictedScreenHeight; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 361 | // Like mOverscanScreen*, but allowed to move into the overscan region where appropriate. |
| 362 | int mRestrictedOverscanScreenLeft, mRestrictedOverscanScreenTop; |
| 363 | int mRestrictedOverscanScreenWidth, mRestrictedOverscanScreenHeight; |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 364 | // The current size of the screen; these may be different than (0,0)-(dw,dh) |
| 365 | // if the status bar can't be hidden; in that case it effectively carves out |
| 366 | // that area of the display from all other windows. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 367 | int mRestrictedScreenLeft, mRestrictedScreenTop; |
| 368 | int mRestrictedScreenWidth, mRestrictedScreenHeight; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 369 | // During layout, the current screen borders accounting for any currently |
| 370 | // visible system UI elements. |
| 371 | int mSystemLeft, mSystemTop, mSystemRight, mSystemBottom; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 372 | // For applications requesting stable content insets, these are them. |
| 373 | int mStableLeft, mStableTop, mStableRight, mStableBottom; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 374 | // For applications requesting stable content insets but have also set the |
| 375 | // fullscreen window flag, these are the stable dimensions without the status bar. |
| 376 | int mStableFullscreenLeft, mStableFullscreenTop; |
| 377 | int mStableFullscreenRight, mStableFullscreenBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 378 | // During layout, the current screen borders with all outer decoration |
| 379 | // (status bar, input method dock) accounted for. |
| 380 | int mCurLeft, mCurTop, mCurRight, mCurBottom; |
| 381 | // During layout, the frame in which content should be displayed |
| 382 | // to the user, accounting for all screen decoration except for any |
| 383 | // space they deem as available for other content. This is usually |
| 384 | // the same as mCur*, but may be larger if the screen decor has supplied |
| 385 | // content insets. |
| 386 | int mContentLeft, mContentTop, mContentRight, mContentBottom; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 387 | // During layout, the frame in which voice content should be displayed |
| 388 | // to the user, accounting for all screen decoration except for any |
| 389 | // space they deem as available for other content. |
| 390 | int mVoiceContentLeft, mVoiceContentTop, mVoiceContentRight, mVoiceContentBottom; |
Dianne Hackborn | 8e11ef0 | 2010-11-18 19:47:42 -0800 | [diff] [blame] | 391 | // 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] | 392 | // windows are placed. |
| 393 | int mDockLeft, mDockTop, mDockRight, mDockBottom; |
| 394 | // During layout, the layer at which the doc window is placed. |
| 395 | int mDockLayer; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 396 | // During layout, this is the layer of the status bar. |
| 397 | int mStatusBarLayer; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 398 | int mLastSystemUiFlags; |
| 399 | // Bits that we are in the process of clearing, so we want to prevent |
| 400 | // them from being set by applications until everything has been updated |
| 401 | // to have them clear. |
| 402 | int mResettingSystemUiFlags = 0; |
| 403 | // Bits that we are currently always keeping cleared. |
| 404 | int mForceClearedSystemUiFlags = 0; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 405 | // What we last reported to system UI about whether the compatibility |
| 406 | // menu needs to be displayed. |
| 407 | boolean mLastFocusNeedsMenu = false; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 408 | |
| 409 | FakeWindow mHideNavFakeWindow = null; |
| 410 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 411 | static final Rect mTmpParentFrame = new Rect(); |
| 412 | static final Rect mTmpDisplayFrame = new Rect(); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 413 | static final Rect mTmpOverscanFrame = new Rect(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 414 | static final Rect mTmpContentFrame = new Rect(); |
| 415 | static final Rect mTmpVisibleFrame = new Rect(); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 416 | static final Rect mTmpDecorFrame = new Rect(); |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 417 | static final Rect mTmpNavigationFrame = new Rect(); |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 418 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 419 | WindowState mTopFullscreenOpaqueWindowState; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 420 | HashSet<IApplicationToken> mAppsToBeHidden = new HashSet<IApplicationToken>(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 421 | boolean mTopIsFullscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 422 | boolean mForceStatusBar; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 423 | boolean mForceStatusBarFromKeyguard; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 424 | boolean mHideLockScreen; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 425 | boolean mForcingShowNavBar; |
| 426 | int mForcingShowNavBarLayer; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 427 | |
| 428 | // States of keyguard dismiss. |
| 429 | private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed. |
| 430 | private static final int DISMISS_KEYGUARD_START = 1; // Keyguard needs to be dismissed. |
| 431 | private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed. |
| 432 | int mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
| 433 | |
| 434 | /** The window that is currently dismissing the keyguard. Dismissing the keyguard must only |
| 435 | * be done once per window. */ |
| 436 | private WindowState mWinDismissingKeyguard; |
| 437 | |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 438 | boolean mShowingLockscreen; |
| 439 | boolean mShowingDream; |
| 440 | boolean mDreamingLockscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 441 | boolean mHomePressed; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 442 | boolean mHomeConsumed; |
| 443 | boolean mHomeDoubleTapPending; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 444 | Intent mHomeIntent; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 445 | Intent mCarDockIntent; |
| 446 | Intent mDeskDockIntent; |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 447 | boolean mSearchKeyShortcutPending; |
| 448 | boolean mConsumeSearchKeyUp; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 449 | boolean mAssistKeyLongPressed; |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 450 | boolean mPendingMetaAction; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 451 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 452 | // support for activating the lock screen while the screen is on |
| 453 | boolean mAllowLockscreenWhenOn; |
| 454 | int mLockScreenTimeout; |
| 455 | boolean mLockScreenTimerActive; |
| 456 | |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 457 | // 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] | 458 | int mEndcallBehavior; |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 459 | |
| 460 | // Behavior of POWER button while in-call and screen on. |
| 461 | // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) |
| 462 | int mIncallPowerBehavior; |
| 463 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 464 | Display mDisplay; |
| 465 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 466 | int mLandscapeRotation = 0; // default landscape rotation |
| 467 | int mSeascapeRotation = 0; // "other" landscape rotation, 180 degrees from mLandscapeRotation |
| 468 | int mPortraitRotation = 0; // default portrait rotation |
| 469 | int mUpsideDownRotation = 0; // "other" portrait rotation |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 470 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 471 | int mOverscanLeft = 0; |
| 472 | int mOverscanTop = 0; |
| 473 | int mOverscanRight = 0; |
| 474 | int mOverscanBottom = 0; |
| 475 | |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 476 | // What we do when the user long presses on home |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 477 | private int mLongPressOnHomeBehavior; |
| 478 | |
| 479 | // What we do when the user double-taps on home |
| 480 | private int mDoubleTapOnHomeBehavior; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 481 | |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 482 | // Screenshot trigger states |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 483 | // Time to volume and power must be pressed within this interval of each other. |
| 484 | private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150; |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 485 | // Increase the chord delay when taking a screenshot from the keyguard |
| 486 | private static final float KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER = 2.5f; |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 487 | private boolean mScreenshotChordEnabled; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 488 | private boolean mVolumeDownKeyTriggered; |
| 489 | private long mVolumeDownKeyTime; |
| 490 | private boolean mVolumeDownKeyConsumedByScreenshotChord; |
| 491 | private boolean mVolumeUpKeyTriggered; |
| 492 | private boolean mPowerKeyTriggered; |
| 493 | private long mPowerKeyTime; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 494 | |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 495 | /* The number of steps between min and max brightness */ |
| 496 | private static final int BRIGHTNESS_STEPS = 10; |
| 497 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 498 | SettingsObserver mSettingsObserver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 499 | ShortcutManager mShortcutManager; |
| 500 | PowerManager.WakeLock mBroadcastWakeLock; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 501 | boolean mHavePendingMediaKeyRepeatWithWakeLock; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 502 | |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 503 | private int mCurrentUserId; |
| 504 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 505 | // Maps global key codes to the components that will handle them. |
| 506 | private GlobalKeyManager mGlobalKeyManager; |
| 507 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 508 | // Fallback actions by key code. |
| 509 | private final SparseArray<KeyCharacterMap.FallbackAction> mFallbackActions = |
| 510 | new SparseArray<KeyCharacterMap.FallbackAction>(); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 511 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 512 | private static final int MSG_ENABLE_POINTER_LOCATION = 1; |
| 513 | private static final int MSG_DISABLE_POINTER_LOCATION = 2; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 514 | private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; |
| 515 | private static final int MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK = 4; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 516 | private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5; |
| 517 | private static final int MSG_KEYGUARD_DRAWN_TIMEOUT = 6; |
| 518 | private static final int MSG_WINDOW_MANAGER_DRAWN_COMPLETE = 7; |
| 519 | private static final int MSG_WAKING_UP = 8; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 520 | |
| 521 | private class PolicyHandler extends Handler { |
| 522 | @Override |
| 523 | public void handleMessage(Message msg) { |
| 524 | switch (msg.what) { |
| 525 | case MSG_ENABLE_POINTER_LOCATION: |
| 526 | enablePointerLocation(); |
| 527 | break; |
| 528 | case MSG_DISABLE_POINTER_LOCATION: |
| 529 | disablePointerLocation(); |
| 530 | break; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 531 | case MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK: |
| 532 | dispatchMediaKeyWithWakeLock((KeyEvent)msg.obj); |
| 533 | break; |
| 534 | case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK: |
| 535 | dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj); |
| 536 | break; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 537 | case MSG_KEYGUARD_DRAWN_COMPLETE: |
| 538 | if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mKeyguardDrawComplete"); |
| 539 | mKeyguardDrawComplete = true; |
| 540 | finishScreenTurningOn(); |
| 541 | break; |
| 542 | case MSG_KEYGUARD_DRAWN_TIMEOUT: |
| 543 | Slog.w(TAG, "Keyguard drawn timeout. Setting mKeyguardDrawComplete"); |
| 544 | mKeyguardDrawComplete = true; |
| 545 | finishScreenTurningOn(); |
| 546 | break; |
| 547 | case MSG_WINDOW_MANAGER_DRAWN_COMPLETE: |
| 548 | if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mWindowManagerDrawComplete"); |
| 549 | mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT); |
| 550 | mWindowManagerDrawComplete = true; |
| 551 | finishScreenTurningOn(); |
| 552 | break; |
| 553 | case MSG_WAKING_UP: |
| 554 | handleWakingUp((ScreenOnListener) msg.obj); |
| 555 | break; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 556 | } |
| 557 | } |
| 558 | } |
| 559 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 560 | private UEventObserver mHDMIObserver = new UEventObserver() { |
| 561 | @Override |
| 562 | public void onUEvent(UEventObserver.UEvent event) { |
| 563 | setHdmiPlugged("1".equals(event.get("SWITCH_STATE"))); |
| 564 | } |
| 565 | }; |
| 566 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 567 | class SettingsObserver extends ContentObserver { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 568 | SettingsObserver(Handler handler) { |
| 569 | super(handler); |
| 570 | } |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 571 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 572 | void observe() { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 573 | // Observe all users' changes |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 574 | ContentResolver resolver = mContext.getContentResolver(); |
| 575 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 576 | Settings.System.END_BUTTON_BEHAVIOR), false, this, |
| 577 | UserHandle.USER_ALL); |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 578 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 579 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this, |
| 580 | UserHandle.USER_ALL); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 581 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
| 582 | Settings.Secure.WAKE_GESTURE_ENABLED), false, this, |
| 583 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 584 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 585 | Settings.System.ACCELEROMETER_ROTATION), false, this, |
| 586 | UserHandle.USER_ALL); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 587 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 588 | Settings.System.USER_ROTATION), false, this, |
| 589 | UserHandle.USER_ALL); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 590 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 591 | Settings.System.SCREEN_OFF_TIMEOUT), false, this, |
| 592 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 593 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 594 | Settings.System.POINTER_LOCATION), false, this, |
| 595 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 596 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 597 | Settings.Secure.DEFAULT_INPUT_METHOD), false, this, |
| 598 | UserHandle.USER_ALL); |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 599 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 600 | Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS), false, this, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 601 | UserHandle.USER_ALL); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 602 | resolver.registerContentObserver(Settings.Global.getUriFor( |
| 603 | Settings.Global.POLICY_CONTROL), false, this, |
| 604 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 605 | updateSettings(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | @Override public void onChange(boolean selfChange) { |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 609 | updateSettings(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 610 | updateRotation(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 611 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 612 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 613 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 614 | class MyWakeGestureListener extends WakeGestureListener { |
| 615 | MyWakeGestureListener(Context context, Handler handler) { |
| 616 | super(context, handler); |
| 617 | } |
| 618 | |
| 619 | @Override |
| 620 | public void onWakeUp() { |
| 621 | synchronized (mLock) { |
| 622 | if (shouldEnableWakeGestureLp()) { |
| 623 | mPowerManager.wakeUp(SystemClock.uptimeMillis()); |
| 624 | } |
| 625 | } |
| 626 | } |
| 627 | } |
| 628 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 629 | class MyOrientationListener extends WindowOrientationListener { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 630 | MyOrientationListener(Context context, Handler handler) { |
| 631 | super(context, handler); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 632 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 633 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 634 | @Override |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 635 | public void onProposedRotationChanged(int rotation) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 636 | if (localLOGV) Slog.v(TAG, "onProposedRotationChanged, rotation=" + rotation); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 637 | updateRotation(false); |
| 638 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 639 | } |
| 640 | MyOrientationListener mOrientationListener; |
| 641 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 642 | private final BarController mStatusBarController = new BarController("StatusBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 643 | View.STATUS_BAR_TRANSIENT, |
| 644 | View.STATUS_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 645 | View.STATUS_BAR_TRANSLUCENT, |
| 646 | StatusBarManager.WINDOW_STATUS_BAR, |
| 647 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 648 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 649 | private final BarController mNavigationBarController = new BarController("NavigationBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 650 | View.NAVIGATION_BAR_TRANSIENT, |
| 651 | View.NAVIGATION_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 652 | View.NAVIGATION_BAR_TRANSLUCENT, |
| 653 | StatusBarManager.WINDOW_NAVIGATION_BAR, |
| 654 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 655 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 656 | private ImmersiveModeConfirmation mImmersiveModeConfirmation; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 657 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 658 | private SystemGesturesPointerEventListener mSystemGestures; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 659 | |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 660 | IStatusBarService getStatusBarService() { |
| 661 | synchronized (mServiceAquireLock) { |
| 662 | if (mStatusBarService == null) { |
| 663 | mStatusBarService = IStatusBarService.Stub.asInterface( |
| 664 | ServiceManager.getService("statusbar")); |
| 665 | } |
| 666 | return mStatusBarService; |
| 667 | } |
| 668 | } |
| 669 | |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 670 | /* |
| 671 | * We always let the sensor be switched on by default except when |
| 672 | * the user has explicitly disabled sensor based rotation or when the |
| 673 | * screen is switched off. |
| 674 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 675 | boolean needSensorRunningLp() { |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 676 | if (mSupportAutoRotation) { |
| 677 | if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 678 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 679 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT |
| 680 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { |
| 681 | // If the application has explicitly requested to follow the |
| 682 | // orientation, then we need to turn the sensor on. |
| 683 | return true; |
| 684 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 685 | } |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 686 | if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 687 | (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 688 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 689 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK))) { |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 690 | // enable accelerometer if we are docked in a dock that enables accelerometer |
| 691 | // orientation management, |
| 692 | return true; |
| 693 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 694 | if (mUserRotationMode == USER_ROTATION_LOCKED) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 695 | // If the setting for using the sensor by default is enabled, then |
| 696 | // we will always leave it on. Note that the user could go to |
| 697 | // a window that forces an orientation that does not use the |
| 698 | // sensor and in theory we could turn it off... however, when next |
| 699 | // turning it on we won't have a good value for the current |
| 700 | // orientation for a little bit, which can cause orientation |
| 701 | // changes to lag, so we'd like to keep it always on. (It will |
| 702 | // still be turned off when the screen is off.) |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 703 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 704 | } |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 705 | return mSupportAutoRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 706 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 707 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 708 | /* |
| 709 | * Various use cases for invoking this function |
| 710 | * screen turning off, should always disable listeners if already enabled |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 711 | * 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] | 712 | * if not already enabled |
| 713 | * screen turned on and current app does not have sensor orientation, disable listeners if |
| 714 | * already enabled |
| 715 | * screen turning on and current app has sensor based orientation, enable listeners if needed |
| 716 | * screen turning on and current app has nosensor based orientation, do nothing |
| 717 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 718 | void updateOrientationListenerLp() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 719 | if (!mOrientationListener.canDetectOrientation()) { |
| 720 | // If sensor is turned off or nonexistent for some reason |
| 721 | return; |
| 722 | } |
| 723 | //Could have been invoked due to screen turning on or off or |
| 724 | //change of the currently visible window's orientation |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 725 | if (localLOGV) Slog.v(TAG, "Screen status="+mScreenOnEarly+ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 726 | ", current orientation="+mCurrentAppOrientation+ |
| 727 | ", SensorEnabled="+mOrientationSensorEnabled); |
| 728 | boolean disable = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 729 | if (mScreenOnEarly) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 730 | if (needSensorRunningLp()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 731 | disable = false; |
| 732 | //enable listener if not already enabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 733 | if (!mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 734 | mOrientationListener.enable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 735 | if(localLOGV) Slog.v(TAG, "Enabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 736 | mOrientationSensorEnabled = true; |
| 737 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 738 | } |
| 739 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 740 | //check if sensors need to be disabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 741 | if (disable && mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 742 | mOrientationListener.disable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 743 | if(localLOGV) Slog.v(TAG, "Disabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 744 | mOrientationSensorEnabled = false; |
| 745 | } |
| 746 | } |
| 747 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 748 | private void interceptPowerKeyDown(boolean handled) { |
| 749 | mPowerKeyHandled = handled; |
| 750 | if (!handled) { |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 751 | mHandler.postDelayed(mPowerLongPress, |
| 752 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 753 | } |
| 754 | } |
| 755 | |
| 756 | private boolean interceptPowerKeyUp(boolean canceled) { |
| 757 | if (!mPowerKeyHandled) { |
| 758 | mHandler.removeCallbacks(mPowerLongPress); |
| 759 | return !canceled; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 760 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 761 | return false; |
| 762 | } |
| 763 | |
| 764 | private void cancelPendingPowerKeyAction() { |
| 765 | if (!mPowerKeyHandled) { |
| 766 | mHandler.removeCallbacks(mPowerLongPress); |
| 767 | } |
Jeff Brown | ff20471 | 2011-10-25 21:27:54 -0700 | [diff] [blame] | 768 | if (mPowerKeyTriggered) { |
| 769 | mPendingPowerKeyUpCanceled = true; |
| 770 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | private void interceptScreenshotChord() { |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 774 | if (mScreenshotChordEnabled |
| 775 | && mVolumeDownKeyTriggered && mPowerKeyTriggered && !mVolumeUpKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 776 | final long now = SystemClock.uptimeMillis(); |
| 777 | if (now <= mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS |
| 778 | && now <= mPowerKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) { |
| 779 | mVolumeDownKeyConsumedByScreenshotChord = true; |
| 780 | cancelPendingPowerKeyAction(); |
| 781 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 782 | mHandler.postDelayed(mScreenshotRunnable, getScreenshotChordLongPressDelay()); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 783 | } |
| 784 | } |
| 785 | } |
| 786 | |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 787 | private long getScreenshotChordLongPressDelay() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 788 | if (mKeyguardDelegate.isShowing()) { |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 789 | // Double the time it takes to take a screenshot from the keyguard |
| 790 | return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER * |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 791 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 792 | } |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 793 | return ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout(); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 794 | } |
| 795 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 796 | private void cancelPendingScreenshotChordAction() { |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 797 | mHandler.removeCallbacks(mScreenshotRunnable); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 798 | } |
| 799 | |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 800 | private void powerShortPress(long eventTime) { |
| 801 | if (mShortPressOnPowerBehavior < 0) { |
| 802 | mShortPressOnPowerBehavior = mContext.getResources().getInteger( |
| 803 | com.android.internal.R.integer.config_shortPressOnPowerBehavior); |
| 804 | } |
| 805 | |
| 806 | switch (mShortPressOnPowerBehavior) { |
| 807 | case SHORT_PRESS_POWER_NOTHING: |
| 808 | break; |
| 809 | case SHORT_PRESS_POWER_GO_TO_SLEEP: |
| 810 | mPowerManager.goToSleep(eventTime, |
| 811 | PowerManager.GO_TO_SLEEP_REASON_USER, 0); |
| 812 | break; |
| 813 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP: |
| 814 | mPowerManager.goToSleep(eventTime, |
| 815 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 816 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 817 | break; |
| 818 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME: |
| 819 | mPowerManager.goToSleep(eventTime, |
| 820 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 821 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 822 | launchHomeFromHotKey(); |
| 823 | break; |
| 824 | } |
| 825 | } |
| 826 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 827 | private final Runnable mPowerLongPress = new Runnable() { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 828 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 829 | public void run() { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 830 | // The context isn't read |
| 831 | if (mLongPressOnPowerBehavior < 0) { |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 832 | mLongPressOnPowerBehavior = mContext.getResources().getInteger( |
| 833 | com.android.internal.R.integer.config_longPressOnPowerBehavior); |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 834 | } |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 835 | int resolvedBehavior = mLongPressOnPowerBehavior; |
| 836 | if (FactoryTest.isLongPressOnPowerOffEnabled()) { |
| 837 | resolvedBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM; |
| 838 | } |
| 839 | |
| 840 | switch (resolvedBehavior) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 841 | case LONG_PRESS_POWER_NOTHING: |
| 842 | break; |
| 843 | case LONG_PRESS_POWER_GLOBAL_ACTIONS: |
| 844 | mPowerKeyHandled = true; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 845 | if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) { |
| 846 | performAuditoryFeedbackForAccessibilityIfNeed(); |
| 847 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 848 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
| 849 | showGlobalActionsDialog(); |
| 850 | break; |
| 851 | case LONG_PRESS_POWER_SHUT_OFF: |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 852 | case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM: |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 853 | mPowerKeyHandled = true; |
| 854 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 855 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 856 | mWindowManagerFuncs.shutdown(resolvedBehavior == LONG_PRESS_POWER_SHUT_OFF); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 857 | break; |
| 858 | } |
| 859 | } |
| 860 | }; |
| 861 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 862 | private final Runnable mScreenshotRunnable = new Runnable() { |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 863 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 864 | public void run() { |
| 865 | takeScreenshot(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 866 | } |
| 867 | }; |
| 868 | |
| 869 | void showGlobalActionsDialog() { |
| 870 | if (mGlobalActions == null) { |
Jeff Brown | 7304c34 | 2012-05-11 18:42:42 -0700 | [diff] [blame] | 871 | mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 872 | } |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 873 | final boolean keyguardShowing = keyguardIsShowingTq(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 874 | mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); |
| 875 | if (keyguardShowing) { |
| 876 | // since it took two seconds of long press to bring this up, |
| 877 | // 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] | 878 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 879 | } |
| 880 | } |
| 881 | |
| 882 | boolean isDeviceProvisioned() { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 883 | return Settings.Global.getInt( |
| 884 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 885 | } |
| 886 | |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 887 | boolean isUserSetupComplete() { |
| 888 | return Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 889 | Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; |
| 890 | } |
| 891 | |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 892 | private void handleLongPressOnHome() { |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 893 | if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 894 | mHomeConsumed = true; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 895 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 896 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 897 | if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) { |
| 898 | toggleRecentApps(); |
| 899 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_ASSIST) { |
| 900 | launchAssistAction(); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 901 | } |
| 902 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 903 | } |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 904 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 905 | private void handleDoubleTapOnHome() { |
| 906 | if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 907 | mHomeConsumed = true; |
| 908 | toggleRecentApps(); |
| 909 | } |
| 910 | } |
| 911 | |
| 912 | private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable() { |
| 913 | @Override |
| 914 | public void run() { |
| 915 | if (mHomeDoubleTapPending) { |
| 916 | mHomeDoubleTapPending = false; |
| 917 | launchHomeFromHotKey(); |
| 918 | } |
| 919 | } |
| 920 | }; |
| 921 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 922 | /** {@inheritDoc} */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 923 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 924 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 925 | WindowManagerFuncs windowManagerFuncs) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 926 | mContext = context; |
| 927 | mWindowManager = windowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 928 | mWindowManagerFuncs = windowManagerFuncs; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 929 | mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); |
| 930 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 931 | mHandler = new PolicyHandler(); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 932 | mWakeGestureListener = new MyWakeGestureListener(mContext, mHandler); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 933 | mOrientationListener = new MyOrientationListener(mContext, mHandler); |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 934 | try { |
| 935 | mOrientationListener.setCurrentRotation(windowManager.getRotation()); |
| 936 | } catch (RemoteException ex) { } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 937 | mSettingsObserver = new SettingsObserver(mHandler); |
| 938 | mSettingsObserver.observe(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 939 | mShortcutManager = new ShortcutManager(context, mHandler); |
| 940 | mShortcutManager.observe(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 941 | mUiMode = context.getResources().getInteger( |
| 942 | com.android.internal.R.integer.config_defaultUiModeType); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 943 | mHomeIntent = new Intent(Intent.ACTION_MAIN, null); |
| 944 | mHomeIntent.addCategory(Intent.CATEGORY_HOME); |
| 945 | mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 946 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 947 | mCarDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 948 | mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK); |
| 949 | mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 950 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 951 | mDeskDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 952 | mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK); |
| 953 | mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 954 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 955 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 956 | mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 957 | mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 958 | "PhoneWindowManager.mBroadcastWakeLock"); |
| 959 | mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 960 | mSupportAutoRotation = mContext.getResources().getBoolean( |
| 961 | com.android.internal.R.bool.config_supportAutoRotation); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 962 | mLidOpenRotation = readRotation( |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 963 | com.android.internal.R.integer.config_lidOpenRotation); |
| 964 | mCarDockRotation = readRotation( |
| 965 | com.android.internal.R.integer.config_carDockRotation); |
| 966 | mDeskDockRotation = readRotation( |
| 967 | com.android.internal.R.integer.config_deskDockRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 968 | mUndockedHdmiRotation = readRotation( |
| 969 | com.android.internal.R.integer.config_undockedHdmiRotation); |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 970 | mCarDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 971 | com.android.internal.R.bool.config_carDockEnablesAccelerometer); |
| 972 | mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 973 | com.android.internal.R.bool.config_deskDockEnablesAccelerometer); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 974 | mLidKeyboardAccessibility = mContext.getResources().getInteger( |
| 975 | com.android.internal.R.integer.config_lidKeyboardAccessibility); |
| 976 | mLidNavigationAccessibility = mContext.getResources().getInteger( |
| 977 | com.android.internal.R.integer.config_lidNavigationAccessibility); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 978 | mLidControlsSleep = mContext.getResources().getBoolean( |
| 979 | com.android.internal.R.bool.config_lidControlsSleep); |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 980 | mTranslucentDecorEnabled = mContext.getResources().getBoolean( |
| 981 | com.android.internal.R.bool.config_enableTranslucentDecor); |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 982 | readConfigurationDependentBehaviors(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 983 | |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 984 | mAccessibilityManager = (AccessibilityManager) context.getSystemService( |
| 985 | Context.ACCESSIBILITY_SERVICE); |
| 986 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 987 | // register for dock events |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 988 | IntentFilter filter = new IntentFilter(); |
| 989 | filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); |
| 990 | filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE); |
| 991 | filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); |
| 992 | filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 993 | filter.addAction(Intent.ACTION_DOCK_EVENT); |
| 994 | Intent intent = context.registerReceiver(mDockReceiver, filter); |
| 995 | if (intent != null) { |
| 996 | // Retrieve current sticky dock event broadcast. |
| 997 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 998 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 999 | } |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 1000 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 1001 | // register for dream-related broadcasts |
| 1002 | filter = new IntentFilter(); |
| 1003 | filter.addAction(Intent.ACTION_DREAMING_STARTED); |
| 1004 | filter.addAction(Intent.ACTION_DREAMING_STOPPED); |
| 1005 | context.registerReceiver(mDreamReceiver, filter); |
| 1006 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1007 | // register for multiuser-relevant broadcasts |
| 1008 | filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); |
| 1009 | context.registerReceiver(mMultiuserReceiver, filter); |
| 1010 | |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 1011 | // monitor for system gestures |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1012 | mSystemGestures = new SystemGesturesPointerEventListener(context, |
| 1013 | new SystemGesturesPointerEventListener.Callbacks() { |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 1014 | @Override |
| 1015 | public void onSwipeFromTop() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1016 | if (mStatusBar != null) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1017 | requestTransientBars(mStatusBar); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1018 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1019 | } |
| 1020 | @Override |
| 1021 | public void onSwipeFromBottom() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1022 | if (mNavigationBar != null && mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1023 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1024 | } |
| 1025 | } |
| 1026 | @Override |
| 1027 | public void onSwipeFromRight() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1028 | if (mNavigationBar != null && !mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1029 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1030 | } |
| 1031 | } |
| 1032 | @Override |
| 1033 | public void onDebug() { |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1034 | // no-op |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1035 | } |
| 1036 | }); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1037 | mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1038 | mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 1039 | |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 1040 | mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 1041 | mLongPressVibePattern = getLongIntArray(mContext.getResources(), |
| 1042 | com.android.internal.R.array.config_longPressVibePattern); |
| 1043 | mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(), |
| 1044 | com.android.internal.R.array.config_virtualKeyVibePattern); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 1045 | mKeyboardTapVibePattern = getLongIntArray(mContext.getResources(), |
| 1046 | com.android.internal.R.array.config_keyboardTapVibePattern); |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 1047 | mClockTickVibePattern = getLongIntArray(mContext.getResources(), |
| 1048 | com.android.internal.R.array.config_clockTickVibePattern); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 1049 | mSafeModeDisabledVibePattern = getLongIntArray(mContext.getResources(), |
| 1050 | com.android.internal.R.array.config_safeModeDisabledVibePattern); |
| 1051 | mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), |
| 1052 | com.android.internal.R.array.config_safeModeEnabledVibePattern); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 1053 | |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1054 | mScreenshotChordEnabled = mContext.getResources().getBoolean( |
| 1055 | com.android.internal.R.bool.config_enableScreenshotChord); |
| 1056 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 1057 | mGlobalKeyManager = new GlobalKeyManager(mContext); |
| 1058 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 1059 | // Controls rotation and the like. |
| 1060 | initializeHdmiState(); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1061 | |
| 1062 | // Match current screen state. |
Jeff Brown | 26c6a50 | 2014-04-11 02:15:54 -0700 | [diff] [blame] | 1063 | if (mPowerManager.isInteractive()) { |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 1064 | wakingUp(null); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1065 | } else { |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 1066 | goingToSleep(WindowManagerPolicy.OFF_BECAUSE_OF_USER); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1067 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1068 | } |
| 1069 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1070 | /** |
| 1071 | * Read values from config.xml that may be overridden depending on |
| 1072 | * the configuration of the device. |
| 1073 | * eg. Disable long press on home goes to recents on sw600dp. |
| 1074 | */ |
| 1075 | private void readConfigurationDependentBehaviors() { |
| 1076 | mLongPressOnHomeBehavior = mContext.getResources().getInteger( |
| 1077 | com.android.internal.R.integer.config_longPressOnHomeBehavior); |
| 1078 | if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING || |
| 1079 | mLongPressOnHomeBehavior > LONG_PRESS_HOME_ASSIST) { |
| 1080 | mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1081 | } |
| 1082 | |
| 1083 | mDoubleTapOnHomeBehavior = mContext.getResources().getInteger( |
| 1084 | com.android.internal.R.integer.config_doubleTapOnHomeBehavior); |
| 1085 | if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING || |
| 1086 | mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 1087 | mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1088 | } |
| 1089 | } |
| 1090 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1091 | @Override |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1092 | public void setInitialDisplaySize(Display display, int width, int height, int density) { |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 1093 | // This method might be called before the policy has been fully initialized |
| 1094 | // or for other displays we don't care about. |
| 1095 | if (mContext == null || display.getDisplayId() != Display.DEFAULT_DISPLAY) { |
| 1096 | return; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1097 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1098 | mDisplay = display; |
| 1099 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1100 | final Resources res = mContext.getResources(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1101 | int shortSize, longSize; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1102 | if (width > height) { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1103 | shortSize = height; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1104 | longSize = width; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1105 | mLandscapeRotation = Surface.ROTATION_0; |
| 1106 | mSeascapeRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1107 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1108 | mPortraitRotation = Surface.ROTATION_90; |
| 1109 | mUpsideDownRotation = Surface.ROTATION_270; |
| 1110 | } else { |
| 1111 | mPortraitRotation = Surface.ROTATION_270; |
| 1112 | mUpsideDownRotation = Surface.ROTATION_90; |
| 1113 | } |
| 1114 | } else { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1115 | shortSize = width; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1116 | longSize = height; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1117 | mPortraitRotation = Surface.ROTATION_0; |
| 1118 | mUpsideDownRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1119 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1120 | mLandscapeRotation = Surface.ROTATION_270; |
| 1121 | mSeascapeRotation = Surface.ROTATION_90; |
| 1122 | } else { |
| 1123 | mLandscapeRotation = Surface.ROTATION_90; |
| 1124 | mSeascapeRotation = Surface.ROTATION_270; |
| 1125 | } |
| 1126 | } |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1127 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1128 | mStatusBarHeight = |
| 1129 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1130 | |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1131 | // Height of the navigation bar when presented horizontally at bottom |
| 1132 | mNavigationBarHeightForRotation[mPortraitRotation] = |
| 1133 | mNavigationBarHeightForRotation[mUpsideDownRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1134 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1135 | mNavigationBarHeightForRotation[mLandscapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1136 | mNavigationBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize( |
| 1137 | com.android.internal.R.dimen.navigation_bar_height_landscape); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1138 | |
| 1139 | // Width of the navigation bar when presented vertically along one side |
| 1140 | mNavigationBarWidthForRotation[mPortraitRotation] = |
| 1141 | mNavigationBarWidthForRotation[mUpsideDownRotation] = |
| 1142 | mNavigationBarWidthForRotation[mLandscapeRotation] = |
| 1143 | mNavigationBarWidthForRotation[mSeascapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1144 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1145 | |
| 1146 | // SystemUI (status bar) layout policy |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1147 | int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1148 | int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1149 | |
Craig Mautner | d4ec3324 | 2013-07-22 10:37:43 -0700 | [diff] [blame] | 1150 | // Allow the navigation bar to move on small devices (phones). |
| 1151 | mNavigationBarCanMove = shortSizeDp < 600; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1152 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1153 | mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1154 | // Allow a system property to override this. Used by the emulator. |
| 1155 | // See also hasNavigationBar(). |
| 1156 | String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); |
| 1157 | if ("1".equals(navBarOverride)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1158 | mHasNavigationBar = false; |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1159 | } else if ("0".equals(navBarOverride)) { |
| 1160 | mHasNavigationBar = true; |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1161 | } |
| 1162 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 1163 | // For demo purposes, allow the rotation of the HDMI display to be controlled. |
| 1164 | // By default, HDMI locks rotation to landscape. |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1165 | if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1166 | mDemoHdmiRotation = mPortraitRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1167 | } else { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1168 | mDemoHdmiRotation = mLandscapeRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1169 | } |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1170 | mDemoHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1171 | |
| 1172 | // Only force the default orientation if the screen is xlarge, at least 960dp x 720dp, per |
| 1173 | // http://developer.android.com/guide/practices/screens_support.html#range |
| 1174 | mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 && |
| 1175 | res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) && |
| 1176 | // For debug purposes the next line turns this feature off with: |
| 1177 | // $ adb shell setprop config.override_forced_orient true |
| 1178 | // $ adb shell wm size reset |
| 1179 | !"true".equals(SystemProperties.get("config.override_forced_orient")); |
| 1180 | } |
| 1181 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1182 | /** |
| 1183 | * @return whether the navigation bar can be hidden, e.g. the device has a |
| 1184 | * navigation bar and touch exploration is not enabled |
| 1185 | */ |
| 1186 | private boolean canHideNavigationBar() { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 1187 | return mHasNavigationBar |
| 1188 | && !mAccessibilityManager.isTouchExplorationEnabled(); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1189 | } |
| 1190 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1191 | @Override |
| 1192 | public boolean isDefaultOrientationForced() { |
| 1193 | return mForceDefaultOrientation; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1196 | @Override |
| 1197 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom) { |
| 1198 | if (display.getDisplayId() == Display.DEFAULT_DISPLAY) { |
| 1199 | mOverscanLeft = left; |
| 1200 | mOverscanTop = top; |
| 1201 | mOverscanRight = right; |
| 1202 | mOverscanBottom = bottom; |
| 1203 | } |
| 1204 | } |
| 1205 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1206 | public void updateSettings() { |
| 1207 | ContentResolver resolver = mContext.getContentResolver(); |
| 1208 | boolean updateRotation = false; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1209 | synchronized (mLock) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1210 | mEndcallBehavior = Settings.System.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1211 | Settings.System.END_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1212 | Settings.System.END_BUTTON_BEHAVIOR_DEFAULT, |
| 1213 | UserHandle.USER_CURRENT); |
| 1214 | mIncallPowerBehavior = Settings.Secure.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1215 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1216 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT, |
| 1217 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1218 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1219 | // Configure wake gesture. |
| 1220 | boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver, |
| 1221 | Settings.Secure.WAKE_GESTURE_ENABLED, 0, |
| 1222 | UserHandle.USER_CURRENT) != 0; |
| 1223 | if (mWakeGestureEnabledSetting != wakeGestureEnabledSetting) { |
| 1224 | mWakeGestureEnabledSetting = wakeGestureEnabledSetting; |
| 1225 | updateWakeGestureListenerLp(); |
| 1226 | } |
| 1227 | |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1228 | // Configure rotation lock. |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1229 | int userRotation = Settings.System.getIntForUser(resolver, |
| 1230 | Settings.System.USER_ROTATION, Surface.ROTATION_0, |
| 1231 | UserHandle.USER_CURRENT); |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1232 | if (mUserRotation != userRotation) { |
| 1233 | mUserRotation = userRotation; |
| 1234 | updateRotation = true; |
| 1235 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1236 | int userRotationMode = Settings.System.getIntForUser(resolver, |
| 1237 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1238 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 1239 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
| 1240 | if (mUserRotationMode != userRotationMode) { |
| 1241 | mUserRotationMode = userRotationMode; |
| 1242 | updateRotation = true; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1243 | updateOrientationListenerLp(); |
| 1244 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1245 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1246 | if (mSystemReady) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1247 | int pointerLocation = Settings.System.getIntForUser(resolver, |
| 1248 | Settings.System.POINTER_LOCATION, 0, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1249 | if (mPointerLocationMode != pointerLocation) { |
| 1250 | mPointerLocationMode = pointerLocation; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1251 | mHandler.sendEmptyMessage(pointerLocation != 0 ? |
| 1252 | MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1253 | } |
| 1254 | } |
| 1255 | // use screen off timeout setting as the timeout for the lockscreen |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1256 | mLockScreenTimeout = Settings.System.getIntForUser(resolver, |
| 1257 | Settings.System.SCREEN_OFF_TIMEOUT, 0, UserHandle.USER_CURRENT); |
| 1258 | String imId = Settings.Secure.getStringForUser(resolver, |
| 1259 | Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1260 | boolean hasSoftInput = imId != null && imId.length() > 0; |
| 1261 | if (mHasSoftInput != hasSoftInput) { |
| 1262 | mHasSoftInput = hasSoftInput; |
| 1263 | updateRotation = true; |
| 1264 | } |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1265 | if (mImmersiveModeConfirmation != null) { |
John Spurlock | 4355a53 | 2014-02-19 09:49:25 -0500 | [diff] [blame] | 1266 | mImmersiveModeConfirmation.loadSetting(mCurrentUserId); |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1267 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 1268 | PolicyControl.reloadFromSetting(mContext); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1269 | } |
| 1270 | if (updateRotation) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1271 | updateRotation(true); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1272 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1273 | } |
| 1274 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1275 | private void updateWakeGestureListenerLp() { |
| 1276 | if (shouldEnableWakeGestureLp()) { |
| 1277 | mWakeGestureListener.requestWakeUpTrigger(); |
| 1278 | } else { |
| 1279 | mWakeGestureListener.cancelWakeUpTrigger(); |
| 1280 | } |
| 1281 | } |
| 1282 | |
| 1283 | private boolean shouldEnableWakeGestureLp() { |
| 1284 | return mWakeGestureEnabledSetting && !mScreenOnEarly |
| 1285 | && (!mLidControlsSleep || mLidState != LID_CLOSED) |
| 1286 | && mWakeGestureListener.isSupported(); |
| 1287 | } |
| 1288 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1289 | private void enablePointerLocation() { |
| 1290 | if (mPointerLocationView == null) { |
| 1291 | mPointerLocationView = new PointerLocationView(mContext); |
| 1292 | mPointerLocationView.setPrintCoords(false); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1293 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 1294 | WindowManager.LayoutParams.MATCH_PARENT, |
| 1295 | WindowManager.LayoutParams.MATCH_PARENT); |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1296 | lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1297 | lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
| 1298 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
| 1299 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1300 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
Jeff Brown | 90fc905 | 2012-10-01 14:44:24 -0700 | [diff] [blame] | 1301 | if (ActivityManager.isHighEndGfx()) { |
| 1302 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1303 | lp.privateFlags |= |
| 1304 | WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; |
| 1305 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1306 | lp.format = PixelFormat.TRANSLUCENT; |
| 1307 | lp.setTitle("PointerLocation"); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1308 | WindowManager wm = (WindowManager) |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1309 | mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1310 | lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1311 | wm.addView(mPointerLocationView, lp); |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1312 | mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1313 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1314 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1315 | |
| 1316 | private void disablePointerLocation() { |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1317 | if (mPointerLocationView != null) { |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1318 | mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView); |
| 1319 | WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1320 | wm.removeView(mPointerLocationView); |
| 1321 | mPointerLocationView = null; |
| 1322 | } |
| 1323 | } |
| 1324 | |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1325 | private int readRotation(int resID) { |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1326 | try { |
| 1327 | int rotation = mContext.getResources().getInteger(resID); |
| 1328 | switch (rotation) { |
| 1329 | case 0: |
| 1330 | return Surface.ROTATION_0; |
| 1331 | case 90: |
| 1332 | return Surface.ROTATION_90; |
| 1333 | case 180: |
| 1334 | return Surface.ROTATION_180; |
| 1335 | case 270: |
| 1336 | return Surface.ROTATION_270; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1337 | } |
| 1338 | } catch (Resources.NotFoundException e) { |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1339 | // fall through |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1340 | } |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1341 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1342 | } |
| 1343 | |
| 1344 | /** {@inheritDoc} */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1345 | @Override |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1346 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1347 | int type = attrs.type; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1348 | |
| 1349 | outAppOp[0] = AppOpsManager.OP_NONE; |
| 1350 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1351 | if (type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW |
| 1352 | || type > WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1353 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1354 | } |
| 1355 | String permission = null; |
| 1356 | switch (type) { |
| 1357 | case TYPE_TOAST: |
| 1358 | // XXX right now the app process has complete control over |
| 1359 | // this... should introduce a token to let the system |
| 1360 | // monitor/control what they are doing. |
| 1361 | break; |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 1362 | case TYPE_DREAM: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1363 | case TYPE_INPUT_METHOD: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1364 | case TYPE_WALLPAPER: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1365 | case TYPE_PRIVATE_PRESENTATION: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1366 | case TYPE_VOICE_INTERACTION: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1367 | // The window manager will check these. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1368 | break; |
| 1369 | case TYPE_PHONE: |
| 1370 | case TYPE_PRIORITY_PHONE: |
| 1371 | case TYPE_SYSTEM_ALERT: |
| 1372 | case TYPE_SYSTEM_ERROR: |
| 1373 | case TYPE_SYSTEM_OVERLAY: |
| 1374 | permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1375 | outAppOp[0] = AppOpsManager.OP_SYSTEM_ALERT_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1376 | break; |
| 1377 | default: |
| 1378 | permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; |
| 1379 | } |
| 1380 | if (permission != null) { |
| 1381 | if (mContext.checkCallingOrSelfPermission(permission) |
| 1382 | != PackageManager.PERMISSION_GRANTED) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1383 | return WindowManagerGlobal.ADD_PERMISSION_DENIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1384 | } |
| 1385 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1386 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1387 | } |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1388 | |
| 1389 | @Override |
| 1390 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs) { |
| 1391 | |
| 1392 | // If this switch statement is modified, modify the comment in the declarations of |
| 1393 | // the type in {@link WindowManager.LayoutParams} as well. |
| 1394 | switch (attrs.type) { |
| 1395 | default: |
| 1396 | // These are the windows that by default are shown only to the user that created |
| 1397 | // them. If this needs to be overridden, set |
| 1398 | // {@link WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS} in |
| 1399 | // {@link WindowManager.LayoutParams}. Note that permission |
| 1400 | // {@link android.Manifest.permission.INTERNAL_SYSTEM_WINDOW} is required as well. |
| 1401 | if ((attrs.privateFlags & PRIVATE_FLAG_SHOW_FOR_ALL_USERS) == 0) { |
| 1402 | return true; |
| 1403 | } |
| 1404 | break; |
| 1405 | |
| 1406 | // These are the windows that by default are shown to all users. However, to |
| 1407 | // protect against spoofing, check permissions below. |
| 1408 | case TYPE_APPLICATION_STARTING: |
| 1409 | case TYPE_BOOT_PROGRESS: |
| 1410 | case TYPE_DISPLAY_OVERLAY: |
| 1411 | case TYPE_HIDDEN_NAV_CONSUMER: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1412 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1413 | case TYPE_KEYGUARD_DIALOG: |
| 1414 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1415 | case TYPE_NAVIGATION_BAR: |
| 1416 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1417 | case TYPE_PHONE: |
| 1418 | case TYPE_POINTER: |
| 1419 | case TYPE_PRIORITY_PHONE: |
| 1420 | case TYPE_RECENTS_OVERLAY: |
| 1421 | case TYPE_SEARCH_BAR: |
| 1422 | case TYPE_STATUS_BAR: |
| 1423 | case TYPE_STATUS_BAR_PANEL: |
| 1424 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1425 | case TYPE_SYSTEM_DIALOG: |
| 1426 | case TYPE_UNIVERSE_BACKGROUND: |
| 1427 | case TYPE_VOLUME_OVERLAY: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1428 | case TYPE_PRIVATE_PRESENTATION: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1429 | break; |
| 1430 | } |
| 1431 | |
| 1432 | // Check if third party app has set window to system window type. |
| 1433 | return mContext.checkCallingOrSelfPermission( |
| 1434 | android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) |
| 1435 | != PackageManager.PERMISSION_GRANTED; |
| 1436 | } |
| 1437 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1438 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1439 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) { |
| 1440 | switch (attrs.type) { |
| 1441 | case TYPE_SYSTEM_OVERLAY: |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1442 | case TYPE_SECURE_SYSTEM_OVERLAY: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1443 | // These types of windows can't receive input events. |
| 1444 | attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1445 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1446 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1447 | break; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1448 | case TYPE_STATUS_BAR: |
| 1449 | |
| 1450 | // If the Keyguard is in a hidden state (occluded by another window), we force to |
| 1451 | // remove the wallpaper and keyguard flag so that any change in-flight after setting |
| 1452 | // the keyguard as occluded wouldn't set these flags again. |
| 1453 | // See {@link #processKeyguardSetHiddenResultLw}. |
| 1454 | if (mKeyguardHidden) { |
| 1455 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 1456 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 1457 | } |
| 1458 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1459 | } |
Adrian Roos | 3850211 | 2014-04-09 21:04:11 +0200 | [diff] [blame] | 1460 | |
| 1461 | if (attrs.type != TYPE_STATUS_BAR) { |
| 1462 | // The status bar is the only window allowed to exhibit keyguard behavior. |
| 1463 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 1464 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1465 | |
| 1466 | if (ActivityManager.isHighEndGfx() |
| 1467 | && (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) { |
| 1468 | attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
| 1469 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 1470 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; |
| 1471 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1472 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1473 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1474 | void readLidState() { |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 1475 | mLidState = mWindowManagerFuncs.getLidState(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1476 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1477 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1478 | private boolean isHidden(int accessibilityMode) { |
| 1479 | switch (accessibilityMode) { |
| 1480 | case 1: |
| 1481 | return mLidState == LID_CLOSED; |
| 1482 | case 2: |
| 1483 | return mLidState == LID_OPEN; |
| 1484 | default: |
| 1485 | return false; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1486 | } |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1487 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1488 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1489 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1490 | @Override |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1491 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 1492 | int navigationPresence) { |
| 1493 | mHaveBuiltInKeyboard = (keyboardPresence & PRESENCE_INTERNAL) != 0; |
| 1494 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1495 | readConfigurationDependentBehaviors(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1496 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1497 | applyLidSwitchState(); |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1498 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1499 | if (config.keyboard == Configuration.KEYBOARD_NOKEYS |
| 1500 | || (keyboardPresence == PRESENCE_INTERNAL |
| 1501 | && isHidden(mLidKeyboardAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1502 | config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1503 | if (!mHasSoftInput) { |
| 1504 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; |
| 1505 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1506 | } |
| 1507 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1508 | if (config.navigation == Configuration.NAVIGATION_NONAV |
| 1509 | || (navigationPresence == PRESENCE_INTERNAL |
| 1510 | && isHidden(mLidNavigationAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1511 | config.navigationHidden = Configuration.NAVIGATIONHIDDEN_YES; |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1512 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1513 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1514 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1515 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1516 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1517 | public int windowTypeToLayerLw(int type) { |
| 1518 | if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1519 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1520 | } |
| 1521 | switch (type) { |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1522 | case TYPE_UNIVERSE_BACKGROUND: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1523 | return 1; |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1524 | case TYPE_PRIVATE_PRESENTATION: |
| 1525 | return 2; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1526 | case TYPE_WALLPAPER: |
| 1527 | // wallpaper is at the bottom, though the window manager may move it. |
| 1528 | return 2; |
| 1529 | case TYPE_PHONE: |
| 1530 | return 3; |
| 1531 | case TYPE_SEARCH_BAR: |
| 1532 | return 4; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1533 | case TYPE_VOICE_INTERACTION: |
| 1534 | // voice interaction layer is almost immediately above apps. |
| 1535 | return 5; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1536 | case TYPE_RECENTS_OVERLAY: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1537 | case TYPE_SYSTEM_DIALOG: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1538 | return 6; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1539 | case TYPE_TOAST: |
| 1540 | // toasts and the plugged-in battery thing |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1541 | return 7; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1542 | case TYPE_PRIORITY_PHONE: |
| 1543 | // 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] | 1544 | return 8; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1545 | case TYPE_DREAM: |
| 1546 | // used for Dreams (screensavers with TYPE_DREAM windows) |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1547 | return 9; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1548 | case TYPE_SYSTEM_ALERT: |
| 1549 | // like the ANR / app crashed dialogs |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1550 | return 10; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1551 | case TYPE_INPUT_METHOD: |
| 1552 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1553 | return 11; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1554 | case TYPE_INPUT_METHOD_DIALOG: |
| 1555 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1556 | return 12; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1557 | case TYPE_KEYGUARD_SCRIM: |
| 1558 | // the safety window that shows behind keyguard while keyguard is starting |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1559 | return 13; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1560 | case TYPE_STATUS_BAR_SUB_PANEL: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1561 | return 14; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1562 | case TYPE_STATUS_BAR: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1563 | return 15; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1564 | case TYPE_STATUS_BAR_PANEL: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1565 | return 16; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1566 | case TYPE_KEYGUARD_DIALOG: |
| 1567 | return 17; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1568 | case TYPE_VOLUME_OVERLAY: |
| 1569 | // the on-screen volume indicator and controller shown when the user |
| 1570 | // changes the device volume |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1571 | return 18; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1572 | case TYPE_SYSTEM_OVERLAY: |
| 1573 | // the on-screen volume indicator and controller shown when the user |
| 1574 | // changes the device volume |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1575 | return 19; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1576 | case TYPE_NAVIGATION_BAR: |
| 1577 | // the navigation bar, if available, shows atop most things |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1578 | return 20; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1579 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1580 | // 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] | 1581 | return 21; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1582 | case TYPE_SYSTEM_ERROR: |
| 1583 | // system-level error dialogs |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1584 | return 22; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1585 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1586 | // used to highlight the magnified portion of a display |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1587 | return 23; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1588 | case TYPE_DISPLAY_OVERLAY: |
| 1589 | // used to simulate secondary display devices |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1590 | return 24; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1591 | case TYPE_DRAG: |
| 1592 | // the drag layer: input for drag-and-drop is associated with this window, |
| 1593 | // which sits above all other focusable windows |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1594 | return 25; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1595 | case TYPE_SECURE_SYSTEM_OVERLAY: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1596 | return 26; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1597 | case TYPE_BOOT_PROGRESS: |
| 1598 | return 27; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1599 | case TYPE_POINTER: |
| 1600 | // the (mouse) pointer layer |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1601 | return 28; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1602 | case TYPE_HIDDEN_NAV_CONSUMER: |
| 1603 | return 29; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1604 | } |
| 1605 | Log.e(TAG, "Unknown window type: " + type); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1606 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1607 | } |
| 1608 | |
| 1609 | /** {@inheritDoc} */ |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1610 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1611 | public int subWindowTypeToLayerLw(int type) { |
| 1612 | switch (type) { |
| 1613 | case TYPE_APPLICATION_PANEL: |
| 1614 | case TYPE_APPLICATION_ATTACHED_DIALOG: |
| 1615 | return APPLICATION_PANEL_SUBLAYER; |
| 1616 | case TYPE_APPLICATION_MEDIA: |
| 1617 | return APPLICATION_MEDIA_SUBLAYER; |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 1618 | case TYPE_APPLICATION_MEDIA_OVERLAY: |
| 1619 | return APPLICATION_MEDIA_OVERLAY_SUBLAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1620 | case TYPE_APPLICATION_SUB_PANEL: |
| 1621 | return APPLICATION_SUB_PANEL_SUBLAYER; |
| 1622 | } |
| 1623 | Log.e(TAG, "Unknown sub-window type: " + type); |
| 1624 | return 0; |
| 1625 | } |
| 1626 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1627 | @Override |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1628 | public int getMaxWallpaperLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1629 | return windowTypeToLayerLw(TYPE_STATUS_BAR); |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1630 | } |
| 1631 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1632 | @Override |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1633 | public int getAboveUniverseLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1634 | return windowTypeToLayerLw(TYPE_SYSTEM_ERROR); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1635 | } |
| 1636 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1637 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1638 | if (mHasNavigationBar) { |
| 1639 | // For a basic navigation bar, when we are in landscape mode we place |
| 1640 | // the navigation bar to the side. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1641 | if (mNavigationBarCanMove && fullWidth > fullHeight) { |
| 1642 | return fullWidth - mNavigationBarWidthForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1643 | } |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1644 | } |
| 1645 | return fullWidth; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1646 | } |
| 1647 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1648 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1649 | if (mHasNavigationBar) { |
| 1650 | // For a basic navigation bar, when we are in portrait mode we place |
| 1651 | // the navigation bar to the bottom. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1652 | if (!mNavigationBarCanMove || fullWidth < fullHeight) { |
| 1653 | return fullHeight - mNavigationBarHeightForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1654 | } |
| 1655 | } |
| 1656 | return fullHeight; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1657 | } |
| 1658 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1659 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
| 1660 | return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1661 | } |
| 1662 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1663 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1664 | // There is a separate status bar at the top of the display. We don't count that as part |
| 1665 | // 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] | 1666 | // we do want to exclude it since applications can't generally use that part |
| 1667 | // of the screen. |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1668 | return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation) - mStatusBarHeight; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1669 | } |
| 1670 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1671 | @Override |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1672 | public boolean doesForceHide(WindowManager.LayoutParams attrs) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1673 | return (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1674 | } |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1675 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1676 | @Override |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1677 | public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs) { |
| 1678 | return attrs.type == TYPE_STATUS_BAR; |
| 1679 | } |
| 1680 | |
| 1681 | @Override |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1682 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs) { |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1683 | switch (attrs.type) { |
| 1684 | case TYPE_STATUS_BAR: |
| 1685 | case TYPE_NAVIGATION_BAR: |
| 1686 | case TYPE_WALLPAPER: |
| 1687 | case TYPE_DREAM: |
| 1688 | case TYPE_UNIVERSE_BACKGROUND: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1689 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1690 | return false; |
| 1691 | default: |
| 1692 | return true; |
| 1693 | } |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1694 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1695 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1696 | /** {@inheritDoc} */ |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1697 | @Override |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1698 | public View addStartingWindow(IBinder appToken, String packageName, int theme, |
| 1699 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1700 | int icon, int logo, int windowFlags) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1701 | if (!SHOW_STARTING_ANIMATIONS) { |
| 1702 | return null; |
| 1703 | } |
| 1704 | if (packageName == null) { |
| 1705 | return null; |
| 1706 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1707 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1708 | WindowManager wm = null; |
| 1709 | View view = null; |
| 1710 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1711 | try { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1712 | Context context = mContext; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1713 | if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow " + packageName |
| 1714 | + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" |
| 1715 | + Integer.toHexString(theme)); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1716 | if (theme != context.getThemeResId() || labelRes != 0) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1717 | try { |
| 1718 | context = context.createPackageContext(packageName, 0); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1719 | context.setTheme(theme); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1720 | } catch (PackageManager.NameNotFoundException e) { |
| 1721 | // Ignore |
| 1722 | } |
| 1723 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1724 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1725 | Window win = PolicyManager.makeNewWindow(context); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1726 | final TypedArray ta = win.getWindowStyle(); |
| 1727 | if (ta.getBoolean( |
| 1728 | com.android.internal.R.styleable.Window_windowDisablePreview, false) |
| 1729 | || ta.getBoolean( |
| 1730 | com.android.internal.R.styleable.Window_windowShowWallpaper,false)) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1731 | return null; |
| 1732 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1733 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1734 | Resources r = context.getResources(); |
| 1735 | win.setTitle(r.getText(labelRes, nonLocalizedLabel)); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1736 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1737 | win.setType( |
| 1738 | WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); |
| 1739 | // Force the window flags: this is a fake window, so it is not really |
| 1740 | // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM |
| 1741 | // flag because we do know that the next window will take input |
| 1742 | // focus, so we want to get the IME window up on top of us right away. |
| 1743 | win.setFlags( |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1744 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1745 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1746 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1747 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1748 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1749 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1750 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1751 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1752 | |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1753 | win.setDefaultIcon(icon); |
| 1754 | win.setDefaultLogo(logo); |
| 1755 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1756 | win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1757 | WindowManager.LayoutParams.MATCH_PARENT); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1758 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1759 | final WindowManager.LayoutParams params = win.getAttributes(); |
| 1760 | params.token = appToken; |
| 1761 | params.packageName = packageName; |
| 1762 | params.windowAnimations = win.getWindowStyle().getResourceId( |
| 1763 | com.android.internal.R.styleable.Window_windowAnimationStyle, 0); |
Dianne Hackborn | 5d927c2 | 2011-09-02 12:22:18 -0700 | [diff] [blame] | 1764 | params.privateFlags |= |
| 1765 | WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1766 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1767 | |
| 1768 | if (!compatInfo.supportsScreen()) { |
| 1769 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; |
| 1770 | } |
| 1771 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1772 | params.setTitle("Starting " + packageName); |
| 1773 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1774 | wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
| 1775 | view = win.getDecorView(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1776 | |
| 1777 | if (win.isFloating()) { |
| 1778 | // Whoops, there is no way to display an animation/preview |
| 1779 | // of such a thing! After all that work... let's skip it. |
| 1780 | // (Note that we must do this here because it is in |
| 1781 | // getDecorView() where the theme is evaluated... maybe |
| 1782 | // we should peek the floating attribute from the theme |
| 1783 | // earlier.) |
| 1784 | return null; |
| 1785 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1786 | |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1787 | if (DEBUG_STARTING_WINDOW) Slog.d( |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1788 | TAG, "Adding starting window for " + packageName |
| 1789 | + " / " + appToken + ": " |
| 1790 | + (view.getParent() != null ? view : null)); |
| 1791 | |
| 1792 | wm.addView(view, params); |
| 1793 | |
| 1794 | // Only return the view if it was successfully added to the |
| 1795 | // window manager... which we can tell by it having a parent. |
| 1796 | return view.getParent() != null ? view : null; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1797 | } catch (WindowManager.BadTokenException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1798 | // ignore |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 1799 | Log.w(TAG, appToken + " already running, starting window not displayed. " + |
| 1800 | e.getMessage()); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1801 | } catch (RuntimeException e) { |
| 1802 | // don't crash if something else bad happens, for example a |
| 1803 | // failure loading resources because we are loading from an app |
| 1804 | // on external storage that has been unmounted. |
| 1805 | Log.w(TAG, appToken + " failed creating starting window", e); |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1806 | } finally { |
| 1807 | if (view != null && view.getParent() == null) { |
| 1808 | Log.w(TAG, "view not successfully added to wm, removing view"); |
| 1809 | wm.removeViewImmediate(view); |
| 1810 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1811 | } |
| 1812 | |
| 1813 | return null; |
| 1814 | } |
| 1815 | |
| 1816 | /** {@inheritDoc} */ |
| 1817 | public void removeStartingWindow(IBinder appToken, View window) { |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1818 | if (DEBUG_STARTING_WINDOW) { |
| 1819 | RuntimeException e = new RuntimeException("here"); |
| 1820 | e.fillInStackTrace(); |
| 1821 | Log.v(TAG, "Removing starting window for " + appToken + ": " + window, e); |
| 1822 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1823 | |
| 1824 | if (window != null) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1825 | WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1826 | wm.removeView(window); |
| 1827 | } |
| 1828 | } |
| 1829 | |
| 1830 | /** |
| 1831 | * Preflight adding a window to the system. |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1832 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1833 | * Currently enforces that three window types are singletons: |
| 1834 | * <ul> |
| 1835 | * <li>STATUS_BAR_TYPE</li> |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1836 | * <li>KEYGUARD_TYPE</li> |
| 1837 | * </ul> |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1838 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1839 | * @param win The window to be added |
| 1840 | * @param attrs Information about the window to be added |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1841 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1842 | * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, |
| 1843 | * WindowManagerImpl.ADD_MULTIPLE_SINGLETON |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1844 | */ |
| 1845 | public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) { |
| 1846 | switch (attrs.type) { |
| 1847 | case TYPE_STATUS_BAR: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1848 | mContext.enforceCallingOrSelfPermission( |
| 1849 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1850 | "PhoneWindowManager"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1851 | if (mStatusBar != null) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1852 | if (mStatusBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1853 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1854 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1855 | } |
| 1856 | mStatusBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1857 | mStatusBarController.setWindow(win); |
John Spurlock | 8fdfe62 | 2014-05-21 17:10:10 -0400 | [diff] [blame] | 1858 | mKeyguardDelegate.hideScrim(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1859 | break; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1860 | case TYPE_NAVIGATION_BAR: |
| 1861 | mContext.enforceCallingOrSelfPermission( |
| 1862 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1863 | "PhoneWindowManager"); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1864 | if (mNavigationBar != null) { |
| 1865 | if (mNavigationBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1866 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1867 | } |
| 1868 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1869 | mNavigationBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1870 | mNavigationBarController.setWindow(win); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 1871 | if (DEBUG_LAYOUT) Slog.i(TAG, "NAVIGATION BAR: " + mNavigationBar); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1872 | break; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1873 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1874 | mContext.enforceCallingOrSelfPermission( |
| 1875 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1876 | "PhoneWindowManager"); |
| 1877 | break; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1878 | case TYPE_STATUS_BAR_PANEL: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1879 | mContext.enforceCallingOrSelfPermission( |
| 1880 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1881 | "PhoneWindowManager"); |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1882 | break; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1883 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1884 | mContext.enforceCallingOrSelfPermission( |
| 1885 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1886 | "PhoneWindowManager"); |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1887 | break; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1888 | case TYPE_KEYGUARD_SCRIM: |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1889 | if (mKeyguardScrim != null) { |
| 1890 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
| 1891 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1892 | mKeyguardScrim = win; |
| 1893 | break; |
| 1894 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1895 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1896 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1897 | } |
| 1898 | |
| 1899 | /** {@inheritDoc} */ |
| 1900 | public void removeWindowLw(WindowState win) { |
| 1901 | if (mStatusBar == win) { |
| 1902 | mStatusBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1903 | mStatusBarController.setWindow(null); |
Jim Miller | c0b676d | 2013-03-22 16:11:08 -0700 | [diff] [blame] | 1904 | mKeyguardDelegate.showScrim(); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1905 | } else if (mKeyguardScrim == win) { |
| 1906 | Log.v(TAG, "Removing keyguard scrim"); |
| 1907 | mKeyguardScrim = null; |
| 1908 | } if (mNavigationBar == win) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1909 | mNavigationBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1910 | mNavigationBarController.setWindow(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1911 | } |
| 1912 | } |
| 1913 | |
| 1914 | static final boolean PRINT_ANIM = false; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1915 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1916 | /** {@inheritDoc} */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1917 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1918 | public int selectAnimationLw(WindowState win, int transit) { |
| 1919 | if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win |
| 1920 | + ": transit=" + transit); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1921 | if (win == mStatusBar) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1922 | boolean isKeyguard = (win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1923 | if (transit == TRANSIT_EXIT |
| 1924 | || transit == TRANSIT_HIDE) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1925 | return isKeyguard ? -1 : R.anim.dock_top_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1926 | } else if (transit == TRANSIT_ENTER |
| 1927 | || transit == TRANSIT_SHOW) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1928 | return isKeyguard ? -1 : R.anim.dock_top_enter; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1929 | } |
| 1930 | } else if (win == mNavigationBar) { |
| 1931 | // This can be on either the bottom or the right. |
| 1932 | if (mNavigationBarOnBottom) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1933 | if (transit == TRANSIT_EXIT |
| 1934 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1935 | return R.anim.dock_bottom_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1936 | } else if (transit == TRANSIT_ENTER |
| 1937 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1938 | return R.anim.dock_bottom_enter; |
| 1939 | } |
| 1940 | } else { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1941 | if (transit == TRANSIT_EXIT |
| 1942 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1943 | return R.anim.dock_right_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1944 | } else if (transit == TRANSIT_ENTER |
| 1945 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1946 | return R.anim.dock_right_enter; |
| 1947 | } |
| 1948 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1949 | } |
| 1950 | |
| 1951 | if (transit == TRANSIT_PREVIEW_DONE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1952 | if (win.hasAppShownWindows()) { |
| 1953 | if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT"); |
| 1954 | return com.android.internal.R.anim.app_starting_exit; |
| 1955 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 1956 | } else if (win.getAttrs().type == TYPE_DREAM && mDreamingLockscreen |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1957 | && transit == TRANSIT_ENTER) { |
| 1958 | // Special case: we are animating in a dream, while the keyguard |
| 1959 | // is shown. We don't want an animation on the dream, because |
| 1960 | // we need it shown immediately with the keyguard animating away |
| 1961 | // to reveal it. |
| 1962 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1963 | } |
| 1964 | |
| 1965 | return 0; |
| 1966 | } |
| 1967 | |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1968 | @Override |
| 1969 | public void selectRotationAnimationLw(int anim[]) { |
| 1970 | if (PRINT_ANIM) Slog.i(TAG, "selectRotationAnimation mTopFullscreen=" |
| 1971 | + mTopFullscreenOpaqueWindowState + " rotationAnimation=" |
| 1972 | + (mTopFullscreenOpaqueWindowState == null ? |
| 1973 | "0" : mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation)); |
| 1974 | if (mTopFullscreenOpaqueWindowState != null && mTopIsFullscreen) { |
| 1975 | switch (mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation) { |
| 1976 | case ROTATION_ANIMATION_CROSSFADE: |
| 1977 | anim[0] = R.anim.rotation_animation_xfade_exit; |
| 1978 | anim[1] = R.anim.rotation_animation_enter; |
| 1979 | break; |
| 1980 | case ROTATION_ANIMATION_JUMPCUT: |
| 1981 | anim[0] = R.anim.rotation_animation_jump_exit; |
| 1982 | anim[1] = R.anim.rotation_animation_enter; |
| 1983 | break; |
| 1984 | case ROTATION_ANIMATION_ROTATE: |
| 1985 | default: |
| 1986 | anim[0] = anim[1] = 0; |
| 1987 | break; |
| 1988 | } |
| 1989 | } else { |
| 1990 | anim[0] = anim[1] = 0; |
| 1991 | } |
| 1992 | } |
| 1993 | |
| 1994 | @Override |
| 1995 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 1996 | boolean forceDefault) { |
| 1997 | switch (exitAnimId) { |
| 1998 | case R.anim.rotation_animation_xfade_exit: |
| 1999 | case R.anim.rotation_animation_jump_exit: |
| 2000 | // These are the only cases that matter. |
| 2001 | if (forceDefault) { |
| 2002 | return false; |
| 2003 | } |
| 2004 | int anim[] = new int[2]; |
| 2005 | selectRotationAnimationLw(anim); |
| 2006 | return (exitAnimId == anim[0] && enterAnimId == anim[1]); |
| 2007 | default: |
| 2008 | return true; |
| 2009 | } |
| 2010 | } |
| 2011 | |
| 2012 | @Override |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 2013 | public Animation createForceHideEnterAnimation(boolean onWallpaper) { |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 2014 | return AnimationUtils.loadAnimation(mContext, |
| 2015 | com.android.internal.R.anim.lock_screen_behind_enter); |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 2016 | } |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 2017 | |
| 2018 | private static void awakenDreams() { |
| 2019 | IDreamManager dreamManager = getDreamManager(); |
| 2020 | if (dreamManager != null) { |
| 2021 | try { |
| 2022 | dreamManager.awaken(); |
| 2023 | } catch (RemoteException e) { |
| 2024 | // fine, stay asleep then |
| 2025 | } |
| 2026 | } |
| 2027 | } |
| 2028 | |
| 2029 | static IDreamManager getDreamManager() { |
| 2030 | return IDreamManager.Stub.asInterface( |
| 2031 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
| 2032 | } |
| 2033 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 2034 | TelephonyManager getTelephonyService() { |
| 2035 | return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2036 | } |
| 2037 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 2038 | static IAudioService getAudioService() { |
| 2039 | IAudioService audioService = IAudioService.Stub.asInterface( |
| 2040 | ServiceManager.checkService(Context.AUDIO_SERVICE)); |
| 2041 | if (audioService == null) { |
| 2042 | Log.w(TAG, "Unable to find IAudioService interface."); |
| 2043 | } |
| 2044 | return audioService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2045 | } |
| 2046 | |
| 2047 | boolean keyguardOn() { |
| 2048 | return keyguardIsShowingTq() || inKeyguardRestrictedKeyInputMode(); |
| 2049 | } |
| 2050 | |
| 2051 | private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { |
| 2052 | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, |
| 2053 | WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, |
| 2054 | }; |
| 2055 | |
| 2056 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2057 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2058 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2059 | final boolean keyguardOn = keyguardOn(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2060 | final int keyCode = event.getKeyCode(); |
| 2061 | final int repeatCount = event.getRepeatCount(); |
| 2062 | final int metaState = event.getMetaState(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2063 | final int flags = event.getFlags(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2064 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 2065 | final boolean canceled = event.isCanceled(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2066 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2067 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2068 | Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount=" |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2069 | + repeatCount + " keyguardOn=" + keyguardOn + " mHomePressed=" + mHomePressed |
| 2070 | + " canceled=" + canceled); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2071 | } |
| 2072 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2073 | // If we think we might have a volume down & power key chord on the way |
| 2074 | // but we're not sure, then tell the dispatcher to wait a little while and |
| 2075 | // try again later before dispatching. |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 2076 | if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2077 | if (mVolumeDownKeyTriggered && !mPowerKeyTriggered) { |
| 2078 | final long now = SystemClock.uptimeMillis(); |
| 2079 | final long timeoutTime = mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS; |
| 2080 | if (now < timeoutTime) { |
| 2081 | return timeoutTime - now; |
| 2082 | } |
| 2083 | } |
| 2084 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN |
| 2085 | && mVolumeDownKeyConsumedByScreenshotChord) { |
| 2086 | if (!down) { |
| 2087 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 2088 | } |
| 2089 | return -1; |
| 2090 | } |
| 2091 | } |
| 2092 | |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2093 | // Cancel any pending meta actions if we see any other keys being pressed between the down |
| 2094 | // of the meta key and its corresponding up. |
| 2095 | if (mPendingMetaAction && keyCode != KeyEvent.KEYCODE_META_LEFT) { |
| 2096 | mPendingMetaAction = false; |
| 2097 | } |
| 2098 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2099 | // First we always handle the home key here, so applications |
| 2100 | // can never break it, although if keyguard is on, we do let |
| 2101 | // it handle it, because that gives us the correct 5 second |
| 2102 | // timeout. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2103 | if (keyCode == KeyEvent.KEYCODE_HOME) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2104 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2105 | // If we have released the home key, and didn't do anything else |
| 2106 | // while it was pressed, then it is time to go home! |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2107 | if (!down) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2108 | cancelPreloadRecentApps(); |
| 2109 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2110 | mHomePressed = false; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2111 | if (mHomeConsumed) { |
| 2112 | mHomeConsumed = false; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2113 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2114 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2115 | |
| 2116 | if (canceled) { |
| 2117 | Log.i(TAG, "Ignoring HOME; event canceled."); |
| 2118 | return -1; |
| 2119 | } |
| 2120 | |
| 2121 | // If an incoming call is ringing, HOME is totally disabled. |
| 2122 | // (The user is already on the InCallScreen at this point, |
| 2123 | // and his ONLY options are to answer or reject the call.) |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 2124 | TelephonyManager telephonyManager = getTelephonyService(); |
| 2125 | if (telephonyManager != null && telephonyManager.isRinging()) { |
| 2126 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); |
| 2127 | return -1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2128 | } |
| 2129 | |
| 2130 | // Delay handling home if a double-tap is possible. |
| 2131 | if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) { |
| 2132 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case |
| 2133 | mHomeDoubleTapPending = true; |
| 2134 | mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable, |
| 2135 | ViewConfiguration.getDoubleTapTimeout()); |
| 2136 | return -1; |
| 2137 | } |
| 2138 | |
| 2139 | // Go home! |
| 2140 | launchHomeFromHotKey(); |
| 2141 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2142 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2143 | |
| 2144 | // If a system window has focus, then it doesn't make sense |
| 2145 | // right now to interact with applications. |
| 2146 | WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null; |
| 2147 | if (attrs != null) { |
| 2148 | final int type = attrs.type; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2149 | if (type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM |
| 2150 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG |
| 2151 | || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2152 | // the "app" is keyguard, so give it the key |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2153 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2154 | } |
| 2155 | final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length; |
| 2156 | for (int i=0; i<typeCount; i++) { |
| 2157 | if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) { |
| 2158 | // 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] | 2159 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2160 | } |
| 2161 | } |
| 2162 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2163 | |
| 2164 | // Remember that home is pressed and handle special actions. |
| 2165 | if (repeatCount == 0) { |
| 2166 | mHomePressed = true; |
| 2167 | if (mHomeDoubleTapPending) { |
| 2168 | mHomeDoubleTapPending = false; |
| 2169 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); |
| 2170 | handleDoubleTapOnHome(); |
| 2171 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI |
| 2172 | || mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 2173 | preloadRecentApps(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2174 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2175 | } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { |
| 2176 | if (!keyguardOn) { |
| 2177 | handleLongPressOnHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2178 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2179 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2180 | return -1; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2181 | } else if (keyCode == KeyEvent.KEYCODE_MENU) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2182 | // Hijack modified menu keys for debugging features |
| 2183 | final int chordBug = KeyEvent.META_SHIFT_ON; |
| 2184 | |
| 2185 | if (down && repeatCount == 0) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2186 | if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2187 | Intent intent = new Intent(Intent.ACTION_BUG_REPORT); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2188 | mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, |
| 2189 | null, null, null, 0, null, null); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2190 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2191 | } else if (SHOW_PROCESSES_ON_ALT_MENU && |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2192 | (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2193 | Intent service = new Intent(); |
| 2194 | service.setClassName(mContext, "com.android.server.LoadAverageService"); |
| 2195 | ContentResolver res = mContext.getContentResolver(); |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2196 | boolean shown = Settings.Global.getInt( |
| 2197 | res, Settings.Global.SHOW_PROCESSES, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2198 | if (!shown) { |
| 2199 | mContext.startService(service); |
| 2200 | } else { |
| 2201 | mContext.stopService(service); |
| 2202 | } |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2203 | Settings.Global.putInt( |
| 2204 | res, Settings.Global.SHOW_PROCESSES, shown ? 0 : 1); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2205 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2206 | } |
| 2207 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2208 | } else if (keyCode == KeyEvent.KEYCODE_SEARCH) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2209 | if (down) { |
| 2210 | if (repeatCount == 0) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2211 | mSearchKeyShortcutPending = true; |
| 2212 | mConsumeSearchKeyUp = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2213 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2214 | } else { |
| 2215 | mSearchKeyShortcutPending = false; |
| 2216 | if (mConsumeSearchKeyUp) { |
| 2217 | mConsumeSearchKeyUp = false; |
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 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2221 | return 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2222 | } else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) { |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2223 | if (!keyguardOn) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2224 | if (down && repeatCount == 0) { |
| 2225 | preloadRecentApps(); |
| 2226 | } else if (!down) { |
| 2227 | toggleRecentApps(); |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2228 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2229 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2230 | return -1; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2231 | } else if (keyCode == KeyEvent.KEYCODE_ASSIST) { |
| 2232 | if (down) { |
| 2233 | if (repeatCount == 0) { |
| 2234 | mAssistKeyLongPressed = false; |
| 2235 | } else if (repeatCount == 1) { |
| 2236 | mAssistKeyLongPressed = true; |
| 2237 | if (!keyguardOn) { |
| 2238 | launchAssistLongPressAction(); |
| 2239 | } |
| 2240 | } |
| 2241 | } else { |
| 2242 | if (mAssistKeyLongPressed) { |
| 2243 | mAssistKeyLongPressed = false; |
| 2244 | } else { |
| 2245 | if (!keyguardOn) { |
| 2246 | launchAssistAction(); |
| 2247 | } |
| 2248 | } |
| 2249 | } |
| 2250 | return -1; |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 2251 | } else if (keyCode == KeyEvent.KEYCODE_SYSRQ) { |
| 2252 | if (down && repeatCount == 0) { |
| 2253 | mHandler.post(mScreenshotRunnable); |
| 2254 | } |
| 2255 | return -1; |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 2256 | } else if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP |
| 2257 | || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) { |
| 2258 | if (down) { |
| 2259 | int direction = keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP ? 1 : -1; |
| 2260 | |
| 2261 | // Disable autobrightness if it's on |
| 2262 | int auto = Settings.System.getIntForUser( |
| 2263 | mContext.getContentResolver(), |
| 2264 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2265 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2266 | UserHandle.USER_CURRENT_OR_SELF); |
| 2267 | if (auto != 0) { |
| 2268 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2269 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2270 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2271 | UserHandle.USER_CURRENT_OR_SELF); |
| 2272 | } |
| 2273 | |
| 2274 | int min = mPowerManager.getMinimumScreenBrightnessSetting(); |
| 2275 | int max = mPowerManager.getMaximumScreenBrightnessSetting(); |
| 2276 | int step = (max - min + BRIGHTNESS_STEPS - 1) / BRIGHTNESS_STEPS * direction; |
| 2277 | int brightness = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 2278 | Settings.System.SCREEN_BRIGHTNESS, |
| 2279 | mPowerManager.getDefaultScreenBrightnessSetting(), |
| 2280 | UserHandle.USER_CURRENT_OR_SELF); |
| 2281 | brightness += step; |
| 2282 | // Make sure we don't go beyond the limits. |
| 2283 | brightness = Math.min(max, brightness); |
| 2284 | brightness = Math.max(min, brightness); |
| 2285 | |
| 2286 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2287 | Settings.System.SCREEN_BRIGHTNESS, brightness, |
| 2288 | UserHandle.USER_CURRENT_OR_SELF); |
| 2289 | Intent intent = new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG); |
| 2290 | mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF); |
| 2291 | } |
| 2292 | return -1; |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2293 | } else if (keyCode == KeyEvent.KEYCODE_META_LEFT) { |
| 2294 | if (down) { |
| 2295 | mPendingMetaAction = true; |
| 2296 | } else if (mPendingMetaAction) { |
| 2297 | mPendingMetaAction = false; |
| 2298 | launchAssistAction(); |
| 2299 | } |
| 2300 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2301 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2302 | |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2303 | // Shortcuts are invoked through Search+key, so intercept those here |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2304 | // Any printing key that is chorded with Search should be consumed |
| 2305 | // even if no shortcut was invoked. This prevents text from being |
| 2306 | // inadvertently inserted when using a keyboard that has built-in macro |
| 2307 | // 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] | 2308 | if (mSearchKeyShortcutPending) { |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2309 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
| 2310 | if (kcm.isPrintingKey(keyCode)) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2311 | mConsumeSearchKeyUp = true; |
| 2312 | mSearchKeyShortcutPending = false; |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2313 | if (down && repeatCount == 0 && !keyguardOn) { |
| 2314 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState); |
| 2315 | if (shortcutIntent != null) { |
| 2316 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2317 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2318 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2319 | } catch (ActivityNotFoundException ex) { |
| 2320 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2321 | + "the activity to which it is registered was not found: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2322 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode), ex); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2323 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2324 | } else { |
| 2325 | Slog.i(TAG, "Dropping unregistered shortcut key combination: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2326 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2327 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2328 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2329 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2330 | } |
| 2331 | } |
| 2332 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2333 | // Invoke shortcuts using Meta. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2334 | if (down && repeatCount == 0 && !keyguardOn |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2335 | && (metaState & KeyEvent.META_META_ON) != 0) { |
| 2336 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2337 | if (kcm.isPrintingKey(keyCode)) { |
| 2338 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, |
| 2339 | metaState & ~(KeyEvent.META_META_ON |
| 2340 | | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON)); |
| 2341 | if (shortcutIntent != null) { |
| 2342 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2343 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2344 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2345 | } catch (ActivityNotFoundException ex) { |
| 2346 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2347 | + "the activity to which it is registered was not found: " |
| 2348 | + "META+" + KeyEvent.keyCodeToString(keyCode), ex); |
| 2349 | } |
| 2350 | return -1; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2351 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2352 | } |
| 2353 | } |
| 2354 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2355 | // Handle application launch keys. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2356 | if (down && repeatCount == 0 && !keyguardOn) { |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2357 | String category = sApplicationLaunchKeyCategories.get(keyCode); |
| 2358 | if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 2359 | Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2360 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2361 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2362 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2363 | } catch (ActivityNotFoundException ex) { |
| 2364 | Slog.w(TAG, "Dropping application launch key because " |
| 2365 | + "the activity to which it is registered was not found: " |
| 2366 | + "keyCode=" + keyCode + ", category=" + category, ex); |
| 2367 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2368 | return -1; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2369 | } |
| 2370 | } |
| 2371 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2372 | // Display task switcher for ALT-TAB or Meta-TAB. |
| 2373 | if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2374 | if (mRecentAppsHeldModifiers == 0 && !keyguardOn) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2375 | final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK; |
| 2376 | if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON) |
| 2377 | || KeyEvent.metaStateHasModifiers( |
| 2378 | shiftlessModifiers, KeyEvent.META_META_ON)) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2379 | mRecentAppsHeldModifiers = shiftlessModifiers; |
| 2380 | showRecentApps(true); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2381 | return -1; |
| 2382 | } |
| 2383 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2384 | } else if (!down && mRecentAppsHeldModifiers != 0 |
| 2385 | && (metaState & mRecentAppsHeldModifiers) == 0) { |
| 2386 | mRecentAppsHeldModifiers = 0; |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 2387 | hideRecentApps(true); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2388 | } |
| 2389 | |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 2390 | // Handle keyboard language switching. |
| 2391 | if (down && repeatCount == 0 |
| 2392 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2393 | || (keyCode == KeyEvent.KEYCODE_SPACE |
| 2394 | && (metaState & KeyEvent.META_CTRL_MASK) != 0))) { |
| 2395 | int direction = (metaState & KeyEvent.META_SHIFT_MASK) != 0 ? -1 : 1; |
| 2396 | mWindowManagerFuncs.switchKeyboardLayout(event.getDeviceId(), direction); |
| 2397 | return -1; |
| 2398 | } |
| 2399 | if (mLanguageSwitchKeyPressed && !down |
| 2400 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2401 | || keyCode == KeyEvent.KEYCODE_SPACE)) { |
| 2402 | mLanguageSwitchKeyPressed = false; |
| 2403 | return -1; |
| 2404 | } |
| 2405 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 2406 | if (mGlobalKeyManager.handleGlobalKey(mContext, keyCode, event)) { |
| 2407 | return -1; |
| 2408 | } |
| 2409 | |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2410 | // Reserve all the META modifier combos for system behavior |
| 2411 | if ((metaState & KeyEvent.META_META_LEFT_ON) != 0) { |
| 2412 | return -1; |
| 2413 | } |
| 2414 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2415 | // Let the application handle the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2416 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2417 | } |
| 2418 | |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2419 | /** {@inheritDoc} */ |
| 2420 | @Override |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2421 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2422 | // Note: This method is only called if the initial down was unhandled. |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2423 | if (DEBUG_INPUT) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2424 | Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction() |
| 2425 | + ", flags=" + event.getFlags() |
| 2426 | + ", keyCode=" + event.getKeyCode() |
| 2427 | + ", scanCode=" + event.getScanCode() |
| 2428 | + ", metaState=" + event.getMetaState() |
| 2429 | + ", repeatCount=" + event.getRepeatCount() |
| 2430 | + ", policyFlags=" + policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2431 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2432 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2433 | KeyEvent fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2434 | if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 2435 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2436 | final int keyCode = event.getKeyCode(); |
| 2437 | final int metaState = event.getMetaState(); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2438 | final boolean initialDown = event.getAction() == KeyEvent.ACTION_DOWN |
| 2439 | && event.getRepeatCount() == 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2440 | |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2441 | // Check for fallback actions specified by the key character map. |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2442 | final FallbackAction fallbackAction; |
| 2443 | if (initialDown) { |
| 2444 | fallbackAction = kcm.getFallbackAction(keyCode, metaState); |
| 2445 | } else { |
| 2446 | fallbackAction = mFallbackActions.get(keyCode); |
| 2447 | } |
| 2448 | |
| 2449 | if (fallbackAction != null) { |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2450 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2451 | Slog.d(TAG, "Fallback: keyCode=" + fallbackAction.keyCode |
| 2452 | + " metaState=" + Integer.toHexString(fallbackAction.metaState)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2453 | } |
| 2454 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2455 | final int flags = event.getFlags() | KeyEvent.FLAG_FALLBACK; |
| 2456 | fallbackEvent = KeyEvent.obtain( |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2457 | event.getDownTime(), event.getEventTime(), |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2458 | event.getAction(), fallbackAction.keyCode, |
| 2459 | event.getRepeatCount(), fallbackAction.metaState, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2460 | event.getDeviceId(), event.getScanCode(), |
| 2461 | flags, event.getSource(), null); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2462 | |
| 2463 | if (!interceptFallback(win, fallbackEvent, policyFlags)) { |
| 2464 | fallbackEvent.recycle(); |
| 2465 | fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2466 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2467 | |
| 2468 | if (initialDown) { |
| 2469 | mFallbackActions.put(keyCode, fallbackAction); |
| 2470 | } else if (event.getAction() == KeyEvent.ACTION_UP) { |
| 2471 | mFallbackActions.remove(keyCode); |
| 2472 | fallbackAction.recycle(); |
| 2473 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2474 | } |
| 2475 | } |
| 2476 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2477 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2478 | if (fallbackEvent == null) { |
| 2479 | Slog.d(TAG, "No fallback."); |
| 2480 | } else { |
| 2481 | Slog.d(TAG, "Performing fallback: " + fallbackEvent); |
| 2482 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2483 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2484 | return fallbackEvent; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2485 | } |
| 2486 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2487 | private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2488 | int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2489 | if ((actions & ACTION_PASS_TO_USER) != 0) { |
| 2490 | long delayMillis = interceptKeyBeforeDispatching( |
| 2491 | win, fallbackEvent, policyFlags); |
| 2492 | if (delayMillis == 0) { |
| 2493 | return true; |
| 2494 | } |
| 2495 | } |
| 2496 | return false; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 2497 | } |
| 2498 | |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2499 | private void launchAssistLongPressAction() { |
| 2500 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 2501 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
| 2502 | |
| 2503 | // launch the search activity |
| 2504 | Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); |
| 2505 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2506 | try { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2507 | // TODO: This only stops the factory-installed search manager. |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2508 | // Need to formalize an API to handle others |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2509 | SearchManager searchManager = getSearchManager(); |
| 2510 | if (searchManager != null) { |
| 2511 | searchManager.stopSearch(); |
| 2512 | } |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2513 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2514 | } catch (ActivityNotFoundException e) { |
| 2515 | Slog.w(TAG, "No activity to handle assist long press action.", e); |
| 2516 | } |
| 2517 | } |
| 2518 | |
| 2519 | private void launchAssistAction() { |
| 2520 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 2521 | Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 2522 | .getAssistIntent(mContext, true, UserHandle.USER_CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2523 | if (intent != null) { |
| 2524 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 2525 | | Intent.FLAG_ACTIVITY_SINGLE_TOP |
| 2526 | | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 2527 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2528 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2529 | } catch (ActivityNotFoundException e) { |
| 2530 | Slog.w(TAG, "No activity to handle assist action.", e); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2531 | } |
| 2532 | } |
| 2533 | } |
| 2534 | |
| 2535 | private SearchManager getSearchManager() { |
| 2536 | if (mSearchManager == null) { |
| 2537 | mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); |
| 2538 | } |
| 2539 | return mSearchManager; |
| 2540 | } |
| 2541 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2542 | private void preloadRecentApps() { |
| 2543 | mPreloadedRecentApps = true; |
| 2544 | try { |
| 2545 | IStatusBarService statusbar = getStatusBarService(); |
| 2546 | if (statusbar != null) { |
| 2547 | statusbar.preloadRecentApps(); |
| 2548 | } |
| 2549 | } catch (RemoteException e) { |
| 2550 | Slog.e(TAG, "RemoteException when preloading recent apps", e); |
| 2551 | // re-acquire status bar service next time it is needed. |
| 2552 | mStatusBarService = null; |
| 2553 | } |
| 2554 | } |
| 2555 | |
| 2556 | private void cancelPreloadRecentApps() { |
| 2557 | if (mPreloadedRecentApps) { |
| 2558 | mPreloadedRecentApps = false; |
| 2559 | try { |
| 2560 | IStatusBarService statusbar = getStatusBarService(); |
| 2561 | if (statusbar != null) { |
| 2562 | statusbar.cancelPreloadRecentApps(); |
| 2563 | } |
| 2564 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2565 | Slog.e(TAG, "RemoteException when cancelling recent apps preload", e); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2566 | // re-acquire status bar service next time it is needed. |
| 2567 | mStatusBarService = null; |
| 2568 | } |
| 2569 | } |
| 2570 | } |
| 2571 | |
| 2572 | private void toggleRecentApps() { |
| 2573 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2574 | try { |
| 2575 | IStatusBarService statusbar = getStatusBarService(); |
| 2576 | if (statusbar != null) { |
| 2577 | statusbar.toggleRecentApps(); |
| 2578 | } |
| 2579 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2580 | Slog.e(TAG, "RemoteException when toggling recent apps", e); |
| 2581 | // re-acquire status bar service next time it is needed. |
| 2582 | mStatusBarService = null; |
| 2583 | } |
| 2584 | } |
| 2585 | |
| 2586 | private void showRecentApps(boolean triggeredFromAltTab) { |
| 2587 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2588 | try { |
| 2589 | IStatusBarService statusbar = getStatusBarService(); |
| 2590 | if (statusbar != null) { |
| 2591 | statusbar.showRecentApps(triggeredFromAltTab); |
| 2592 | } |
| 2593 | } catch (RemoteException e) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2594 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
| 2595 | // re-acquire status bar service next time it is needed. |
| 2596 | mStatusBarService = null; |
| 2597 | } |
| 2598 | } |
| 2599 | |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 2600 | private void hideRecentApps(boolean triggeredFromAltTab) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2601 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2602 | try { |
| 2603 | IStatusBarService statusbar = getStatusBarService(); |
| 2604 | if (statusbar != null) { |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 2605 | statusbar.hideRecentApps(triggeredFromAltTab); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2606 | } |
| 2607 | } catch (RemoteException e) { |
| 2608 | Slog.e(TAG, "RemoteException when closing recent apps", e); |
| 2609 | // re-acquire status bar service next time it is needed. |
| 2610 | mStatusBarService = null; |
| 2611 | } |
| 2612 | } |
| 2613 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2614 | /** |
| 2615 | * A home key -> launch home action was detected. Take the appropriate action |
| 2616 | * given the situation with the keyguard. |
| 2617 | */ |
| 2618 | void launchHomeFromHotKey() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2619 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowingAndNotOccluded()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2620 | // don't launch home if keyguard showing |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2621 | } else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2622 | // when in keyguard restricted mode, must first verify unlock |
| 2623 | // before launching home |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2624 | mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2625 | public void onKeyguardExitResult(boolean success) { |
| 2626 | if (success) { |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2627 | try { |
| 2628 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2629 | } catch (RemoteException e) { |
| 2630 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2631 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2632 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2633 | } |
| 2634 | } |
| 2635 | }); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame^] | 2636 | } else if (mRecentsVisible) { |
| 2637 | // Recents is started on top of Home, so when we launch home while recents is open, let |
| 2638 | // it do its own animation and then finish itself |
| 2639 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
| 2640 | hideRecentApps(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2641 | } else { |
| 2642 | // no keyguard stuff to worry about, just launch home! |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2643 | try { |
| 2644 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2645 | } catch (RemoteException e) { |
| 2646 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2647 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2648 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2649 | } |
| 2650 | } |
| 2651 | |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2652 | private final Runnable mClearHideNavigationFlag = new Runnable() { |
| 2653 | @Override |
| 2654 | public void run() { |
| 2655 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
| 2656 | // Clear flags. |
| 2657 | mForceClearedSystemUiFlags &= |
| 2658 | ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 2659 | } |
| 2660 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2661 | } |
| 2662 | }; |
| 2663 | |
| 2664 | /** |
| 2665 | * Input handler used while nav bar is hidden. Captures any touch on the screen, |
| 2666 | * to determine when the nav bar should be shown and prevent applications from |
| 2667 | * receiving those touches. |
| 2668 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2669 | final class HideNavInputEventReceiver extends InputEventReceiver { |
| 2670 | public HideNavInputEventReceiver(InputChannel inputChannel, Looper looper) { |
| 2671 | super(inputChannel, looper); |
| 2672 | } |
| 2673 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2674 | @Override |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2675 | public void onInputEvent(InputEvent event) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2676 | boolean handled = false; |
| 2677 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 2678 | if (event instanceof MotionEvent |
| 2679 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 2680 | final MotionEvent motionEvent = (MotionEvent)event; |
| 2681 | if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2682 | // When the user taps down, we re-show the nav bar. |
| 2683 | boolean changed = false; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2684 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2685 | // Any user activity always causes us to show the |
| 2686 | // navigation controls, if they had been hidden. |
| 2687 | // We also clear the low profile and only content |
| 2688 | // flags so that tapping on the screen will atomically |
| 2689 | // restore all currently hidden screen decorations. |
| 2690 | int newVal = mResettingSystemUiFlags | |
| 2691 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| 2692 | View.SYSTEM_UI_FLAG_LOW_PROFILE | |
| 2693 | View.SYSTEM_UI_FLAG_FULLSCREEN; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2694 | if (mResettingSystemUiFlags != newVal) { |
| 2695 | mResettingSystemUiFlags = newVal; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2696 | changed = true; |
| 2697 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2698 | // We don't allow the system's nav bar to be hidden |
| 2699 | // again for 1 second, to prevent applications from |
| 2700 | // spamming us and keeping it from being shown. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2701 | newVal = mForceClearedSystemUiFlags | |
| 2702 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2703 | if (mForceClearedSystemUiFlags != newVal) { |
| 2704 | mForceClearedSystemUiFlags = newVal; |
| 2705 | changed = true; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2706 | mHandler.postDelayed(mClearHideNavigationFlag, 1000); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2707 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2708 | } |
| 2709 | if (changed) { |
| 2710 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 2711 | } |
| 2712 | } |
| 2713 | } |
| 2714 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2715 | finishInputEvent(event, handled); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2716 | } |
| 2717 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2718 | } |
| 2719 | final InputEventReceiver.Factory mHideNavInputEventReceiverFactory = |
| 2720 | new InputEventReceiver.Factory() { |
| 2721 | @Override |
| 2722 | public InputEventReceiver createInputEventReceiver( |
| 2723 | InputChannel inputChannel, Looper looper) { |
| 2724 | return new HideNavInputEventReceiver(inputChannel, looper); |
| 2725 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2726 | }; |
| 2727 | |
| 2728 | @Override |
| 2729 | public int adjustSystemUiVisibilityLw(int visibility) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2730 | mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
| 2731 | mNavigationBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame^] | 2732 | mRecentsVisible = (visibility & View.RECENT_APPS_VISIBLE) > 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2733 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2734 | // Reset any bits in mForceClearingStatusBarVisibility that |
| 2735 | // are now clear. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2736 | mResettingSystemUiFlags &= visibility; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2737 | // Clear any bits in the new visibility that are currently being |
| 2738 | // force cleared, before reporting it. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2739 | return visibility & ~mResettingSystemUiFlags |
| 2740 | & ~mForceClearedSystemUiFlags; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2741 | } |
| 2742 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2743 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2744 | public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 2745 | final int fl = PolicyControl.getWindowFlags(null, attrs); |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 2746 | final int sysuiVis = PolicyControl.getSystemUiVisibility(null, attrs); |
| 2747 | final int systemUiVisibility = (sysuiVis | attrs.subtreeSystemUiVisibility); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2748 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2749 | 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] | 2750 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2751 | int availRight, availBottom; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 2752 | if (canHideNavigationBar() && |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2753 | (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2754 | availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 2755 | availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
| 2756 | } else { |
| 2757 | availRight = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 2758 | availBottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
| 2759 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2760 | if ((systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2761 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 2762 | contentInset.set(mStableFullscreenLeft, mStableFullscreenTop, |
| 2763 | availRight - mStableFullscreenRight, |
| 2764 | availBottom - mStableFullscreenBottom); |
| 2765 | } else { |
| 2766 | contentInset.set(mStableLeft, mStableTop, |
| 2767 | availRight - mStableRight, availBottom - mStableBottom); |
| 2768 | } |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2769 | } else if ((fl & FLAG_FULLSCREEN) != 0 || (fl & FLAG_LAYOUT_IN_OVERSCAN) != 0) { |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2770 | contentInset.setEmpty(); |
| 2771 | } else if ((systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2772 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) { |
| 2773 | contentInset.set(mCurLeft, mCurTop, |
| 2774 | availRight - mCurRight, availBottom - mCurBottom); |
| 2775 | } else { |
| 2776 | contentInset.set(mCurLeft, mCurTop, |
| 2777 | availRight - mCurRight, availBottom - mCurBottom); |
| 2778 | } |
| 2779 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2780 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2781 | contentInset.setEmpty(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2782 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2783 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2784 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2785 | @Override |
| 2786 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
| 2787 | int displayRotation) { |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2788 | final int overscanLeft, overscanTop, overscanRight, overscanBottom; |
| 2789 | if (isDefaultDisplay) { |
| 2790 | switch (displayRotation) { |
| 2791 | case Surface.ROTATION_90: |
| 2792 | overscanLeft = mOverscanTop; |
| 2793 | overscanTop = mOverscanRight; |
| 2794 | overscanRight = mOverscanBottom; |
| 2795 | overscanBottom = mOverscanLeft; |
| 2796 | break; |
| 2797 | case Surface.ROTATION_180: |
| 2798 | overscanLeft = mOverscanRight; |
| 2799 | overscanTop = mOverscanBottom; |
| 2800 | overscanRight = mOverscanLeft; |
| 2801 | overscanBottom = mOverscanTop; |
| 2802 | break; |
| 2803 | case Surface.ROTATION_270: |
| 2804 | overscanLeft = mOverscanBottom; |
| 2805 | overscanTop = mOverscanLeft; |
| 2806 | overscanRight = mOverscanTop; |
| 2807 | overscanBottom = mOverscanRight; |
| 2808 | break; |
| 2809 | default: |
| 2810 | overscanLeft = mOverscanLeft; |
| 2811 | overscanTop = mOverscanTop; |
| 2812 | overscanRight = mOverscanRight; |
| 2813 | overscanBottom = mOverscanBottom; |
| 2814 | break; |
| 2815 | } |
| 2816 | } else { |
| 2817 | overscanLeft = 0; |
| 2818 | overscanTop = 0; |
| 2819 | overscanRight = 0; |
| 2820 | overscanBottom = 0; |
| 2821 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2822 | mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0; |
| 2823 | mOverscanScreenTop = mRestrictedOverscanScreenTop = 0; |
| 2824 | mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth; |
| 2825 | mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2826 | mSystemLeft = 0; |
| 2827 | mSystemTop = 0; |
| 2828 | mSystemRight = displayWidth; |
| 2829 | mSystemBottom = displayHeight; |
| 2830 | mUnrestrictedScreenLeft = overscanLeft; |
| 2831 | mUnrestrictedScreenTop = overscanTop; |
| 2832 | mUnrestrictedScreenWidth = displayWidth - overscanLeft - overscanRight; |
| 2833 | mUnrestrictedScreenHeight = displayHeight - overscanTop - overscanBottom; |
| 2834 | mRestrictedScreenLeft = mUnrestrictedScreenLeft; |
| 2835 | mRestrictedScreenTop = mUnrestrictedScreenTop; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2836 | mRestrictedScreenWidth = mSystemGestures.screenWidth = mUnrestrictedScreenWidth; |
| 2837 | mRestrictedScreenHeight = mSystemGestures.screenHeight = mUnrestrictedScreenHeight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2838 | mDockLeft = mContentLeft = mVoiceContentLeft = mStableLeft = mStableFullscreenLeft |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2839 | = mCurLeft = mUnrestrictedScreenLeft; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2840 | mDockTop = mContentTop = mVoiceContentTop = mStableTop = mStableFullscreenTop |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2841 | = mCurTop = mUnrestrictedScreenTop; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2842 | mDockRight = mContentRight = mVoiceContentRight = mStableRight = mStableFullscreenRight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2843 | = mCurRight = displayWidth - overscanRight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2844 | mDockBottom = mContentBottom = mVoiceContentBottom = mStableBottom = mStableFullscreenBottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2845 | = mCurBottom = displayHeight - overscanBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2846 | mDockLayer = 0x10000000; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 2847 | mStatusBarLayer = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2848 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2849 | // start with the current dock rect, which will be (0,0,displayWidth,displayHeight) |
| 2850 | final Rect pf = mTmpParentFrame; |
| 2851 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2852 | final Rect of = mTmpOverscanFrame; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2853 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2854 | final Rect dcf = mTmpDecorFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2855 | pf.left = df.left = of.left = vf.left = mDockLeft; |
| 2856 | pf.top = df.top = of.top = vf.top = mDockTop; |
| 2857 | pf.right = df.right = of.right = vf.right = mDockRight; |
| 2858 | pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2859 | dcf.setEmpty(); // Decor frame N/A for system bars. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2860 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2861 | if (isDefaultDisplay) { |
| 2862 | // For purposes of putting out fake window up to steal focus, we will |
| 2863 | // drive nav being hidden only by whether it is requested. |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2864 | final int sysui = mLastSystemUiFlags; |
| 2865 | boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 2866 | boolean navTranslucent = (sysui |
| 2867 | & (View.NAVIGATION_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 2868 | boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0; |
| 2869 | boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
| 2870 | boolean navAllowedHidden = immersive || immersiveSticky; |
| 2871 | navTranslucent &= !immersiveSticky; // transient trumps translucent |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 2872 | navTranslucent &= areTranslucentBarsAllowed(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2873 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2874 | // When the navigation bar isn't visible, we put up a fake |
| 2875 | // input window to catch all touch events. This way we can |
| 2876 | // detect when the user presses anywhere to bring back the nav |
| 2877 | // bar and ensure the application doesn't see the event. |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 2878 | if (navVisible || navAllowedHidden) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2879 | if (mHideNavFakeWindow != null) { |
| 2880 | mHideNavFakeWindow.dismiss(); |
| 2881 | mHideNavFakeWindow = null; |
| 2882 | } |
| 2883 | } else if (mHideNavFakeWindow == null) { |
| 2884 | mHideNavFakeWindow = mWindowManagerFuncs.addFakeWindow( |
| 2885 | mHandler.getLooper(), mHideNavInputEventReceiverFactory, |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 2886 | "hidden nav", WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER, 0, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2887 | 0, false, false, true); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2888 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2889 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2890 | // For purposes of positioning and showing the nav bar, if we have |
| 2891 | // decided that it can't be hidden (because of the screen aspect ratio), |
| 2892 | // then take that into account. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 2893 | navVisible |= !canHideNavigationBar(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2894 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2895 | boolean updateSysUiVisibility = false; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2896 | if (mNavigationBar != null) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2897 | boolean transientNavBarShowing = mNavigationBarController.isTransientShowing(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2898 | // Force the navigation bar to its appropriate place and |
| 2899 | // size. We need to do this directly, instead of relying on |
| 2900 | // it to bubble up from the nav bar, because this needs to |
| 2901 | // change atomically with screen rotations. |
| 2902 | mNavigationBarOnBottom = (!mNavigationBarCanMove || displayWidth < displayHeight); |
| 2903 | if (mNavigationBarOnBottom) { |
| 2904 | // 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] | 2905 | int top = displayHeight - overscanBottom |
| 2906 | - mNavigationBarHeightForRotation[displayRotation]; |
| 2907 | mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2908 | mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 2909 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2910 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2911 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2912 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2913 | mDockBottom = mTmpNavigationFrame.top; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2914 | mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop; |
| 2915 | mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2916 | } else { |
| 2917 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2918 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2919 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 2920 | if (navVisible && !navTranslucent && !navAllowedHidden |
| 2921 | && !mNavigationBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2922 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2923 | // If the opaque nav bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2924 | // and not in the process of animating on or off, then |
| 2925 | // we can tell the app that it is covered by it. |
| 2926 | mSystemBottom = mTmpNavigationFrame.top; |
| 2927 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2928 | } else { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2929 | // Landscape screen; nav bar goes to the right. |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2930 | int left = displayWidth - overscanRight |
| 2931 | - mNavigationBarWidthForRotation[displayRotation]; |
| 2932 | mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2933 | mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 2934 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2935 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2936 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2937 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2938 | mDockRight = mTmpNavigationFrame.left; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2939 | mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft; |
| 2940 | mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2941 | } else { |
| 2942 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2943 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2944 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2945 | if (navVisible && !navTranslucent && !mNavigationBar.isAnimatingLw() |
| 2946 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2947 | // If the nav bar is currently requested to be visible, |
| 2948 | // and not in the process of animating on or off, then |
| 2949 | // we can tell the app that it is covered by it. |
| 2950 | mSystemRight = mTmpNavigationFrame.left; |
| 2951 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2952 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2953 | // Make sure the content and current rectangles are updated to |
| 2954 | // account for the restrictions from the navigation bar. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2955 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 2956 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 2957 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 2958 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2959 | mStatusBarLayer = mNavigationBar.getSurfaceLayer(); |
| 2960 | // And compute the final frame. |
| 2961 | mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2962 | mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2963 | if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2964 | if (mNavigationBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2965 | updateSysUiVisibility = true; |
| 2966 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2967 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2968 | 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] | 2969 | mDockLeft, mDockTop, mDockRight, mDockBottom)); |
| 2970 | |
| 2971 | // decide where the status bar goes ahead of time |
| 2972 | if (mStatusBar != null) { |
| 2973 | // apply any navigation bar insets |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2974 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 2975 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 2976 | pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft; |
| 2977 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight |
| 2978 | + mUnrestrictedScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2979 | vf.left = mStableLeft; |
| 2980 | vf.top = mStableTop; |
| 2981 | vf.right = mStableRight; |
| 2982 | vf.bottom = mStableBottom; |
| 2983 | |
| 2984 | mStatusBarLayer = mStatusBar.getSurfaceLayer(); |
| 2985 | |
| 2986 | // Let the status bar determine its size. |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2987 | mStatusBar.computeFrameLw(pf, df, vf, vf, vf, dcf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2988 | |
| 2989 | // For layout, the status bar is always at the top with our fixed height. |
| 2990 | mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 2991 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2992 | boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 2993 | boolean statusBarTranslucent = (sysui |
| 2994 | & (View.STATUS_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 2995 | statusBarTranslucent &= areTranslucentBarsAllowed(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 2996 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2997 | // If the status bar is hidden, we don't want to cause |
| 2998 | // windows behind it to scroll. |
John Spurlock | eda1f69 | 2013-09-16 11:38:44 -0400 | [diff] [blame] | 2999 | if (mStatusBar.isVisibleLw() && !statusBarTransient) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3000 | // Status bar may go away, so the screen area it occupies |
| 3001 | // is available to apps but just covering them when the |
| 3002 | // status bar is visible. |
| 3003 | mDockTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3004 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3005 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 3006 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 3007 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 3008 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3009 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3010 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar: " + |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3011 | String.format( |
| 3012 | "dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]", |
| 3013 | mDockLeft, mDockTop, mDockRight, mDockBottom, |
| 3014 | mContentLeft, mContentTop, mContentRight, mContentBottom, |
| 3015 | mCurLeft, mCurTop, mCurRight, mCurBottom)); |
| 3016 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3017 | if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3018 | && !statusBarTransient && !statusBarTranslucent |
| 3019 | && !mStatusBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3020 | // If the opaque status bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3021 | // and not in the process of animating on or off, then |
| 3022 | // we can tell the app that it is covered by it. |
| 3023 | mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3024 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3025 | if (mStatusBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3026 | updateSysUiVisibility = true; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3027 | } |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 3028 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3029 | if (updateSysUiVisibility) { |
| 3030 | updateSystemUiVisibilityLw(); |
| 3031 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3032 | } |
| 3033 | } |
| 3034 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 3035 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 3036 | @Override |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3037 | public int getSystemDecorLayerLw() { |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 3038 | if (mStatusBar != null) return mStatusBar.getSurfaceLayer(); |
| 3039 | if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer(); |
| 3040 | return 0; |
| 3041 | } |
| 3042 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 3043 | @Override |
| 3044 | public void getContentRectLw(Rect r) { |
| 3045 | r.set(mContentLeft, mContentTop, mContentRight, mContentBottom); |
| 3046 | } |
| 3047 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3048 | void setAttachedWindowFrames(WindowState win, int fl, int adjust, WindowState attached, |
| 3049 | 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] | 3050 | if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) { |
| 3051 | // Here's a special case: if this attached window is a panel that is |
| 3052 | // above the dock window, and the window it is attached to is below |
| 3053 | // the dock window, then the frames we computed for the window it is |
| 3054 | // attached to can not be used because the dock is effectively part |
| 3055 | // of the underlying window and the attached window is floating on top |
| 3056 | // of the whole thing. So, we ignore the attached window and explicitly |
| 3057 | // compute the frames that would be appropriate without the dock. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3058 | df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3059 | df.top = of.top = cf.top = vf.top = mDockTop; |
| 3060 | df.right = of.right = cf.right = vf.right = mDockRight; |
| 3061 | df.bottom = of.bottom = cf.bottom = vf.bottom = mDockBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3062 | } else { |
| 3063 | // The effective display frame of the attached window depends on |
| 3064 | // whether it is taking care of insetting its content. If not, |
| 3065 | // we need to use the parent's content frame so that the entire |
| 3066 | // window is positioned within that content. Otherwise we can use |
| 3067 | // the display frame and let the attached window take care of |
| 3068 | // positioning its content appropriately. |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3069 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3070 | cf.set(attached.getOverscanFrameLw()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3071 | } else { |
| 3072 | // If the window is resizing, then we want to base the content |
| 3073 | // frame on our attached content frame to resize... however, |
| 3074 | // things can be tricky if the attached window is NOT in resize |
| 3075 | // mode, in which case its content frame will be larger. |
| 3076 | // Ungh. So to deal with that, make sure the content frame |
| 3077 | // we end up using is not covering the IM dock. |
| 3078 | cf.set(attached.getContentFrameLw()); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3079 | if (attached.isVoiceInteraction()) { |
| 3080 | if (cf.left < mVoiceContentLeft) cf.left = mVoiceContentLeft; |
| 3081 | if (cf.top < mVoiceContentTop) cf.top = mVoiceContentTop; |
| 3082 | if (cf.right > mVoiceContentRight) cf.right = mVoiceContentRight; |
| 3083 | if (cf.bottom > mVoiceContentBottom) cf.bottom = mVoiceContentBottom; |
| 3084 | } else if (attached.getSurfaceLayer() < mDockLayer) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3085 | if (cf.left < mContentLeft) cf.left = mContentLeft; |
| 3086 | if (cf.top < mContentTop) cf.top = mContentTop; |
| 3087 | if (cf.right > mContentRight) cf.right = mContentRight; |
| 3088 | if (cf.bottom > mContentBottom) cf.bottom = mContentBottom; |
| 3089 | } |
| 3090 | } |
| 3091 | df.set(insetDecors ? attached.getDisplayFrameLw() : cf); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3092 | of.set(insetDecors ? attached.getOverscanFrameLw() : cf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3093 | vf.set(attached.getVisibleFrameLw()); |
| 3094 | } |
| 3095 | // The LAYOUT_IN_SCREEN flag is used to determine whether the attached |
| 3096 | // window should be positioned relative to its parent or the entire |
| 3097 | // screen. |
| 3098 | pf.set((fl & FLAG_LAYOUT_IN_SCREEN) == 0 |
| 3099 | ? attached.getFrameLw() : df); |
| 3100 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3101 | |
| 3102 | private void applyStableConstraints(int sysui, int fl, Rect r) { |
| 3103 | if ((sysui & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 3104 | // If app is requesting a stable layout, don't let the |
| 3105 | // content insets go below the stable values. |
| 3106 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 3107 | if (r.left < mStableFullscreenLeft) r.left = mStableFullscreenLeft; |
| 3108 | if (r.top < mStableFullscreenTop) r.top = mStableFullscreenTop; |
| 3109 | if (r.right > mStableFullscreenRight) r.right = mStableFullscreenRight; |
| 3110 | if (r.bottom > mStableFullscreenBottom) r.bottom = mStableFullscreenBottom; |
| 3111 | } else { |
| 3112 | if (r.left < mStableLeft) r.left = mStableLeft; |
| 3113 | if (r.top < mStableTop) r.top = mStableTop; |
| 3114 | if (r.right > mStableRight) r.right = mStableRight; |
| 3115 | if (r.bottom > mStableBottom) r.bottom = mStableBottom; |
| 3116 | } |
| 3117 | } |
| 3118 | } |
| 3119 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3120 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3121 | @Override |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 3122 | public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs, |
| 3123 | WindowState attached) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3124 | // we've already done the status bar |
Craig Mautner | beac106 | 2014-06-03 14:38:57 -0700 | [diff] [blame] | 3125 | if ((win == mStatusBar && !doesForceHide(attrs)) || win == mNavigationBar) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3126 | return; |
| 3127 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3128 | final boolean isDefaultDisplay = win.isDefaultDisplay(); |
| 3129 | final boolean needsToOffsetInputMethodTarget = isDefaultDisplay && |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3130 | (win == mLastInputMethodTargetWindow && mLastInputMethodWindow != null); |
| 3131 | if (needsToOffsetInputMethodTarget) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3132 | 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] | 3133 | offsetInputMethodWindowLw(mLastInputMethodWindow); |
| 3134 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3135 | |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3136 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3137 | final int sim = attrs.softInputMode; |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 3138 | final int sysUiFl = PolicyControl.getSystemUiVisibility(win, null); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3139 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3140 | final Rect pf = mTmpParentFrame; |
| 3141 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3142 | final Rect of = mTmpOverscanFrame; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3143 | final Rect cf = mTmpContentFrame; |
| 3144 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3145 | final Rect dcf = mTmpDecorFrame; |
| 3146 | dcf.setEmpty(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3147 | |
| 3148 | final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3149 | && mNavigationBar != null && mNavigationBar.isVisibleLw()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3150 | |
Craig Mautner | f683b56 | 2012-10-02 11:10:57 -0700 | [diff] [blame] | 3151 | final int adjust = sim & SOFT_INPUT_MASK_ADJUST; |
| 3152 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3153 | if (!isDefaultDisplay) { |
| 3154 | if (attached != null) { |
| 3155 | // If this window is attached to another, our display |
| 3156 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3157 | setAttachedWindowFrames(win, fl, adjust, attached, true, pf, df, of, cf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3158 | } else { |
| 3159 | // Give the window full screen. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3160 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3161 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3162 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3163 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3164 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3165 | = mOverscanScreenTop + mOverscanScreenHeight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3166 | } |
| 3167 | } else if (attrs.type == TYPE_INPUT_METHOD) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3168 | pf.left = df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3169 | pf.top = df.top = of.top = cf.top = vf.top = mDockTop; |
| 3170 | pf.right = df.right = of.right = cf.right = vf.right = mDockRight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3171 | // IM dock windows layout below the nav bar... |
John Spurlock | 57beb3b | 2013-10-10 10:27:44 -0400 | [diff] [blame] | 3172 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3173 | // ...with content insets above the nav bar |
| 3174 | cf.bottom = vf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3175 | // IM dock windows always go to the bottom of the screen. |
| 3176 | attrs.gravity = Gravity.BOTTOM; |
| 3177 | mDockLayer = win.getSurfaceLayer(); |
| 3178 | } else { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3179 | |
| 3180 | // Default policy decor for the default display |
| 3181 | dcf.left = mSystemLeft; |
| 3182 | dcf.top = mSystemTop; |
| 3183 | dcf.right = mSystemRight; |
| 3184 | dcf.bottom = mSystemBottom; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3185 | final boolean inheritTranslucentDecor = (attrs.privateFlags |
| 3186 | & WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR) != 0; |
John Spurlock | 65567d4 | 2013-10-08 10:08:32 -0400 | [diff] [blame] | 3187 | final boolean isAppWindow = |
| 3188 | attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW && |
| 3189 | attrs.type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 3190 | final boolean topAtRest = |
| 3191 | win == mTopFullscreenOpaqueWindowState && !win.isAnimatingLw(); |
| 3192 | if (isAppWindow && !inheritTranslucentDecor && !topAtRest) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3193 | if ((sysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 |
| 3194 | && (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3195 | && (fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == 0 |
| 3196 | && (fl & WindowManager.LayoutParams. |
| 3197 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3198 | // Ensure policy decor includes status bar |
| 3199 | dcf.top = mStableTop; |
| 3200 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3201 | if ((fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3202 | && (sysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0 |
| 3203 | && (fl & WindowManager.LayoutParams. |
| 3204 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3205 | // Ensure policy decor includes navigation bar |
| 3206 | dcf.bottom = mStableBottom; |
| 3207 | dcf.right = mStableRight; |
| 3208 | } |
| 3209 | } |
| 3210 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3211 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) |
| 3212 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3213 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3214 | + "): IN_SCREEN, INSET_DECOR"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3215 | // This is the case for a normal activity window: we want it |
| 3216 | // to cover all of the screen space, and it can take care of |
| 3217 | // moving its contents to account for screen decorations that |
| 3218 | // intrude into that space. |
| 3219 | if (attached != null) { |
| 3220 | // If this window is attached to another, our display |
| 3221 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3222 | 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] | 3223 | } else { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3224 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3225 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3226 | // Status bar panels are the only windows who can go on top of |
| 3227 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3228 | // permission, so they have the same privileges as the status |
| 3229 | // bar itself. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3230 | // |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3231 | // However, they should still dodge the navigation bar if it exists. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3232 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3233 | pf.left = df.left = of.left = hasNavBar |
| 3234 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3235 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3236 | pf.right = df.right = of.right = hasNavBar |
| 3237 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
| 3238 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3239 | pf.bottom = df.bottom = of.bottom = hasNavBar |
| 3240 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
| 3241 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3242 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3243 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3244 | "Laying out status bar window: (%d,%d - %d,%d)", |
| 3245 | pf.left, pf.top, pf.right, pf.bottom)); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3246 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3247 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3248 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3249 | // Asking to layout into the overscan region, so give it that pure |
| 3250 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3251 | pf.left = df.left = of.left = mOverscanScreenLeft; |
| 3252 | pf.top = df.top = of.top = mOverscanScreenTop; |
| 3253 | pf.right = df.right = of.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3254 | pf.bottom = df.bottom = of.bottom = mOverscanScreenTop |
| 3255 | + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3256 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3257 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3258 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3259 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3260 | // Asking for layout as if the nav bar is hidden, lets the |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3261 | // application extend into the unrestricted overscan screen area. We |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3262 | // only do this for application windows to ensure no window that |
| 3263 | // can be above the nav bar can do this. |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3264 | pf.left = df.left = mOverscanScreenLeft; |
| 3265 | pf.top = df.top = mOverscanScreenTop; |
| 3266 | pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3267 | pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3268 | // We need to tell the app about where the frame inside the overscan |
| 3269 | // is, so it can inset its content by that amount -- it didn't ask |
| 3270 | // to actually extend itself into the overscan region. |
| 3271 | of.left = mUnrestrictedScreenLeft; |
| 3272 | of.top = mUnrestrictedScreenTop; |
| 3273 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3274 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3275 | } else { |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3276 | pf.left = df.left = mRestrictedOverscanScreenLeft; |
| 3277 | pf.top = df.top = mRestrictedOverscanScreenTop; |
| 3278 | pf.right = df.right = mRestrictedOverscanScreenLeft |
| 3279 | + mRestrictedOverscanScreenWidth; |
| 3280 | pf.bottom = df.bottom = mRestrictedOverscanScreenTop |
| 3281 | + mRestrictedOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3282 | // We need to tell the app about where the frame inside the overscan |
| 3283 | // is, so it can inset its content by that amount -- it didn't ask |
| 3284 | // to actually extend itself into the overscan region. |
| 3285 | of.left = mUnrestrictedScreenLeft; |
| 3286 | of.top = mUnrestrictedScreenTop; |
| 3287 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3288 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3289 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3290 | |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3291 | if ((fl & FLAG_FULLSCREEN) == 0) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3292 | if (win.isVoiceInteraction()) { |
| 3293 | cf.left = mVoiceContentLeft; |
| 3294 | cf.top = mVoiceContentTop; |
| 3295 | cf.right = mVoiceContentRight; |
| 3296 | cf.bottom = mVoiceContentBottom; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3297 | } else { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3298 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
| 3299 | cf.left = mDockLeft; |
| 3300 | cf.top = mDockTop; |
| 3301 | cf.right = mDockRight; |
| 3302 | cf.bottom = mDockBottom; |
| 3303 | } else { |
| 3304 | cf.left = mContentLeft; |
| 3305 | cf.top = mContentTop; |
| 3306 | cf.right = mContentRight; |
| 3307 | cf.bottom = mContentBottom; |
| 3308 | } |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3309 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3310 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3311 | // Full screen windows are always given a layout that is as if the |
| 3312 | // status bar and other transient decors are gone. This is to avoid |
| 3313 | // bad states when moving from a window that is not hding the |
| 3314 | // status bar to one that is. |
| 3315 | cf.left = mRestrictedScreenLeft; |
| 3316 | cf.top = mRestrictedScreenTop; |
| 3317 | cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 3318 | cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3319 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3320 | applyStableConstraints(sysUiFl, fl, cf); |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3321 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3322 | vf.left = mCurLeft; |
| 3323 | vf.top = mCurTop; |
| 3324 | vf.right = mCurRight; |
| 3325 | vf.bottom = mCurBottom; |
| 3326 | } else { |
| 3327 | vf.set(cf); |
| 3328 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3329 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3330 | } else if ((fl & FLAG_LAYOUT_IN_SCREEN) != 0 || (sysUiFl |
| 3331 | & (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 3332 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3333 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3334 | "): IN_SCREEN"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3335 | // A window that has requested to fill the entire screen just |
| 3336 | // gets everything, period. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3337 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3338 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3339 | pf.left = df.left = of.left = cf.left = hasNavBar |
| 3340 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3341 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3342 | pf.right = df.right = of.right = cf.right = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3343 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3344 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3345 | pf.bottom = df.bottom = of.bottom = cf.bottom = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3346 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3347 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3348 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3349 | "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)", |
| 3350 | pf.left, pf.top, pf.right, pf.bottom)); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 3351 | } else if (attrs.type == TYPE_NAVIGATION_BAR |
| 3352 | || attrs.type == TYPE_NAVIGATION_BAR_PANEL) { |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3353 | // The navigation bar has Real Ultimate Power. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3354 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3355 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3356 | pf.right = df.right = of.right = mUnrestrictedScreenLeft |
| 3357 | + mUnrestrictedScreenWidth; |
| 3358 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop |
| 3359 | + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3360 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3361 | "Laying out navigation bar window: (%d,%d - %d,%d)", |
| 3362 | pf.left, pf.top, pf.right, pf.bottom)); |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3363 | } else if ((attrs.type == TYPE_SECURE_SYSTEM_OVERLAY |
| 3364 | || attrs.type == TYPE_BOOT_PROGRESS) |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 3365 | && ((fl & FLAG_FULLSCREEN) != 0)) { |
| 3366 | // Fullscreen secure system overlays get what they ask for. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3367 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3368 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3369 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3370 | + mOverscanScreenWidth; |
| 3371 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3372 | + mOverscanScreenHeight; |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 3373 | } else if (attrs.type == TYPE_BOOT_PROGRESS |
| 3374 | || attrs.type == TYPE_UNIVERSE_BACKGROUND) { |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3375 | // Boot progress screen always covers entire display. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3376 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3377 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3378 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3379 | + mOverscanScreenWidth; |
| 3380 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3381 | + mOverscanScreenHeight; |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3382 | } else if (attrs.type == TYPE_WALLPAPER) { |
| 3383 | // The wallpaper also has Real Ultimate Power. |
| 3384 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3385 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3386 | pf.right = df.right = of.right = cf.right |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3387 | = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3388 | pf.bottom = df.bottom = of.bottom = cf.bottom |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3389 | = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3390 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3391 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3392 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3393 | // Asking to layout into the overscan region, so give it that pure |
| 3394 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3395 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3396 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3397 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3398 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3399 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3400 | = mOverscanScreenTop + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3401 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3402 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Craig Mautner | beac106 | 2014-06-03 14:38:57 -0700 | [diff] [blame] | 3403 | && (attrs.type == TYPE_STATUS_BAR |
| 3404 | || attrs.type == TYPE_TOAST |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3405 | || (attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3406 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW))) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3407 | // Asking for layout as if the nav bar is hidden, lets the |
| 3408 | // application extend into the unrestricted screen area. We |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3409 | // 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] | 3410 | // can be above the nav bar can do this. |
| 3411 | // XXX This assumes that an app asking for this will also |
| 3412 | // ask for layout in only content. We can't currently figure out |
| 3413 | // 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] | 3414 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3415 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3416 | pf.right = df.right = of.right = cf.right = mUnrestrictedScreenLeft |
| 3417 | + mUnrestrictedScreenWidth; |
| 3418 | pf.bottom = df.bottom = of.bottom = cf.bottom = mUnrestrictedScreenTop |
| 3419 | + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3420 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3421 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3422 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3423 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3424 | + mRestrictedScreenWidth; |
| 3425 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3426 | + mRestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3427 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3428 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3429 | applyStableConstraints(sysUiFl, fl, cf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3430 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3431 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3432 | vf.left = mCurLeft; |
| 3433 | vf.top = mCurTop; |
| 3434 | vf.right = mCurRight; |
| 3435 | vf.bottom = mCurBottom; |
| 3436 | } else { |
| 3437 | vf.set(cf); |
| 3438 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3439 | } else if (attached != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3440 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3441 | "): attached to " + attached); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3442 | // A child window should be placed inside of the same visible |
| 3443 | // frame that its parent had. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3444 | 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] | 3445 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3446 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3447 | "): normal window"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3448 | // Otherwise, a normal window must be placed inside the content |
| 3449 | // of all screen decorations. |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3450 | if (attrs.type == TYPE_STATUS_BAR_PANEL) { |
| 3451 | // Status bar panels are the only windows who can go on top of |
| 3452 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3453 | // permission, so they have the same privileges as the status |
| 3454 | // bar itself. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3455 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3456 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3457 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3458 | + mRestrictedScreenWidth; |
| 3459 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3460 | + mRestrictedScreenHeight; |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3461 | } else if (attrs.type == TYPE_TOAST || attrs.type == TYPE_SYSTEM_ALERT |
| 3462 | || attrs.type == TYPE_VOLUME_OVERLAY) { |
| 3463 | // These dialogs are stable to interim decor changes. |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3464 | pf.left = df.left = of.left = cf.left = mStableLeft; |
| 3465 | pf.top = df.top = of.top = cf.top = mStableTop; |
| 3466 | pf.right = df.right = of.right = cf.right = mStableRight; |
| 3467 | pf.bottom = df.bottom = of.bottom = cf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3468 | } else { |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3469 | pf.left = mContentLeft; |
| 3470 | pf.top = mContentTop; |
| 3471 | pf.right = mContentRight; |
| 3472 | pf.bottom = mContentBottom; |
Dianne Hackborn | 20d9474 | 2014-05-29 18:35:45 -0700 | [diff] [blame] | 3473 | if (win.isVoiceInteraction()) { |
| 3474 | df.left = of.left = cf.left = mVoiceContentLeft; |
| 3475 | df.top = of.top = cf.top = mVoiceContentTop; |
| 3476 | df.right = of.right = cf.right = mVoiceContentRight; |
| 3477 | df.bottom = of.bottom = cf.bottom = mVoiceContentBottom; |
| 3478 | } else if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3479 | df.left = of.left = cf.left = mDockLeft; |
| 3480 | df.top = of.top = cf.top = mDockTop; |
| 3481 | df.right = of.right = cf.right = mDockRight; |
| 3482 | df.bottom = of.bottom = cf.bottom = mDockBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3483 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3484 | df.left = of.left = cf.left = mContentLeft; |
| 3485 | df.top = of.top = cf.top = mContentTop; |
| 3486 | df.right = of.right = cf.right = mContentRight; |
| 3487 | df.bottom = of.bottom = cf.bottom = mContentBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3488 | } |
| 3489 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3490 | vf.left = mCurLeft; |
| 3491 | vf.top = mCurTop; |
| 3492 | vf.right = mCurRight; |
| 3493 | vf.bottom = mCurBottom; |
| 3494 | } else { |
| 3495 | vf.set(cf); |
| 3496 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3497 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3498 | } |
| 3499 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3500 | |
Craig Mautner | b816bed | 2013-07-23 10:26:17 -0700 | [diff] [blame] | 3501 | // TYPE_SYSTEM_ERROR is above the NavigationBar so it can't be allowed to extend over it. |
| 3502 | if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0 && attrs.type != TYPE_SYSTEM_ERROR) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3503 | df.left = df.top = of.left = of.top = cf.left = cf.top = vf.left = vf.top = -10000; |
| 3504 | df.right = df.bottom = of.right = of.bottom = cf.right = cf.bottom |
| 3505 | = vf.right = vf.bottom = 10000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3506 | } |
| 3507 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3508 | 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] | 3509 | + ": sim=#" + Integer.toHexString(sim) |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3510 | + " attach=" + attached + " type=" + attrs.type |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3511 | + String.format(" flags=0x%08x", fl) |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 3512 | + " pf=" + pf.toShortString() + " df=" + df.toShortString() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3513 | + " of=" + of.toShortString() |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3514 | + " cf=" + cf.toShortString() + " vf=" + vf.toShortString() |
| 3515 | + " dcf=" + dcf.toShortString()); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3516 | |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3517 | win.computeFrameLw(pf, df, of, cf, vf, dcf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3518 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3519 | // Dock windows carve out the bottom of the screen, so normal windows |
| 3520 | // can't appear underneath them. |
Craig Mautner | 8bd206b | 2012-10-03 10:32:02 -0700 | [diff] [blame] | 3521 | if (attrs.type == TYPE_INPUT_METHOD && win.isVisibleOrBehindKeyguardLw() |
| 3522 | && !win.getGivenInsetsPendingLw()) { |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3523 | setLastInputMethodWindowLw(null, null); |
| 3524 | offsetInputMethodWindowLw(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3525 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3526 | if (attrs.type == TYPE_VOICE_INTERACTION && win.isVisibleOrBehindKeyguardLw() |
| 3527 | && !win.getGivenInsetsPendingLw()) { |
| 3528 | offsetVoiceInputWindowLw(win); |
| 3529 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3530 | } |
| 3531 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3532 | private void offsetInputMethodWindowLw(WindowState win) { |
| 3533 | int top = win.getContentFrameLw().top; |
| 3534 | top += win.getGivenContentInsetsLw().top; |
| 3535 | if (mContentBottom > top) { |
| 3536 | mContentBottom = top; |
| 3537 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3538 | if (mVoiceContentBottom > top) { |
| 3539 | mVoiceContentBottom = top; |
| 3540 | } |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3541 | top = win.getVisibleFrameLw().top; |
| 3542 | top += win.getGivenVisibleInsetsLw().top; |
| 3543 | if (mCurBottom > top) { |
| 3544 | mCurBottom = top; |
| 3545 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3546 | if (DEBUG_LAYOUT) Slog.v(TAG, "Input method: mDockBottom=" |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3547 | + mDockBottom + " mContentBottom=" |
| 3548 | + mContentBottom + " mCurBottom=" + mCurBottom); |
| 3549 | } |
| 3550 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3551 | private void offsetVoiceInputWindowLw(WindowState win) { |
| 3552 | final int gravity = win.getAttrs().gravity; |
| 3553 | switch (gravity&((Gravity.AXIS_PULL_BEFORE|Gravity.AXIS_PULL_AFTER) |
| 3554 | << Gravity.AXIS_X_SHIFT)) { |
| 3555 | case Gravity.AXIS_PULL_BEFORE<<Gravity.AXIS_X_SHIFT: { |
| 3556 | int right = win.getContentFrameLw().right - win.getGivenContentInsetsLw().right; |
| 3557 | if (mVoiceContentLeft < right) { |
| 3558 | mVoiceContentLeft = right; |
| 3559 | } |
| 3560 | } break; |
| 3561 | case Gravity.AXIS_PULL_AFTER<<Gravity.AXIS_X_SHIFT: { |
| 3562 | int left = win.getContentFrameLw().left - win.getGivenContentInsetsLw().left; |
| 3563 | if (mVoiceContentRight < left) { |
| 3564 | mVoiceContentRight = left; |
| 3565 | } |
| 3566 | } break; |
| 3567 | } |
| 3568 | switch (gravity&((Gravity.AXIS_PULL_BEFORE|Gravity.AXIS_PULL_AFTER) |
| 3569 | << Gravity.AXIS_Y_SHIFT)) { |
| 3570 | case Gravity.AXIS_PULL_BEFORE<<Gravity.AXIS_Y_SHIFT: { |
| 3571 | int bottom = win.getContentFrameLw().bottom - win.getGivenContentInsetsLw().bottom; |
| 3572 | if (mVoiceContentTop < bottom) { |
| 3573 | mVoiceContentTop = bottom; |
| 3574 | } |
| 3575 | } break; |
| 3576 | case Gravity.AXIS_PULL_AFTER<<Gravity.AXIS_Y_SHIFT: { |
| 3577 | int top = win.getContentFrameLw().top - win.getGivenContentInsetsLw().top; |
| 3578 | if (mVoiceContentBottom < top) { |
| 3579 | mVoiceContentBottom = top; |
| 3580 | } |
| 3581 | } break; |
| 3582 | } |
| 3583 | } |
| 3584 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3585 | /** {@inheritDoc} */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 3586 | @Override |
| 3587 | public void finishLayoutLw() { |
| 3588 | return; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3589 | } |
| 3590 | |
| 3591 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3592 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3593 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3594 | mTopFullscreenOpaqueWindowState = null; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3595 | mAppsToBeHidden.clear(); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3596 | mForceStatusBar = false; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3597 | mForceStatusBarFromKeyguard = false; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3598 | mForcingShowNavBar = false; |
| 3599 | mForcingShowNavBarLayer = -1; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3600 | |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3601 | mHideLockScreen = false; |
| 3602 | mAllowLockscreenWhenOn = false; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3603 | mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3604 | mShowingLockscreen = false; |
| 3605 | mShowingDream = false; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3606 | } |
| 3607 | |
| 3608 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3609 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3610 | public void applyPostLayoutPolicyLw(WindowState win, |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3611 | WindowManager.LayoutParams attrs) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3612 | if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw=" |
| 3613 | + win.isVisibleOrBehindKeyguardLw()); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3614 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3615 | if (mTopFullscreenOpaqueWindowState == null |
| 3616 | && win.isVisibleLw() && attrs.type == TYPE_INPUT_METHOD) { |
| 3617 | mForcingShowNavBar = true; |
| 3618 | mForcingShowNavBarLayer = win.getSurfaceLayer(); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3619 | } |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 3620 | if (attrs.type == TYPE_STATUS_BAR && (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 3621 | mForceStatusBarFromKeyguard = true; |
| 3622 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3623 | if (mTopFullscreenOpaqueWindowState == null && |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 3624 | win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3625 | if ((fl & FLAG_FORCE_NOT_FULLSCREEN) != 0) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3626 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3627 | mForceStatusBarFromKeyguard = true; |
| 3628 | } else { |
| 3629 | mForceStatusBar = true; |
| 3630 | } |
| 3631 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3632 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3633 | mShowingLockscreen = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3634 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3635 | boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3636 | && attrs.type <= LAST_APPLICATION_WINDOW; |
| 3637 | if (attrs.type == TYPE_DREAM) { |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3638 | // If the lockscreen was showing when the dream started then wait |
| 3639 | // for the dream to draw before hiding the lockscreen. |
| 3640 | if (!mDreamingLockscreen |
| 3641 | || (win.isVisibleLw() && win.hasDrawnLw())) { |
| 3642 | mShowingDream = true; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3643 | appWindow = true; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3644 | } |
| 3645 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3646 | |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 3647 | final boolean showWhenLocked = (fl & FLAG_SHOW_WHEN_LOCKED) != 0; |
Craig Mautner | 74ee938 | 2014-04-01 15:20:16 -0700 | [diff] [blame] | 3648 | final boolean dismissKeyguard = (fl & FLAG_DISMISS_KEYGUARD) != 0; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3649 | if (appWindow) { |
Craig Mautner | 4bdab6b | 2014-04-01 12:05:11 -0700 | [diff] [blame] | 3650 | if (showWhenLocked || (dismissKeyguard && !isKeyguardSecure())) { |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3651 | mAppsToBeHidden.remove(win.getAppToken()); |
| 3652 | } else { |
| 3653 | mAppsToBeHidden.add(win.getAppToken()); |
| 3654 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3655 | if (attrs.x == 0 && attrs.y == 0 |
| 3656 | && attrs.width == WindowManager.LayoutParams.MATCH_PARENT |
| 3657 | && attrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
| 3658 | if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win); |
| 3659 | mTopFullscreenOpaqueWindowState = win; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3660 | if (mAppsToBeHidden.isEmpty()) { |
Craig Mautner | da09ae3 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3661 | if (showWhenLocked) { |
| 3662 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 3663 | "Setting mHideLockScreen to true by win " + win); |
| 3664 | mHideLockScreen = true; |
| 3665 | mForceStatusBarFromKeyguard = false; |
| 3666 | } |
Craig Mautner | 4bdab6b | 2014-04-01 12:05:11 -0700 | [diff] [blame] | 3667 | if (dismissKeyguard && mDismissKeyguard == DISMISS_KEYGUARD_NONE) { |
Craig Mautner | da09ae3 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3668 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 3669 | "Setting mDismissKeyguard true by win " + win); |
| 3670 | mDismissKeyguard = mWinDismissingKeyguard == win ? |
| 3671 | DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START; |
| 3672 | mWinDismissingKeyguard = win; |
| 3673 | mForceStatusBarFromKeyguard = mShowingLockscreen && isKeyguardSecure(); |
| 3674 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3675 | } |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 3676 | if ((fl & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) { |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3677 | mAllowLockscreenWhenOn = true; |
| 3678 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3679 | } |
| 3680 | } |
| 3681 | } |
| 3682 | } |
| 3683 | |
| 3684 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3685 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3686 | public int finishPostLayoutPolicyLw() { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3687 | int changes = 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3688 | boolean topIsFullscreen = false; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3689 | |
| 3690 | final WindowManager.LayoutParams lp = (mTopFullscreenOpaqueWindowState != null) |
| 3691 | ? mTopFullscreenOpaqueWindowState.getAttrs() |
| 3692 | : null; |
| 3693 | |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3694 | // If we are not currently showing a dream then remember the current |
| 3695 | // lockscreen state. We will use this to determine whether the dream |
| 3696 | // started while the lockscreen was showing and remember this state |
| 3697 | // while the dream is showing. |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3698 | if (!mShowingDream) { |
| 3699 | mDreamingLockscreen = mShowingLockscreen; |
| 3700 | } |
| 3701 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3702 | if (mStatusBar != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3703 | if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3704 | + " forcefkg=" + mForceStatusBarFromKeyguard |
Dianne Hackborn | d70bc2f | 2009-10-06 23:25:51 -0700 | [diff] [blame] | 3705 | + " top=" + mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3706 | if (mForceStatusBar || mForceStatusBarFromKeyguard) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3707 | if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3708 | if (mStatusBarController.setBarShowingLw(true)) { |
| 3709 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3710 | } |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 3711 | // Maintain fullscreen layout until incoming animation is complete. |
| 3712 | topIsFullscreen = mTopIsFullscreen && mStatusBar.isAnimatingLw(); |
John Spurlock | f92b616 | 2013-11-11 15:01:16 -0500 | [diff] [blame] | 3713 | // Transient status bar on the lockscreen is not allowed |
| 3714 | if (mForceStatusBarFromKeyguard && mStatusBarController.isTransientShowing()) { |
| 3715 | mStatusBarController.updateVisibilityLw(false /*transientAllowed*/, |
| 3716 | mLastSystemUiFlags, mLastSystemUiFlags); |
| 3717 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3718 | } else if (mTopFullscreenOpaqueWindowState != null) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3719 | final int fl = PolicyControl.getWindowFlags(null, lp); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3720 | if (localLOGV) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3721 | Slog.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw() |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3722 | + " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw()); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3723 | Slog.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs() |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3724 | + " lp.flags=0x" + Integer.toHexString(fl)); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3725 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3726 | topIsFullscreen = (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0 |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3727 | || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3728 | // The subtle difference between the window for mTopFullscreenOpaqueWindowState |
| 3729 | // and mTopIsFullscreen is that that mTopIsFullscreen is set only if the window |
| 3730 | // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the |
| 3731 | // case though. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3732 | if (mStatusBarController.isTransientShowing()) { |
| 3733 | if (mStatusBarController.setBarShowingLw(true)) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3734 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3735 | } |
| 3736 | } else if (topIsFullscreen) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3737 | if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3738 | if (mStatusBarController.setBarShowingLw(false)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3739 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3740 | } else { |
Craig Mautner | c5a6e44 | 2013-06-05 17:22:35 -0700 | [diff] [blame] | 3741 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar already hiding"); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 3742 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3743 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3744 | 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] | 3745 | if (mStatusBarController.setBarShowingLw(true)) { |
| 3746 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3747 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3748 | } |
| 3749 | } |
| 3750 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3751 | |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 3752 | if (mTopIsFullscreen != topIsFullscreen) { |
| 3753 | if (!topIsFullscreen) { |
| 3754 | // Force another layout when status bar becomes fully shown. |
| 3755 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3756 | } |
| 3757 | mTopIsFullscreen = topIsFullscreen; |
| 3758 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3759 | |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3760 | // Hide the key guard if a visible window explicitly specifies that it wants to be |
| 3761 | // displayed when the screen is locked. |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3762 | if (mKeyguardDelegate != null && mStatusBar != null) { |
| 3763 | if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard=" |
| 3764 | + mHideLockScreen); |
| 3765 | if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !isKeyguardSecure()) { |
| 3766 | mKeyguardHidden = true; |
| 3767 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(true))) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3768 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3769 | | FINISH_LAYOUT_REDO_CONFIG |
| 3770 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3771 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3772 | if (mKeyguardDelegate.isShowing()) { |
| 3773 | mHandler.post(new Runnable() { |
| 3774 | @Override |
| 3775 | public void run() { |
| 3776 | mKeyguardDelegate.keyguardDone(false, false); |
| 3777 | } |
| 3778 | }); |
| 3779 | } |
| 3780 | } else if (mHideLockScreen) { |
| 3781 | mKeyguardHidden = true; |
| 3782 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(true))) { |
| 3783 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3784 | | FINISH_LAYOUT_REDO_CONFIG |
| 3785 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3786 | } |
| 3787 | } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) { |
| 3788 | // This is the case of keyguard isSecure() and not mHideLockScreen. |
| 3789 | if (mDismissKeyguard == DISMISS_KEYGUARD_START) { |
| 3790 | // Only launch the next keyguard unlock window once per window. |
| 3791 | mKeyguardHidden = false; |
| 3792 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(false))) { |
| 3793 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3794 | | FINISH_LAYOUT_REDO_CONFIG |
| 3795 | | FINISH_LAYOUT_REDO_WALLPAPER; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3796 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3797 | mHandler.post(new Runnable() { |
| 3798 | @Override |
| 3799 | public void run() { |
| 3800 | mKeyguardDelegate.dismiss(); |
| 3801 | } |
| 3802 | }); |
| 3803 | } |
| 3804 | } else { |
| 3805 | mWinDismissingKeyguard = null; |
| 3806 | mKeyguardHidden = false; |
| 3807 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(false))) { |
| 3808 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3809 | | FINISH_LAYOUT_REDO_CONFIG |
| 3810 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3811 | } |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 3812 | } |
| 3813 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3814 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3815 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3816 | // If the navigation bar has been hidden or shown, we need to do another |
| 3817 | // layout pass to update that window. |
| 3818 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3819 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3820 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3821 | // update since mAllowLockscreenWhenOn might have changed |
| 3822 | updateLockScreenTimeout(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3823 | return changes; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3824 | } |
| 3825 | |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3826 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3827 | * 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] | 3828 | * immediately need to put the wallpaper directly behind the Keyguard when a window with flag |
| 3829 | * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED} gets dismissed. If we |
| 3830 | * would wait for Keyguard to change the flags, that would be running asynchronously and thus be |
| 3831 | * too late so the user might see the window behind. |
| 3832 | * |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3833 | * @param setHiddenResult The result code from {@link IKeyguardService#setOccluded}. |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3834 | * @return Whether the flags have changed and we have to redo the layout. |
| 3835 | */ |
| 3836 | private boolean processKeyguardSetHiddenResultLw(int setHiddenResult) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3837 | if (setHiddenResult |
| 3838 | == IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_SET_FLAGS) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3839 | mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD; |
| 3840 | mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 3841 | return true; |
| 3842 | } else if (setHiddenResult |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3843 | == IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_UNSET_FLAGS) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3844 | mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD; |
| 3845 | mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER; |
| 3846 | return true; |
| 3847 | } else { |
| 3848 | return false; |
| 3849 | } |
| 3850 | } |
| 3851 | |
| 3852 | private boolean isStatusBarKeyguard() { |
| 3853 | return mStatusBar != null |
| 3854 | && (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
| 3855 | } |
| 3856 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3857 | public boolean allowAppAnimationsLw() { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3858 | if (isStatusBarKeyguard() || mShowingDream) { |
Craig Mautner | 2881630 | 2013-10-10 20:31:00 -0700 | [diff] [blame] | 3859 | // 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] | 3860 | return false; |
| 3861 | } |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3862 | return true; |
| 3863 | } |
| 3864 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3865 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus) { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3866 | mFocusedWindow = newFocus; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3867 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3868 | // If the navigation bar has been hidden or shown, we need to do another |
| 3869 | // layout pass to update that window. |
| 3870 | return FINISH_LAYOUT_REDO_LAYOUT; |
| 3871 | } |
| 3872 | return 0; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3873 | } |
| 3874 | |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 3875 | /** {@inheritDoc} */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3876 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
| 3877 | // lid changed state |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3878 | final int newLidState = lidOpen ? LID_OPEN : LID_CLOSED; |
| 3879 | if (newLidState == mLidState) { |
| 3880 | return; |
| 3881 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3882 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3883 | mLidState = newLidState; |
| 3884 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3885 | updateRotation(true); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3886 | |
| 3887 | if (lidOpen) { |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 3888 | mPowerManager.wakeUp(SystemClock.uptimeMillis()); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3889 | } else if (!mLidControlsSleep) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3890 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3891 | } |
| 3892 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3893 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3894 | void setHdmiPlugged(boolean plugged) { |
| 3895 | if (mHdmiPlugged != plugged) { |
| 3896 | mHdmiPlugged = plugged; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3897 | updateRotation(true, true); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3898 | Intent intent = new Intent(ACTION_HDMI_PLUGGED); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3899 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3900 | intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 3901 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3902 | } |
| 3903 | } |
| 3904 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3905 | void initializeHdmiState() { |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 3906 | boolean plugged = false; |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3907 | // watch for HDMI plug messages if the hdmi switch exists |
| 3908 | if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) { |
| 3909 | mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi"); |
| 3910 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3911 | final String filename = "/sys/class/switch/hdmi/state"; |
| 3912 | FileReader reader = null; |
| 3913 | try { |
| 3914 | reader = new FileReader(filename); |
| 3915 | char[] buf = new char[15]; |
| 3916 | int n = reader.read(buf); |
| 3917 | if (n > 1) { |
| 3918 | plugged = 0 != Integer.parseInt(new String(buf, 0, n-1)); |
| 3919 | } |
| 3920 | } catch (IOException ex) { |
| 3921 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 3922 | } catch (NumberFormatException ex) { |
| 3923 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 3924 | } finally { |
| 3925 | if (reader != null) { |
| 3926 | try { |
| 3927 | reader.close(); |
| 3928 | } catch (IOException ex) { |
| 3929 | } |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3930 | } |
| 3931 | } |
| 3932 | } |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 3933 | // This dance forces the code in setHdmiPlugged to run. |
| 3934 | // Always do this so the sticky intent is stuck (to false) if there is no hdmi. |
| 3935 | mHdmiPlugged = !plugged; |
| 3936 | setHdmiPlugged(!mHdmiPlugged); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3937 | } |
| 3938 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3939 | /** |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3940 | * @return Whether music is being played right now "locally" (e.g. on the device's speakers |
| 3941 | * or wired headphones) or "remotely" (e.g. on a device using the Cast protocol and |
| 3942 | * controlled by this device, or through remote submix). |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3943 | */ |
| 3944 | boolean isMusicActive() { |
Eric Laurent | 413cb9d | 2009-07-17 11:52:43 -0700 | [diff] [blame] | 3945 | final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); |
| 3946 | if (am == null) { |
| 3947 | Log.w(TAG, "isMusicActive: couldn't get AudioManager reference"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3948 | return false; |
| 3949 | } |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3950 | return am.isLocalOrRemoteMusicActive(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3951 | } |
| 3952 | |
| 3953 | /** |
| 3954 | * Tell the audio service to adjust the volume appropriate to the event. |
| 3955 | * @param keycode |
| 3956 | */ |
Mike Lockwood | a53e381 | 2009-09-25 10:51:39 -0400 | [diff] [blame] | 3957 | void handleVolumeKey(int stream, int keycode) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3958 | IAudioService audioService = getAudioService(); |
| 3959 | if (audioService == null) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3960 | return; |
| 3961 | } |
| 3962 | try { |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3963 | // 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] | 3964 | // 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] | 3965 | // that the music stops right before we call this. |
| 3966 | // Otherwise we might also be in a remote playback case. |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 3967 | // TODO: Actually handle MUTE. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3968 | mBroadcastWakeLock.acquire(); |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3969 | if (stream == AudioSystem.STREAM_MUSIC) { |
| 3970 | audioService.adjustLocalOrRemoteStreamVolume(stream, |
| 3971 | keycode == KeyEvent.KEYCODE_VOLUME_UP |
| 3972 | ? AudioManager.ADJUST_RAISE |
| 3973 | : AudioManager.ADJUST_LOWER, |
| 3974 | mContext.getOpPackageName()); |
| 3975 | } else { |
| 3976 | audioService.adjustStreamVolume(stream, |
| 3977 | keycode == KeyEvent.KEYCODE_VOLUME_UP |
| 3978 | ? AudioManager.ADJUST_RAISE |
| 3979 | : AudioManager.ADJUST_LOWER, |
| 3980 | 0, |
| 3981 | mContext.getOpPackageName()); |
| 3982 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3983 | } catch (RemoteException e) { |
Jean-Michel Trivi | fca1e60 | 2013-10-10 18:12:59 -0700 | [diff] [blame] | 3984 | Log.w(TAG, "IAudioService.adjust*StreamVolume() threw RemoteException " + e); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3985 | } finally { |
| 3986 | mBroadcastWakeLock.release(); |
| 3987 | } |
| 3988 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3989 | |
Dianne Hackborn | c0e3f24 | 2011-08-19 14:19:10 -0700 | [diff] [blame] | 3990 | final Object mScreenshotLock = new Object(); |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3991 | ServiceConnection mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3992 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3993 | final Runnable mScreenshotTimeout = new Runnable() { |
| 3994 | @Override public void run() { |
| 3995 | synchronized (mScreenshotLock) { |
| 3996 | if (mScreenshotConnection != null) { |
| 3997 | mContext.unbindService(mScreenshotConnection); |
| 3998 | mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 3999 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4000 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4001 | } |
| 4002 | }; |
| 4003 | |
| 4004 | // Assume this is called from the Handler thread. |
| 4005 | private void takeScreenshot() { |
| 4006 | synchronized (mScreenshotLock) { |
| 4007 | if (mScreenshotConnection != null) { |
| 4008 | return; |
| 4009 | } |
| 4010 | ComponentName cn = new ComponentName("com.android.systemui", |
| 4011 | "com.android.systemui.screenshot.TakeScreenshotService"); |
| 4012 | Intent intent = new Intent(); |
| 4013 | intent.setComponent(cn); |
| 4014 | ServiceConnection conn = new ServiceConnection() { |
| 4015 | @Override |
| 4016 | public void onServiceConnected(ComponentName name, IBinder service) { |
| 4017 | synchronized (mScreenshotLock) { |
| 4018 | if (mScreenshotConnection != this) { |
| 4019 | return; |
| 4020 | } |
| 4021 | Messenger messenger = new Messenger(service); |
| 4022 | Message msg = Message.obtain(null, 1); |
| 4023 | final ServiceConnection myConn = this; |
| 4024 | Handler h = new Handler(mHandler.getLooper()) { |
| 4025 | @Override |
| 4026 | public void handleMessage(Message msg) { |
| 4027 | synchronized (mScreenshotLock) { |
| 4028 | if (mScreenshotConnection == myConn) { |
| 4029 | mContext.unbindService(mScreenshotConnection); |
| 4030 | mScreenshotConnection = null; |
| 4031 | mHandler.removeCallbacks(mScreenshotTimeout); |
| 4032 | } |
| 4033 | } |
| 4034 | } |
| 4035 | }; |
| 4036 | msg.replyTo = new Messenger(h); |
Winson Chung | a63bb84 | 2011-10-17 10:26:28 -0700 | [diff] [blame] | 4037 | msg.arg1 = msg.arg2 = 0; |
| 4038 | if (mStatusBar != null && mStatusBar.isVisibleLw()) |
| 4039 | msg.arg1 = 1; |
| 4040 | if (mNavigationBar != null && mNavigationBar.isVisibleLw()) |
| 4041 | msg.arg2 = 1; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4042 | try { |
| 4043 | messenger.send(msg); |
| 4044 | } catch (RemoteException e) { |
| 4045 | } |
| 4046 | } |
| 4047 | } |
| 4048 | @Override |
| 4049 | public void onServiceDisconnected(ComponentName name) {} |
| 4050 | }; |
Amith Yamasani | 27b89e6 | 2013-01-16 12:30:11 -0800 | [diff] [blame] | 4051 | if (mContext.bindServiceAsUser( |
| 4052 | intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4053 | mScreenshotConnection = conn; |
| 4054 | mHandler.postDelayed(mScreenshotTimeout, 10000); |
| 4055 | } |
| 4056 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4057 | } |
| 4058 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4059 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4060 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4061 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 4062 | if (!mSystemBooted) { |
| 4063 | // If we have not yet booted, don't let key events do anything. |
| 4064 | return 0; |
| 4065 | } |
| 4066 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4067 | final boolean interactive = (policyFlags & FLAG_INTERACTIVE) != 0; |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 4068 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 4069 | final boolean canceled = event.isCanceled(); |
| 4070 | final int keyCode = event.getKeyCode(); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 4071 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4072 | final boolean isInjected = (policyFlags & WindowManagerPolicy.FLAG_INJECTED) != 0; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4073 | |
Mike Lockwood | c72b15f | 2009-11-28 20:58:22 -0500 | [diff] [blame] | 4074 | // If screen is off then we treat the case where the keyguard is open but hidden |
| 4075 | // the same as if it were open and in front. |
| 4076 | // This will prevent any keys other than the power button from waking the screen |
| 4077 | // when the keyguard is hidden by another activity. |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4078 | final boolean keyguardActive = (mKeyguardDelegate == null ? false : |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4079 | (interactive ? |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4080 | mKeyguardDelegate.isShowingAndNotOccluded() : |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4081 | mKeyguardDelegate.isShowing())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4082 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4083 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4084 | Log.d(TAG, "interceptKeyTq keycode=" + keyCode |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4085 | + " interactive=" + interactive + " keyguardActive=" + keyguardActive |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4086 | + " policyFlags=" + Integer.toHexString(policyFlags)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4087 | } |
| 4088 | |
Jeff Brown | 98392ef | 2011-09-12 18:24:59 -0700 | [diff] [blame] | 4089 | if (down && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 |
| 4090 | && event.getRepeatCount() == 0) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4091 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
| 4092 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4093 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4094 | // Basic policy based on interactive state. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4095 | int result; |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 4096 | boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0 |
| 4097 | || event.isWakeKey(); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4098 | if (interactive || (isInjected && !isWakeKey)) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4099 | // When the screen is on or if the key is injected pass the key to the application. |
| 4100 | result = ACTION_PASS_TO_USER; |
| 4101 | } else { |
| 4102 | // When the screen is off and the key is not injected, determine whether |
| 4103 | // to wake the device but don't pass the key to the application. |
| 4104 | result = 0; |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4105 | if (isWakeKey && (!down || !isWakeKeyWhenScreenOff(keyCode))) { |
| 4106 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4107 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4108 | } |
| 4109 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 4110 | // If the key would be handled globally, just return the result, don't worry about special |
| 4111 | // key processing. |
| 4112 | if (mGlobalKeyManager.shouldHandleGlobalKey(keyCode, event)) { |
| 4113 | return result; |
| 4114 | } |
| 4115 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4116 | // Handle special keys. |
| 4117 | switch (keyCode) { |
| 4118 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 4119 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4120 | case KeyEvent.KEYCODE_VOLUME_MUTE: { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4121 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { |
| 4122 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4123 | if (interactive && !mVolumeDownKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4124 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4125 | mVolumeDownKeyTriggered = true; |
| 4126 | mVolumeDownKeyTime = event.getDownTime(); |
| 4127 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 4128 | cancelPendingPowerKeyAction(); |
| 4129 | interceptScreenshotChord(); |
| 4130 | } |
| 4131 | } else { |
| 4132 | mVolumeDownKeyTriggered = false; |
| 4133 | cancelPendingScreenshotChordAction(); |
| 4134 | } |
| 4135 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { |
| 4136 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4137 | if (interactive && !mVolumeUpKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4138 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4139 | mVolumeUpKeyTriggered = true; |
| 4140 | cancelPendingPowerKeyAction(); |
| 4141 | cancelPendingScreenshotChordAction(); |
| 4142 | } |
| 4143 | } else { |
| 4144 | mVolumeUpKeyTriggered = false; |
| 4145 | cancelPendingScreenshotChordAction(); |
| 4146 | } |
| 4147 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4148 | if (down) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4149 | TelephonyManager telephonyManager = getTelephonyService(); |
| 4150 | if (telephonyManager != null) { |
| 4151 | if (telephonyManager.isRinging()) { |
| 4152 | // If an incoming call is ringing, either VOLUME key means |
| 4153 | // "silence ringer". We handle these keys here, rather than |
| 4154 | // in the InCallScreen, to make sure we'll respond to them |
| 4155 | // even if the InCallScreen hasn't come to the foreground yet. |
| 4156 | // Look for the DOWN event here, to agree with the "fallback" |
| 4157 | // behavior in the InCallScreen. |
| 4158 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4159 | + " VOLUME key-down while ringing: Silence ringer!"); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4160 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4161 | // Silence the ringer. (It's safe to call this |
| 4162 | // even if the ringer has already been silenced.) |
| 4163 | telephonyManager.silenceRinger(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4164 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4165 | // And *don't* pass this key thru to the current activity |
| 4166 | // (which is probably the InCallScreen.) |
| 4167 | result &= ~ACTION_PASS_TO_USER; |
| 4168 | break; |
| 4169 | } |
| 4170 | if (telephonyManager.isOffhook() |
| 4171 | && (result & ACTION_PASS_TO_USER) == 0) { |
| 4172 | // If we are in call but we decided not to pass the key to |
| 4173 | // the application, handle the volume change here. |
| 4174 | handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keyCode); |
| 4175 | break; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4176 | } |
| 4177 | } |
| 4178 | |
| 4179 | if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { |
| 4180 | // If music is playing but we decided not to pass the key to the |
| 4181 | // application, handle the volume change here. |
| 4182 | handleVolumeKey(AudioManager.STREAM_MUSIC, keyCode); |
| 4183 | break; |
| 4184 | } |
| 4185 | } |
| 4186 | break; |
| 4187 | } |
| 4188 | |
| 4189 | case KeyEvent.KEYCODE_ENDCALL: { |
| 4190 | result &= ~ACTION_PASS_TO_USER; |
| 4191 | if (down) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4192 | TelephonyManager telephonyManager = getTelephonyService(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4193 | boolean hungUp = false; |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4194 | if (telephonyManager != null) { |
| 4195 | hungUp = telephonyManager.endCall(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4196 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4197 | interceptPowerKeyDown(!interactive || hungUp); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4198 | } else { |
| 4199 | if (interceptPowerKeyUp(canceled)) { |
| 4200 | if ((mEndcallBehavior |
| 4201 | & Settings.System.END_BUTTON_BEHAVIOR_HOME) != 0) { |
| 4202 | if (goHome()) { |
| 4203 | break; |
Dianne Hackborn | 0041e97 | 2009-07-24 17:14:43 -0700 | [diff] [blame] | 4204 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4205 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4206 | if ((mEndcallBehavior |
| 4207 | & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4208 | mPowerManager.goToSleep(event.getEventTime()); |
| 4209 | isWakeKey = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4210 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4211 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4212 | } |
| 4213 | break; |
| 4214 | } |
| 4215 | |
| 4216 | case KeyEvent.KEYCODE_POWER: { |
| 4217 | result &= ~ACTION_PASS_TO_USER; |
| 4218 | if (down) { |
Jeff Brown | 26c6a50 | 2014-04-11 02:15:54 -0700 | [diff] [blame] | 4219 | boolean panic = mImmersiveModeConfirmation.onPowerKeyDown(interactive, |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 4220 | event.getDownTime(), isImmersiveMode(mLastSystemUiFlags)); |
| 4221 | if (panic) { |
| 4222 | mHandler.post(mRequestTransientNav); |
| 4223 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4224 | if (interactive && !mPowerKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4225 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4226 | mPowerKeyTriggered = true; |
| 4227 | mPowerKeyTime = event.getDownTime(); |
| 4228 | interceptScreenshotChord(); |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4229 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4230 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4231 | TelephonyManager telephonyManager = getTelephonyService(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4232 | boolean hungUp = false; |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4233 | if (telephonyManager != null) { |
| 4234 | if (telephonyManager.isRinging()) { |
| 4235 | // Pressing Power while there's a ringing incoming |
| 4236 | // call should silence the ringer. |
| 4237 | telephonyManager.silenceRinger(); |
| 4238 | } else if ((mIncallPowerBehavior |
| 4239 | & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 |
| 4240 | && telephonyManager.isOffhook() && interactive) { |
| 4241 | // Otherwise, if "Power button ends call" is enabled, |
| 4242 | // the Power button will hang up any current active call. |
| 4243 | hungUp = telephonyManager.endCall(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4244 | } |
| 4245 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4246 | interceptPowerKeyDown(!interactive || hungUp |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4247 | || mVolumeDownKeyTriggered || mVolumeUpKeyTriggered); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4248 | } else { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4249 | mPowerKeyTriggered = false; |
| 4250 | cancelPendingScreenshotChordAction(); |
| 4251 | if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) { |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 4252 | powerShortPress(event.getEventTime()); |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4253 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4254 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4255 | mPendingPowerKeyUpCanceled = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4256 | } |
| 4257 | break; |
| 4258 | } |
| 4259 | |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4260 | case KeyEvent.KEYCODE_SLEEP: { |
| 4261 | result &= ~ACTION_PASS_TO_USER; |
| 4262 | mPowerManager.goToSleep(event.getEventTime()); |
| 4263 | isWakeKey = false; |
| 4264 | break; |
| 4265 | } |
| 4266 | |
| 4267 | case KeyEvent.KEYCODE_WAKEUP: { |
| 4268 | result &= ~ACTION_PASS_TO_USER; |
| 4269 | break; |
| 4270 | } |
| 4271 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4272 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4273 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4274 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4275 | if (down) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4276 | TelephonyManager telephonyManager = getTelephonyService(); |
| 4277 | if (telephonyManager != null) { |
| 4278 | if (!telephonyManager.isIdle()) { |
| 4279 | // Suppress PLAY/PAUSE toggle when phone is ringing or in-call |
| 4280 | // to avoid music playback. |
| 4281 | break; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4282 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4283 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4284 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4285 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4286 | case KeyEvent.KEYCODE_MUTE: |
| 4287 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4288 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4289 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4290 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4291 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4292 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
| 4293 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4294 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 4295 | // Only do this if we would otherwise not pass it to the user. In that |
| 4296 | // case, the PhoneWindow class will do the same thing, except it will |
| 4297 | // 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] | 4298 | // Note that we need to make a copy of the key event here because the |
| 4299 | // original key event will be recycled when we return. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4300 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4301 | Message msg = mHandler.obtainMessage(MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK, |
| 4302 | new KeyEvent(event)); |
| 4303 | msg.setAsynchronous(true); |
| 4304 | msg.sendToTarget(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4305 | } |
| 4306 | break; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4307 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4308 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4309 | case KeyEvent.KEYCODE_CALL: { |
| 4310 | if (down) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4311 | TelephonyManager telephonyManager = getTelephonyService(); |
| 4312 | if (telephonyManager != null) { |
| 4313 | if (telephonyManager.isRinging()) { |
| 4314 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4315 | + " CALL key-down while ringing: Answer the call!"); |
| 4316 | telephonyManager.answerRingingCall(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4317 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4318 | // And *don't* pass this key thru to the current activity |
| 4319 | // (which is presumably the InCallScreen.) |
| 4320 | result &= ~ACTION_PASS_TO_USER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4321 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4322 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4323 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4324 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4325 | } |
| 4326 | } |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4327 | |
| 4328 | if (isWakeKey) { |
| 4329 | mPowerManager.wakeUp(event.getEventTime()); |
| 4330 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4331 | return result; |
| 4332 | } |
| 4333 | |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4334 | /** |
| 4335 | * When the screen is off we ignore some keys that might otherwise typically |
| 4336 | * be considered wake keys. We filter them out here. |
| 4337 | * |
| 4338 | * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it |
| 4339 | * is always considered a wake key. |
| 4340 | */ |
| 4341 | private boolean isWakeKeyWhenScreenOff(int keyCode) { |
| 4342 | switch (keyCode) { |
| 4343 | // ignore volume keys unless docked |
| 4344 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4345 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 4346 | case KeyEvent.KEYCODE_VOLUME_MUTE: |
| 4347 | return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 4348 | |
| 4349 | // ignore media and camera keys |
| 4350 | case KeyEvent.KEYCODE_MUTE: |
| 4351 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4352 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4353 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4354 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4355 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4356 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4357 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4358 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4359 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
| 4360 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4361 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4362 | case KeyEvent.KEYCODE_CAMERA: |
| 4363 | return false; |
| 4364 | } |
| 4365 | return true; |
| 4366 | } |
| 4367 | |
| 4368 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4369 | /** {@inheritDoc} */ |
| 4370 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4371 | public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) { |
| 4372 | // We already know this is a wake motion so just wake up. |
| 4373 | // Note that we would observe policyFlags containing |
| 4374 | // FLAG_WAKE and FLAG_INTERACTIVE here. |
| 4375 | mPowerManager.wakeUp(whenNanos / 1000000); |
| 4376 | return 0; |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4377 | } |
| 4378 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4379 | void dispatchMediaKeyWithWakeLock(KeyEvent event) { |
| 4380 | if (DEBUG_INPUT) { |
| 4381 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: " + event); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4382 | } |
| 4383 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4384 | if (mHavePendingMediaKeyRepeatWithWakeLock) { |
| 4385 | if (DEBUG_INPUT) { |
| 4386 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: canceled repeat"); |
| 4387 | } |
| 4388 | |
| 4389 | mHandler.removeMessages(MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK); |
| 4390 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4391 | mBroadcastWakeLock.release(); // pending repeat was holding onto the wake lock |
| 4392 | } |
| 4393 | |
| 4394 | dispatchMediaKeyWithWakeLockToAudioService(event); |
| 4395 | |
| 4396 | if (event.getAction() == KeyEvent.ACTION_DOWN |
| 4397 | && event.getRepeatCount() == 0) { |
| 4398 | mHavePendingMediaKeyRepeatWithWakeLock = true; |
| 4399 | |
| 4400 | Message msg = mHandler.obtainMessage( |
| 4401 | MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK, event); |
| 4402 | msg.setAsynchronous(true); |
| 4403 | mHandler.sendMessageDelayed(msg, ViewConfiguration.getKeyRepeatTimeout()); |
| 4404 | } else { |
| 4405 | mBroadcastWakeLock.release(); |
| 4406 | } |
| 4407 | } |
| 4408 | |
| 4409 | void dispatchMediaKeyRepeatWithWakeLock(KeyEvent event) { |
| 4410 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4411 | |
| 4412 | KeyEvent repeatEvent = KeyEvent.changeTimeRepeat(event, |
| 4413 | SystemClock.uptimeMillis(), 1, event.getFlags() | KeyEvent.FLAG_LONG_PRESS); |
| 4414 | if (DEBUG_INPUT) { |
| 4415 | Slog.d(TAG, "dispatchMediaKeyRepeatWithWakeLock: " + repeatEvent); |
| 4416 | } |
| 4417 | |
| 4418 | dispatchMediaKeyWithWakeLockToAudioService(repeatEvent); |
| 4419 | mBroadcastWakeLock.release(); |
| 4420 | } |
| 4421 | |
| 4422 | void dispatchMediaKeyWithWakeLockToAudioService(KeyEvent event) { |
| 4423 | if (ActivityManagerNative.isSystemReady()) { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 4424 | if (USE_SESSIONS) { |
| 4425 | MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(event, true); |
| 4426 | } else { |
| 4427 | IAudioService audioService = getAudioService(); |
| 4428 | if (audioService != null) { |
| 4429 | try { |
| 4430 | audioService.dispatchMediaKeyEventUnderWakelock(event); |
| 4431 | } catch (RemoteException e) { |
| 4432 | Log.e(TAG, "dispatchMediaKeyEvent threw exception " + e); |
| 4433 | } |
Jean-Michel Trivi | c680222 | 2012-04-30 11:15:03 -0700 | [diff] [blame] | 4434 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4435 | } |
| 4436 | } |
| 4437 | } |
| 4438 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4439 | BroadcastReceiver mDockReceiver = new BroadcastReceiver() { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4440 | @Override |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4441 | public void onReceive(Context context, Intent intent) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 4442 | if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { |
| 4443 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 4444 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4445 | } else { |
| 4446 | try { |
| 4447 | IUiModeManager uiModeService = IUiModeManager.Stub.asInterface( |
| 4448 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 4449 | mUiMode = uiModeService.getCurrentModeType(); |
| 4450 | } catch (RemoteException e) { |
| 4451 | } |
Dianne Hackborn | 80fa166 | 2009-10-07 14:02:10 -0700 | [diff] [blame] | 4452 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4453 | updateRotation(true); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4454 | synchronized (mLock) { |
| 4455 | updateOrientationListenerLp(); |
| 4456 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4457 | } |
| 4458 | }; |
| 4459 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4460 | BroadcastReceiver mDreamReceiver = new BroadcastReceiver() { |
| 4461 | @Override |
| 4462 | public void onReceive(Context context, Intent intent) { |
| 4463 | if (Intent.ACTION_DREAMING_STARTED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4464 | if (mKeyguardDelegate != null) { |
| 4465 | mKeyguardDelegate.onDreamingStarted(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4466 | } |
| 4467 | } else if (Intent.ACTION_DREAMING_STOPPED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4468 | if (mKeyguardDelegate != null) { |
| 4469 | mKeyguardDelegate.onDreamingStopped(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4470 | } |
| 4471 | } |
| 4472 | } |
| 4473 | }; |
| 4474 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4475 | BroadcastReceiver mMultiuserReceiver = new BroadcastReceiver() { |
| 4476 | @Override |
| 4477 | public void onReceive(Context context, Intent intent) { |
| 4478 | if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { |
| 4479 | // tickle the settings observer: this first ensures that we're |
| 4480 | // observing the relevant settings for the newly-active user, |
| 4481 | // and then updates our own bookkeeping based on the now- |
| 4482 | // current user. |
| 4483 | mSettingsObserver.onChange(false); |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4484 | |
| 4485 | // force a re-application of focused window sysui visibility. |
| 4486 | // the window may never have been shown for this user |
| 4487 | // e.g. the keyguard when going through the new-user setup flow |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4488 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4489 | mLastSystemUiFlags = 0; |
| 4490 | updateSystemUiVisibilityLw(); |
| 4491 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4492 | } |
| 4493 | } |
| 4494 | }; |
| 4495 | |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 4496 | private final Runnable mRequestTransientNav = new Runnable() { |
| 4497 | @Override |
| 4498 | public void run() { |
| 4499 | requestTransientBars(mNavigationBar); |
| 4500 | } |
| 4501 | }; |
| 4502 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 4503 | private void requestTransientBars(WindowState swipeTarget) { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4504 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 4505 | if (!isUserSetupComplete()) { |
| 4506 | // Swipe-up for navigation bar is disabled during setup |
| 4507 | return; |
| 4508 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4509 | boolean sb = mStatusBarController.checkShowTransientBarLw(); |
| 4510 | boolean nb = mNavigationBarController.checkShowTransientBarLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4511 | if (sb || nb) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 4512 | WindowState barTarget = sb ? mStatusBar : mNavigationBar; |
| 4513 | if (sb ^ nb && barTarget != swipeTarget) { |
| 4514 | if (DEBUG) Slog.d(TAG, "Not showing transient bar, wrong swipe target"); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4515 | return; |
| 4516 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4517 | if (sb) mStatusBarController.showTransient(); |
| 4518 | if (nb) mNavigationBarController.showTransient(); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 4519 | mImmersiveModeConfirmation.confirmCurrentPrompt(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4520 | updateSystemUiVisibilityLw(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 4521 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4522 | } |
| 4523 | } |
| 4524 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4525 | @Override |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 4526 | public void goingToSleep(int why) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4527 | EventLog.writeEvent(70000, 0); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4528 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4529 | mScreenOnEarly = false; |
| 4530 | mScreenOnFully = false; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4531 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4532 | if (mKeyguardDelegate != null) { |
| 4533 | mKeyguardDelegate.onScreenTurnedOff(why); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4534 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4535 | synchronized (mLock) { |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 4536 | updateWakeGestureListenerLp(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4537 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4538 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4539 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4540 | } |
| 4541 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4542 | @Override |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 4543 | public void wakingUp(final ScreenOnListener screenOnListener) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4544 | EventLog.writeEvent(70000, 1); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4545 | if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on...", |
| 4546 | new RuntimeException("here").fillInStackTrace()); |
| 4547 | mHandler.obtainMessage(MSG_WAKING_UP, screenOnListener).sendToTarget(); |
| 4548 | } |
| 4549 | |
| 4550 | // Called on the mHandler thread. |
| 4551 | private void handleWakingUp(final ScreenOnListener screenOnListener) { |
| 4552 | if (screenOnListener != null) { |
| 4553 | mScreenOnListeners.add(screenOnListener); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 4554 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4555 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4556 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4557 | mScreenOnEarly = true; |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 4558 | updateWakeGestureListenerLp(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4559 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4560 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4561 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4562 | |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4563 | mKeyguardDrawComplete = false; |
| 4564 | mWindowManagerDrawComplete = false; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4565 | if (mKeyguardDelegate != null) { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4566 | mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT); |
| 4567 | mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT, 1000); |
| 4568 | mKeyguardDelegate.onScreenTurnedOn(mKeyguardDelegateCallback); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4569 | } else { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4570 | if (DEBUG_WAKEUP) Slog.d(TAG, "null mKeyguardDelegate: setting mKeyguardDrawComplete."); |
| 4571 | mKeyguardDrawComplete = true; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4572 | } |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4573 | mWindowManagerInternal.waitForAllWindowsDrawn(mWindowManagerDrawCallback, 500); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4574 | } |
| 4575 | |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4576 | // Called on the mHandler thread. |
| 4577 | private void finishScreenTurningOn() { |
| 4578 | if (DEBUG_WAKEUP) Slog.d(TAG, |
| 4579 | "finishScreenTurningOn: mKeyguardDrawComplete=" + mKeyguardDrawComplete |
| 4580 | + " mWindowManagerDrawComplete=" + mWindowManagerDrawComplete); |
| 4581 | if (!mKeyguardDrawComplete || !mWindowManagerDrawComplete) { |
| 4582 | return; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4583 | } |
| 4584 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4585 | synchronized (mLock) { |
| 4586 | mScreenOnFully = true; |
| 4587 | } |
| 4588 | |
Jeff Brown | 4fc4527 | 2012-10-10 18:28:14 -0700 | [diff] [blame] | 4589 | try { |
| 4590 | mWindowManager.setEventDispatching(true); |
| 4591 | } catch (RemoteException unhandled) { |
| 4592 | } |
| 4593 | |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4594 | for (int i = mScreenOnListeners.size() - 1; i >=0; --i) { |
| 4595 | mScreenOnListeners.remove(i).onScreenOn(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4596 | } |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4597 | |
| 4598 | setKeyguardDrawn(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4599 | } |
| 4600 | |
| 4601 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4602 | public boolean isScreenOnEarly() { |
| 4603 | return mScreenOnEarly; |
| 4604 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4605 | |
| 4606 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4607 | public boolean isScreenOnFully() { |
| 4608 | return mScreenOnFully; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4609 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4610 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4611 | /** {@inheritDoc} */ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4612 | public void enableKeyguard(boolean enabled) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4613 | if (mKeyguardDelegate != null) { |
| 4614 | mKeyguardDelegate.setKeyguardEnabled(enabled); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4615 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4616 | } |
| 4617 | |
| 4618 | /** {@inheritDoc} */ |
| 4619 | public void exitKeyguardSecurely(OnKeyguardExitResult callback) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4620 | if (mKeyguardDelegate != null) { |
| 4621 | mKeyguardDelegate.verifyUnlock(callback); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4622 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4623 | } |
| 4624 | |
Mike Lockwood | f791330 | 2009-11-28 22:27:10 -0500 | [diff] [blame] | 4625 | private boolean keyguardIsShowingTq() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4626 | if (mKeyguardDelegate == null) return false; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4627 | return mKeyguardDelegate.isShowingAndNotOccluded(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4628 | } |
| 4629 | |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4630 | |
| 4631 | /** {@inheritDoc} */ |
| 4632 | public boolean isKeyguardLocked() { |
| 4633 | return keyguardOn(); |
| 4634 | } |
| 4635 | |
| 4636 | /** {@inheritDoc} */ |
| 4637 | public boolean isKeyguardSecure() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4638 | if (mKeyguardDelegate == null) return false; |
| 4639 | return mKeyguardDelegate.isSecure(); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4640 | } |
| 4641 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4642 | /** {@inheritDoc} */ |
| 4643 | public boolean inKeyguardRestrictedKeyInputMode() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4644 | if (mKeyguardDelegate == null) return false; |
| 4645 | return mKeyguardDelegate.isInputRestricted(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4646 | } |
| 4647 | |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4648 | public void dismissKeyguardLw() { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 4649 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4650 | mHandler.post(new Runnable() { |
| 4651 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4652 | if (mKeyguardDelegate.isDismissable()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4653 | // Can we just finish the keyguard straight away? |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4654 | mKeyguardDelegate.keyguardDone(false, true); |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4655 | } else { |
| 4656 | // ask the keyguard to prompt the user to authenticate if necessary |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4657 | mKeyguardDelegate.dismiss(); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4658 | } |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4659 | } |
| 4660 | }); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4661 | } |
| 4662 | } |
| 4663 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 4664 | private void setKeyguardDrawn() { |
| 4665 | synchronized (mLock) { |
| 4666 | mKeyguardDrawn = true; |
| 4667 | } |
| 4668 | try { |
| 4669 | mWindowManager.enableScreenIfNeeded(); |
| 4670 | } catch (RemoteException unhandled) { |
| 4671 | } |
| 4672 | } |
| 4673 | |
| 4674 | @Override |
| 4675 | public boolean isKeyguardDrawnLw() { |
| 4676 | synchronized (mLock) { |
| 4677 | return mKeyguardDrawn; |
| 4678 | } |
| 4679 | } |
| 4680 | |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4681 | @Override |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 4682 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4683 | if (mKeyguardDelegate != null) { |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 4684 | mKeyguardDelegate.startKeyguardExitAnimation(startTime, fadeoutDuration); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4685 | } |
| 4686 | } |
| 4687 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4688 | void sendCloseSystemWindows() { |
| 4689 | sendCloseSystemWindows(mContext, null); |
| 4690 | } |
| 4691 | |
| 4692 | void sendCloseSystemWindows(String reason) { |
| 4693 | sendCloseSystemWindows(mContext, reason); |
| 4694 | } |
| 4695 | |
| 4696 | static void sendCloseSystemWindows(Context context, String reason) { |
| 4697 | if (ActivityManagerNative.isSystemReady()) { |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 4698 | try { |
| 4699 | ActivityManagerNative.getDefault().closeSystemDialogs(reason); |
| 4700 | } catch (RemoteException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4701 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4702 | } |
| 4703 | } |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 4704 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4705 | @Override |
| 4706 | public int rotationForOrientationLw(int orientation, int lastRotation) { |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4707 | if (false) { |
| 4708 | Slog.v(TAG, "rotationForOrientationLw(orient=" |
| 4709 | + orientation + ", last=" + lastRotation |
| 4710 | + "); user=" + mUserRotation + " " |
| 4711 | + ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) |
| 4712 | ? "USER_ROTATION_LOCKED" : "") |
| 4713 | ); |
| 4714 | } |
| 4715 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 4716 | if (mForceDefaultOrientation) { |
| 4717 | return Surface.ROTATION_0; |
| 4718 | } |
| 4719 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4720 | synchronized (mLock) { |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4721 | int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 |
| 4722 | if (sensorRotation < 0) { |
Jeff Brown | 0f862b4 | 2012-09-27 21:11:01 -0700 | [diff] [blame] | 4723 | sensorRotation = lastRotation; |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4724 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4725 | |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4726 | final int preferredRotation; |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 4727 | if (mLidState == LID_OPEN && mLidOpenRotation >= 0) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4728 | // Ignore sensor when lid switch is open and rotation is forced. |
| 4729 | preferredRotation = mLidOpenRotation; |
| 4730 | } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4731 | && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4732 | // Ignore sensor when in car dock unless explicitly enabled. |
| 4733 | // This case can override the behavior of NOSENSOR, and can also |
| 4734 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4735 | preferredRotation = mCarDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4736 | ? sensorRotation : mCarDockRotation; |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 4737 | } else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 4738 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 4739 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4740 | && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4741 | // Ignore sensor when in desk dock unless explicitly enabled. |
| 4742 | // This case can override the behavior of NOSENSOR, and can also |
| 4743 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4744 | preferredRotation = mDeskDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4745 | ? sensorRotation : mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4746 | } else if (mHdmiPlugged && mDemoHdmiRotationLock) { |
| 4747 | // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled. |
Jeff Brown | eb3e4b9 | 2011-12-06 19:54:24 -0800 | [diff] [blame] | 4748 | // Note that the dock orientation overrides the HDMI orientation. |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4749 | preferredRotation = mDemoHdmiRotation; |
| 4750 | } else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED |
| 4751 | && mUndockedHdmiRotation >= 0) { |
| 4752 | // Ignore sensor when plugged into HDMI and an undocked orientation has |
| 4753 | // been specified in the configuration (only for legacy devices without |
| 4754 | // full multi-display support). |
| 4755 | // Note that the dock orientation overrides the HDMI orientation. |
| 4756 | preferredRotation = mUndockedHdmiRotation; |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4757 | } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { |
| 4758 | // Application just wants to remain locked in the last rotation. |
| 4759 | preferredRotation = lastRotation; |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 4760 | } else if (!mSupportAutoRotation) { |
| 4761 | // If we don't support auto-rotation then bail out here and ignore |
| 4762 | // the sensor and any rotation lock settings. |
| 4763 | preferredRotation = -1; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4764 | } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4765 | && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4766 | || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED |
| 4767 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE |
| 4768 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT |
| 4769 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER)) |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4770 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 4771 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4772 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 4773 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { |
| 4774 | // Otherwise, use sensor only if requested by the application or enabled |
| 4775 | // by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR. |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4776 | if (mAllowAllRotations < 0) { |
| 4777 | // Can't read this during init() because the context doesn't |
| 4778 | // have display metrics at that time so we cannot determine |
| 4779 | // tablet vs. phone then. |
| 4780 | mAllowAllRotations = mContext.getResources().getBoolean( |
| 4781 | com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; |
| 4782 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4783 | if (sensorRotation != Surface.ROTATION_180 |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4784 | || mAllowAllRotations == 1 |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4785 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4786 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4787 | preferredRotation = sensorRotation; |
| 4788 | } else { |
| 4789 | preferredRotation = lastRotation; |
| 4790 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4791 | } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED |
| 4792 | && orientation != ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { |
| 4793 | // Apply rotation lock. Does not apply to NOSENSOR. |
| 4794 | // The idea is that the user rotation expresses a weak preference for the direction |
| 4795 | // of gravity and as NOSENSOR is never affected by gravity, then neither should |
| 4796 | // 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] | 4797 | preferredRotation = mUserRotation; |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4798 | } else { |
| 4799 | // No overriding preference. |
| 4800 | // We will do exactly what the application asked us to do. |
| 4801 | preferredRotation = -1; |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4802 | } |
| 4803 | |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4804 | switch (orientation) { |
| 4805 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4806 | // Return portrait unless overridden. |
| 4807 | if (isAnyPortrait(preferredRotation)) { |
| 4808 | return preferredRotation; |
| 4809 | } |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4810 | return mPortraitRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4811 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4812 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4813 | // Return landscape unless overridden. |
| 4814 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4815 | return preferredRotation; |
| 4816 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4817 | return mLandscapeRotation; |
| 4818 | |
| 4819 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4820 | // Return reverse portrait unless overridden. |
| 4821 | if (isAnyPortrait(preferredRotation)) { |
| 4822 | return preferredRotation; |
| 4823 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4824 | return mUpsideDownRotation; |
| 4825 | |
| 4826 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4827 | // Return seascape unless overridden. |
| 4828 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4829 | return preferredRotation; |
| 4830 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4831 | return mSeascapeRotation; |
| 4832 | |
| 4833 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4834 | case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4835 | // Return either landscape rotation. |
| 4836 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4837 | return preferredRotation; |
| 4838 | } |
| 4839 | if (isLandscapeOrSeascape(lastRotation)) { |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 4840 | return lastRotation; |
| 4841 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4842 | return mLandscapeRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4843 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4844 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4845 | case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4846 | // Return either portrait rotation. |
| 4847 | if (isAnyPortrait(preferredRotation)) { |
| 4848 | return preferredRotation; |
| 4849 | } |
| 4850 | if (isAnyPortrait(lastRotation)) { |
| 4851 | return lastRotation; |
| 4852 | } |
| 4853 | return mPortraitRotation; |
| 4854 | |
| 4855 | default: |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 4856 | // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, |
| 4857 | // just return the preferred orientation we already calculated. |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4858 | if (preferredRotation >= 0) { |
| 4859 | return preferredRotation; |
| 4860 | } |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 4861 | return Surface.ROTATION_0; |
Daniel Sandler | e7e5ac2 | 2011-02-22 16:10:21 -0500 | [diff] [blame] | 4862 | } |
| 4863 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4864 | } |
| 4865 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4866 | @Override |
| 4867 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation) { |
| 4868 | switch (orientation) { |
| 4869 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
| 4870 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
| 4871 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
| 4872 | return isAnyPortrait(rotation); |
| 4873 | |
| 4874 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
| 4875 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
| 4876 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
| 4877 | return isLandscapeOrSeascape(rotation); |
| 4878 | |
| 4879 | default: |
| 4880 | return true; |
| 4881 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4882 | } |
| 4883 | |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4884 | @Override |
| 4885 | public void setRotationLw(int rotation) { |
| 4886 | mOrientationListener.setCurrentRotation(rotation); |
| 4887 | } |
| 4888 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4889 | private boolean isLandscapeOrSeascape(int rotation) { |
| 4890 | return rotation == mLandscapeRotation || rotation == mSeascapeRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4891 | } |
| 4892 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4893 | private boolean isAnyPortrait(int rotation) { |
| 4894 | return rotation == mPortraitRotation || rotation == mUpsideDownRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4895 | } |
| 4896 | |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4897 | public int getUserRotationMode() { |
| 4898 | return Settings.System.getIntForUser(mContext.getContentResolver(), |
Brett Chabot | 7e55c40 | 2013-05-16 19:38:08 -0700 | [diff] [blame] | 4899 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
| 4900 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 4901 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4902 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4903 | |
| 4904 | // User rotation: to be used when all else fails in assigning an orientation to the device |
| 4905 | public void setUserRotationMode(int mode, int rot) { |
| 4906 | ContentResolver res = mContext.getContentResolver(); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4907 | |
| 4908 | // mUserRotationMode and mUserRotation will be assigned by the content observer |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4909 | if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4910 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4911 | Settings.System.USER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4912 | rot, |
| 4913 | UserHandle.USER_CURRENT); |
| 4914 | Settings.System.putIntForUser(res, |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4915 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4916 | 0, |
| 4917 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4918 | } else { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4919 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4920 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4921 | 1, |
| 4922 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4923 | } |
| 4924 | } |
| 4925 | |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 4926 | public void setSafeMode(boolean safeMode) { |
| 4927 | mSafeMode = safeMode; |
| 4928 | performHapticFeedbackLw(null, safeMode |
| 4929 | ? HapticFeedbackConstants.SAFE_MODE_ENABLED |
| 4930 | : HapticFeedbackConstants.SAFE_MODE_DISABLED, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4931 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4932 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 4933 | static long[] getLongIntArray(Resources r, int resid) { |
| 4934 | int[] ar = r.getIntArray(resid); |
| 4935 | if (ar == null) { |
| 4936 | return null; |
| 4937 | } |
| 4938 | long[] out = new long[ar.length]; |
| 4939 | for (int i=0; i<ar.length; i++) { |
| 4940 | out[i] = ar[i]; |
| 4941 | } |
| 4942 | return out; |
| 4943 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4944 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4945 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4946 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4947 | public void systemReady() { |
Mike Lockwood | ed8902d | 2013-11-15 11:01:47 -0800 | [diff] [blame] | 4948 | mKeyguardDelegate = new KeyguardServiceDelegate(mContext, null); |
| 4949 | mKeyguardDelegate.onSystemReady(); |
| 4950 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 4951 | synchronized (mLock) { |
| 4952 | updateOrientationListenerLp(); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 4953 | mSystemReady = true; |
| 4954 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4955 | @Override |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 4956 | public void run() { |
| 4957 | updateSettings(); |
| 4958 | } |
| 4959 | }); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4960 | } |
| 4961 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4962 | |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 4963 | /** {@inheritDoc} */ |
| 4964 | public void systemBooted() { |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 4965 | if (mKeyguardDelegate != null) { |
| 4966 | mKeyguardDelegate.onBootCompleted(); |
| 4967 | } |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 4968 | synchronized (mLock) { |
| 4969 | mSystemBooted = true; |
| 4970 | } |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4971 | wakingUp(null); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 4972 | } |
| 4973 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 4974 | ProgressDialog mBootMsgDialog = null; |
| 4975 | |
| 4976 | /** {@inheritDoc} */ |
| 4977 | public void showBootMessage(final CharSequence msg, final boolean always) { |
| 4978 | mHandler.post(new Runnable() { |
| 4979 | @Override public void run() { |
| 4980 | if (mBootMsgDialog == null) { |
Craig Stout | 4c0cb8a | 2014-04-04 13:03:10 -0700 | [diff] [blame] | 4981 | int theme; |
| 4982 | if (mContext.getPackageManager().hasSystemFeature( |
| 4983 | PackageManager.FEATURE_WATCH)) { |
| 4984 | theme = com.android.internal.R.style.Theme_Micro_Dialog_Alert; |
| 4985 | } else if (mContext.getPackageManager().hasSystemFeature( |
| 4986 | PackageManager.FEATURE_TELEVISION)) { |
| 4987 | theme = com.android.internal.R.style.Theme_Leanback_Dialog_Alert; |
| 4988 | } else { |
| 4989 | theme = 0; |
| 4990 | } |
Vinod Krishnan | fa8fc41 | 2014-04-18 14:35:53 -0700 | [diff] [blame] | 4991 | |
| 4992 | mBootMsgDialog = new ProgressDialog(mContext, theme) { |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 4993 | // This dialog will consume all events coming in to |
| 4994 | // it, to avoid it trying to do things too early in boot. |
| 4995 | @Override public boolean dispatchKeyEvent(KeyEvent event) { |
| 4996 | return true; |
| 4997 | } |
| 4998 | @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 4999 | return true; |
| 5000 | } |
| 5001 | @Override public boolean dispatchTouchEvent(MotionEvent ev) { |
| 5002 | return true; |
| 5003 | } |
| 5004 | @Override public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 5005 | return true; |
| 5006 | } |
| 5007 | @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 5008 | return true; |
| 5009 | } |
| 5010 | @Override public boolean dispatchPopulateAccessibilityEvent( |
| 5011 | AccessibilityEvent event) { |
| 5012 | return true; |
| 5013 | } |
| 5014 | }; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5015 | mBootMsgDialog.setTitle(R.string.android_upgrading_title); |
| 5016 | mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); |
| 5017 | mBootMsgDialog.setIndeterminate(true); |
| 5018 | mBootMsgDialog.getWindow().setType( |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 5019 | WindowManager.LayoutParams.TYPE_BOOT_PROGRESS); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5020 | mBootMsgDialog.getWindow().addFlags( |
| 5021 | WindowManager.LayoutParams.FLAG_DIM_BEHIND |
| 5022 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); |
| 5023 | mBootMsgDialog.getWindow().setDimAmount(1); |
Dianne Hackborn | d9efb95 | 2011-12-07 14:56:51 -0800 | [diff] [blame] | 5024 | WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes(); |
| 5025 | lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 5026 | mBootMsgDialog.getWindow().setAttributes(lp); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5027 | mBootMsgDialog.setCancelable(false); |
| 5028 | mBootMsgDialog.show(); |
| 5029 | } |
| 5030 | mBootMsgDialog.setMessage(msg); |
| 5031 | } |
| 5032 | }); |
| 5033 | } |
| 5034 | |
| 5035 | /** {@inheritDoc} */ |
| 5036 | public void hideBootMessages() { |
| 5037 | mHandler.post(new Runnable() { |
| 5038 | @Override public void run() { |
| 5039 | if (mBootMsgDialog != null) { |
| 5040 | mBootMsgDialog.dismiss(); |
| 5041 | mBootMsgDialog = null; |
| 5042 | } |
| 5043 | } |
| 5044 | }); |
| 5045 | } |
| 5046 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5047 | /** {@inheritDoc} */ |
| 5048 | public void userActivity() { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5049 | // *************************************** |
| 5050 | // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE |
| 5051 | // *************************************** |
| 5052 | // THIS IS CALLED FROM DEEP IN THE POWER MANAGER |
| 5053 | // WITH ITS LOCKS HELD. |
| 5054 | // |
| 5055 | // This code must be VERY careful about the locks |
| 5056 | // it acquires. |
| 5057 | // In fact, the current code acquires way too many, |
| 5058 | // and probably has lurking deadlocks. |
| 5059 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5060 | synchronized (mScreenLockTimeout) { |
| 5061 | if (mLockScreenTimerActive) { |
| 5062 | // reset the timer |
| 5063 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 5064 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 5065 | } |
| 5066 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 5067 | } |
| 5068 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5069 | class ScreenLockTimeout implements Runnable { |
| 5070 | Bundle options; |
| 5071 | |
| 5072 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5073 | public void run() { |
| 5074 | synchronized (this) { |
| 5075 | if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5076 | if (mKeyguardDelegate != null) { |
| 5077 | mKeyguardDelegate.doKeyguardTimeout(options); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 5078 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5079 | mLockScreenTimerActive = false; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5080 | options = null; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5081 | } |
| 5082 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5083 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5084 | public void setLockOptions(Bundle options) { |
| 5085 | this.options = options; |
| 5086 | } |
| 5087 | } |
| 5088 | |
| 5089 | ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout(); |
| 5090 | |
| 5091 | public void lockNow(Bundle options) { |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 5092 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); |
| 5093 | mHandler.removeCallbacks(mScreenLockTimeout); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5094 | if (options != null) { |
| 5095 | // In case multiple calls are made to lockNow, we don't wipe out the options |
| 5096 | // until the runnable actually executes. |
| 5097 | mScreenLockTimeout.setLockOptions(options); |
| 5098 | } |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 5099 | mHandler.post(mScreenLockTimeout); |
| 5100 | } |
| 5101 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5102 | private void updateLockScreenTimeout() { |
| 5103 | synchronized (mScreenLockTimeout) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 5104 | boolean enable = (mAllowLockscreenWhenOn && mScreenOnEarly && |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5105 | mKeyguardDelegate != null && mKeyguardDelegate.isSecure()); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5106 | if (mLockScreenTimerActive != enable) { |
| 5107 | if (enable) { |
| 5108 | if (localLOGV) Log.v(TAG, "setting lockscreen timer"); |
| 5109 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 5110 | } else { |
| 5111 | if (localLOGV) Log.v(TAG, "clearing lockscreen timer"); |
| 5112 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 5113 | } |
| 5114 | mLockScreenTimerActive = enable; |
| 5115 | } |
| 5116 | } |
| 5117 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5118 | |
| 5119 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5120 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5121 | public void enableScreenAfterBoot() { |
| 5122 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5123 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5124 | updateRotation(true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5125 | } |
Dianne Hackborn | f54c8f9 | 2009-09-19 14:03:57 -0700 | [diff] [blame] | 5126 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5127 | private void applyLidSwitchState() { |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5128 | if (mLidState == LID_CLOSED && mLidControlsSleep) { |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 5129 | mPowerManager.goToSleep(SystemClock.uptimeMillis(), |
| 5130 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 5131 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5132 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5133 | |
| 5134 | synchronized (mLock) { |
| 5135 | updateWakeGestureListenerLp(); |
| 5136 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5137 | } |
| 5138 | |
| 5139 | void updateRotation(boolean alwaysSendConfiguration) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5140 | try { |
| 5141 | //set orientation on WindowManager |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 5142 | mWindowManager.updateRotation(alwaysSendConfiguration, false); |
| 5143 | } catch (RemoteException e) { |
| 5144 | // Ignore |
| 5145 | } |
| 5146 | } |
| 5147 | |
| 5148 | void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout) { |
| 5149 | try { |
| 5150 | //set orientation on WindowManager |
| 5151 | mWindowManager.updateRotation(alwaysSendConfiguration, forceRelayout); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5152 | } catch (RemoteException e) { |
| 5153 | // Ignore |
| 5154 | } |
| 5155 | } |
| 5156 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5157 | /** |
| 5158 | * Return an Intent to launch the currently active dock app as home. Returns |
| 5159 | * null if the standard home should be launched, which is the case if any of the following is |
| 5160 | * true: |
| 5161 | * <ul> |
| 5162 | * <li>The device is not in either car mode or desk mode |
| 5163 | * <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false |
| 5164 | * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false |
| 5165 | * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME |
| 5166 | * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME |
| 5167 | * </ul> |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5168 | * @return A dock intent. |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5169 | */ |
| 5170 | Intent createHomeDockIntent() { |
| 5171 | Intent intent = null; |
| 5172 | |
| 5173 | // What home does is based on the mode, not the dock state. That |
| 5174 | // is, when in car mode you should be taken to car home regardless |
| 5175 | // of whether we are actually in a car dock. |
| 5176 | if (mUiMode == Configuration.UI_MODE_TYPE_CAR) { |
| 5177 | if (ENABLE_CAR_DOCK_HOME_CAPTURE) { |
| 5178 | intent = mCarDockIntent; |
| 5179 | } |
| 5180 | } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { |
| 5181 | if (ENABLE_DESK_DOCK_HOME_CAPTURE) { |
| 5182 | intent = mDeskDockIntent; |
| 5183 | } |
| 5184 | } |
| 5185 | |
| 5186 | if (intent == null) { |
| 5187 | return null; |
| 5188 | } |
| 5189 | |
| 5190 | ActivityInfo ai = null; |
| 5191 | ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser( |
| 5192 | intent, |
John Spurlock | f56bef1 | 2013-07-09 09:51:46 -0400 | [diff] [blame] | 5193 | PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 5194 | mCurrentUserId); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5195 | if (info != null) { |
| 5196 | ai = info.activityInfo; |
| 5197 | } |
| 5198 | if (ai != null |
| 5199 | && ai.metaData != null |
| 5200 | && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { |
| 5201 | intent = new Intent(intent); |
| 5202 | intent.setClassName(ai.packageName, ai.name); |
| 5203 | return intent; |
| 5204 | } |
| 5205 | |
| 5206 | return null; |
| 5207 | } |
| 5208 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5209 | void startDockOrHome() { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 5210 | awakenDreams(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5211 | |
| 5212 | Intent dock = createHomeDockIntent(); |
| 5213 | if (dock != null) { |
| 5214 | try { |
| 5215 | mContext.startActivityAsUser(dock, UserHandle.CURRENT); |
| 5216 | return; |
| 5217 | } catch (ActivityNotFoundException e) { |
| 5218 | } |
| 5219 | } |
| 5220 | |
Dianne Hackborn | d888399 | 2012-09-07 15:58:52 -0700 | [diff] [blame] | 5221 | mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5222 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5223 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5224 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5225 | * goes to the home screen |
| 5226 | * @return whether it did anything |
| 5227 | */ |
| 5228 | boolean goHome() { |
| 5229 | if (false) { |
| 5230 | // This code always brings home to the front. |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 5231 | try { |
| 5232 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 5233 | } catch (RemoteException e) { |
| 5234 | } |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 5235 | sendCloseSystemWindows(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5236 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5237 | } else { |
| 5238 | // This code brings home to the front or, if it is already |
| 5239 | // at the front, puts the device to sleep. |
| 5240 | try { |
Wink Saville | d2e6a33 | 2010-02-12 12:12:06 -0800 | [diff] [blame] | 5241 | if (SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1) { |
| 5242 | /// Roll back EndcallBehavior as the cupcake design to pass P1 lab entry. |
| 5243 | Log.d(TAG, "UTS-TEST-MODE"); |
| 5244 | } else { |
| 5245 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 5246 | sendCloseSystemWindows(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5247 | Intent dock = createHomeDockIntent(); |
| 5248 | if (dock != null) { |
| 5249 | int result = ActivityManagerNative.getDefault() |
| 5250 | .startActivityAsUser(null, null, dock, |
| 5251 | dock.resolveTypeIfNeeded(mContext.getContentResolver()), |
| 5252 | null, null, 0, |
| 5253 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
| 5254 | null, null, null, UserHandle.USER_CURRENT); |
| 5255 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
| 5256 | return false; |
| 5257 | } |
| 5258 | } |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5259 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5260 | int result = ActivityManagerNative.getDefault() |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5261 | .startActivityAsUser(null, null, mHomeIntent, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5262 | mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 5263 | null, null, 0, |
| 5264 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
Dianne Hackborn | 5e03e2c | 2012-09-06 14:21:19 -0700 | [diff] [blame] | 5265 | null, null, null, UserHandle.USER_CURRENT); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 5266 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5267 | return false; |
| 5268 | } |
| 5269 | } catch (RemoteException ex) { |
| 5270 | // bummer, the activity manager, which is in this process, is dead |
| 5271 | } |
| 5272 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5273 | return true; |
| 5274 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5275 | |
| 5276 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5277 | public void setCurrentOrientationLw(int newOrientation) { |
| 5278 | synchronized (mLock) { |
| 5279 | if (newOrientation != mCurrentAppOrientation) { |
| 5280 | mCurrentAppOrientation = newOrientation; |
| 5281 | updateOrientationListenerLp(); |
| 5282 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5283 | } |
| 5284 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5285 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5286 | private void performAuditoryFeedbackForAccessibilityIfNeed() { |
| 5287 | if (!isGlobalAccessibilityGestureEnabled()) { |
| 5288 | return; |
| 5289 | } |
| 5290 | AudioManager audioManager = (AudioManager) mContext.getSystemService( |
| 5291 | Context.AUDIO_SERVICE); |
| 5292 | if (audioManager.isSilentMode()) { |
| 5293 | return; |
| 5294 | } |
| 5295 | Ringtone ringTone = RingtoneManager.getRingtone(mContext, |
| 5296 | Settings.System.DEFAULT_NOTIFICATION_URI); |
| 5297 | ringTone.setStreamType(AudioManager.STREAM_MUSIC); |
| 5298 | ringTone.play(); |
| 5299 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5300 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5301 | private boolean isGlobalAccessibilityGestureEnabled() { |
| 5302 | return Settings.Global.getInt(mContext.getContentResolver(), |
| 5303 | Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1; |
| 5304 | } |
| 5305 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5306 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5307 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { |
Svetoslav Ganov | 9617921 | 2012-10-10 14:17:45 -0700 | [diff] [blame] | 5308 | if (!mVibrator.hasVibrator()) { |
| 5309 | return false; |
| 5310 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5311 | final boolean hapticsDisabled = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 5312 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) == 0; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5313 | if (!always && (hapticsDisabled || mKeyguardDelegate.isShowingAndNotOccluded())) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5314 | return false; |
| 5315 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5316 | long[] pattern = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5317 | switch (effectId) { |
| 5318 | case HapticFeedbackConstants.LONG_PRESS: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5319 | pattern = mLongPressVibePattern; |
| 5320 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5321 | case HapticFeedbackConstants.VIRTUAL_KEY: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5322 | pattern = mVirtualKeyVibePattern; |
| 5323 | break; |
| 5324 | case HapticFeedbackConstants.KEYBOARD_TAP: |
| 5325 | pattern = mKeyboardTapVibePattern; |
| 5326 | break; |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 5327 | case HapticFeedbackConstants.CLOCK_TICK: |
| 5328 | pattern = mClockTickVibePattern; |
| 5329 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5330 | case HapticFeedbackConstants.SAFE_MODE_DISABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5331 | pattern = mSafeModeDisabledVibePattern; |
| 5332 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5333 | case HapticFeedbackConstants.SAFE_MODE_ENABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5334 | pattern = mSafeModeEnabledVibePattern; |
| 5335 | break; |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5336 | default: |
| 5337 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5338 | } |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5339 | int owningUid; |
| 5340 | String owningPackage; |
| 5341 | if (win != null) { |
| 5342 | owningUid = win.getOwningUid(); |
| 5343 | owningPackage = win.getOwningPackage(); |
| 5344 | } else { |
| 5345 | owningUid = android.os.Process.myUid(); |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 5346 | owningPackage = mContext.getOpPackageName(); |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5347 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5348 | if (pattern.length == 1) { |
| 5349 | // One-shot vibration |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 5350 | mVibrator.vibrate(owningUid, owningPackage, pattern[0], AudioManager.STREAM_SYSTEM); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5351 | } else { |
| 5352 | // Pattern vibration |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 5353 | mVibrator.vibrate(owningUid, owningPackage, pattern, -1, AudioManager.STREAM_SYSTEM); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5354 | } |
| 5355 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5356 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5357 | |
| 5358 | @Override |
| 5359 | public void keepScreenOnStartedLw() { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 5360 | } |
| 5361 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5362 | @Override |
| 5363 | public void keepScreenOnStoppedLw() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5364 | if (mKeyguardDelegate != null && !mKeyguardDelegate.isShowingAndNotOccluded()) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 5365 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5366 | } |
| 5367 | } |
Mike Lockwood | fcb3924 | 2009-10-21 23:01:07 -0400 | [diff] [blame] | 5368 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5369 | private int updateSystemUiVisibilityLw() { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5370 | // If there is no window focused, there will be nobody to handle the events |
| 5371 | // 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] | 5372 | WindowState win = mFocusedWindow != null ? mFocusedWindow : mTopFullscreenOpaqueWindowState; |
| 5373 | if (win == null) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5374 | return 0; |
| 5375 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5376 | if ((win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 && mHideLockScreen == true) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5377 | // We are updating at a point where the keyguard has gotten |
| 5378 | // focus, but we were last in a state where the top window is |
| 5379 | // hiding it. This is probably because the keyguard as been |
| 5380 | // shown while the top window was displayed, so we want to ignore |
| 5381 | // it here because this is just a very transient change and it |
| 5382 | // will quickly lose focus once it correctly gets hidden. |
| 5383 | return 0; |
| 5384 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 5385 | |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 5386 | int tmpVisibility = PolicyControl.getSystemUiVisibility(win, null) |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5387 | & ~mResettingSystemUiFlags |
| 5388 | & ~mForceClearedSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5389 | if (mForcingShowNavBar && win.getSurfaceLayer() < mForcingShowNavBarLayer) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5390 | tmpVisibility &= ~PolicyControl.adjustClearableFlags(win, View.SYSTEM_UI_CLEARABLE_FLAGS); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5391 | } |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5392 | final int visibility = updateSystemBarsLw(win, mLastSystemUiFlags, tmpVisibility); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5393 | final int diff = visibility ^ mLastSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5394 | final boolean needsMenu = win.getNeedsMenuLw(mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 5395 | if (diff == 0 && mLastFocusNeedsMenu == needsMenu |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5396 | && mFocusedApp == win.getAppToken()) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5397 | return 0; |
| 5398 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5399 | mLastSystemUiFlags = visibility; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5400 | mLastFocusNeedsMenu = needsMenu; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5401 | mFocusedApp = win.getAppToken(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5402 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5403 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5404 | public void run() { |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5405 | try { |
| 5406 | IStatusBarService statusbar = getStatusBarService(); |
| 5407 | if (statusbar != null) { |
| 5408 | statusbar.setSystemUiVisibility(visibility, 0xffffffff); |
| 5409 | statusbar.topAppWindowChanged(needsMenu); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5410 | } |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5411 | } catch (RemoteException e) { |
| 5412 | // re-acquire status bar service next time it is needed. |
| 5413 | mStatusBarService = null; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5414 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5415 | } |
| 5416 | }); |
| 5417 | return diff; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5418 | } |
| 5419 | |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5420 | private int updateSystemBarsLw(WindowState win, int oldVis, int vis) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5421 | // apply translucent bar vis flags |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5422 | WindowState transWin = isStatusBarKeyguard() && !mHideLockScreen |
| 5423 | ? mStatusBar |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5424 | : mTopFullscreenOpaqueWindowState; |
| 5425 | vis = mStatusBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 5426 | vis = mNavigationBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 5427 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5428 | // prevent status bar interaction from clearing certain flags |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5429 | boolean statusBarHasFocus = win.getAttrs().type == TYPE_STATUS_BAR; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5430 | if (statusBarHasFocus) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5431 | int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
| 5432 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 5433 | | View.SYSTEM_UI_FLAG_IMMERSIVE |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5434 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
| 5435 | if (!isStatusBarKeyguard() || mHideLockScreen) { |
| 5436 | flags |= View.STATUS_BAR_TRANSLUCENT | View.NAVIGATION_BAR_TRANSLUCENT; |
| 5437 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5438 | vis = (vis & ~flags) | (oldVis & flags); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5439 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5440 | |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5441 | if (!areTranslucentBarsAllowed()) { |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 5442 | vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT |
| 5443 | | View.SYSTEM_UI_TRANSPARENT); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5444 | } |
| 5445 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5446 | // update status bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5447 | boolean immersiveSticky = |
| 5448 | (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5449 | boolean hideStatusBarWM = |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5450 | mTopFullscreenOpaqueWindowState != null && |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5451 | (PolicyControl.getWindowFlags(mTopFullscreenOpaqueWindowState, null) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5452 | & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; |
| 5453 | boolean hideStatusBarSysui = |
| 5454 | (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5455 | boolean hideNavBarSysui = |
| 5456 | (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5457 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5458 | boolean transientStatusBarAllowed = |
| 5459 | mStatusBar != null && ( |
| 5460 | hideStatusBarWM |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5461 | || (hideStatusBarSysui && immersiveSticky) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5462 | || statusBarHasFocus); |
| 5463 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5464 | boolean transientNavBarAllowed = |
| 5465 | mNavigationBar != null && |
| 5466 | hideNavBarSysui && immersiveSticky; |
| 5467 | |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 5468 | boolean denyTransientStatus = mStatusBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5469 | && !transientStatusBarAllowed && hideStatusBarSysui; |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 5470 | boolean denyTransientNav = mNavigationBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5471 | && !transientNavBarAllowed; |
| 5472 | if (denyTransientStatus || denyTransientNav) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5473 | // clear the clearable flags instead |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5474 | clearClearableFlagsLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5475 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5476 | |
| 5477 | vis = mStatusBarController.updateVisibilityLw(transientStatusBarAllowed, oldVis, vis); |
| 5478 | |
| 5479 | // update navigation bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5480 | boolean oldImmersiveMode = isImmersiveMode(oldVis); |
| 5481 | boolean newImmersiveMode = isImmersiveMode(vis); |
| 5482 | if (win != null && oldImmersiveMode != newImmersiveMode) { |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5483 | final String pkg = win.getOwningPackage(); |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 5484 | mImmersiveModeConfirmation.immersiveModeChanged(pkg, newImmersiveMode, |
| 5485 | isUserSetupComplete()); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5486 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5487 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5488 | vis = mNavigationBarController.updateVisibilityLw(transientNavBarAllowed, oldVis, vis); |
| 5489 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 5490 | return vis; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5491 | } |
| 5492 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5493 | private void clearClearableFlagsLw() { |
| 5494 | int newVal = mResettingSystemUiFlags | View.SYSTEM_UI_CLEARABLE_FLAGS; |
| 5495 | if (newVal != mResettingSystemUiFlags) { |
| 5496 | mResettingSystemUiFlags = newVal; |
| 5497 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 5498 | } |
| 5499 | } |
| 5500 | |
| 5501 | private boolean isImmersiveMode(int vis) { |
| 5502 | 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] | 5503 | return mNavigationBar != null |
| 5504 | && (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0 |
Daniel Sandler | 900ece5 | 2013-10-18 15:53:27 -0400 | [diff] [blame] | 5505 | && (vis & flags) != 0 |
| 5506 | && canHideNavigationBar(); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5507 | } |
| 5508 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5509 | /** |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5510 | * @return whether the navigation or status bar can be made translucent |
| 5511 | * |
| 5512 | * This should return true unless touch exploration is not enabled or |
| 5513 | * R.boolean.config_enableTranslucentDecor is false. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5514 | */ |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5515 | private boolean areTranslucentBarsAllowed() { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 5516 | return mTranslucentDecorEnabled |
| 5517 | && !mAccessibilityManager.isTouchExplorationEnabled(); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5518 | } |
| 5519 | |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5520 | // Use this instead of checking config_showNavigationBar so that it can be consistently |
| 5521 | // overridden by qemu.hw.mainkeys in the emulator. |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5522 | @Override |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5523 | public boolean hasNavigationBar() { |
| 5524 | return mHasNavigationBar; |
| 5525 | } |
| 5526 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 5527 | @Override |
| 5528 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target) { |
| 5529 | mLastInputMethodWindow = ime; |
| 5530 | mLastInputMethodTargetWindow = target; |
| 5531 | } |
| 5532 | |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5533 | @Override |
Satoshi Kataoka | 658c7b8 | 2013-10-10 17:03:51 +0900 | [diff] [blame] | 5534 | public int getInputMethodWindowVisibleHeightLw() { |
| 5535 | return mDockBottom - mCurBottom; |
| 5536 | } |
| 5537 | |
| 5538 | @Override |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5539 | public void setCurrentUserLw(int newUserId) { |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 5540 | mCurrentUserId = newUserId; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5541 | if (mKeyguardDelegate != null) { |
| 5542 | mKeyguardDelegate.setCurrentUser(newUserId); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5543 | } |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 5544 | if (mStatusBarService != null) { |
| 5545 | try { |
| 5546 | mStatusBarService.setCurrentUser(newUserId); |
| 5547 | } catch (RemoteException e) { |
| 5548 | // oh well |
| 5549 | } |
| 5550 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5551 | setLastInputMethodWindowLw(null, null); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5552 | } |
| 5553 | |
| 5554 | @Override |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 5555 | public boolean canMagnifyWindow(int windowType) { |
| 5556 | switch (windowType) { |
| 5557 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD: |
| 5558 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG: |
| 5559 | case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR: |
| 5560 | case WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY: { |
| 5561 | return false; |
| 5562 | } |
| 5563 | } |
| 5564 | return true; |
| 5565 | } |
| 5566 | |
| 5567 | @Override |
| 5568 | public boolean isTopLevelWindow(int windowType) { |
| 5569 | if (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW |
| 5570 | && windowType <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 5571 | return (windowType == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG); |
| 5572 | } |
| 5573 | return true; |
| 5574 | } |
| 5575 | |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 5576 | @Override |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 5577 | public void dump(String prefix, PrintWriter pw, String[] args) { |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5578 | pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5579 | pw.print(" mSystemReady="); pw.print(mSystemReady); |
| 5580 | pw.print(" mSystemBooted="); pw.println(mSystemBooted); |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 5581 | pw.print(prefix); pw.print("mLidState="); pw.print(mLidState); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5582 | pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); |
| 5583 | pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5584 | if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 |
| 5585 | || mForceClearedSystemUiFlags != 0) { |
| 5586 | pw.print(prefix); pw.print("mLastSystemUiFlags=0x"); |
| 5587 | pw.print(Integer.toHexString(mLastSystemUiFlags)); |
| 5588 | pw.print(" mResettingSystemUiFlags=0x"); |
| 5589 | pw.print(Integer.toHexString(mResettingSystemUiFlags)); |
| 5590 | pw.print(" mForceClearedSystemUiFlags=0x"); |
| 5591 | pw.println(Integer.toHexString(mForceClearedSystemUiFlags)); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5592 | } |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5593 | if (mLastFocusNeedsMenu) { |
| 5594 | pw.print(prefix); pw.print("mLastFocusNeedsMenu="); |
| 5595 | pw.println(mLastFocusNeedsMenu); |
| 5596 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5597 | pw.print(prefix); pw.print("mWakeGestureEnabledSetting="); |
| 5598 | pw.println(mWakeGestureEnabledSetting); |
| 5599 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 5600 | pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5601 | pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); |
| 5602 | pw.print(" mDockMode="); pw.print(mDockMode); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5603 | pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); |
| 5604 | pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); |
| 5605 | pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); |
| 5606 | pw.print(" mUserRotation="); pw.print(mUserRotation); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 5607 | pw.print(" mAllowAllRotations="); pw.println(mAllowAllRotations); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5608 | pw.print(prefix); pw.print("mCurrentAppOrientation="); pw.println(mCurrentAppOrientation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5609 | pw.print(prefix); pw.print("mCarDockEnablesAccelerometer="); |
| 5610 | pw.print(mCarDockEnablesAccelerometer); |
| 5611 | pw.print(" mDeskDockEnablesAccelerometer="); |
| 5612 | pw.println(mDeskDockEnablesAccelerometer); |
| 5613 | pw.print(prefix); pw.print("mLidKeyboardAccessibility="); |
| 5614 | pw.print(mLidKeyboardAccessibility); |
| 5615 | pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5616 | pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep); |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 5617 | pw.print(prefix); |
| 5618 | pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior); |
| 5619 | pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior); |
| 5620 | pw.print(prefix); pw.print("mHasSoftInput="); pw.println(mHasSoftInput); |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 5621 | pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly); |
| 5622 | pw.print(" mScreenOnFully="); pw.print(mScreenOnFully); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5623 | pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 5624 | pw.print(prefix); pw.print("mOverscanScreen=("); pw.print(mOverscanScreenLeft); |
| 5625 | pw.print(","); pw.print(mOverscanScreenTop); |
| 5626 | pw.print(") "); pw.print(mOverscanScreenWidth); |
| 5627 | pw.print("x"); pw.println(mOverscanScreenHeight); |
| 5628 | if (mOverscanLeft != 0 || mOverscanTop != 0 |
| 5629 | || mOverscanRight != 0 || mOverscanBottom != 0) { |
| 5630 | pw.print(prefix); pw.print("mOverscan left="); pw.print(mOverscanLeft); |
| 5631 | pw.print(" top="); pw.print(mOverscanTop); |
| 5632 | pw.print(" right="); pw.print(mOverscanRight); |
| 5633 | pw.print(" bottom="); pw.println(mOverscanBottom); |
| 5634 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 5635 | pw.print(prefix); pw.print("mRestrictedOverscanScreen=("); |
| 5636 | pw.print(mRestrictedOverscanScreenLeft); |
| 5637 | pw.print(","); pw.print(mRestrictedOverscanScreenTop); |
| 5638 | pw.print(") "); pw.print(mRestrictedOverscanScreenWidth); |
| 5639 | pw.print("x"); pw.println(mRestrictedOverscanScreenHeight); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5640 | pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft); |
| 5641 | pw.print(","); pw.print(mUnrestrictedScreenTop); |
| 5642 | pw.print(") "); pw.print(mUnrestrictedScreenWidth); |
| 5643 | pw.print("x"); pw.println(mUnrestrictedScreenHeight); |
| 5644 | pw.print(prefix); pw.print("mRestrictedScreen=("); pw.print(mRestrictedScreenLeft); |
| 5645 | pw.print(","); pw.print(mRestrictedScreenTop); |
| 5646 | pw.print(") "); pw.print(mRestrictedScreenWidth); |
| 5647 | pw.print("x"); pw.println(mRestrictedScreenHeight); |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 5648 | pw.print(prefix); pw.print("mStableFullscreen=("); pw.print(mStableFullscreenLeft); |
| 5649 | pw.print(","); pw.print(mStableFullscreenTop); |
| 5650 | pw.print(")-("); pw.print(mStableFullscreenRight); |
| 5651 | pw.print(","); pw.print(mStableFullscreenBottom); pw.println(")"); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 5652 | pw.print(prefix); pw.print("mStable=("); pw.print(mStableLeft); |
| 5653 | pw.print(","); pw.print(mStableTop); |
| 5654 | pw.print(")-("); pw.print(mStableRight); |
| 5655 | pw.print(","); pw.print(mStableBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5656 | pw.print(prefix); pw.print("mSystem=("); pw.print(mSystemLeft); |
| 5657 | pw.print(","); pw.print(mSystemTop); |
| 5658 | pw.print(")-("); pw.print(mSystemRight); |
| 5659 | pw.print(","); pw.print(mSystemBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5660 | pw.print(prefix); pw.print("mCur=("); pw.print(mCurLeft); |
| 5661 | pw.print(","); pw.print(mCurTop); |
| 5662 | pw.print(")-("); pw.print(mCurRight); |
| 5663 | pw.print(","); pw.print(mCurBottom); pw.println(")"); |
| 5664 | pw.print(prefix); pw.print("mContent=("); pw.print(mContentLeft); |
| 5665 | pw.print(","); pw.print(mContentTop); |
| 5666 | pw.print(")-("); pw.print(mContentRight); |
| 5667 | pw.print(","); pw.print(mContentBottom); pw.println(")"); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 5668 | pw.print(prefix); pw.print("mVoiceContent=("); pw.print(mVoiceContentLeft); |
| 5669 | pw.print(","); pw.print(mVoiceContentTop); |
| 5670 | pw.print(")-("); pw.print(mVoiceContentRight); |
| 5671 | pw.print(","); pw.print(mVoiceContentBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5672 | pw.print(prefix); pw.print("mDock=("); pw.print(mDockLeft); |
| 5673 | pw.print(","); pw.print(mDockTop); |
| 5674 | pw.print(")-("); pw.print(mDockRight); |
| 5675 | pw.print(","); pw.print(mDockBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5676 | pw.print(prefix); pw.print("mDockLayer="); pw.print(mDockLayer); |
| 5677 | pw.print(" mStatusBarLayer="); pw.println(mStatusBarLayer); |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5678 | pw.print(prefix); pw.print("mShowingLockscreen="); pw.print(mShowingLockscreen); |
| 5679 | pw.print(" mShowingDream="); pw.print(mShowingDream); |
| 5680 | pw.print(" mDreamingLockscreen="); pw.println(mDreamingLockscreen); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5681 | if (mLastInputMethodWindow != null) { |
| 5682 | pw.print(prefix); pw.print("mLastInputMethodWindow="); |
| 5683 | pw.println(mLastInputMethodWindow); |
| 5684 | } |
| 5685 | if (mLastInputMethodTargetWindow != null) { |
| 5686 | pw.print(prefix); pw.print("mLastInputMethodTargetWindow="); |
| 5687 | pw.println(mLastInputMethodTargetWindow); |
| 5688 | } |
| 5689 | if (mStatusBar != null) { |
| 5690 | pw.print(prefix); pw.print("mStatusBar="); |
| 5691 | pw.println(mStatusBar); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5692 | pw.print(prefix); pw.print("isStatusBarKeyguard="); |
| 5693 | pw.print(isStatusBarKeyguard()); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5694 | } |
| 5695 | if (mNavigationBar != null) { |
| 5696 | pw.print(prefix); pw.print("mNavigationBar="); |
| 5697 | pw.println(mNavigationBar); |
| 5698 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5699 | if (mFocusedWindow != null) { |
| 5700 | pw.print(prefix); pw.print("mFocusedWindow="); |
| 5701 | pw.println(mFocusedWindow); |
| 5702 | } |
| 5703 | if (mFocusedApp != null) { |
| 5704 | pw.print(prefix); pw.print("mFocusedApp="); |
| 5705 | pw.println(mFocusedApp); |
| 5706 | } |
| 5707 | if (mWinDismissingKeyguard != null) { |
| 5708 | pw.print(prefix); pw.print("mWinDismissingKeyguard="); |
| 5709 | pw.println(mWinDismissingKeyguard); |
| 5710 | } |
| 5711 | if (mTopFullscreenOpaqueWindowState != null) { |
| 5712 | pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); |
| 5713 | pw.println(mTopFullscreenOpaqueWindowState); |
| 5714 | } |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5715 | if (mForcingShowNavBar) { |
| 5716 | pw.print(prefix); pw.print("mForcingShowNavBar="); |
| 5717 | pw.println(mForcingShowNavBar); pw.print( "mForcingShowNavBarLayer="); |
| 5718 | pw.println(mForcingShowNavBarLayer); |
| 5719 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5720 | pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5721 | pw.print(" mHideLockScreen="); pw.println(mHideLockScreen); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5722 | pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); |
| 5723 | pw.print(" mForceStatusBarFromKeyguard="); |
| 5724 | pw.println(mForceStatusBarFromKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5725 | pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 5726 | pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5727 | pw.print(" mHomePressed="); pw.println(mHomePressed); |
| 5728 | pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); |
| 5729 | pw.print(" mLockScreenTimeout="); pw.print(mLockScreenTimeout); |
| 5730 | pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive); |
| 5731 | pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior); |
| 5732 | pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior); |
| 5733 | pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior); |
| 5734 | pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation); |
| 5735 | pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); |
| 5736 | pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); |
| 5737 | pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 5738 | pw.print(prefix); pw.print("mDemoHdmiRotation="); pw.print(mDemoHdmiRotation); |
| 5739 | pw.print(" mDemoHdmiRotationLock="); pw.println(mDemoHdmiRotationLock); |
| 5740 | pw.print(prefix); pw.print("mUndockedHdmiRotation="); pw.println(mUndockedHdmiRotation); |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 5741 | |
Tim Kilbourn | d7c0c2e | 2014-05-29 16:08:10 -0700 | [diff] [blame] | 5742 | mGlobalKeyManager.dump(prefix, pw); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5743 | mStatusBarController.dump(pw, prefix); |
| 5744 | mNavigationBarController.dump(pw, prefix); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5745 | PolicyControl.dump(prefix, pw); |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 5746 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5747 | if (mWakeGestureListener != null) { |
| 5748 | mWakeGestureListener.dump(pw, prefix); |
| 5749 | } |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 5750 | if (mOrientationListener != null) { |
| 5751 | mOrientationListener.dump(pw, prefix); |
| 5752 | } |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5753 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5754 | } |