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; |
| 45 | import android.media.IAudioService; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 46 | import android.media.Ringtone; |
| 47 | import android.media.RingtoneManager; |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 48 | import android.media.session.MediaController; |
| 49 | import android.media.session.MediaSession; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 50 | import android.media.session.MediaSessionLegacyHelper; |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 51 | import android.media.session.MediaSessionManager; |
| 52 | import android.media.session.PlaybackState; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 53 | import android.os.Bundle; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 54 | import android.os.FactoryTest; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 55 | import android.os.Handler; |
| 56 | import android.os.IBinder; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 57 | import android.os.Looper; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 58 | import android.os.Message; |
| 59 | import android.os.Messenger; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 60 | import android.os.PowerManager; |
| 61 | import android.os.RemoteException; |
| 62 | import android.os.ServiceManager; |
| 63 | import android.os.SystemClock; |
| 64 | import android.os.SystemProperties; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 65 | import android.os.UEventObserver; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 66 | import android.os.UserHandle; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 67 | import android.os.Vibrator; |
| 68 | import android.provider.Settings; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 69 | import android.service.dreams.DreamManagerInternal; |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 70 | import android.service.dreams.DreamService; |
| 71 | import android.service.dreams.IDreamManager; |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 72 | import android.telecomm.TelecommManager; |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 73 | import android.util.DisplayMetrics; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 74 | import android.util.EventLog; |
| 75 | import android.util.Log; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 76 | import android.util.Slog; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 77 | import android.util.SparseArray; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 78 | import android.view.Display; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 79 | import android.view.Gravity; |
| 80 | import android.view.HapticFeedbackConstants; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 81 | import android.view.IApplicationToken; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 82 | import android.view.IWindowManager; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 83 | import android.view.InputChannel; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 84 | import android.view.InputDevice; |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 85 | import android.view.InputEvent; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 86 | import android.view.InputEventReceiver; |
Jeff Brown | 6b53e8d | 2010-11-10 16:03:06 -0800 | [diff] [blame] | 87 | import android.view.KeyCharacterMap; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 88 | import android.view.KeyCharacterMap.FallbackAction; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 89 | import android.view.KeyEvent; |
| 90 | import android.view.MotionEvent; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 91 | import android.view.Surface; |
| 92 | import android.view.View; |
| 93 | import android.view.ViewConfiguration; |
| 94 | import android.view.Window; |
| 95 | import android.view.WindowManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 96 | import android.view.WindowManagerGlobal; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 97 | import android.view.WindowManagerInternal; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 98 | import android.view.WindowManagerPolicy; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 99 | import android.view.accessibility.AccessibilityEvent; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 100 | import android.view.accessibility.AccessibilityManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 101 | import android.view.animation.Animation; |
| 102 | import android.view.animation.AnimationUtils; |
| 103 | |
| 104 | import com.android.internal.R; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 105 | import com.android.internal.policy.IKeyguardService; |
| 106 | import com.android.internal.policy.IKeyguardServiceConstants; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 107 | import com.android.internal.policy.PolicyManager; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 108 | import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 109 | import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate.ShowListener; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 110 | import com.android.internal.statusbar.IStatusBarService; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 111 | import com.android.internal.widget.PointerLocationView; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 112 | import com.android.server.LocalServices; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 113 | |
| 114 | import java.io.File; |
| 115 | import java.io.FileReader; |
| 116 | import java.io.IOException; |
| 117 | import java.io.PrintWriter; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 118 | import java.util.ArrayList; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 119 | import java.util.HashSet; |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 120 | import java.util.List; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 121 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 122 | import static android.view.WindowManager.LayoutParams.*; |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 123 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; |
| 124 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; |
| 125 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 126 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 127 | /** |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 128 | * WindowManagerPolicy implementation for the Android phone UI. This |
| 129 | * introduces a new method suffix, Lp, for an internal lock of the |
| 130 | * PhoneWindowManager. This is used to protect some internal state, and |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 131 | * 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] | 132 | * of both of those when held. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 133 | */ |
| 134 | public class PhoneWindowManager implements WindowManagerPolicy { |
| 135 | static final String TAG = "WindowManager"; |
| 136 | static final boolean DEBUG = false; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 137 | static final boolean localLOGV = false; |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 138 | static final boolean DEBUG_LAYOUT = false; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 139 | static final boolean DEBUG_INPUT = false; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 140 | static final boolean DEBUG_STARTING_WINDOW = false; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 141 | static final boolean DEBUG_WAKEUP = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 142 | static final boolean SHOW_STARTING_ANIMATIONS = true; |
| 143 | static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 144 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 145 | // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. |
| 146 | // No longer recommended for desk docks; still useful in car docks. |
| 147 | static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; |
| 148 | static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; |
| 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; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 233 | DreamManagerInternal mDreamManagerInternal; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 234 | IStatusBarService mStatusBarService; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 235 | boolean mPreloadedRecentApps; |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 236 | final Object mServiceAquireLock = new Object(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 237 | Vibrator mVibrator; // Vibrator for giving feedback of orientation changes |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 238 | SearchManager mSearchManager; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 239 | AccessibilityManager mAccessibilityManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 240 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 241 | // Vibrator pattern for haptic feedback of a long press. |
| 242 | long[] mLongPressVibePattern; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 243 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 244 | // Vibrator pattern for haptic feedback of virtual key press. |
| 245 | long[] mVirtualKeyVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 246 | |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 247 | // Vibrator pattern for a short vibration. |
| 248 | long[] mKeyboardTapVibePattern; |
| 249 | |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 250 | // Vibrator pattern for a short vibration when tapping on an hour/minute tick of a Clock. |
| 251 | long[] mClockTickVibePattern; |
| 252 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 253 | // Vibrator pattern for haptic feedback during boot when safe mode is disabled. |
| 254 | long[] mSafeModeDisabledVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 255 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 256 | // Vibrator pattern for haptic feedback during boot when safe mode is enabled. |
| 257 | long[] mSafeModeEnabledVibePattern; |
Romain Guy | 8154cd3 | 2010-03-29 14:41:15 -0700 | [diff] [blame] | 258 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 259 | /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */ |
| 260 | boolean mEnableShiftMenuBugReports = false; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 261 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 262 | boolean mSafeMode; |
| 263 | WindowState mStatusBar = null; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 264 | int mStatusBarHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 265 | WindowState mNavigationBar = null; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 266 | boolean mHasNavigationBar = false; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 267 | boolean mCanHideNavigationBar = false; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 268 | boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side? |
| 269 | boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*? |
| 270 | int[] mNavigationBarHeightForRotation = new int[4]; |
| 271 | int[] mNavigationBarWidthForRotation = new int[4]; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 272 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 273 | KeyguardServiceDelegate mKeyguardDelegate; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 274 | // The following are only accessed on the mHandler thread. |
| 275 | boolean mKeyguardDrawComplete; |
| 276 | boolean mWindowManagerDrawComplete; |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 277 | ScreenOnListener mScreenOnListener; |
| 278 | final Runnable mWindowManagerDrawCallback = new Runnable() { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 279 | @Override |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 280 | public void run() { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 281 | if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for display!"); |
| 282 | mHandler.sendEmptyMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE); |
| 283 | } |
| 284 | }; |
| 285 | final ShowListener mKeyguardDelegateCallback = new ShowListener() { |
| 286 | @Override |
| 287 | public void onShown(IBinder windowToken) { |
| 288 | if (DEBUG_WAKEUP) Slog.d(TAG, "mKeyguardDelegate.ShowListener.onShown."); |
| 289 | mHandler.sendEmptyMessage(MSG_KEYGUARD_DRAWN_COMPLETE); |
| 290 | } |
| 291 | }; |
| 292 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 293 | GlobalActions mGlobalActions; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 294 | volatile boolean mPowerKeyHandled; // accessed from input reader and handler thread |
| 295 | boolean mPendingPowerKeyUpCanceled; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 296 | Handler mHandler; |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 297 | WindowState mLastInputMethodWindow = null; |
| 298 | WindowState mLastInputMethodTargetWindow = null; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 299 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 300 | boolean mRecentsVisible; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 301 | int mRecentAppsHeldModifiers; |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 302 | boolean mLanguageSwitchKeyPressed; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 303 | |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 304 | int mLidState = LID_ABSENT; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 305 | boolean mHaveBuiltInKeyboard; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 306 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 307 | boolean mSystemReady; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 308 | boolean mSystemBooted; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 309 | boolean mHdmiPlugged; |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 310 | IUiModeManager mUiModeManager; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 311 | int mUiMode; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 312 | int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 313 | int mLidOpenRotation; |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 314 | int mCarDockRotation; |
| 315 | int mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 316 | int mUndockedHdmiRotation; |
| 317 | int mDemoHdmiRotation; |
| 318 | boolean mDemoHdmiRotationLock; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 319 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 320 | boolean mWakeGestureEnabledSetting; |
| 321 | MyWakeGestureListener mWakeGestureListener; |
| 322 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 323 | // Default display does not rotate, apps that require non-default orientation will have to |
| 324 | // have the orientation emulated. |
| 325 | private boolean mForceDefaultOrientation = false; |
| 326 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 327 | int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; |
| 328 | int mUserRotation = Surface.ROTATION_0; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 329 | boolean mAccelerometerDefault; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 330 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 331 | boolean mSupportAutoRotation; |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 332 | int mAllowAllRotations = -1; |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 333 | boolean mCarDockEnablesAccelerometer; |
| 334 | boolean mDeskDockEnablesAccelerometer; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 335 | int mLidKeyboardAccessibility; |
| 336 | int mLidNavigationAccessibility; |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 337 | boolean mLidControlsSleep; |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 338 | int mShortPressOnPowerBehavior = -1; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 339 | int mLongPressOnPowerBehavior = -1; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 340 | boolean mScreenOnEarly = false; |
| 341 | boolean mScreenOnFully = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 342 | boolean mOrientationSensorEnabled = false; |
| 343 | int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 344 | boolean mHasSoftInput = false; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 345 | boolean mTranslucentDecorEnabled = true; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 346 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 347 | int mPointerLocationMode = 0; // guarded by mLock |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 348 | |
| 349 | // The last window we were told about in focusChanged. |
| 350 | WindowState mFocusedWindow; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 351 | IApplicationToken mFocusedApp; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 352 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 353 | PointerLocationView mPointerLocationView; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 354 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 355 | // The current size of the screen; really; extends into the overscan area of |
| 356 | // the screen and doesn't account for any system elements like the status bar. |
| 357 | int mOverscanScreenLeft, mOverscanScreenTop; |
| 358 | int mOverscanScreenWidth, mOverscanScreenHeight; |
| 359 | // The current visible size of the screen; really; (ir)regardless of whether the status |
| 360 | // bar can be hidden but not extending into the overscan area. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 361 | int mUnrestrictedScreenLeft, mUnrestrictedScreenTop; |
| 362 | int mUnrestrictedScreenWidth, mUnrestrictedScreenHeight; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 363 | // Like mOverscanScreen*, but allowed to move into the overscan region where appropriate. |
| 364 | int mRestrictedOverscanScreenLeft, mRestrictedOverscanScreenTop; |
| 365 | int mRestrictedOverscanScreenWidth, mRestrictedOverscanScreenHeight; |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 366 | // The current size of the screen; these may be different than (0,0)-(dw,dh) |
| 367 | // if the status bar can't be hidden; in that case it effectively carves out |
| 368 | // that area of the display from all other windows. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 369 | int mRestrictedScreenLeft, mRestrictedScreenTop; |
| 370 | int mRestrictedScreenWidth, mRestrictedScreenHeight; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 371 | // During layout, the current screen borders accounting for any currently |
| 372 | // visible system UI elements. |
| 373 | int mSystemLeft, mSystemTop, mSystemRight, mSystemBottom; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 374 | // For applications requesting stable content insets, these are them. |
| 375 | int mStableLeft, mStableTop, mStableRight, mStableBottom; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 376 | // For applications requesting stable content insets but have also set the |
| 377 | // fullscreen window flag, these are the stable dimensions without the status bar. |
| 378 | int mStableFullscreenLeft, mStableFullscreenTop; |
| 379 | int mStableFullscreenRight, mStableFullscreenBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 380 | // During layout, the current screen borders with all outer decoration |
| 381 | // (status bar, input method dock) accounted for. |
| 382 | int mCurLeft, mCurTop, mCurRight, mCurBottom; |
| 383 | // During layout, the frame in which content should be displayed |
| 384 | // to the user, accounting for all screen decoration except for any |
| 385 | // space they deem as available for other content. This is usually |
| 386 | // the same as mCur*, but may be larger if the screen decor has supplied |
| 387 | // content insets. |
| 388 | int mContentLeft, mContentTop, mContentRight, mContentBottom; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 389 | // During layout, the frame in which voice content should be displayed |
| 390 | // to the user, accounting for all screen decoration except for any |
| 391 | // space they deem as available for other content. |
| 392 | int mVoiceContentLeft, mVoiceContentTop, mVoiceContentRight, mVoiceContentBottom; |
Dianne Hackborn | 8e11ef0 | 2010-11-18 19:47:42 -0800 | [diff] [blame] | 393 | // 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] | 394 | // windows are placed. |
| 395 | int mDockLeft, mDockTop, mDockRight, mDockBottom; |
| 396 | // During layout, the layer at which the doc window is placed. |
| 397 | int mDockLayer; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 398 | // During layout, this is the layer of the status bar. |
| 399 | int mStatusBarLayer; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 400 | int mLastSystemUiFlags; |
| 401 | // Bits that we are in the process of clearing, so we want to prevent |
| 402 | // them from being set by applications until everything has been updated |
| 403 | // to have them clear. |
| 404 | int mResettingSystemUiFlags = 0; |
| 405 | // Bits that we are currently always keeping cleared. |
| 406 | int mForceClearedSystemUiFlags = 0; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 407 | // What we last reported to system UI about whether the compatibility |
| 408 | // menu needs to be displayed. |
| 409 | boolean mLastFocusNeedsMenu = false; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 410 | |
| 411 | FakeWindow mHideNavFakeWindow = null; |
| 412 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 413 | static final Rect mTmpParentFrame = new Rect(); |
| 414 | static final Rect mTmpDisplayFrame = new Rect(); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 415 | static final Rect mTmpOverscanFrame = new Rect(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 416 | static final Rect mTmpContentFrame = new Rect(); |
| 417 | static final Rect mTmpVisibleFrame = new Rect(); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 418 | static final Rect mTmpDecorFrame = new Rect(); |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 419 | static final Rect mTmpStableFrame = new Rect(); |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 420 | static final Rect mTmpNavigationFrame = new Rect(); |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 421 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 422 | WindowState mTopFullscreenOpaqueWindowState; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 423 | HashSet<IApplicationToken> mAppsToBeHidden = new HashSet<IApplicationToken>(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 424 | boolean mTopIsFullscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 425 | boolean mForceStatusBar; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 426 | boolean mForceStatusBarFromKeyguard; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 427 | boolean mHideLockScreen; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 428 | boolean mForcingShowNavBar; |
| 429 | int mForcingShowNavBarLayer; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 430 | |
| 431 | // States of keyguard dismiss. |
| 432 | private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed. |
| 433 | private static final int DISMISS_KEYGUARD_START = 1; // Keyguard needs to be dismissed. |
| 434 | private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed. |
| 435 | int mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
| 436 | |
| 437 | /** The window that is currently dismissing the keyguard. Dismissing the keyguard must only |
| 438 | * be done once per window. */ |
| 439 | private WindowState mWinDismissingKeyguard; |
| 440 | |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 441 | /** The window that is currently showing "over" the keyguard. If there is an app window |
| 442 | * belonging to another app on top of this the keyguard shows. If there is a fullscreen |
| 443 | * app window under this, still dismiss the keyguard but don't show the app underneath. Show |
| 444 | * the wallpaper. */ |
| 445 | private WindowState mWinShowWhenLocked; |
| 446 | |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 447 | boolean mShowingLockscreen; |
| 448 | boolean mShowingDream; |
| 449 | boolean mDreamingLockscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 450 | boolean mHomePressed; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 451 | boolean mHomeConsumed; |
| 452 | boolean mHomeDoubleTapPending; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 453 | Intent mHomeIntent; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 454 | Intent mCarDockIntent; |
| 455 | Intent mDeskDockIntent; |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 456 | boolean mSearchKeyShortcutPending; |
| 457 | boolean mConsumeSearchKeyUp; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 458 | boolean mAssistKeyLongPressed; |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 459 | boolean mPendingMetaAction; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 460 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 461 | // support for activating the lock screen while the screen is on |
| 462 | boolean mAllowLockscreenWhenOn; |
| 463 | int mLockScreenTimeout; |
| 464 | boolean mLockScreenTimerActive; |
| 465 | |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 466 | // 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] | 467 | int mEndcallBehavior; |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 468 | |
| 469 | // Behavior of POWER button while in-call and screen on. |
| 470 | // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) |
| 471 | int mIncallPowerBehavior; |
| 472 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 473 | Display mDisplay; |
| 474 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 475 | int mLandscapeRotation = 0; // default landscape rotation |
| 476 | int mSeascapeRotation = 0; // "other" landscape rotation, 180 degrees from mLandscapeRotation |
| 477 | int mPortraitRotation = 0; // default portrait rotation |
| 478 | int mUpsideDownRotation = 0; // "other" portrait rotation |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 479 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 480 | int mOverscanLeft = 0; |
| 481 | int mOverscanTop = 0; |
| 482 | int mOverscanRight = 0; |
| 483 | int mOverscanBottom = 0; |
| 484 | |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 485 | // What we do when the user long presses on home |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 486 | private int mLongPressOnHomeBehavior; |
| 487 | |
| 488 | // What we do when the user double-taps on home |
| 489 | private int mDoubleTapOnHomeBehavior; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 490 | |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 491 | // Screenshot trigger states |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 492 | // Time to volume and power must be pressed within this interval of each other. |
| 493 | private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150; |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 494 | // Increase the chord delay when taking a screenshot from the keyguard |
| 495 | private static final float KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER = 2.5f; |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 496 | private boolean mScreenshotChordEnabled; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 497 | private boolean mVolumeDownKeyTriggered; |
| 498 | private long mVolumeDownKeyTime; |
| 499 | private boolean mVolumeDownKeyConsumedByScreenshotChord; |
| 500 | private boolean mVolumeUpKeyTriggered; |
| 501 | private boolean mPowerKeyTriggered; |
| 502 | private long mPowerKeyTime; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 503 | |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 504 | /* The number of steps between min and max brightness */ |
| 505 | private static final int BRIGHTNESS_STEPS = 10; |
| 506 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 507 | SettingsObserver mSettingsObserver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 508 | ShortcutManager mShortcutManager; |
| 509 | PowerManager.WakeLock mBroadcastWakeLock; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 510 | boolean mHavePendingMediaKeyRepeatWithWakeLock; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 511 | |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 512 | private int mCurrentUserId; |
| 513 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 514 | // Maps global key codes to the components that will handle them. |
| 515 | private GlobalKeyManager mGlobalKeyManager; |
| 516 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 517 | // Fallback actions by key code. |
| 518 | private final SparseArray<KeyCharacterMap.FallbackAction> mFallbackActions = |
| 519 | new SparseArray<KeyCharacterMap.FallbackAction>(); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 520 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 521 | private static final int MSG_ENABLE_POINTER_LOCATION = 1; |
| 522 | private static final int MSG_DISABLE_POINTER_LOCATION = 2; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 523 | private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; |
| 524 | 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] | 525 | private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5; |
| 526 | private static final int MSG_KEYGUARD_DRAWN_TIMEOUT = 6; |
| 527 | private static final int MSG_WINDOW_MANAGER_DRAWN_COMPLETE = 7; |
| 528 | private static final int MSG_WAKING_UP = 8; |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 529 | private static final int MSG_DISPATCH_SHOW_RECENTS = 9; |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 530 | private static final int MSG_DISPATCH_SHOW_GLOBAL_ACTIONS = 10; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 531 | |
| 532 | private class PolicyHandler extends Handler { |
| 533 | @Override |
| 534 | public void handleMessage(Message msg) { |
| 535 | switch (msg.what) { |
| 536 | case MSG_ENABLE_POINTER_LOCATION: |
| 537 | enablePointerLocation(); |
| 538 | break; |
| 539 | case MSG_DISABLE_POINTER_LOCATION: |
| 540 | disablePointerLocation(); |
| 541 | break; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 542 | case MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK: |
| 543 | dispatchMediaKeyWithWakeLock((KeyEvent)msg.obj); |
| 544 | break; |
| 545 | case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK: |
| 546 | dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj); |
| 547 | break; |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 548 | case MSG_DISPATCH_SHOW_RECENTS: |
| 549 | showRecentApps(false); |
| 550 | break; |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 551 | case MSG_DISPATCH_SHOW_GLOBAL_ACTIONS: |
| 552 | showGlobalActionsInternal(); |
| 553 | break; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 554 | case MSG_KEYGUARD_DRAWN_COMPLETE: |
| 555 | if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mKeyguardDrawComplete"); |
| 556 | mKeyguardDrawComplete = true; |
| 557 | finishScreenTurningOn(); |
| 558 | break; |
| 559 | case MSG_KEYGUARD_DRAWN_TIMEOUT: |
| 560 | Slog.w(TAG, "Keyguard drawn timeout. Setting mKeyguardDrawComplete"); |
| 561 | mKeyguardDrawComplete = true; |
| 562 | finishScreenTurningOn(); |
| 563 | break; |
| 564 | case MSG_WINDOW_MANAGER_DRAWN_COMPLETE: |
| 565 | if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mWindowManagerDrawComplete"); |
| 566 | mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT); |
| 567 | mWindowManagerDrawComplete = true; |
| 568 | finishScreenTurningOn(); |
| 569 | break; |
| 570 | case MSG_WAKING_UP: |
| 571 | handleWakingUp((ScreenOnListener) msg.obj); |
| 572 | break; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 573 | } |
| 574 | } |
| 575 | } |
| 576 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 577 | private UEventObserver mHDMIObserver = new UEventObserver() { |
| 578 | @Override |
| 579 | public void onUEvent(UEventObserver.UEvent event) { |
| 580 | setHdmiPlugged("1".equals(event.get("SWITCH_STATE"))); |
| 581 | } |
| 582 | }; |
| 583 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 584 | class SettingsObserver extends ContentObserver { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 585 | SettingsObserver(Handler handler) { |
| 586 | super(handler); |
| 587 | } |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 588 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 589 | void observe() { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 590 | // Observe all users' changes |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 591 | ContentResolver resolver = mContext.getContentResolver(); |
| 592 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 593 | Settings.System.END_BUTTON_BEHAVIOR), false, this, |
| 594 | UserHandle.USER_ALL); |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 595 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 596 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this, |
| 597 | UserHandle.USER_ALL); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 598 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
| 599 | Settings.Secure.WAKE_GESTURE_ENABLED), false, this, |
| 600 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 601 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 602 | Settings.System.ACCELEROMETER_ROTATION), false, this, |
| 603 | UserHandle.USER_ALL); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 604 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 605 | Settings.System.USER_ROTATION), false, this, |
| 606 | UserHandle.USER_ALL); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 607 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 608 | Settings.System.SCREEN_OFF_TIMEOUT), false, this, |
| 609 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 610 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 611 | Settings.System.POINTER_LOCATION), false, this, |
| 612 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 613 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 614 | Settings.Secure.DEFAULT_INPUT_METHOD), false, this, |
| 615 | UserHandle.USER_ALL); |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 616 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 617 | Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS), false, this, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 618 | UserHandle.USER_ALL); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 619 | resolver.registerContentObserver(Settings.Global.getUriFor( |
| 620 | Settings.Global.POLICY_CONTROL), false, this, |
| 621 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 622 | updateSettings(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | @Override public void onChange(boolean selfChange) { |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 626 | updateSettings(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 627 | updateRotation(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 628 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 629 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 630 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 631 | class MyWakeGestureListener extends WakeGestureListener { |
| 632 | MyWakeGestureListener(Context context, Handler handler) { |
| 633 | super(context, handler); |
| 634 | } |
| 635 | |
| 636 | @Override |
| 637 | public void onWakeUp() { |
| 638 | synchronized (mLock) { |
| 639 | if (shouldEnableWakeGestureLp()) { |
Jeff Brown | e07b94b | 2014-06-18 15:56:27 -0700 | [diff] [blame] | 640 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 641 | mPowerManager.wakeUp(SystemClock.uptimeMillis()); |
| 642 | } |
| 643 | } |
| 644 | } |
| 645 | } |
| 646 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 647 | class MyOrientationListener extends WindowOrientationListener { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 648 | MyOrientationListener(Context context, Handler handler) { |
| 649 | super(context, handler); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 650 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 651 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 652 | @Override |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 653 | public void onProposedRotationChanged(int rotation) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 654 | if (localLOGV) Slog.v(TAG, "onProposedRotationChanged, rotation=" + rotation); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 655 | updateRotation(false); |
| 656 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 657 | } |
| 658 | MyOrientationListener mOrientationListener; |
| 659 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 660 | private final BarController mStatusBarController = new BarController("StatusBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 661 | View.STATUS_BAR_TRANSIENT, |
| 662 | View.STATUS_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 663 | View.STATUS_BAR_TRANSLUCENT, |
| 664 | StatusBarManager.WINDOW_STATUS_BAR, |
| 665 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 666 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 667 | private final BarController mNavigationBarController = new BarController("NavigationBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 668 | View.NAVIGATION_BAR_TRANSIENT, |
| 669 | View.NAVIGATION_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 670 | View.NAVIGATION_BAR_TRANSLUCENT, |
| 671 | StatusBarManager.WINDOW_NAVIGATION_BAR, |
| 672 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 673 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 674 | private ImmersiveModeConfirmation mImmersiveModeConfirmation; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 675 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 676 | private SystemGesturesPointerEventListener mSystemGestures; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 677 | |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 678 | IStatusBarService getStatusBarService() { |
| 679 | synchronized (mServiceAquireLock) { |
| 680 | if (mStatusBarService == null) { |
| 681 | mStatusBarService = IStatusBarService.Stub.asInterface( |
| 682 | ServiceManager.getService("statusbar")); |
| 683 | } |
| 684 | return mStatusBarService; |
| 685 | } |
| 686 | } |
| 687 | |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 688 | /* |
| 689 | * We always let the sensor be switched on by default except when |
| 690 | * the user has explicitly disabled sensor based rotation or when the |
| 691 | * screen is switched off. |
| 692 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 693 | boolean needSensorRunningLp() { |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 694 | if (mSupportAutoRotation) { |
| 695 | if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 696 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 697 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT |
| 698 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { |
| 699 | // If the application has explicitly requested to follow the |
| 700 | // orientation, then we need to turn the sensor on. |
| 701 | return true; |
| 702 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 703 | } |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 704 | if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 705 | (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 706 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 707 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK))) { |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 708 | // enable accelerometer if we are docked in a dock that enables accelerometer |
| 709 | // orientation management, |
| 710 | return true; |
| 711 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 712 | if (mUserRotationMode == USER_ROTATION_LOCKED) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 713 | // If the setting for using the sensor by default is enabled, then |
| 714 | // we will always leave it on. Note that the user could go to |
| 715 | // a window that forces an orientation that does not use the |
| 716 | // sensor and in theory we could turn it off... however, when next |
| 717 | // turning it on we won't have a good value for the current |
| 718 | // orientation for a little bit, which can cause orientation |
| 719 | // changes to lag, so we'd like to keep it always on. (It will |
| 720 | // still be turned off when the screen is off.) |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 721 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 722 | } |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 723 | return mSupportAutoRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 724 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 725 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 726 | /* |
| 727 | * Various use cases for invoking this function |
| 728 | * screen turning off, should always disable listeners if already enabled |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 729 | * 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] | 730 | * if not already enabled |
| 731 | * screen turned on and current app does not have sensor orientation, disable listeners if |
| 732 | * already enabled |
| 733 | * screen turning on and current app has sensor based orientation, enable listeners if needed |
| 734 | * screen turning on and current app has nosensor based orientation, do nothing |
| 735 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 736 | void updateOrientationListenerLp() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 737 | if (!mOrientationListener.canDetectOrientation()) { |
| 738 | // If sensor is turned off or nonexistent for some reason |
| 739 | return; |
| 740 | } |
| 741 | //Could have been invoked due to screen turning on or off or |
| 742 | //change of the currently visible window's orientation |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 743 | if (localLOGV) Slog.v(TAG, "Screen status="+mScreenOnEarly+ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 744 | ", current orientation="+mCurrentAppOrientation+ |
| 745 | ", SensorEnabled="+mOrientationSensorEnabled); |
| 746 | boolean disable = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 747 | if (mScreenOnEarly) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 748 | if (needSensorRunningLp()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 749 | disable = false; |
| 750 | //enable listener if not already enabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 751 | if (!mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 752 | mOrientationListener.enable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 753 | if(localLOGV) Slog.v(TAG, "Enabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 754 | mOrientationSensorEnabled = true; |
| 755 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 756 | } |
| 757 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 758 | //check if sensors need to be disabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 759 | if (disable && mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 760 | mOrientationListener.disable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 761 | if(localLOGV) Slog.v(TAG, "Disabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 762 | mOrientationSensorEnabled = false; |
| 763 | } |
| 764 | } |
| 765 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 766 | private void interceptPowerKeyDown(boolean handled) { |
| 767 | mPowerKeyHandled = handled; |
| 768 | if (!handled) { |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 769 | mHandler.postDelayed(mPowerLongPress, |
| 770 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 771 | } |
| 772 | } |
| 773 | |
| 774 | private boolean interceptPowerKeyUp(boolean canceled) { |
| 775 | if (!mPowerKeyHandled) { |
| 776 | mHandler.removeCallbacks(mPowerLongPress); |
| 777 | return !canceled; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 778 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 779 | return false; |
| 780 | } |
| 781 | |
| 782 | private void cancelPendingPowerKeyAction() { |
| 783 | if (!mPowerKeyHandled) { |
| 784 | mHandler.removeCallbacks(mPowerLongPress); |
| 785 | } |
Jeff Brown | ff20471 | 2011-10-25 21:27:54 -0700 | [diff] [blame] | 786 | if (mPowerKeyTriggered) { |
| 787 | mPendingPowerKeyUpCanceled = true; |
| 788 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | private void interceptScreenshotChord() { |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 792 | if (mScreenshotChordEnabled |
| 793 | && mVolumeDownKeyTriggered && mPowerKeyTriggered && !mVolumeUpKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 794 | final long now = SystemClock.uptimeMillis(); |
| 795 | if (now <= mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS |
| 796 | && now <= mPowerKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) { |
| 797 | mVolumeDownKeyConsumedByScreenshotChord = true; |
| 798 | cancelPendingPowerKeyAction(); |
| 799 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 800 | mHandler.postDelayed(mScreenshotRunnable, getScreenshotChordLongPressDelay()); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 801 | } |
| 802 | } |
| 803 | } |
| 804 | |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 805 | private long getScreenshotChordLongPressDelay() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 806 | if (mKeyguardDelegate.isShowing()) { |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 807 | // Double the time it takes to take a screenshot from the keyguard |
| 808 | return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER * |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 809 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 810 | } |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 811 | return ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout(); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 812 | } |
| 813 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 814 | private void cancelPendingScreenshotChordAction() { |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 815 | mHandler.removeCallbacks(mScreenshotRunnable); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 816 | } |
| 817 | |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 818 | private void powerShortPress(long eventTime) { |
| 819 | if (mShortPressOnPowerBehavior < 0) { |
| 820 | mShortPressOnPowerBehavior = mContext.getResources().getInteger( |
| 821 | com.android.internal.R.integer.config_shortPressOnPowerBehavior); |
| 822 | } |
| 823 | |
| 824 | switch (mShortPressOnPowerBehavior) { |
| 825 | case SHORT_PRESS_POWER_NOTHING: |
| 826 | break; |
| 827 | case SHORT_PRESS_POWER_GO_TO_SLEEP: |
| 828 | mPowerManager.goToSleep(eventTime, |
| 829 | PowerManager.GO_TO_SLEEP_REASON_USER, 0); |
| 830 | break; |
| 831 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP: |
| 832 | mPowerManager.goToSleep(eventTime, |
| 833 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 834 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 835 | break; |
| 836 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME: |
| 837 | mPowerManager.goToSleep(eventTime, |
| 838 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 839 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 840 | launchHomeFromHotKey(); |
| 841 | break; |
| 842 | } |
| 843 | } |
| 844 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 845 | private final Runnable mPowerLongPress = new Runnable() { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 846 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 847 | public void run() { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 848 | // The context isn't read |
| 849 | if (mLongPressOnPowerBehavior < 0) { |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 850 | mLongPressOnPowerBehavior = mContext.getResources().getInteger( |
| 851 | com.android.internal.R.integer.config_longPressOnPowerBehavior); |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 852 | } |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 853 | int resolvedBehavior = mLongPressOnPowerBehavior; |
| 854 | if (FactoryTest.isLongPressOnPowerOffEnabled()) { |
| 855 | resolvedBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM; |
| 856 | } |
| 857 | |
| 858 | switch (resolvedBehavior) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 859 | case LONG_PRESS_POWER_NOTHING: |
| 860 | break; |
| 861 | case LONG_PRESS_POWER_GLOBAL_ACTIONS: |
| 862 | mPowerKeyHandled = true; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 863 | if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) { |
| 864 | performAuditoryFeedbackForAccessibilityIfNeed(); |
| 865 | } |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 866 | showGlobalActionsInternal(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 867 | break; |
| 868 | case LONG_PRESS_POWER_SHUT_OFF: |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 869 | case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM: |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 870 | mPowerKeyHandled = true; |
| 871 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 872 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 873 | mWindowManagerFuncs.shutdown(resolvedBehavior == LONG_PRESS_POWER_SHUT_OFF); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 874 | break; |
| 875 | } |
| 876 | } |
| 877 | }; |
| 878 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 879 | private final Runnable mScreenshotRunnable = new Runnable() { |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 880 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 881 | public void run() { |
| 882 | takeScreenshot(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 883 | } |
| 884 | }; |
| 885 | |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 886 | @Override |
| 887 | public void showGlobalActions() { |
| 888 | mHandler.removeMessages(MSG_DISPATCH_SHOW_GLOBAL_ACTIONS); |
| 889 | mHandler.sendEmptyMessage(MSG_DISPATCH_SHOW_GLOBAL_ACTIONS); |
| 890 | } |
| 891 | |
| 892 | void showGlobalActionsInternal() { |
| 893 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 894 | if (mGlobalActions == null) { |
Jeff Brown | 7304c34 | 2012-05-11 18:42:42 -0700 | [diff] [blame] | 895 | mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 896 | } |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 897 | final boolean keyguardShowing = keyguardIsShowingTq(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 898 | mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); |
| 899 | if (keyguardShowing) { |
| 900 | // since it took two seconds of long press to bring this up, |
| 901 | // 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] | 902 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 903 | } |
| 904 | } |
| 905 | |
| 906 | boolean isDeviceProvisioned() { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 907 | return Settings.Global.getInt( |
| 908 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 909 | } |
| 910 | |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 911 | boolean isUserSetupComplete() { |
| 912 | return Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 913 | Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; |
| 914 | } |
| 915 | |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 916 | private void handleLongPressOnHome() { |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 917 | if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 918 | mHomeConsumed = true; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 919 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 920 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 921 | if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) { |
| 922 | toggleRecentApps(); |
| 923 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_ASSIST) { |
| 924 | launchAssistAction(); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 925 | } |
| 926 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 927 | } |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 928 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 929 | private void handleDoubleTapOnHome() { |
| 930 | if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 931 | mHomeConsumed = true; |
| 932 | toggleRecentApps(); |
| 933 | } |
| 934 | } |
| 935 | |
| 936 | private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable() { |
| 937 | @Override |
| 938 | public void run() { |
| 939 | if (mHomeDoubleTapPending) { |
| 940 | mHomeDoubleTapPending = false; |
| 941 | launchHomeFromHotKey(); |
| 942 | } |
| 943 | } |
| 944 | }; |
| 945 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 946 | /** {@inheritDoc} */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 947 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 948 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 949 | WindowManagerFuncs windowManagerFuncs) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 950 | mContext = context; |
| 951 | mWindowManager = windowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 952 | mWindowManagerFuncs = windowManagerFuncs; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 953 | mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 954 | mDreamManagerInternal = LocalServices.getService(DreamManagerInternal.class); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 955 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 956 | mHandler = new PolicyHandler(); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 957 | mWakeGestureListener = new MyWakeGestureListener(mContext, mHandler); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 958 | mOrientationListener = new MyOrientationListener(mContext, mHandler); |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 959 | try { |
| 960 | mOrientationListener.setCurrentRotation(windowManager.getRotation()); |
| 961 | } catch (RemoteException ex) { } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 962 | mSettingsObserver = new SettingsObserver(mHandler); |
| 963 | mSettingsObserver.observe(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 964 | mShortcutManager = new ShortcutManager(context, mHandler); |
| 965 | mShortcutManager.observe(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 966 | mUiMode = context.getResources().getInteger( |
| 967 | com.android.internal.R.integer.config_defaultUiModeType); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 968 | mHomeIntent = new Intent(Intent.ACTION_MAIN, null); |
| 969 | mHomeIntent.addCategory(Intent.CATEGORY_HOME); |
| 970 | mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 971 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 972 | mCarDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 973 | mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK); |
| 974 | mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 975 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 976 | mDeskDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 977 | mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK); |
| 978 | mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 979 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 980 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 981 | mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 982 | mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 983 | "PhoneWindowManager.mBroadcastWakeLock"); |
| 984 | mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 985 | mSupportAutoRotation = mContext.getResources().getBoolean( |
| 986 | com.android.internal.R.bool.config_supportAutoRotation); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 987 | mLidOpenRotation = readRotation( |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 988 | com.android.internal.R.integer.config_lidOpenRotation); |
| 989 | mCarDockRotation = readRotation( |
| 990 | com.android.internal.R.integer.config_carDockRotation); |
| 991 | mDeskDockRotation = readRotation( |
| 992 | com.android.internal.R.integer.config_deskDockRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 993 | mUndockedHdmiRotation = readRotation( |
| 994 | com.android.internal.R.integer.config_undockedHdmiRotation); |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 995 | mCarDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 996 | com.android.internal.R.bool.config_carDockEnablesAccelerometer); |
| 997 | mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 998 | com.android.internal.R.bool.config_deskDockEnablesAccelerometer); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 999 | mLidKeyboardAccessibility = mContext.getResources().getInteger( |
| 1000 | com.android.internal.R.integer.config_lidKeyboardAccessibility); |
| 1001 | mLidNavigationAccessibility = mContext.getResources().getInteger( |
| 1002 | com.android.internal.R.integer.config_lidNavigationAccessibility); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1003 | mLidControlsSleep = mContext.getResources().getBoolean( |
| 1004 | com.android.internal.R.bool.config_lidControlsSleep); |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 1005 | mTranslucentDecorEnabled = mContext.getResources().getBoolean( |
| 1006 | com.android.internal.R.bool.config_enableTranslucentDecor); |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1007 | readConfigurationDependentBehaviors(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1008 | |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 1009 | mAccessibilityManager = (AccessibilityManager) context.getSystemService( |
| 1010 | Context.ACCESSIBILITY_SERVICE); |
| 1011 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1012 | // register for dock events |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 1013 | IntentFilter filter = new IntentFilter(); |
| 1014 | filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); |
| 1015 | filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE); |
| 1016 | filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); |
| 1017 | filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1018 | filter.addAction(Intent.ACTION_DOCK_EVENT); |
| 1019 | Intent intent = context.registerReceiver(mDockReceiver, filter); |
| 1020 | if (intent != null) { |
| 1021 | // Retrieve current sticky dock event broadcast. |
| 1022 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 1023 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 1024 | } |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 1025 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 1026 | // register for dream-related broadcasts |
| 1027 | filter = new IntentFilter(); |
| 1028 | filter.addAction(Intent.ACTION_DREAMING_STARTED); |
| 1029 | filter.addAction(Intent.ACTION_DREAMING_STOPPED); |
| 1030 | context.registerReceiver(mDreamReceiver, filter); |
| 1031 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1032 | // register for multiuser-relevant broadcasts |
| 1033 | filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); |
| 1034 | context.registerReceiver(mMultiuserReceiver, filter); |
| 1035 | |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 1036 | // monitor for system gestures |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1037 | mSystemGestures = new SystemGesturesPointerEventListener(context, |
| 1038 | new SystemGesturesPointerEventListener.Callbacks() { |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 1039 | @Override |
| 1040 | public void onSwipeFromTop() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1041 | if (mStatusBar != null) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1042 | requestTransientBars(mStatusBar); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1043 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1044 | } |
| 1045 | @Override |
| 1046 | public void onSwipeFromBottom() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1047 | if (mNavigationBar != null && mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1048 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1049 | } |
| 1050 | } |
| 1051 | @Override |
| 1052 | public void onSwipeFromRight() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1053 | if (mNavigationBar != null && !mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1054 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1055 | } |
| 1056 | } |
| 1057 | @Override |
| 1058 | public void onDebug() { |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1059 | // no-op |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1060 | } |
| 1061 | }); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1062 | mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1063 | mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 1064 | |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 1065 | mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 1066 | mLongPressVibePattern = getLongIntArray(mContext.getResources(), |
| 1067 | com.android.internal.R.array.config_longPressVibePattern); |
| 1068 | mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(), |
| 1069 | com.android.internal.R.array.config_virtualKeyVibePattern); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 1070 | mKeyboardTapVibePattern = getLongIntArray(mContext.getResources(), |
| 1071 | com.android.internal.R.array.config_keyboardTapVibePattern); |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 1072 | mClockTickVibePattern = getLongIntArray(mContext.getResources(), |
| 1073 | com.android.internal.R.array.config_clockTickVibePattern); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 1074 | mSafeModeDisabledVibePattern = getLongIntArray(mContext.getResources(), |
| 1075 | com.android.internal.R.array.config_safeModeDisabledVibePattern); |
| 1076 | mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), |
| 1077 | com.android.internal.R.array.config_safeModeEnabledVibePattern); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 1078 | |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1079 | mScreenshotChordEnabled = mContext.getResources().getBoolean( |
| 1080 | com.android.internal.R.bool.config_enableScreenshotChord); |
| 1081 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 1082 | mGlobalKeyManager = new GlobalKeyManager(mContext); |
| 1083 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 1084 | // Controls rotation and the like. |
| 1085 | initializeHdmiState(); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1086 | |
| 1087 | // Match current screen state. |
Jeff Brown | 26c6a50 | 2014-04-11 02:15:54 -0700 | [diff] [blame] | 1088 | if (mPowerManager.isInteractive()) { |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 1089 | wakingUp(null); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1090 | } else { |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 1091 | goingToSleep(WindowManagerPolicy.OFF_BECAUSE_OF_USER); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1092 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1093 | } |
| 1094 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1095 | /** |
| 1096 | * Read values from config.xml that may be overridden depending on |
| 1097 | * the configuration of the device. |
| 1098 | * eg. Disable long press on home goes to recents on sw600dp. |
| 1099 | */ |
| 1100 | private void readConfigurationDependentBehaviors() { |
| 1101 | mLongPressOnHomeBehavior = mContext.getResources().getInteger( |
| 1102 | com.android.internal.R.integer.config_longPressOnHomeBehavior); |
| 1103 | if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING || |
| 1104 | mLongPressOnHomeBehavior > LONG_PRESS_HOME_ASSIST) { |
| 1105 | mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1106 | } |
| 1107 | |
| 1108 | mDoubleTapOnHomeBehavior = mContext.getResources().getInteger( |
| 1109 | com.android.internal.R.integer.config_doubleTapOnHomeBehavior); |
| 1110 | if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING || |
| 1111 | mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 1112 | mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1113 | } |
| 1114 | } |
| 1115 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1116 | @Override |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1117 | public void setInitialDisplaySize(Display display, int width, int height, int density) { |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 1118 | // This method might be called before the policy has been fully initialized |
| 1119 | // or for other displays we don't care about. |
| 1120 | if (mContext == null || display.getDisplayId() != Display.DEFAULT_DISPLAY) { |
| 1121 | return; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1122 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1123 | mDisplay = display; |
| 1124 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1125 | final Resources res = mContext.getResources(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1126 | int shortSize, longSize; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1127 | if (width > height) { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1128 | shortSize = height; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1129 | longSize = width; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1130 | mLandscapeRotation = Surface.ROTATION_0; |
| 1131 | mSeascapeRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1132 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1133 | mPortraitRotation = Surface.ROTATION_90; |
| 1134 | mUpsideDownRotation = Surface.ROTATION_270; |
| 1135 | } else { |
| 1136 | mPortraitRotation = Surface.ROTATION_270; |
| 1137 | mUpsideDownRotation = Surface.ROTATION_90; |
| 1138 | } |
| 1139 | } else { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1140 | shortSize = width; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1141 | longSize = height; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1142 | mPortraitRotation = Surface.ROTATION_0; |
| 1143 | mUpsideDownRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1144 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1145 | mLandscapeRotation = Surface.ROTATION_270; |
| 1146 | mSeascapeRotation = Surface.ROTATION_90; |
| 1147 | } else { |
| 1148 | mLandscapeRotation = Surface.ROTATION_90; |
| 1149 | mSeascapeRotation = Surface.ROTATION_270; |
| 1150 | } |
| 1151 | } |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1152 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1153 | mStatusBarHeight = |
| 1154 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1155 | |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1156 | // Height of the navigation bar when presented horizontally at bottom |
| 1157 | mNavigationBarHeightForRotation[mPortraitRotation] = |
| 1158 | mNavigationBarHeightForRotation[mUpsideDownRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1159 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1160 | mNavigationBarHeightForRotation[mLandscapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1161 | mNavigationBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize( |
| 1162 | com.android.internal.R.dimen.navigation_bar_height_landscape); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1163 | |
| 1164 | // Width of the navigation bar when presented vertically along one side |
| 1165 | mNavigationBarWidthForRotation[mPortraitRotation] = |
| 1166 | mNavigationBarWidthForRotation[mUpsideDownRotation] = |
| 1167 | mNavigationBarWidthForRotation[mLandscapeRotation] = |
| 1168 | mNavigationBarWidthForRotation[mSeascapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1169 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1170 | |
| 1171 | // SystemUI (status bar) layout policy |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1172 | int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1173 | int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1174 | |
Craig Mautner | d4ec3324 | 2013-07-22 10:37:43 -0700 | [diff] [blame] | 1175 | // Allow the navigation bar to move on small devices (phones). |
| 1176 | mNavigationBarCanMove = shortSizeDp < 600; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1177 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1178 | mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1179 | // Allow a system property to override this. Used by the emulator. |
| 1180 | // See also hasNavigationBar(). |
| 1181 | String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); |
| 1182 | if ("1".equals(navBarOverride)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1183 | mHasNavigationBar = false; |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1184 | } else if ("0".equals(navBarOverride)) { |
| 1185 | mHasNavigationBar = true; |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1186 | } |
| 1187 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 1188 | // For demo purposes, allow the rotation of the HDMI display to be controlled. |
| 1189 | // By default, HDMI locks rotation to landscape. |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1190 | if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1191 | mDemoHdmiRotation = mPortraitRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1192 | } else { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1193 | mDemoHdmiRotation = mLandscapeRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1194 | } |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1195 | mDemoHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1196 | |
| 1197 | // Only force the default orientation if the screen is xlarge, at least 960dp x 720dp, per |
| 1198 | // http://developer.android.com/guide/practices/screens_support.html#range |
| 1199 | mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 && |
| 1200 | res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) && |
| 1201 | // For debug purposes the next line turns this feature off with: |
| 1202 | // $ adb shell setprop config.override_forced_orient true |
| 1203 | // $ adb shell wm size reset |
| 1204 | !"true".equals(SystemProperties.get("config.override_forced_orient")); |
| 1205 | } |
| 1206 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1207 | /** |
| 1208 | * @return whether the navigation bar can be hidden, e.g. the device has a |
| 1209 | * navigation bar and touch exploration is not enabled |
| 1210 | */ |
| 1211 | private boolean canHideNavigationBar() { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 1212 | return mHasNavigationBar |
| 1213 | && !mAccessibilityManager.isTouchExplorationEnabled(); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1214 | } |
| 1215 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1216 | @Override |
| 1217 | public boolean isDefaultOrientationForced() { |
| 1218 | return mForceDefaultOrientation; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1219 | } |
| 1220 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1221 | @Override |
| 1222 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom) { |
| 1223 | if (display.getDisplayId() == Display.DEFAULT_DISPLAY) { |
| 1224 | mOverscanLeft = left; |
| 1225 | mOverscanTop = top; |
| 1226 | mOverscanRight = right; |
| 1227 | mOverscanBottom = bottom; |
| 1228 | } |
| 1229 | } |
| 1230 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1231 | public void updateSettings() { |
| 1232 | ContentResolver resolver = mContext.getContentResolver(); |
| 1233 | boolean updateRotation = false; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1234 | synchronized (mLock) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1235 | mEndcallBehavior = Settings.System.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1236 | Settings.System.END_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1237 | Settings.System.END_BUTTON_BEHAVIOR_DEFAULT, |
| 1238 | UserHandle.USER_CURRENT); |
| 1239 | mIncallPowerBehavior = Settings.Secure.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1240 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1241 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT, |
| 1242 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1243 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1244 | // Configure wake gesture. |
| 1245 | boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver, |
| 1246 | Settings.Secure.WAKE_GESTURE_ENABLED, 0, |
| 1247 | UserHandle.USER_CURRENT) != 0; |
| 1248 | if (mWakeGestureEnabledSetting != wakeGestureEnabledSetting) { |
| 1249 | mWakeGestureEnabledSetting = wakeGestureEnabledSetting; |
| 1250 | updateWakeGestureListenerLp(); |
| 1251 | } |
| 1252 | |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1253 | // Configure rotation lock. |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1254 | int userRotation = Settings.System.getIntForUser(resolver, |
| 1255 | Settings.System.USER_ROTATION, Surface.ROTATION_0, |
| 1256 | UserHandle.USER_CURRENT); |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1257 | if (mUserRotation != userRotation) { |
| 1258 | mUserRotation = userRotation; |
| 1259 | updateRotation = true; |
| 1260 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1261 | int userRotationMode = Settings.System.getIntForUser(resolver, |
| 1262 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1263 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 1264 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
| 1265 | if (mUserRotationMode != userRotationMode) { |
| 1266 | mUserRotationMode = userRotationMode; |
| 1267 | updateRotation = true; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1268 | updateOrientationListenerLp(); |
| 1269 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1270 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1271 | if (mSystemReady) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1272 | int pointerLocation = Settings.System.getIntForUser(resolver, |
| 1273 | Settings.System.POINTER_LOCATION, 0, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1274 | if (mPointerLocationMode != pointerLocation) { |
| 1275 | mPointerLocationMode = pointerLocation; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1276 | mHandler.sendEmptyMessage(pointerLocation != 0 ? |
| 1277 | MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1278 | } |
| 1279 | } |
| 1280 | // use screen off timeout setting as the timeout for the lockscreen |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1281 | mLockScreenTimeout = Settings.System.getIntForUser(resolver, |
| 1282 | Settings.System.SCREEN_OFF_TIMEOUT, 0, UserHandle.USER_CURRENT); |
| 1283 | String imId = Settings.Secure.getStringForUser(resolver, |
| 1284 | Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1285 | boolean hasSoftInput = imId != null && imId.length() > 0; |
| 1286 | if (mHasSoftInput != hasSoftInput) { |
| 1287 | mHasSoftInput = hasSoftInput; |
| 1288 | updateRotation = true; |
| 1289 | } |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1290 | if (mImmersiveModeConfirmation != null) { |
John Spurlock | 4355a53 | 2014-02-19 09:49:25 -0500 | [diff] [blame] | 1291 | mImmersiveModeConfirmation.loadSetting(mCurrentUserId); |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1292 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 1293 | PolicyControl.reloadFromSetting(mContext); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1294 | } |
| 1295 | if (updateRotation) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1296 | updateRotation(true); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1297 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1298 | } |
| 1299 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1300 | private void updateWakeGestureListenerLp() { |
| 1301 | if (shouldEnableWakeGestureLp()) { |
| 1302 | mWakeGestureListener.requestWakeUpTrigger(); |
| 1303 | } else { |
| 1304 | mWakeGestureListener.cancelWakeUpTrigger(); |
| 1305 | } |
| 1306 | } |
| 1307 | |
| 1308 | private boolean shouldEnableWakeGestureLp() { |
| 1309 | return mWakeGestureEnabledSetting && !mScreenOnEarly |
| 1310 | && (!mLidControlsSleep || mLidState != LID_CLOSED) |
| 1311 | && mWakeGestureListener.isSupported(); |
| 1312 | } |
| 1313 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1314 | private void enablePointerLocation() { |
| 1315 | if (mPointerLocationView == null) { |
| 1316 | mPointerLocationView = new PointerLocationView(mContext); |
| 1317 | mPointerLocationView.setPrintCoords(false); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1318 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 1319 | WindowManager.LayoutParams.MATCH_PARENT, |
| 1320 | WindowManager.LayoutParams.MATCH_PARENT); |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1321 | lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1322 | lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
| 1323 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
| 1324 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1325 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
Jeff Brown | 90fc905 | 2012-10-01 14:44:24 -0700 | [diff] [blame] | 1326 | if (ActivityManager.isHighEndGfx()) { |
| 1327 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1328 | lp.privateFlags |= |
| 1329 | WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; |
| 1330 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1331 | lp.format = PixelFormat.TRANSLUCENT; |
| 1332 | lp.setTitle("PointerLocation"); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1333 | WindowManager wm = (WindowManager) |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1334 | mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1335 | lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1336 | wm.addView(mPointerLocationView, lp); |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1337 | mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1338 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1339 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1340 | |
| 1341 | private void disablePointerLocation() { |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1342 | if (mPointerLocationView != null) { |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1343 | mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView); |
| 1344 | WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1345 | wm.removeView(mPointerLocationView); |
| 1346 | mPointerLocationView = null; |
| 1347 | } |
| 1348 | } |
| 1349 | |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1350 | private int readRotation(int resID) { |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1351 | try { |
| 1352 | int rotation = mContext.getResources().getInteger(resID); |
| 1353 | switch (rotation) { |
| 1354 | case 0: |
| 1355 | return Surface.ROTATION_0; |
| 1356 | case 90: |
| 1357 | return Surface.ROTATION_90; |
| 1358 | case 180: |
| 1359 | return Surface.ROTATION_180; |
| 1360 | case 270: |
| 1361 | return Surface.ROTATION_270; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1362 | } |
| 1363 | } catch (Resources.NotFoundException e) { |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1364 | // fall through |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1365 | } |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1366 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1367 | } |
| 1368 | |
| 1369 | /** {@inheritDoc} */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1370 | @Override |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1371 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1372 | int type = attrs.type; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1373 | |
| 1374 | outAppOp[0] = AppOpsManager.OP_NONE; |
| 1375 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1376 | if (type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW |
| 1377 | || type > WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1378 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1379 | } |
| 1380 | String permission = null; |
| 1381 | switch (type) { |
| 1382 | case TYPE_TOAST: |
| 1383 | // XXX right now the app process has complete control over |
| 1384 | // this... should introduce a token to let the system |
| 1385 | // monitor/control what they are doing. |
Jason Monk | 1c7c319 | 2014-06-26 12:52:18 -0400 | [diff] [blame] | 1386 | outAppOp[0] = AppOpsManager.OP_TOAST_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1387 | break; |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 1388 | case TYPE_DREAM: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1389 | case TYPE_INPUT_METHOD: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1390 | case TYPE_WALLPAPER: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1391 | case TYPE_PRIVATE_PRESENTATION: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1392 | case TYPE_VOICE_INTERACTION: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1393 | // The window manager will check these. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1394 | break; |
| 1395 | case TYPE_PHONE: |
| 1396 | case TYPE_PRIORITY_PHONE: |
| 1397 | case TYPE_SYSTEM_ALERT: |
| 1398 | case TYPE_SYSTEM_ERROR: |
| 1399 | case TYPE_SYSTEM_OVERLAY: |
| 1400 | permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1401 | outAppOp[0] = AppOpsManager.OP_SYSTEM_ALERT_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1402 | break; |
| 1403 | default: |
| 1404 | permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; |
| 1405 | } |
| 1406 | if (permission != null) { |
| 1407 | if (mContext.checkCallingOrSelfPermission(permission) |
| 1408 | != PackageManager.PERMISSION_GRANTED) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1409 | return WindowManagerGlobal.ADD_PERMISSION_DENIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1410 | } |
| 1411 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1412 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1413 | } |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1414 | |
| 1415 | @Override |
| 1416 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs) { |
| 1417 | |
| 1418 | // If this switch statement is modified, modify the comment in the declarations of |
| 1419 | // the type in {@link WindowManager.LayoutParams} as well. |
| 1420 | switch (attrs.type) { |
| 1421 | default: |
| 1422 | // These are the windows that by default are shown only to the user that created |
| 1423 | // them. If this needs to be overridden, set |
| 1424 | // {@link WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS} in |
| 1425 | // {@link WindowManager.LayoutParams}. Note that permission |
| 1426 | // {@link android.Manifest.permission.INTERNAL_SYSTEM_WINDOW} is required as well. |
| 1427 | if ((attrs.privateFlags & PRIVATE_FLAG_SHOW_FOR_ALL_USERS) == 0) { |
| 1428 | return true; |
| 1429 | } |
| 1430 | break; |
| 1431 | |
| 1432 | // These are the windows that by default are shown to all users. However, to |
| 1433 | // protect against spoofing, check permissions below. |
| 1434 | case TYPE_APPLICATION_STARTING: |
| 1435 | case TYPE_BOOT_PROGRESS: |
| 1436 | case TYPE_DISPLAY_OVERLAY: |
| 1437 | case TYPE_HIDDEN_NAV_CONSUMER: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1438 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1439 | case TYPE_KEYGUARD_DIALOG: |
| 1440 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1441 | case TYPE_NAVIGATION_BAR: |
| 1442 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1443 | case TYPE_PHONE: |
| 1444 | case TYPE_POINTER: |
| 1445 | case TYPE_PRIORITY_PHONE: |
| 1446 | case TYPE_RECENTS_OVERLAY: |
| 1447 | case TYPE_SEARCH_BAR: |
| 1448 | case TYPE_STATUS_BAR: |
| 1449 | case TYPE_STATUS_BAR_PANEL: |
| 1450 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1451 | case TYPE_SYSTEM_DIALOG: |
| 1452 | case TYPE_UNIVERSE_BACKGROUND: |
| 1453 | case TYPE_VOLUME_OVERLAY: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1454 | case TYPE_PRIVATE_PRESENTATION: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1455 | break; |
| 1456 | } |
| 1457 | |
| 1458 | // Check if third party app has set window to system window type. |
| 1459 | return mContext.checkCallingOrSelfPermission( |
| 1460 | android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) |
| 1461 | != PackageManager.PERMISSION_GRANTED; |
| 1462 | } |
| 1463 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1464 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1465 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) { |
| 1466 | switch (attrs.type) { |
| 1467 | case TYPE_SYSTEM_OVERLAY: |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1468 | case TYPE_SECURE_SYSTEM_OVERLAY: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1469 | // These types of windows can't receive input events. |
| 1470 | attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1471 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1472 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1473 | break; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1474 | case TYPE_STATUS_BAR: |
| 1475 | |
| 1476 | // If the Keyguard is in a hidden state (occluded by another window), we force to |
| 1477 | // remove the wallpaper and keyguard flag so that any change in-flight after setting |
| 1478 | // the keyguard as occluded wouldn't set these flags again. |
| 1479 | // See {@link #processKeyguardSetHiddenResultLw}. |
| 1480 | if (mKeyguardHidden) { |
| 1481 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 1482 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 1483 | } |
| 1484 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1485 | } |
Adrian Roos | 3850211 | 2014-04-09 21:04:11 +0200 | [diff] [blame] | 1486 | |
| 1487 | if (attrs.type != TYPE_STATUS_BAR) { |
| 1488 | // The status bar is the only window allowed to exhibit keyguard behavior. |
| 1489 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 1490 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1491 | |
| 1492 | if (ActivityManager.isHighEndGfx() |
| 1493 | && (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) { |
| 1494 | attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
| 1495 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 1496 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; |
| 1497 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1498 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1499 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1500 | void readLidState() { |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 1501 | mLidState = mWindowManagerFuncs.getLidState(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1502 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1503 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1504 | private boolean isHidden(int accessibilityMode) { |
| 1505 | switch (accessibilityMode) { |
| 1506 | case 1: |
| 1507 | return mLidState == LID_CLOSED; |
| 1508 | case 2: |
| 1509 | return mLidState == LID_OPEN; |
| 1510 | default: |
| 1511 | return false; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1512 | } |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [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 |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1517 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 1518 | int navigationPresence) { |
| 1519 | mHaveBuiltInKeyboard = (keyboardPresence & PRESENCE_INTERNAL) != 0; |
| 1520 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1521 | readConfigurationDependentBehaviors(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1522 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1523 | applyLidSwitchState(); |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1524 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1525 | if (config.keyboard == Configuration.KEYBOARD_NOKEYS |
| 1526 | || (keyboardPresence == PRESENCE_INTERNAL |
| 1527 | && isHidden(mLidKeyboardAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1528 | config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1529 | if (!mHasSoftInput) { |
| 1530 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; |
| 1531 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1532 | } |
| 1533 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1534 | if (config.navigation == Configuration.NAVIGATION_NONAV |
| 1535 | || (navigationPresence == PRESENCE_INTERNAL |
| 1536 | && isHidden(mLidNavigationAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1537 | config.navigationHidden = Configuration.NAVIGATIONHIDDEN_YES; |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1538 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1539 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1540 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1541 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1542 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1543 | public int windowTypeToLayerLw(int type) { |
| 1544 | if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1545 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1546 | } |
| 1547 | switch (type) { |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1548 | case TYPE_UNIVERSE_BACKGROUND: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1549 | return 1; |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1550 | case TYPE_PRIVATE_PRESENTATION: |
| 1551 | return 2; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1552 | case TYPE_WALLPAPER: |
| 1553 | // wallpaper is at the bottom, though the window manager may move it. |
| 1554 | return 2; |
| 1555 | case TYPE_PHONE: |
| 1556 | return 3; |
| 1557 | case TYPE_SEARCH_BAR: |
| 1558 | return 4; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1559 | case TYPE_VOICE_INTERACTION: |
| 1560 | // voice interaction layer is almost immediately above apps. |
| 1561 | return 5; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1562 | case TYPE_RECENTS_OVERLAY: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1563 | case TYPE_SYSTEM_DIALOG: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1564 | return 6; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1565 | case TYPE_TOAST: |
| 1566 | // toasts and the plugged-in battery thing |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1567 | return 7; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1568 | case TYPE_PRIORITY_PHONE: |
| 1569 | // 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] | 1570 | return 8; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1571 | case TYPE_DREAM: |
| 1572 | // used for Dreams (screensavers with TYPE_DREAM windows) |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1573 | return 9; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1574 | case TYPE_SYSTEM_ALERT: |
| 1575 | // like the ANR / app crashed dialogs |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1576 | return 10; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1577 | case TYPE_INPUT_METHOD: |
| 1578 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1579 | return 11; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1580 | case TYPE_INPUT_METHOD_DIALOG: |
| 1581 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1582 | return 12; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1583 | case TYPE_KEYGUARD_SCRIM: |
| 1584 | // the safety window that shows behind keyguard while keyguard is starting |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1585 | return 13; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1586 | case TYPE_STATUS_BAR_SUB_PANEL: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1587 | return 14; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1588 | case TYPE_STATUS_BAR: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1589 | return 15; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1590 | case TYPE_STATUS_BAR_PANEL: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1591 | return 16; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1592 | case TYPE_KEYGUARD_DIALOG: |
| 1593 | return 17; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1594 | case TYPE_VOLUME_OVERLAY: |
| 1595 | // the on-screen volume indicator and controller shown when the user |
| 1596 | // changes the device volume |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1597 | return 18; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1598 | case TYPE_SYSTEM_OVERLAY: |
| 1599 | // the on-screen volume indicator and controller shown when the user |
| 1600 | // changes the device volume |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1601 | return 19; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1602 | case TYPE_NAVIGATION_BAR: |
| 1603 | // the navigation bar, if available, shows atop most things |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1604 | return 20; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1605 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1606 | // 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] | 1607 | return 21; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1608 | case TYPE_SYSTEM_ERROR: |
| 1609 | // system-level error dialogs |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1610 | return 22; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1611 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1612 | // used to highlight the magnified portion of a display |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1613 | return 23; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1614 | case TYPE_DISPLAY_OVERLAY: |
| 1615 | // used to simulate secondary display devices |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1616 | return 24; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1617 | case TYPE_DRAG: |
| 1618 | // the drag layer: input for drag-and-drop is associated with this window, |
| 1619 | // which sits above all other focusable windows |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1620 | return 25; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1621 | case TYPE_SECURE_SYSTEM_OVERLAY: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1622 | return 26; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1623 | case TYPE_BOOT_PROGRESS: |
| 1624 | return 27; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1625 | case TYPE_POINTER: |
| 1626 | // the (mouse) pointer layer |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1627 | return 28; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1628 | case TYPE_HIDDEN_NAV_CONSUMER: |
| 1629 | return 29; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1630 | } |
| 1631 | Log.e(TAG, "Unknown window type: " + type); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1632 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1633 | } |
| 1634 | |
| 1635 | /** {@inheritDoc} */ |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1636 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1637 | public int subWindowTypeToLayerLw(int type) { |
| 1638 | switch (type) { |
| 1639 | case TYPE_APPLICATION_PANEL: |
| 1640 | case TYPE_APPLICATION_ATTACHED_DIALOG: |
| 1641 | return APPLICATION_PANEL_SUBLAYER; |
| 1642 | case TYPE_APPLICATION_MEDIA: |
| 1643 | return APPLICATION_MEDIA_SUBLAYER; |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 1644 | case TYPE_APPLICATION_MEDIA_OVERLAY: |
| 1645 | return APPLICATION_MEDIA_OVERLAY_SUBLAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1646 | case TYPE_APPLICATION_SUB_PANEL: |
| 1647 | return APPLICATION_SUB_PANEL_SUBLAYER; |
| 1648 | } |
| 1649 | Log.e(TAG, "Unknown sub-window type: " + type); |
| 1650 | return 0; |
| 1651 | } |
| 1652 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1653 | @Override |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1654 | public int getMaxWallpaperLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1655 | return windowTypeToLayerLw(TYPE_STATUS_BAR); |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1656 | } |
| 1657 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1658 | @Override |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1659 | public int getAboveUniverseLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1660 | return windowTypeToLayerLw(TYPE_SYSTEM_ERROR); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1661 | } |
| 1662 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1663 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1664 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1665 | if (mHasNavigationBar) { |
| 1666 | // For a basic navigation bar, when we are in landscape mode we place |
| 1667 | // the navigation bar to the side. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1668 | if (mNavigationBarCanMove && fullWidth > fullHeight) { |
| 1669 | return fullWidth - mNavigationBarWidthForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1670 | } |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1671 | } |
| 1672 | return fullWidth; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1673 | } |
| 1674 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1675 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1676 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1677 | if (mHasNavigationBar) { |
| 1678 | // For a basic navigation bar, when we are in portrait mode we place |
| 1679 | // the navigation bar to the bottom. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1680 | if (!mNavigationBarCanMove || fullWidth < fullHeight) { |
| 1681 | return fullHeight - mNavigationBarHeightForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1682 | } |
| 1683 | } |
| 1684 | return fullHeight; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1685 | } |
| 1686 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1687 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1688 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
| 1689 | return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1690 | } |
| 1691 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1692 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1693 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1694 | // There is a separate status bar at the top of the display. We don't count that as part |
| 1695 | // 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] | 1696 | // we do want to exclude it since applications can't generally use that part |
| 1697 | // of the screen. |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1698 | return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation) - mStatusBarHeight; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1699 | } |
| 1700 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1701 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 1702 | public boolean isForceHiding(WindowManager.LayoutParams attrs) { |
| 1703 | return (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 || |
Adrian Roos | 69e510d | 2014-07-13 14:57:59 +0200 | [diff] [blame^] | 1704 | (isKeyguardHostWindow(attrs) && isKeyguardSecureIncludingHidden()) || |
| 1705 | (attrs.type == TYPE_KEYGUARD_SCRIM); |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1706 | } |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1707 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1708 | @Override |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1709 | public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs) { |
| 1710 | return attrs.type == TYPE_STATUS_BAR; |
| 1711 | } |
| 1712 | |
| 1713 | @Override |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1714 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs) { |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1715 | switch (attrs.type) { |
| 1716 | case TYPE_STATUS_BAR: |
| 1717 | case TYPE_NAVIGATION_BAR: |
| 1718 | case TYPE_WALLPAPER: |
| 1719 | case TYPE_DREAM: |
| 1720 | case TYPE_UNIVERSE_BACKGROUND: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1721 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1722 | return false; |
| 1723 | default: |
| 1724 | return true; |
| 1725 | } |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1726 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1727 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1728 | /** {@inheritDoc} */ |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1729 | @Override |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1730 | public View addStartingWindow(IBinder appToken, String packageName, int theme, |
| 1731 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1732 | int icon, int logo, int windowFlags) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1733 | if (!SHOW_STARTING_ANIMATIONS) { |
| 1734 | return null; |
| 1735 | } |
| 1736 | if (packageName == null) { |
| 1737 | return null; |
| 1738 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1739 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1740 | WindowManager wm = null; |
| 1741 | View view = null; |
| 1742 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1743 | try { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1744 | Context context = mContext; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1745 | if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow " + packageName |
| 1746 | + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" |
| 1747 | + Integer.toHexString(theme)); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1748 | if (theme != context.getThemeResId() || labelRes != 0) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1749 | try { |
| 1750 | context = context.createPackageContext(packageName, 0); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1751 | context.setTheme(theme); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1752 | } catch (PackageManager.NameNotFoundException e) { |
| 1753 | // Ignore |
| 1754 | } |
| 1755 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1756 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1757 | Window win = PolicyManager.makeNewWindow(context); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1758 | final TypedArray ta = win.getWindowStyle(); |
| 1759 | if (ta.getBoolean( |
| 1760 | com.android.internal.R.styleable.Window_windowDisablePreview, false) |
| 1761 | || ta.getBoolean( |
| 1762 | com.android.internal.R.styleable.Window_windowShowWallpaper,false)) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1763 | return null; |
| 1764 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1765 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1766 | Resources r = context.getResources(); |
| 1767 | win.setTitle(r.getText(labelRes, nonLocalizedLabel)); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1768 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1769 | win.setType( |
| 1770 | WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); |
| 1771 | // Force the window flags: this is a fake window, so it is not really |
| 1772 | // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM |
| 1773 | // flag because we do know that the next window will take input |
| 1774 | // focus, so we want to get the IME window up on top of us right away. |
| 1775 | win.setFlags( |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1776 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1777 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1778 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1779 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1780 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1781 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1782 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1783 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1784 | |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1785 | win.setDefaultIcon(icon); |
| 1786 | win.setDefaultLogo(logo); |
| 1787 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1788 | win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1789 | WindowManager.LayoutParams.MATCH_PARENT); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1790 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1791 | final WindowManager.LayoutParams params = win.getAttributes(); |
| 1792 | params.token = appToken; |
| 1793 | params.packageName = packageName; |
| 1794 | params.windowAnimations = win.getWindowStyle().getResourceId( |
| 1795 | com.android.internal.R.styleable.Window_windowAnimationStyle, 0); |
Dianne Hackborn | 5d927c2 | 2011-09-02 12:22:18 -0700 | [diff] [blame] | 1796 | params.privateFlags |= |
| 1797 | WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1798 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1799 | |
| 1800 | if (!compatInfo.supportsScreen()) { |
| 1801 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; |
| 1802 | } |
| 1803 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1804 | params.setTitle("Starting " + packageName); |
| 1805 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1806 | wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
| 1807 | view = win.getDecorView(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1808 | |
| 1809 | if (win.isFloating()) { |
| 1810 | // Whoops, there is no way to display an animation/preview |
| 1811 | // of such a thing! After all that work... let's skip it. |
| 1812 | // (Note that we must do this here because it is in |
| 1813 | // getDecorView() where the theme is evaluated... maybe |
| 1814 | // we should peek the floating attribute from the theme |
| 1815 | // earlier.) |
| 1816 | return null; |
| 1817 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1818 | |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1819 | if (DEBUG_STARTING_WINDOW) Slog.d( |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1820 | TAG, "Adding starting window for " + packageName |
| 1821 | + " / " + appToken + ": " |
| 1822 | + (view.getParent() != null ? view : null)); |
| 1823 | |
| 1824 | wm.addView(view, params); |
| 1825 | |
| 1826 | // Only return the view if it was successfully added to the |
| 1827 | // window manager... which we can tell by it having a parent. |
| 1828 | return view.getParent() != null ? view : null; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1829 | } catch (WindowManager.BadTokenException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1830 | // ignore |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 1831 | Log.w(TAG, appToken + " already running, starting window not displayed. " + |
| 1832 | e.getMessage()); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1833 | } catch (RuntimeException e) { |
| 1834 | // don't crash if something else bad happens, for example a |
| 1835 | // failure loading resources because we are loading from an app |
| 1836 | // on external storage that has been unmounted. |
| 1837 | Log.w(TAG, appToken + " failed creating starting window", e); |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1838 | } finally { |
| 1839 | if (view != null && view.getParent() == null) { |
| 1840 | Log.w(TAG, "view not successfully added to wm, removing view"); |
| 1841 | wm.removeViewImmediate(view); |
| 1842 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1843 | } |
| 1844 | |
| 1845 | return null; |
| 1846 | } |
| 1847 | |
| 1848 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1849 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1850 | public void removeStartingWindow(IBinder appToken, View window) { |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1851 | if (DEBUG_STARTING_WINDOW) { |
| 1852 | RuntimeException e = new RuntimeException("here"); |
| 1853 | e.fillInStackTrace(); |
| 1854 | Log.v(TAG, "Removing starting window for " + appToken + ": " + window, e); |
| 1855 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1856 | |
| 1857 | if (window != null) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1858 | WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1859 | wm.removeView(window); |
| 1860 | } |
| 1861 | } |
| 1862 | |
| 1863 | /** |
| 1864 | * Preflight adding a window to the system. |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1865 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1866 | * Currently enforces that three window types are singletons: |
| 1867 | * <ul> |
| 1868 | * <li>STATUS_BAR_TYPE</li> |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1869 | * <li>KEYGUARD_TYPE</li> |
| 1870 | * </ul> |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1871 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1872 | * @param win The window to be added |
| 1873 | * @param attrs Information about the window to be added |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1874 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1875 | * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, |
| 1876 | * WindowManagerImpl.ADD_MULTIPLE_SINGLETON |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1877 | */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1878 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1879 | public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) { |
| 1880 | switch (attrs.type) { |
| 1881 | case TYPE_STATUS_BAR: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1882 | mContext.enforceCallingOrSelfPermission( |
| 1883 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1884 | "PhoneWindowManager"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1885 | if (mStatusBar != null) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1886 | if (mStatusBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1887 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1888 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1889 | } |
| 1890 | mStatusBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1891 | mStatusBarController.setWindow(win); |
John Spurlock | 8fdfe62 | 2014-05-21 17:10:10 -0400 | [diff] [blame] | 1892 | mKeyguardDelegate.hideScrim(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1893 | break; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1894 | case TYPE_NAVIGATION_BAR: |
| 1895 | mContext.enforceCallingOrSelfPermission( |
| 1896 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1897 | "PhoneWindowManager"); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1898 | if (mNavigationBar != null) { |
| 1899 | if (mNavigationBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1900 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1901 | } |
| 1902 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1903 | mNavigationBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1904 | mNavigationBarController.setWindow(win); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 1905 | if (DEBUG_LAYOUT) Slog.i(TAG, "NAVIGATION BAR: " + mNavigationBar); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1906 | break; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1907 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1908 | mContext.enforceCallingOrSelfPermission( |
| 1909 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1910 | "PhoneWindowManager"); |
| 1911 | break; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1912 | case TYPE_STATUS_BAR_PANEL: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1913 | mContext.enforceCallingOrSelfPermission( |
| 1914 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1915 | "PhoneWindowManager"); |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1916 | break; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1917 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1918 | mContext.enforceCallingOrSelfPermission( |
| 1919 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1920 | "PhoneWindowManager"); |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1921 | break; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1922 | case TYPE_KEYGUARD_SCRIM: |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1923 | if (mKeyguardScrim != null) { |
| 1924 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
| 1925 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1926 | mKeyguardScrim = win; |
| 1927 | break; |
| 1928 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1929 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1930 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1931 | } |
| 1932 | |
| 1933 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1934 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1935 | public void removeWindowLw(WindowState win) { |
| 1936 | if (mStatusBar == win) { |
| 1937 | mStatusBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1938 | mStatusBarController.setWindow(null); |
Jim Miller | c0b676d | 2013-03-22 16:11:08 -0700 | [diff] [blame] | 1939 | mKeyguardDelegate.showScrim(); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1940 | } else if (mKeyguardScrim == win) { |
| 1941 | Log.v(TAG, "Removing keyguard scrim"); |
| 1942 | mKeyguardScrim = null; |
| 1943 | } if (mNavigationBar == win) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1944 | mNavigationBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1945 | mNavigationBarController.setWindow(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1946 | } |
| 1947 | } |
| 1948 | |
| 1949 | static final boolean PRINT_ANIM = false; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1950 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1951 | /** {@inheritDoc} */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1952 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1953 | public int selectAnimationLw(WindowState win, int transit) { |
| 1954 | if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win |
| 1955 | + ": transit=" + transit); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1956 | if (win == mStatusBar) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1957 | boolean isKeyguard = (win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1958 | if (transit == TRANSIT_EXIT |
| 1959 | || transit == TRANSIT_HIDE) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1960 | return isKeyguard ? -1 : R.anim.dock_top_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1961 | } else if (transit == TRANSIT_ENTER |
| 1962 | || transit == TRANSIT_SHOW) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1963 | return isKeyguard ? -1 : R.anim.dock_top_enter; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1964 | } |
| 1965 | } else if (win == mNavigationBar) { |
| 1966 | // This can be on either the bottom or the right. |
| 1967 | if (mNavigationBarOnBottom) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1968 | if (transit == TRANSIT_EXIT |
| 1969 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1970 | return R.anim.dock_bottom_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1971 | } else if (transit == TRANSIT_ENTER |
| 1972 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1973 | return R.anim.dock_bottom_enter; |
| 1974 | } |
| 1975 | } else { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1976 | if (transit == TRANSIT_EXIT |
| 1977 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1978 | return R.anim.dock_right_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1979 | } else if (transit == TRANSIT_ENTER |
| 1980 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1981 | return R.anim.dock_right_enter; |
| 1982 | } |
| 1983 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1984 | } |
| 1985 | |
| 1986 | if (transit == TRANSIT_PREVIEW_DONE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1987 | if (win.hasAppShownWindows()) { |
| 1988 | if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT"); |
| 1989 | return com.android.internal.R.anim.app_starting_exit; |
| 1990 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 1991 | } else if (win.getAttrs().type == TYPE_DREAM && mDreamingLockscreen |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1992 | && transit == TRANSIT_ENTER) { |
| 1993 | // Special case: we are animating in a dream, while the keyguard |
| 1994 | // is shown. We don't want an animation on the dream, because |
| 1995 | // we need it shown immediately with the keyguard animating away |
| 1996 | // to reveal it. |
| 1997 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1998 | } |
| 1999 | |
| 2000 | return 0; |
| 2001 | } |
| 2002 | |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 2003 | @Override |
| 2004 | public void selectRotationAnimationLw(int anim[]) { |
| 2005 | if (PRINT_ANIM) Slog.i(TAG, "selectRotationAnimation mTopFullscreen=" |
| 2006 | + mTopFullscreenOpaqueWindowState + " rotationAnimation=" |
| 2007 | + (mTopFullscreenOpaqueWindowState == null ? |
| 2008 | "0" : mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation)); |
| 2009 | if (mTopFullscreenOpaqueWindowState != null && mTopIsFullscreen) { |
| 2010 | switch (mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation) { |
| 2011 | case ROTATION_ANIMATION_CROSSFADE: |
| 2012 | anim[0] = R.anim.rotation_animation_xfade_exit; |
| 2013 | anim[1] = R.anim.rotation_animation_enter; |
| 2014 | break; |
| 2015 | case ROTATION_ANIMATION_JUMPCUT: |
| 2016 | anim[0] = R.anim.rotation_animation_jump_exit; |
| 2017 | anim[1] = R.anim.rotation_animation_enter; |
| 2018 | break; |
| 2019 | case ROTATION_ANIMATION_ROTATE: |
| 2020 | default: |
| 2021 | anim[0] = anim[1] = 0; |
| 2022 | break; |
| 2023 | } |
| 2024 | } else { |
| 2025 | anim[0] = anim[1] = 0; |
| 2026 | } |
| 2027 | } |
| 2028 | |
| 2029 | @Override |
| 2030 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 2031 | boolean forceDefault) { |
| 2032 | switch (exitAnimId) { |
| 2033 | case R.anim.rotation_animation_xfade_exit: |
| 2034 | case R.anim.rotation_animation_jump_exit: |
| 2035 | // These are the only cases that matter. |
| 2036 | if (forceDefault) { |
| 2037 | return false; |
| 2038 | } |
| 2039 | int anim[] = new int[2]; |
| 2040 | selectRotationAnimationLw(anim); |
| 2041 | return (exitAnimId == anim[0] && enterAnimId == anim[1]); |
| 2042 | default: |
| 2043 | return true; |
| 2044 | } |
| 2045 | } |
| 2046 | |
| 2047 | @Override |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 2048 | public Animation createForceHideEnterAnimation(boolean onWallpaper) { |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 2049 | return AnimationUtils.loadAnimation(mContext, |
| 2050 | com.android.internal.R.anim.lock_screen_behind_enter); |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 2051 | } |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 2052 | |
| 2053 | private static void awakenDreams() { |
| 2054 | IDreamManager dreamManager = getDreamManager(); |
| 2055 | if (dreamManager != null) { |
| 2056 | try { |
| 2057 | dreamManager.awaken(); |
| 2058 | } catch (RemoteException e) { |
| 2059 | // fine, stay asleep then |
| 2060 | } |
| 2061 | } |
| 2062 | } |
| 2063 | |
| 2064 | static IDreamManager getDreamManager() { |
| 2065 | return IDreamManager.Stub.asInterface( |
| 2066 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
| 2067 | } |
| 2068 | |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2069 | TelecommManager getTelecommService() { |
| 2070 | return (TelecommManager) mContext.getSystemService(Context.TELECOMM_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2071 | } |
| 2072 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 2073 | static IAudioService getAudioService() { |
| 2074 | IAudioService audioService = IAudioService.Stub.asInterface( |
| 2075 | ServiceManager.checkService(Context.AUDIO_SERVICE)); |
| 2076 | if (audioService == null) { |
| 2077 | Log.w(TAG, "Unable to find IAudioService interface."); |
| 2078 | } |
| 2079 | return audioService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2080 | } |
| 2081 | |
| 2082 | boolean keyguardOn() { |
| 2083 | return keyguardIsShowingTq() || inKeyguardRestrictedKeyInputMode(); |
| 2084 | } |
| 2085 | |
| 2086 | private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { |
| 2087 | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, |
| 2088 | WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, |
| 2089 | }; |
| 2090 | |
| 2091 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2092 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2093 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2094 | final boolean keyguardOn = keyguardOn(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2095 | final int keyCode = event.getKeyCode(); |
| 2096 | final int repeatCount = event.getRepeatCount(); |
| 2097 | final int metaState = event.getMetaState(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2098 | final int flags = event.getFlags(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2099 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 2100 | final boolean canceled = event.isCanceled(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2101 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2102 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2103 | Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount=" |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2104 | + repeatCount + " keyguardOn=" + keyguardOn + " mHomePressed=" + mHomePressed |
| 2105 | + " canceled=" + canceled); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2106 | } |
| 2107 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2108 | // If we think we might have a volume down & power key chord on the way |
| 2109 | // but we're not sure, then tell the dispatcher to wait a little while and |
| 2110 | // try again later before dispatching. |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 2111 | if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2112 | if (mVolumeDownKeyTriggered && !mPowerKeyTriggered) { |
| 2113 | final long now = SystemClock.uptimeMillis(); |
| 2114 | final long timeoutTime = mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS; |
| 2115 | if (now < timeoutTime) { |
| 2116 | return timeoutTime - now; |
| 2117 | } |
| 2118 | } |
| 2119 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN |
| 2120 | && mVolumeDownKeyConsumedByScreenshotChord) { |
| 2121 | if (!down) { |
| 2122 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 2123 | } |
| 2124 | return -1; |
| 2125 | } |
| 2126 | } |
| 2127 | |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2128 | // Cancel any pending meta actions if we see any other keys being pressed between the down |
| 2129 | // of the meta key and its corresponding up. |
| 2130 | if (mPendingMetaAction && keyCode != KeyEvent.KEYCODE_META_LEFT) { |
| 2131 | mPendingMetaAction = false; |
| 2132 | } |
| 2133 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2134 | // First we always handle the home key here, so applications |
| 2135 | // can never break it, although if keyguard is on, we do let |
| 2136 | // it handle it, because that gives us the correct 5 second |
| 2137 | // timeout. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2138 | if (keyCode == KeyEvent.KEYCODE_HOME) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2139 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2140 | // If we have released the home key, and didn't do anything else |
| 2141 | // while it was pressed, then it is time to go home! |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2142 | if (!down) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2143 | cancelPreloadRecentApps(); |
| 2144 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2145 | mHomePressed = false; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2146 | if (mHomeConsumed) { |
| 2147 | mHomeConsumed = false; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2148 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2149 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2150 | |
| 2151 | if (canceled) { |
| 2152 | Log.i(TAG, "Ignoring HOME; event canceled."); |
| 2153 | return -1; |
| 2154 | } |
| 2155 | |
| 2156 | // If an incoming call is ringing, HOME is totally disabled. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2157 | // (The user is already on the InCallUI at this point, |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2158 | // and his ONLY options are to answer or reject the call.) |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2159 | TelecommManager telecommManager = getTelecommService(); |
| 2160 | if (telecommManager != null && telecommManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 2161 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); |
| 2162 | return -1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2163 | } |
| 2164 | |
| 2165 | // Delay handling home if a double-tap is possible. |
| 2166 | if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) { |
| 2167 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case |
| 2168 | mHomeDoubleTapPending = true; |
| 2169 | mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable, |
| 2170 | ViewConfiguration.getDoubleTapTimeout()); |
| 2171 | return -1; |
| 2172 | } |
| 2173 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2174 | // If there's a dream running then use home to escape the dream |
| 2175 | // but don't actually go home. |
| 2176 | if (mDreamManagerInternal != null && mDreamManagerInternal.isDreaming()) { |
| 2177 | mDreamManagerInternal.stopDream(); |
| 2178 | return -1; |
| 2179 | } |
| 2180 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2181 | // Go home! |
| 2182 | launchHomeFromHotKey(); |
| 2183 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2184 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2185 | |
| 2186 | // If a system window has focus, then it doesn't make sense |
| 2187 | // right now to interact with applications. |
| 2188 | WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null; |
| 2189 | if (attrs != null) { |
| 2190 | final int type = attrs.type; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2191 | if (type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM |
| 2192 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG |
| 2193 | || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2194 | // the "app" is keyguard, so give it the key |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2195 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2196 | } |
| 2197 | final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length; |
| 2198 | for (int i=0; i<typeCount; i++) { |
| 2199 | if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) { |
| 2200 | // 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] | 2201 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2202 | } |
| 2203 | } |
| 2204 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2205 | |
| 2206 | // Remember that home is pressed and handle special actions. |
| 2207 | if (repeatCount == 0) { |
| 2208 | mHomePressed = true; |
| 2209 | if (mHomeDoubleTapPending) { |
| 2210 | mHomeDoubleTapPending = false; |
| 2211 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); |
| 2212 | handleDoubleTapOnHome(); |
| 2213 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI |
| 2214 | || mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 2215 | preloadRecentApps(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2216 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2217 | } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { |
| 2218 | if (!keyguardOn) { |
| 2219 | handleLongPressOnHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2220 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2221 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2222 | return -1; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2223 | } else if (keyCode == KeyEvent.KEYCODE_MENU) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2224 | // Hijack modified menu keys for debugging features |
| 2225 | final int chordBug = KeyEvent.META_SHIFT_ON; |
| 2226 | |
| 2227 | if (down && repeatCount == 0) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2228 | if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2229 | Intent intent = new Intent(Intent.ACTION_BUG_REPORT); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2230 | mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, |
| 2231 | null, null, null, 0, null, null); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2232 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2233 | } else if (SHOW_PROCESSES_ON_ALT_MENU && |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2234 | (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2235 | Intent service = new Intent(); |
| 2236 | service.setClassName(mContext, "com.android.server.LoadAverageService"); |
| 2237 | ContentResolver res = mContext.getContentResolver(); |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2238 | boolean shown = Settings.Global.getInt( |
| 2239 | res, Settings.Global.SHOW_PROCESSES, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2240 | if (!shown) { |
| 2241 | mContext.startService(service); |
| 2242 | } else { |
| 2243 | mContext.stopService(service); |
| 2244 | } |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2245 | Settings.Global.putInt( |
| 2246 | res, Settings.Global.SHOW_PROCESSES, shown ? 0 : 1); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2247 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2248 | } |
| 2249 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2250 | } else if (keyCode == KeyEvent.KEYCODE_SEARCH) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2251 | if (down) { |
| 2252 | if (repeatCount == 0) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2253 | mSearchKeyShortcutPending = true; |
| 2254 | mConsumeSearchKeyUp = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2255 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2256 | } else { |
| 2257 | mSearchKeyShortcutPending = false; |
| 2258 | if (mConsumeSearchKeyUp) { |
| 2259 | mConsumeSearchKeyUp = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2260 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2261 | } |
| 2262 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2263 | return 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2264 | } else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) { |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2265 | if (!keyguardOn) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2266 | if (down && repeatCount == 0) { |
| 2267 | preloadRecentApps(); |
| 2268 | } else if (!down) { |
| 2269 | toggleRecentApps(); |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2270 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2271 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2272 | return -1; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2273 | } else if (keyCode == KeyEvent.KEYCODE_ASSIST) { |
| 2274 | if (down) { |
| 2275 | if (repeatCount == 0) { |
| 2276 | mAssistKeyLongPressed = false; |
| 2277 | } else if (repeatCount == 1) { |
| 2278 | mAssistKeyLongPressed = true; |
| 2279 | if (!keyguardOn) { |
| 2280 | launchAssistLongPressAction(); |
| 2281 | } |
| 2282 | } |
| 2283 | } else { |
| 2284 | if (mAssistKeyLongPressed) { |
| 2285 | mAssistKeyLongPressed = false; |
| 2286 | } else { |
| 2287 | if (!keyguardOn) { |
| 2288 | launchAssistAction(); |
| 2289 | } |
| 2290 | } |
| 2291 | } |
| 2292 | return -1; |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 2293 | } else if (keyCode == KeyEvent.KEYCODE_SYSRQ) { |
| 2294 | if (down && repeatCount == 0) { |
| 2295 | mHandler.post(mScreenshotRunnable); |
| 2296 | } |
| 2297 | return -1; |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 2298 | } else if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP |
| 2299 | || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) { |
| 2300 | if (down) { |
| 2301 | int direction = keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP ? 1 : -1; |
| 2302 | |
| 2303 | // Disable autobrightness if it's on |
| 2304 | int auto = Settings.System.getIntForUser( |
| 2305 | mContext.getContentResolver(), |
| 2306 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2307 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2308 | UserHandle.USER_CURRENT_OR_SELF); |
| 2309 | if (auto != 0) { |
| 2310 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2311 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2312 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2313 | UserHandle.USER_CURRENT_OR_SELF); |
| 2314 | } |
| 2315 | |
| 2316 | int min = mPowerManager.getMinimumScreenBrightnessSetting(); |
| 2317 | int max = mPowerManager.getMaximumScreenBrightnessSetting(); |
| 2318 | int step = (max - min + BRIGHTNESS_STEPS - 1) / BRIGHTNESS_STEPS * direction; |
| 2319 | int brightness = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 2320 | Settings.System.SCREEN_BRIGHTNESS, |
| 2321 | mPowerManager.getDefaultScreenBrightnessSetting(), |
| 2322 | UserHandle.USER_CURRENT_OR_SELF); |
| 2323 | brightness += step; |
| 2324 | // Make sure we don't go beyond the limits. |
| 2325 | brightness = Math.min(max, brightness); |
| 2326 | brightness = Math.max(min, brightness); |
| 2327 | |
| 2328 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2329 | Settings.System.SCREEN_BRIGHTNESS, brightness, |
| 2330 | UserHandle.USER_CURRENT_OR_SELF); |
| 2331 | Intent intent = new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG); |
| 2332 | mContext.sendBroadcastAsUser(intent, UserHandle.CURRENT_OR_SELF); |
| 2333 | } |
| 2334 | return -1; |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2335 | } else if (keyCode == KeyEvent.KEYCODE_META_LEFT) { |
| 2336 | if (down) { |
| 2337 | mPendingMetaAction = true; |
| 2338 | } else if (mPendingMetaAction) { |
| 2339 | mPendingMetaAction = false; |
| 2340 | launchAssistAction(); |
| 2341 | } |
| 2342 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2343 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2344 | |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2345 | // Shortcuts are invoked through Search+key, so intercept those here |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2346 | // Any printing key that is chorded with Search should be consumed |
| 2347 | // even if no shortcut was invoked. This prevents text from being |
| 2348 | // inadvertently inserted when using a keyboard that has built-in macro |
| 2349 | // 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] | 2350 | if (mSearchKeyShortcutPending) { |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2351 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
| 2352 | if (kcm.isPrintingKey(keyCode)) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2353 | mConsumeSearchKeyUp = true; |
| 2354 | mSearchKeyShortcutPending = false; |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2355 | if (down && repeatCount == 0 && !keyguardOn) { |
| 2356 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState); |
| 2357 | if (shortcutIntent != null) { |
| 2358 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2359 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2360 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2361 | } catch (ActivityNotFoundException ex) { |
| 2362 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2363 | + "the activity to which it is registered was not found: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2364 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode), ex); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2365 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2366 | } else { |
| 2367 | Slog.i(TAG, "Dropping unregistered shortcut key combination: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2368 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2369 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2370 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2371 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2372 | } |
| 2373 | } |
| 2374 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2375 | // Invoke shortcuts using Meta. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2376 | if (down && repeatCount == 0 && !keyguardOn |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2377 | && (metaState & KeyEvent.META_META_ON) != 0) { |
| 2378 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2379 | if (kcm.isPrintingKey(keyCode)) { |
| 2380 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, |
| 2381 | metaState & ~(KeyEvent.META_META_ON |
| 2382 | | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON)); |
| 2383 | if (shortcutIntent != null) { |
| 2384 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2385 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2386 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2387 | } catch (ActivityNotFoundException ex) { |
| 2388 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2389 | + "the activity to which it is registered was not found: " |
| 2390 | + "META+" + KeyEvent.keyCodeToString(keyCode), ex); |
| 2391 | } |
| 2392 | return -1; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2393 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2394 | } |
| 2395 | } |
| 2396 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2397 | // Handle application launch keys. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2398 | if (down && repeatCount == 0 && !keyguardOn) { |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2399 | String category = sApplicationLaunchKeyCategories.get(keyCode); |
| 2400 | if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 2401 | Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2402 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2403 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2404 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2405 | } catch (ActivityNotFoundException ex) { |
| 2406 | Slog.w(TAG, "Dropping application launch key because " |
| 2407 | + "the activity to which it is registered was not found: " |
| 2408 | + "keyCode=" + keyCode + ", category=" + category, ex); |
| 2409 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2410 | return -1; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2411 | } |
| 2412 | } |
| 2413 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2414 | // Display task switcher for ALT-TAB or Meta-TAB. |
| 2415 | if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2416 | if (mRecentAppsHeldModifiers == 0 && !keyguardOn) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2417 | final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK; |
Winson Chung | c6011de | 2014-06-30 18:04:55 -0700 | [diff] [blame] | 2418 | if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON)) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2419 | mRecentAppsHeldModifiers = shiftlessModifiers; |
| 2420 | showRecentApps(true); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2421 | return -1; |
| 2422 | } |
| 2423 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2424 | } else if (!down && mRecentAppsHeldModifiers != 0 |
| 2425 | && (metaState & mRecentAppsHeldModifiers) == 0) { |
| 2426 | mRecentAppsHeldModifiers = 0; |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 2427 | hideRecentApps(true); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2428 | } |
| 2429 | |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 2430 | // Handle keyboard language switching. |
| 2431 | if (down && repeatCount == 0 |
| 2432 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2433 | || (keyCode == KeyEvent.KEYCODE_SPACE |
| 2434 | && (metaState & KeyEvent.META_CTRL_MASK) != 0))) { |
| 2435 | int direction = (metaState & KeyEvent.META_SHIFT_MASK) != 0 ? -1 : 1; |
| 2436 | mWindowManagerFuncs.switchKeyboardLayout(event.getDeviceId(), direction); |
| 2437 | return -1; |
| 2438 | } |
| 2439 | if (mLanguageSwitchKeyPressed && !down |
| 2440 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2441 | || keyCode == KeyEvent.KEYCODE_SPACE)) { |
| 2442 | mLanguageSwitchKeyPressed = false; |
| 2443 | return -1; |
| 2444 | } |
| 2445 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 2446 | if (mGlobalKeyManager.handleGlobalKey(mContext, keyCode, event)) { |
| 2447 | return -1; |
| 2448 | } |
| 2449 | |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2450 | // Reserve all the META modifier combos for system behavior |
| 2451 | if ((metaState & KeyEvent.META_META_LEFT_ON) != 0) { |
| 2452 | return -1; |
| 2453 | } |
| 2454 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2455 | // Let the application handle the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2456 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2457 | } |
| 2458 | |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2459 | /** {@inheritDoc} */ |
| 2460 | @Override |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2461 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2462 | // Note: This method is only called if the initial down was unhandled. |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2463 | if (DEBUG_INPUT) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2464 | Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction() |
| 2465 | + ", flags=" + event.getFlags() |
| 2466 | + ", keyCode=" + event.getKeyCode() |
| 2467 | + ", scanCode=" + event.getScanCode() |
| 2468 | + ", metaState=" + event.getMetaState() |
| 2469 | + ", repeatCount=" + event.getRepeatCount() |
| 2470 | + ", policyFlags=" + policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2471 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2472 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2473 | KeyEvent fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2474 | if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 2475 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2476 | final int keyCode = event.getKeyCode(); |
| 2477 | final int metaState = event.getMetaState(); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2478 | final boolean initialDown = event.getAction() == KeyEvent.ACTION_DOWN |
| 2479 | && event.getRepeatCount() == 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2480 | |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2481 | // Check for fallback actions specified by the key character map. |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2482 | final FallbackAction fallbackAction; |
| 2483 | if (initialDown) { |
| 2484 | fallbackAction = kcm.getFallbackAction(keyCode, metaState); |
| 2485 | } else { |
| 2486 | fallbackAction = mFallbackActions.get(keyCode); |
| 2487 | } |
| 2488 | |
| 2489 | if (fallbackAction != null) { |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2490 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2491 | Slog.d(TAG, "Fallback: keyCode=" + fallbackAction.keyCode |
| 2492 | + " metaState=" + Integer.toHexString(fallbackAction.metaState)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2493 | } |
| 2494 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2495 | final int flags = event.getFlags() | KeyEvent.FLAG_FALLBACK; |
| 2496 | fallbackEvent = KeyEvent.obtain( |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2497 | event.getDownTime(), event.getEventTime(), |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2498 | event.getAction(), fallbackAction.keyCode, |
| 2499 | event.getRepeatCount(), fallbackAction.metaState, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2500 | event.getDeviceId(), event.getScanCode(), |
| 2501 | flags, event.getSource(), null); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2502 | |
| 2503 | if (!interceptFallback(win, fallbackEvent, policyFlags)) { |
| 2504 | fallbackEvent.recycle(); |
| 2505 | fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2506 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2507 | |
| 2508 | if (initialDown) { |
| 2509 | mFallbackActions.put(keyCode, fallbackAction); |
| 2510 | } else if (event.getAction() == KeyEvent.ACTION_UP) { |
| 2511 | mFallbackActions.remove(keyCode); |
| 2512 | fallbackAction.recycle(); |
| 2513 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2514 | } |
| 2515 | } |
| 2516 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2517 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2518 | if (fallbackEvent == null) { |
| 2519 | Slog.d(TAG, "No fallback."); |
| 2520 | } else { |
| 2521 | Slog.d(TAG, "Performing fallback: " + fallbackEvent); |
| 2522 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2523 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2524 | return fallbackEvent; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2525 | } |
| 2526 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2527 | private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2528 | int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2529 | if ((actions & ACTION_PASS_TO_USER) != 0) { |
| 2530 | long delayMillis = interceptKeyBeforeDispatching( |
| 2531 | win, fallbackEvent, policyFlags); |
| 2532 | if (delayMillis == 0) { |
| 2533 | return true; |
| 2534 | } |
| 2535 | } |
| 2536 | return false; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 2537 | } |
| 2538 | |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2539 | private void launchAssistLongPressAction() { |
| 2540 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 2541 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
| 2542 | |
| 2543 | // launch the search activity |
| 2544 | Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); |
| 2545 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2546 | try { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2547 | // TODO: This only stops the factory-installed search manager. |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2548 | // Need to formalize an API to handle others |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2549 | SearchManager searchManager = getSearchManager(); |
| 2550 | if (searchManager != null) { |
| 2551 | searchManager.stopSearch(); |
| 2552 | } |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2553 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2554 | } catch (ActivityNotFoundException e) { |
| 2555 | Slog.w(TAG, "No activity to handle assist long press action.", e); |
| 2556 | } |
| 2557 | } |
| 2558 | |
| 2559 | private void launchAssistAction() { |
| 2560 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 2561 | Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 2562 | .getAssistIntent(mContext, true, UserHandle.USER_CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2563 | if (intent != null) { |
| 2564 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 2565 | | Intent.FLAG_ACTIVITY_SINGLE_TOP |
| 2566 | | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 2567 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2568 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2569 | } catch (ActivityNotFoundException e) { |
| 2570 | Slog.w(TAG, "No activity to handle assist action.", e); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2571 | } |
| 2572 | } |
| 2573 | } |
| 2574 | |
| 2575 | private SearchManager getSearchManager() { |
| 2576 | if (mSearchManager == null) { |
| 2577 | mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); |
| 2578 | } |
| 2579 | return mSearchManager; |
| 2580 | } |
| 2581 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2582 | private void preloadRecentApps() { |
| 2583 | mPreloadedRecentApps = true; |
| 2584 | try { |
| 2585 | IStatusBarService statusbar = getStatusBarService(); |
| 2586 | if (statusbar != null) { |
| 2587 | statusbar.preloadRecentApps(); |
| 2588 | } |
| 2589 | } catch (RemoteException e) { |
| 2590 | Slog.e(TAG, "RemoteException when preloading recent apps", e); |
| 2591 | // re-acquire status bar service next time it is needed. |
| 2592 | mStatusBarService = null; |
| 2593 | } |
| 2594 | } |
| 2595 | |
| 2596 | private void cancelPreloadRecentApps() { |
| 2597 | if (mPreloadedRecentApps) { |
| 2598 | mPreloadedRecentApps = false; |
| 2599 | try { |
| 2600 | IStatusBarService statusbar = getStatusBarService(); |
| 2601 | if (statusbar != null) { |
| 2602 | statusbar.cancelPreloadRecentApps(); |
| 2603 | } |
| 2604 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2605 | Slog.e(TAG, "RemoteException when cancelling recent apps preload", e); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2606 | // re-acquire status bar service next time it is needed. |
| 2607 | mStatusBarService = null; |
| 2608 | } |
| 2609 | } |
| 2610 | } |
| 2611 | |
| 2612 | private void toggleRecentApps() { |
| 2613 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2614 | try { |
| 2615 | IStatusBarService statusbar = getStatusBarService(); |
| 2616 | if (statusbar != null) { |
| 2617 | statusbar.toggleRecentApps(); |
| 2618 | } |
| 2619 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2620 | Slog.e(TAG, "RemoteException when toggling recent apps", e); |
| 2621 | // re-acquire status bar service next time it is needed. |
| 2622 | mStatusBarService = null; |
| 2623 | } |
| 2624 | } |
| 2625 | |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 2626 | @Override |
| 2627 | public void showRecentApps() { |
| 2628 | mHandler.removeMessages(MSG_DISPATCH_SHOW_RECENTS); |
| 2629 | mHandler.sendEmptyMessage(MSG_DISPATCH_SHOW_RECENTS); |
| 2630 | } |
| 2631 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2632 | private void showRecentApps(boolean triggeredFromAltTab) { |
| 2633 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2634 | try { |
| 2635 | IStatusBarService statusbar = getStatusBarService(); |
| 2636 | if (statusbar != null) { |
| 2637 | statusbar.showRecentApps(triggeredFromAltTab); |
| 2638 | } |
| 2639 | } catch (RemoteException e) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2640 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
| 2641 | // re-acquire status bar service next time it is needed. |
| 2642 | mStatusBarService = null; |
| 2643 | } |
| 2644 | } |
| 2645 | |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 2646 | private void hideRecentApps(boolean triggeredFromAltTab) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2647 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2648 | try { |
| 2649 | IStatusBarService statusbar = getStatusBarService(); |
| 2650 | if (statusbar != null) { |
Winson Chung | 6cb485f | 2014-05-19 10:30:43 -0700 | [diff] [blame] | 2651 | statusbar.hideRecentApps(triggeredFromAltTab); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2652 | } |
| 2653 | } catch (RemoteException e) { |
| 2654 | Slog.e(TAG, "RemoteException when closing recent apps", e); |
| 2655 | // re-acquire status bar service next time it is needed. |
| 2656 | mStatusBarService = null; |
| 2657 | } |
| 2658 | } |
| 2659 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2660 | /** |
| 2661 | * A home key -> launch home action was detected. Take the appropriate action |
| 2662 | * given the situation with the keyguard. |
| 2663 | */ |
| 2664 | void launchHomeFromHotKey() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2665 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowingAndNotOccluded()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2666 | // don't launch home if keyguard showing |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2667 | } else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2668 | // when in keyguard restricted mode, must first verify unlock |
| 2669 | // before launching home |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2670 | mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() { |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2671 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2672 | public void onKeyguardExitResult(boolean success) { |
| 2673 | if (success) { |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2674 | try { |
| 2675 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2676 | } catch (RemoteException e) { |
| 2677 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2678 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2679 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2680 | } |
| 2681 | } |
| 2682 | }); |
| 2683 | } else { |
| 2684 | // no keyguard stuff to worry about, just launch home! |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2685 | try { |
| 2686 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2687 | } catch (RemoteException e) { |
| 2688 | } |
Winson Chung | d543c1b | 2014-06-23 15:06:45 -0700 | [diff] [blame] | 2689 | if (mRecentsVisible) { |
| 2690 | // Hide Recents and notify it to launch Home |
| 2691 | awakenDreams(); |
| 2692 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
| 2693 | hideRecentApps(false); |
| 2694 | } else { |
| 2695 | // Otherwise, just launch Home |
| 2696 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
| 2697 | startDockOrHome(); |
| 2698 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2699 | } |
| 2700 | } |
| 2701 | |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2702 | private final Runnable mClearHideNavigationFlag = new Runnable() { |
| 2703 | @Override |
| 2704 | public void run() { |
| 2705 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
| 2706 | // Clear flags. |
| 2707 | mForceClearedSystemUiFlags &= |
| 2708 | ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 2709 | } |
| 2710 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2711 | } |
| 2712 | }; |
| 2713 | |
| 2714 | /** |
| 2715 | * Input handler used while nav bar is hidden. Captures any touch on the screen, |
| 2716 | * to determine when the nav bar should be shown and prevent applications from |
| 2717 | * receiving those touches. |
| 2718 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2719 | final class HideNavInputEventReceiver extends InputEventReceiver { |
| 2720 | public HideNavInputEventReceiver(InputChannel inputChannel, Looper looper) { |
| 2721 | super(inputChannel, looper); |
| 2722 | } |
| 2723 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2724 | @Override |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2725 | public void onInputEvent(InputEvent event) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2726 | boolean handled = false; |
| 2727 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 2728 | if (event instanceof MotionEvent |
| 2729 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 2730 | final MotionEvent motionEvent = (MotionEvent)event; |
| 2731 | if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2732 | // When the user taps down, we re-show the nav bar. |
| 2733 | boolean changed = false; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2734 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2735 | // Any user activity always causes us to show the |
| 2736 | // navigation controls, if they had been hidden. |
| 2737 | // We also clear the low profile and only content |
| 2738 | // flags so that tapping on the screen will atomically |
| 2739 | // restore all currently hidden screen decorations. |
| 2740 | int newVal = mResettingSystemUiFlags | |
| 2741 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| 2742 | View.SYSTEM_UI_FLAG_LOW_PROFILE | |
| 2743 | View.SYSTEM_UI_FLAG_FULLSCREEN; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2744 | if (mResettingSystemUiFlags != newVal) { |
| 2745 | mResettingSystemUiFlags = newVal; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2746 | changed = true; |
| 2747 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2748 | // We don't allow the system's nav bar to be hidden |
| 2749 | // again for 1 second, to prevent applications from |
| 2750 | // spamming us and keeping it from being shown. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2751 | newVal = mForceClearedSystemUiFlags | |
| 2752 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2753 | if (mForceClearedSystemUiFlags != newVal) { |
| 2754 | mForceClearedSystemUiFlags = newVal; |
| 2755 | changed = true; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2756 | mHandler.postDelayed(mClearHideNavigationFlag, 1000); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2757 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2758 | } |
| 2759 | if (changed) { |
| 2760 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 2761 | } |
| 2762 | } |
| 2763 | } |
| 2764 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2765 | finishInputEvent(event, handled); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2766 | } |
| 2767 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2768 | } |
| 2769 | final InputEventReceiver.Factory mHideNavInputEventReceiverFactory = |
| 2770 | new InputEventReceiver.Factory() { |
| 2771 | @Override |
| 2772 | public InputEventReceiver createInputEventReceiver( |
| 2773 | InputChannel inputChannel, Looper looper) { |
| 2774 | return new HideNavInputEventReceiver(inputChannel, looper); |
| 2775 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2776 | }; |
| 2777 | |
| 2778 | @Override |
| 2779 | public int adjustSystemUiVisibilityLw(int visibility) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2780 | mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
| 2781 | mNavigationBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 2782 | mRecentsVisible = (visibility & View.RECENT_APPS_VISIBLE) > 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2783 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2784 | // Reset any bits in mForceClearingStatusBarVisibility that |
| 2785 | // are now clear. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2786 | mResettingSystemUiFlags &= visibility; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2787 | // Clear any bits in the new visibility that are currently being |
| 2788 | // force cleared, before reporting it. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2789 | return visibility & ~mResettingSystemUiFlags |
| 2790 | & ~mForceClearedSystemUiFlags; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2791 | } |
| 2792 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2793 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2794 | public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 2795 | final int fl = PolicyControl.getWindowFlags(null, attrs); |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 2796 | final int sysuiVis = PolicyControl.getSystemUiVisibility(null, attrs); |
| 2797 | final int systemUiVisibility = (sysuiVis | attrs.subtreeSystemUiVisibility); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2798 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2799 | 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] | 2800 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2801 | int availRight, availBottom; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 2802 | if (canHideNavigationBar() && |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2803 | (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2804 | availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 2805 | availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
| 2806 | } else { |
| 2807 | availRight = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 2808 | availBottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
| 2809 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2810 | if ((systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2811 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 2812 | contentInset.set(mStableFullscreenLeft, mStableFullscreenTop, |
| 2813 | availRight - mStableFullscreenRight, |
| 2814 | availBottom - mStableFullscreenBottom); |
| 2815 | } else { |
| 2816 | contentInset.set(mStableLeft, mStableTop, |
| 2817 | availRight - mStableRight, availBottom - mStableBottom); |
| 2818 | } |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2819 | } else if ((fl & FLAG_FULLSCREEN) != 0 || (fl & FLAG_LAYOUT_IN_OVERSCAN) != 0) { |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2820 | contentInset.setEmpty(); |
| 2821 | } else if ((systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2822 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) { |
| 2823 | contentInset.set(mCurLeft, mCurTop, |
| 2824 | availRight - mCurRight, availBottom - mCurBottom); |
| 2825 | } else { |
| 2826 | contentInset.set(mCurLeft, mCurTop, |
| 2827 | availRight - mCurRight, availBottom - mCurBottom); |
| 2828 | } |
| 2829 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2830 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2831 | contentInset.setEmpty(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2832 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2833 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2834 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2835 | @Override |
| 2836 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
| 2837 | int displayRotation) { |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2838 | final int overscanLeft, overscanTop, overscanRight, overscanBottom; |
| 2839 | if (isDefaultDisplay) { |
| 2840 | switch (displayRotation) { |
| 2841 | case Surface.ROTATION_90: |
| 2842 | overscanLeft = mOverscanTop; |
| 2843 | overscanTop = mOverscanRight; |
| 2844 | overscanRight = mOverscanBottom; |
| 2845 | overscanBottom = mOverscanLeft; |
| 2846 | break; |
| 2847 | case Surface.ROTATION_180: |
| 2848 | overscanLeft = mOverscanRight; |
| 2849 | overscanTop = mOverscanBottom; |
| 2850 | overscanRight = mOverscanLeft; |
| 2851 | overscanBottom = mOverscanTop; |
| 2852 | break; |
| 2853 | case Surface.ROTATION_270: |
| 2854 | overscanLeft = mOverscanBottom; |
| 2855 | overscanTop = mOverscanLeft; |
| 2856 | overscanRight = mOverscanTop; |
| 2857 | overscanBottom = mOverscanRight; |
| 2858 | break; |
| 2859 | default: |
| 2860 | overscanLeft = mOverscanLeft; |
| 2861 | overscanTop = mOverscanTop; |
| 2862 | overscanRight = mOverscanRight; |
| 2863 | overscanBottom = mOverscanBottom; |
| 2864 | break; |
| 2865 | } |
| 2866 | } else { |
| 2867 | overscanLeft = 0; |
| 2868 | overscanTop = 0; |
| 2869 | overscanRight = 0; |
| 2870 | overscanBottom = 0; |
| 2871 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2872 | mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0; |
| 2873 | mOverscanScreenTop = mRestrictedOverscanScreenTop = 0; |
| 2874 | mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth; |
| 2875 | mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2876 | mSystemLeft = 0; |
| 2877 | mSystemTop = 0; |
| 2878 | mSystemRight = displayWidth; |
| 2879 | mSystemBottom = displayHeight; |
| 2880 | mUnrestrictedScreenLeft = overscanLeft; |
| 2881 | mUnrestrictedScreenTop = overscanTop; |
| 2882 | mUnrestrictedScreenWidth = displayWidth - overscanLeft - overscanRight; |
| 2883 | mUnrestrictedScreenHeight = displayHeight - overscanTop - overscanBottom; |
| 2884 | mRestrictedScreenLeft = mUnrestrictedScreenLeft; |
| 2885 | mRestrictedScreenTop = mUnrestrictedScreenTop; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2886 | mRestrictedScreenWidth = mSystemGestures.screenWidth = mUnrestrictedScreenWidth; |
| 2887 | mRestrictedScreenHeight = mSystemGestures.screenHeight = mUnrestrictedScreenHeight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2888 | mDockLeft = mContentLeft = mVoiceContentLeft = mStableLeft = mStableFullscreenLeft |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2889 | = mCurLeft = mUnrestrictedScreenLeft; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2890 | mDockTop = mContentTop = mVoiceContentTop = mStableTop = mStableFullscreenTop |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2891 | = mCurTop = mUnrestrictedScreenTop; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2892 | mDockRight = mContentRight = mVoiceContentRight = mStableRight = mStableFullscreenRight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2893 | = mCurRight = displayWidth - overscanRight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2894 | mDockBottom = mContentBottom = mVoiceContentBottom = mStableBottom = mStableFullscreenBottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2895 | = mCurBottom = displayHeight - overscanBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2896 | mDockLayer = 0x10000000; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 2897 | mStatusBarLayer = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2898 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2899 | // start with the current dock rect, which will be (0,0,displayWidth,displayHeight) |
| 2900 | final Rect pf = mTmpParentFrame; |
| 2901 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2902 | final Rect of = mTmpOverscanFrame; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2903 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2904 | final Rect dcf = mTmpDecorFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2905 | pf.left = df.left = of.left = vf.left = mDockLeft; |
| 2906 | pf.top = df.top = of.top = vf.top = mDockTop; |
| 2907 | pf.right = df.right = of.right = vf.right = mDockRight; |
| 2908 | pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2909 | dcf.setEmpty(); // Decor frame N/A for system bars. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2910 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2911 | if (isDefaultDisplay) { |
| 2912 | // For purposes of putting out fake window up to steal focus, we will |
| 2913 | // drive nav being hidden only by whether it is requested. |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2914 | final int sysui = mLastSystemUiFlags; |
| 2915 | boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 2916 | boolean navTranslucent = (sysui |
| 2917 | & (View.NAVIGATION_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 2918 | boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0; |
| 2919 | boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
| 2920 | boolean navAllowedHidden = immersive || immersiveSticky; |
| 2921 | navTranslucent &= !immersiveSticky; // transient trumps translucent |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 2922 | navTranslucent &= areTranslucentBarsAllowed(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2923 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2924 | // When the navigation bar isn't visible, we put up a fake |
| 2925 | // input window to catch all touch events. This way we can |
| 2926 | // detect when the user presses anywhere to bring back the nav |
| 2927 | // bar and ensure the application doesn't see the event. |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 2928 | if (navVisible || navAllowedHidden) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2929 | if (mHideNavFakeWindow != null) { |
| 2930 | mHideNavFakeWindow.dismiss(); |
| 2931 | mHideNavFakeWindow = null; |
| 2932 | } |
| 2933 | } else if (mHideNavFakeWindow == null) { |
| 2934 | mHideNavFakeWindow = mWindowManagerFuncs.addFakeWindow( |
| 2935 | mHandler.getLooper(), mHideNavInputEventReceiverFactory, |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 2936 | "hidden nav", WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER, 0, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2937 | 0, false, false, true); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2938 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2939 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2940 | // For purposes of positioning and showing the nav bar, if we have |
| 2941 | // decided that it can't be hidden (because of the screen aspect ratio), |
| 2942 | // then take that into account. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 2943 | navVisible |= !canHideNavigationBar(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2944 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2945 | boolean updateSysUiVisibility = false; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2946 | if (mNavigationBar != null) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2947 | boolean transientNavBarShowing = mNavigationBarController.isTransientShowing(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2948 | // Force the navigation bar to its appropriate place and |
| 2949 | // size. We need to do this directly, instead of relying on |
| 2950 | // it to bubble up from the nav bar, because this needs to |
| 2951 | // change atomically with screen rotations. |
| 2952 | mNavigationBarOnBottom = (!mNavigationBarCanMove || displayWidth < displayHeight); |
| 2953 | if (mNavigationBarOnBottom) { |
| 2954 | // 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] | 2955 | int top = displayHeight - overscanBottom |
| 2956 | - mNavigationBarHeightForRotation[displayRotation]; |
| 2957 | mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2958 | mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 2959 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2960 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2961 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2962 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2963 | mDockBottom = mTmpNavigationFrame.top; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2964 | mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop; |
| 2965 | mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2966 | } else { |
| 2967 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2968 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2969 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 2970 | if (navVisible && !navTranslucent && !navAllowedHidden |
| 2971 | && !mNavigationBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2972 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2973 | // If the opaque nav bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2974 | // and not in the process of animating on or off, then |
| 2975 | // we can tell the app that it is covered by it. |
| 2976 | mSystemBottom = mTmpNavigationFrame.top; |
| 2977 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2978 | } else { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2979 | // Landscape screen; nav bar goes to the right. |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2980 | int left = displayWidth - overscanRight |
| 2981 | - mNavigationBarWidthForRotation[displayRotation]; |
| 2982 | mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2983 | mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 2984 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2985 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2986 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2987 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2988 | mDockRight = mTmpNavigationFrame.left; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2989 | mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft; |
| 2990 | mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2991 | } else { |
| 2992 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2993 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2994 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2995 | if (navVisible && !navTranslucent && !mNavigationBar.isAnimatingLw() |
| 2996 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2997 | // If the nav bar is currently requested to be visible, |
| 2998 | // and not in the process of animating on or off, then |
| 2999 | // we can tell the app that it is covered by it. |
| 3000 | mSystemRight = mTmpNavigationFrame.left; |
| 3001 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3002 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3003 | // Make sure the content and current rectangles are updated to |
| 3004 | // account for the restrictions from the navigation bar. |
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 | mStatusBarLayer = mNavigationBar.getSurfaceLayer(); |
| 3010 | // And compute the final frame. |
| 3011 | mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3012 | mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf, |
| 3013 | mTmpNavigationFrame); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3014 | if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3015 | if (mNavigationBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3016 | updateSysUiVisibility = true; |
| 3017 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3018 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3019 | 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] | 3020 | mDockLeft, mDockTop, mDockRight, mDockBottom)); |
| 3021 | |
| 3022 | // decide where the status bar goes ahead of time |
| 3023 | if (mStatusBar != null) { |
| 3024 | // apply any navigation bar insets |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3025 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3026 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3027 | pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft; |
| 3028 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight |
| 3029 | + mUnrestrictedScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3030 | vf.left = mStableLeft; |
| 3031 | vf.top = mStableTop; |
| 3032 | vf.right = mStableRight; |
| 3033 | vf.bottom = mStableBottom; |
| 3034 | |
| 3035 | mStatusBarLayer = mStatusBar.getSurfaceLayer(); |
| 3036 | |
| 3037 | // Let the status bar determine its size. |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3038 | mStatusBar.computeFrameLw(pf, df, vf, vf, vf, dcf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3039 | |
| 3040 | // For layout, the status bar is always at the top with our fixed height. |
| 3041 | mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3042 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3043 | boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3044 | boolean statusBarTranslucent = (sysui |
| 3045 | & (View.STATUS_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 3046 | statusBarTranslucent &= areTranslucentBarsAllowed(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3047 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3048 | // If the status bar is hidden, we don't want to cause |
| 3049 | // windows behind it to scroll. |
John Spurlock | eda1f69 | 2013-09-16 11:38:44 -0400 | [diff] [blame] | 3050 | if (mStatusBar.isVisibleLw() && !statusBarTransient) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3051 | // Status bar may go away, so the screen area it occupies |
| 3052 | // is available to apps but just covering them when the |
| 3053 | // status bar is visible. |
| 3054 | mDockTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3055 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3056 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 3057 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 3058 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 3059 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3060 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3061 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar: " + |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3062 | String.format( |
| 3063 | "dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]", |
| 3064 | mDockLeft, mDockTop, mDockRight, mDockBottom, |
| 3065 | mContentLeft, mContentTop, mContentRight, mContentBottom, |
| 3066 | mCurLeft, mCurTop, mCurRight, mCurBottom)); |
| 3067 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3068 | if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3069 | && !statusBarTransient && !statusBarTranslucent |
| 3070 | && !mStatusBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3071 | // If the opaque status bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3072 | // and not in the process of animating on or off, then |
| 3073 | // we can tell the app that it is covered by it. |
| 3074 | mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3075 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3076 | if (mStatusBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3077 | updateSysUiVisibility = true; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3078 | } |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 3079 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3080 | if (updateSysUiVisibility) { |
| 3081 | updateSystemUiVisibilityLw(); |
| 3082 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3083 | } |
| 3084 | } |
| 3085 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 3086 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 3087 | @Override |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3088 | public int getSystemDecorLayerLw() { |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 3089 | if (mStatusBar != null) return mStatusBar.getSurfaceLayer(); |
| 3090 | if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer(); |
| 3091 | return 0; |
| 3092 | } |
| 3093 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 3094 | @Override |
| 3095 | public void getContentRectLw(Rect r) { |
| 3096 | r.set(mContentLeft, mContentTop, mContentRight, mContentBottom); |
| 3097 | } |
| 3098 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3099 | void setAttachedWindowFrames(WindowState win, int fl, int adjust, WindowState attached, |
| 3100 | 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] | 3101 | if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) { |
| 3102 | // Here's a special case: if this attached window is a panel that is |
| 3103 | // above the dock window, and the window it is attached to is below |
| 3104 | // the dock window, then the frames we computed for the window it is |
| 3105 | // attached to can not be used because the dock is effectively part |
| 3106 | // of the underlying window and the attached window is floating on top |
| 3107 | // of the whole thing. So, we ignore the attached window and explicitly |
| 3108 | // compute the frames that would be appropriate without the dock. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3109 | df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3110 | df.top = of.top = cf.top = vf.top = mDockTop; |
| 3111 | df.right = of.right = cf.right = vf.right = mDockRight; |
| 3112 | df.bottom = of.bottom = cf.bottom = vf.bottom = mDockBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3113 | } else { |
| 3114 | // The effective display frame of the attached window depends on |
| 3115 | // whether it is taking care of insetting its content. If not, |
| 3116 | // we need to use the parent's content frame so that the entire |
| 3117 | // window is positioned within that content. Otherwise we can use |
| 3118 | // the display frame and let the attached window take care of |
| 3119 | // positioning its content appropriately. |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3120 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3121 | cf.set(attached.getOverscanFrameLw()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3122 | } else { |
| 3123 | // If the window is resizing, then we want to base the content |
| 3124 | // frame on our attached content frame to resize... however, |
| 3125 | // things can be tricky if the attached window is NOT in resize |
| 3126 | // mode, in which case its content frame will be larger. |
| 3127 | // Ungh. So to deal with that, make sure the content frame |
| 3128 | // we end up using is not covering the IM dock. |
| 3129 | cf.set(attached.getContentFrameLw()); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3130 | if (attached.isVoiceInteraction()) { |
| 3131 | if (cf.left < mVoiceContentLeft) cf.left = mVoiceContentLeft; |
| 3132 | if (cf.top < mVoiceContentTop) cf.top = mVoiceContentTop; |
| 3133 | if (cf.right > mVoiceContentRight) cf.right = mVoiceContentRight; |
| 3134 | if (cf.bottom > mVoiceContentBottom) cf.bottom = mVoiceContentBottom; |
| 3135 | } else if (attached.getSurfaceLayer() < mDockLayer) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3136 | if (cf.left < mContentLeft) cf.left = mContentLeft; |
| 3137 | if (cf.top < mContentTop) cf.top = mContentTop; |
| 3138 | if (cf.right > mContentRight) cf.right = mContentRight; |
| 3139 | if (cf.bottom > mContentBottom) cf.bottom = mContentBottom; |
| 3140 | } |
| 3141 | } |
| 3142 | df.set(insetDecors ? attached.getDisplayFrameLw() : cf); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3143 | of.set(insetDecors ? attached.getOverscanFrameLw() : cf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3144 | vf.set(attached.getVisibleFrameLw()); |
| 3145 | } |
| 3146 | // The LAYOUT_IN_SCREEN flag is used to determine whether the attached |
| 3147 | // window should be positioned relative to its parent or the entire |
| 3148 | // screen. |
| 3149 | pf.set((fl & FLAG_LAYOUT_IN_SCREEN) == 0 |
| 3150 | ? attached.getFrameLw() : df); |
| 3151 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3152 | |
| 3153 | private void applyStableConstraints(int sysui, int fl, Rect r) { |
| 3154 | if ((sysui & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 3155 | // If app is requesting a stable layout, don't let the |
| 3156 | // content insets go below the stable values. |
| 3157 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 3158 | if (r.left < mStableFullscreenLeft) r.left = mStableFullscreenLeft; |
| 3159 | if (r.top < mStableFullscreenTop) r.top = mStableFullscreenTop; |
| 3160 | if (r.right > mStableFullscreenRight) r.right = mStableFullscreenRight; |
| 3161 | if (r.bottom > mStableFullscreenBottom) r.bottom = mStableFullscreenBottom; |
| 3162 | } else { |
| 3163 | if (r.left < mStableLeft) r.left = mStableLeft; |
| 3164 | if (r.top < mStableTop) r.top = mStableTop; |
| 3165 | if (r.right > mStableRight) r.right = mStableRight; |
| 3166 | if (r.bottom > mStableBottom) r.bottom = mStableBottom; |
| 3167 | } |
| 3168 | } |
| 3169 | } |
| 3170 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3171 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3172 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3173 | public void layoutWindowLw(WindowState win, WindowState attached) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3174 | // we've already done the status bar |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3175 | final WindowManager.LayoutParams attrs = win.getAttrs(); |
| 3176 | if ((win == mStatusBar && (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) == 0) || |
| 3177 | win == mNavigationBar) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3178 | return; |
| 3179 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3180 | final boolean isDefaultDisplay = win.isDefaultDisplay(); |
| 3181 | final boolean needsToOffsetInputMethodTarget = isDefaultDisplay && |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3182 | (win == mLastInputMethodTargetWindow && mLastInputMethodWindow != null); |
| 3183 | if (needsToOffsetInputMethodTarget) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3184 | 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] | 3185 | offsetInputMethodWindowLw(mLastInputMethodWindow); |
| 3186 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3187 | |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3188 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3189 | final int sim = attrs.softInputMode; |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 3190 | final int sysUiFl = PolicyControl.getSystemUiVisibility(win, null); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3191 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3192 | final Rect pf = mTmpParentFrame; |
| 3193 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3194 | final Rect of = mTmpOverscanFrame; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3195 | final Rect cf = mTmpContentFrame; |
| 3196 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3197 | final Rect dcf = mTmpDecorFrame; |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3198 | final Rect sf = mTmpStableFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3199 | dcf.setEmpty(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3200 | |
| 3201 | final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3202 | && mNavigationBar != null && mNavigationBar.isVisibleLw()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3203 | |
Craig Mautner | f683b56 | 2012-10-02 11:10:57 -0700 | [diff] [blame] | 3204 | final int adjust = sim & SOFT_INPUT_MASK_ADJUST; |
| 3205 | |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3206 | if (isDefaultDisplay) { |
| 3207 | sf.set(mStableLeft, mStableTop, mStableRight, mStableBottom); |
| 3208 | } else { |
| 3209 | sf.set(mOverscanLeft, mOverscanTop, mOverscanRight, mOverscanBottom); |
| 3210 | } |
| 3211 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3212 | if (!isDefaultDisplay) { |
| 3213 | if (attached != null) { |
| 3214 | // If this window is attached to another, our display |
| 3215 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3216 | setAttachedWindowFrames(win, fl, adjust, attached, true, pf, df, of, cf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3217 | } else { |
| 3218 | // Give the window full screen. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3219 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3220 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3221 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3222 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3223 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3224 | = mOverscanScreenTop + mOverscanScreenHeight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3225 | } |
| 3226 | } else if (attrs.type == TYPE_INPUT_METHOD) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3227 | pf.left = df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3228 | pf.top = df.top = of.top = cf.top = vf.top = mDockTop; |
| 3229 | pf.right = df.right = of.right = cf.right = vf.right = mDockRight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3230 | // IM dock windows layout below the nav bar... |
John Spurlock | 57beb3b | 2013-10-10 10:27:44 -0400 | [diff] [blame] | 3231 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3232 | // ...with content insets above the nav bar |
| 3233 | cf.bottom = vf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3234 | // IM dock windows always go to the bottom of the screen. |
| 3235 | attrs.gravity = Gravity.BOTTOM; |
| 3236 | mDockLayer = win.getSurfaceLayer(); |
| 3237 | } else { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3238 | |
| 3239 | // Default policy decor for the default display |
| 3240 | dcf.left = mSystemLeft; |
| 3241 | dcf.top = mSystemTop; |
| 3242 | dcf.right = mSystemRight; |
| 3243 | dcf.bottom = mSystemBottom; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3244 | final boolean inheritTranslucentDecor = (attrs.privateFlags |
| 3245 | & WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR) != 0; |
John Spurlock | 65567d4 | 2013-10-08 10:08:32 -0400 | [diff] [blame] | 3246 | final boolean isAppWindow = |
| 3247 | attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW && |
| 3248 | attrs.type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 3249 | final boolean topAtRest = |
| 3250 | win == mTopFullscreenOpaqueWindowState && !win.isAnimatingLw(); |
| 3251 | if (isAppWindow && !inheritTranslucentDecor && !topAtRest) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3252 | if ((sysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 |
| 3253 | && (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3254 | && (fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == 0 |
| 3255 | && (fl & WindowManager.LayoutParams. |
| 3256 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3257 | // Ensure policy decor includes status bar |
| 3258 | dcf.top = mStableTop; |
| 3259 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3260 | if ((fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3261 | && (sysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0 |
| 3262 | && (fl & WindowManager.LayoutParams. |
| 3263 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3264 | // Ensure policy decor includes navigation bar |
| 3265 | dcf.bottom = mStableBottom; |
| 3266 | dcf.right = mStableRight; |
| 3267 | } |
| 3268 | } |
| 3269 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3270 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) |
| 3271 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3272 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3273 | + "): IN_SCREEN, INSET_DECOR"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3274 | // This is the case for a normal activity window: we want it |
| 3275 | // to cover all of the screen space, and it can take care of |
| 3276 | // moving its contents to account for screen decorations that |
| 3277 | // intrude into that space. |
| 3278 | if (attached != null) { |
| 3279 | // If this window is attached to another, our display |
| 3280 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3281 | 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] | 3282 | } else { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3283 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3284 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3285 | // Status bar panels are the only windows who can go on top of |
| 3286 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3287 | // permission, so they have the same privileges as the status |
| 3288 | // bar itself. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3289 | // |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3290 | // However, they should still dodge the navigation bar if it exists. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3291 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3292 | pf.left = df.left = of.left = hasNavBar |
| 3293 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3294 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3295 | pf.right = df.right = of.right = hasNavBar |
| 3296 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
| 3297 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3298 | pf.bottom = df.bottom = of.bottom = hasNavBar |
| 3299 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
| 3300 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3301 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3302 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3303 | "Laying out status bar window: (%d,%d - %d,%d)", |
| 3304 | pf.left, pf.top, pf.right, pf.bottom)); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3305 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3306 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3307 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3308 | // Asking to layout into the overscan region, so give it that pure |
| 3309 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3310 | pf.left = df.left = of.left = mOverscanScreenLeft; |
| 3311 | pf.top = df.top = of.top = mOverscanScreenTop; |
| 3312 | pf.right = df.right = of.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3313 | pf.bottom = df.bottom = of.bottom = mOverscanScreenTop |
| 3314 | + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3315 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3316 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3317 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3318 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3319 | // Asking for layout as if the nav bar is hidden, lets the |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3320 | // application extend into the unrestricted overscan screen area. We |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3321 | // only do this for application windows to ensure no window that |
| 3322 | // can be above the nav bar can do this. |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3323 | pf.left = df.left = mOverscanScreenLeft; |
| 3324 | pf.top = df.top = mOverscanScreenTop; |
| 3325 | pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3326 | pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3327 | // We need to tell the app about where the frame inside the overscan |
| 3328 | // is, so it can inset its content by that amount -- it didn't ask |
| 3329 | // to actually extend itself into the overscan region. |
| 3330 | of.left = mUnrestrictedScreenLeft; |
| 3331 | of.top = mUnrestrictedScreenTop; |
| 3332 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3333 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3334 | } else { |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3335 | pf.left = df.left = mRestrictedOverscanScreenLeft; |
| 3336 | pf.top = df.top = mRestrictedOverscanScreenTop; |
| 3337 | pf.right = df.right = mRestrictedOverscanScreenLeft |
| 3338 | + mRestrictedOverscanScreenWidth; |
| 3339 | pf.bottom = df.bottom = mRestrictedOverscanScreenTop |
| 3340 | + mRestrictedOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3341 | // We need to tell the app about where the frame inside the overscan |
| 3342 | // is, so it can inset its content by that amount -- it didn't ask |
| 3343 | // to actually extend itself into the overscan region. |
| 3344 | of.left = mUnrestrictedScreenLeft; |
| 3345 | of.top = mUnrestrictedScreenTop; |
| 3346 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3347 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3348 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3349 | |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3350 | if ((fl & FLAG_FULLSCREEN) == 0) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3351 | if (win.isVoiceInteraction()) { |
| 3352 | cf.left = mVoiceContentLeft; |
| 3353 | cf.top = mVoiceContentTop; |
| 3354 | cf.right = mVoiceContentRight; |
| 3355 | cf.bottom = mVoiceContentBottom; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3356 | } else { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3357 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
| 3358 | cf.left = mDockLeft; |
| 3359 | cf.top = mDockTop; |
| 3360 | cf.right = mDockRight; |
| 3361 | cf.bottom = mDockBottom; |
| 3362 | } else { |
| 3363 | cf.left = mContentLeft; |
| 3364 | cf.top = mContentTop; |
| 3365 | cf.right = mContentRight; |
| 3366 | cf.bottom = mContentBottom; |
| 3367 | } |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3368 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3369 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3370 | // Full screen windows are always given a layout that is as if the |
| 3371 | // status bar and other transient decors are gone. This is to avoid |
| 3372 | // bad states when moving from a window that is not hding the |
| 3373 | // status bar to one that is. |
| 3374 | cf.left = mRestrictedScreenLeft; |
| 3375 | cf.top = mRestrictedScreenTop; |
| 3376 | cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 3377 | cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3378 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3379 | applyStableConstraints(sysUiFl, fl, cf); |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3380 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3381 | vf.left = mCurLeft; |
| 3382 | vf.top = mCurTop; |
| 3383 | vf.right = mCurRight; |
| 3384 | vf.bottom = mCurBottom; |
| 3385 | } else { |
| 3386 | vf.set(cf); |
| 3387 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3388 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3389 | } else if ((fl & FLAG_LAYOUT_IN_SCREEN) != 0 || (sysUiFl |
| 3390 | & (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 3391 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3392 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3393 | "): IN_SCREEN"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3394 | // A window that has requested to fill the entire screen just |
| 3395 | // gets everything, period. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3396 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3397 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3398 | pf.left = df.left = of.left = cf.left = hasNavBar |
| 3399 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3400 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3401 | pf.right = df.right = of.right = cf.right = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3402 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3403 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3404 | pf.bottom = df.bottom = of.bottom = cf.bottom = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3405 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3406 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3407 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3408 | "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)", |
| 3409 | pf.left, pf.top, pf.right, pf.bottom)); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 3410 | } else if (attrs.type == TYPE_NAVIGATION_BAR |
| 3411 | || attrs.type == TYPE_NAVIGATION_BAR_PANEL) { |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3412 | // The navigation bar has Real Ultimate Power. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3413 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3414 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3415 | pf.right = df.right = of.right = mUnrestrictedScreenLeft |
| 3416 | + mUnrestrictedScreenWidth; |
| 3417 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop |
| 3418 | + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3419 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3420 | "Laying out navigation bar window: (%d,%d - %d,%d)", |
| 3421 | pf.left, pf.top, pf.right, pf.bottom)); |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3422 | } else if ((attrs.type == TYPE_SECURE_SYSTEM_OVERLAY |
| 3423 | || attrs.type == TYPE_BOOT_PROGRESS) |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 3424 | && ((fl & FLAG_FULLSCREEN) != 0)) { |
| 3425 | // Fullscreen secure system overlays get what they ask for. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3426 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3427 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3428 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3429 | + mOverscanScreenWidth; |
| 3430 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3431 | + mOverscanScreenHeight; |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 3432 | } else if (attrs.type == TYPE_BOOT_PROGRESS |
| 3433 | || attrs.type == TYPE_UNIVERSE_BACKGROUND) { |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3434 | // Boot progress screen always covers entire display. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3435 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3436 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3437 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3438 | + mOverscanScreenWidth; |
| 3439 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3440 | + mOverscanScreenHeight; |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3441 | } else if (attrs.type == TYPE_WALLPAPER) { |
| 3442 | // The wallpaper also has Real Ultimate Power. |
| 3443 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3444 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3445 | pf.right = df.right = of.right = cf.right |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3446 | = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3447 | pf.bottom = df.bottom = of.bottom = cf.bottom |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3448 | = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3449 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3450 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3451 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3452 | // Asking to layout into the overscan region, so give it that pure |
| 3453 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3454 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3455 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3456 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3457 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3458 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3459 | = mOverscanScreenTop + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3460 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3461 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Craig Mautner | beac106 | 2014-06-03 14:38:57 -0700 | [diff] [blame] | 3462 | && (attrs.type == TYPE_STATUS_BAR |
| 3463 | || attrs.type == TYPE_TOAST |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3464 | || (attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3465 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW))) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3466 | // Asking for layout as if the nav bar is hidden, lets the |
| 3467 | // application extend into the unrestricted screen area. We |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3468 | // 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] | 3469 | // can be above the nav bar can do this. |
| 3470 | // XXX This assumes that an app asking for this will also |
| 3471 | // ask for layout in only content. We can't currently figure out |
| 3472 | // 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] | 3473 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3474 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3475 | pf.right = df.right = of.right = cf.right = mUnrestrictedScreenLeft |
| 3476 | + mUnrestrictedScreenWidth; |
| 3477 | pf.bottom = df.bottom = of.bottom = cf.bottom = mUnrestrictedScreenTop |
| 3478 | + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3479 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3480 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3481 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3482 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3483 | + mRestrictedScreenWidth; |
| 3484 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3485 | + mRestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3486 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3487 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3488 | applyStableConstraints(sysUiFl, fl, cf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3489 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3490 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3491 | vf.left = mCurLeft; |
| 3492 | vf.top = mCurTop; |
| 3493 | vf.right = mCurRight; |
| 3494 | vf.bottom = mCurBottom; |
| 3495 | } else { |
| 3496 | vf.set(cf); |
| 3497 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3498 | } else if (attached != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3499 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3500 | "): attached to " + attached); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3501 | // A child window should be placed inside of the same visible |
| 3502 | // frame that its parent had. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3503 | 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] | 3504 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3505 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3506 | "): normal window"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3507 | // Otherwise, a normal window must be placed inside the content |
| 3508 | // of all screen decorations. |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3509 | if (attrs.type == TYPE_STATUS_BAR_PANEL) { |
| 3510 | // Status bar panels are the only windows who can go on top of |
| 3511 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3512 | // permission, so they have the same privileges as the status |
| 3513 | // bar itself. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3514 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3515 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3516 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3517 | + mRestrictedScreenWidth; |
| 3518 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3519 | + mRestrictedScreenHeight; |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3520 | } else if (attrs.type == TYPE_TOAST || attrs.type == TYPE_SYSTEM_ALERT |
| 3521 | || attrs.type == TYPE_VOLUME_OVERLAY) { |
| 3522 | // These dialogs are stable to interim decor changes. |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3523 | pf.left = df.left = of.left = cf.left = mStableLeft; |
| 3524 | pf.top = df.top = of.top = cf.top = mStableTop; |
| 3525 | pf.right = df.right = of.right = cf.right = mStableRight; |
| 3526 | pf.bottom = df.bottom = of.bottom = cf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3527 | } else { |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3528 | pf.left = mContentLeft; |
| 3529 | pf.top = mContentTop; |
| 3530 | pf.right = mContentRight; |
| 3531 | pf.bottom = mContentBottom; |
Dianne Hackborn | 20d9474 | 2014-05-29 18:35:45 -0700 | [diff] [blame] | 3532 | if (win.isVoiceInteraction()) { |
| 3533 | df.left = of.left = cf.left = mVoiceContentLeft; |
| 3534 | df.top = of.top = cf.top = mVoiceContentTop; |
| 3535 | df.right = of.right = cf.right = mVoiceContentRight; |
| 3536 | df.bottom = of.bottom = cf.bottom = mVoiceContentBottom; |
| 3537 | } else if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3538 | df.left = of.left = cf.left = mDockLeft; |
| 3539 | df.top = of.top = cf.top = mDockTop; |
| 3540 | df.right = of.right = cf.right = mDockRight; |
| 3541 | df.bottom = of.bottom = cf.bottom = mDockBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3542 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3543 | df.left = of.left = cf.left = mContentLeft; |
| 3544 | df.top = of.top = cf.top = mContentTop; |
| 3545 | df.right = of.right = cf.right = mContentRight; |
| 3546 | df.bottom = of.bottom = cf.bottom = mContentBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3547 | } |
| 3548 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3549 | vf.left = mCurLeft; |
| 3550 | vf.top = mCurTop; |
| 3551 | vf.right = mCurRight; |
| 3552 | vf.bottom = mCurBottom; |
| 3553 | } else { |
| 3554 | vf.set(cf); |
| 3555 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3556 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3557 | } |
| 3558 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3559 | |
Craig Mautner | b816bed | 2013-07-23 10:26:17 -0700 | [diff] [blame] | 3560 | // TYPE_SYSTEM_ERROR is above the NavigationBar so it can't be allowed to extend over it. |
| 3561 | if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0 && attrs.type != TYPE_SYSTEM_ERROR) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3562 | df.left = df.top = of.left = of.top = cf.left = cf.top = vf.left = vf.top = -10000; |
| 3563 | df.right = df.bottom = of.right = of.bottom = cf.right = cf.bottom |
| 3564 | = vf.right = vf.bottom = 10000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3565 | } |
| 3566 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3567 | 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] | 3568 | + ": sim=#" + Integer.toHexString(sim) |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3569 | + " attach=" + attached + " type=" + attrs.type |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3570 | + String.format(" flags=0x%08x", fl) |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 3571 | + " pf=" + pf.toShortString() + " df=" + df.toShortString() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3572 | + " of=" + of.toShortString() |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3573 | + " cf=" + cf.toShortString() + " vf=" + vf.toShortString() |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3574 | + " dcf=" + dcf.toShortString() |
| 3575 | + " sf=" + sf.toShortString()); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3576 | |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3577 | win.computeFrameLw(pf, df, of, cf, vf, dcf, sf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3578 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3579 | // Dock windows carve out the bottom of the screen, so normal windows |
| 3580 | // can't appear underneath them. |
Craig Mautner | 8bd206b | 2012-10-03 10:32:02 -0700 | [diff] [blame] | 3581 | if (attrs.type == TYPE_INPUT_METHOD && win.isVisibleOrBehindKeyguardLw() |
| 3582 | && !win.getGivenInsetsPendingLw()) { |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3583 | setLastInputMethodWindowLw(null, null); |
| 3584 | offsetInputMethodWindowLw(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3585 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3586 | if (attrs.type == TYPE_VOICE_INTERACTION && win.isVisibleOrBehindKeyguardLw() |
| 3587 | && !win.getGivenInsetsPendingLw()) { |
| 3588 | offsetVoiceInputWindowLw(win); |
| 3589 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3590 | } |
| 3591 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3592 | private void offsetInputMethodWindowLw(WindowState win) { |
| 3593 | int top = win.getContentFrameLw().top; |
| 3594 | top += win.getGivenContentInsetsLw().top; |
| 3595 | if (mContentBottom > top) { |
| 3596 | mContentBottom = top; |
| 3597 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3598 | if (mVoiceContentBottom > top) { |
| 3599 | mVoiceContentBottom = top; |
| 3600 | } |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3601 | top = win.getVisibleFrameLw().top; |
| 3602 | top += win.getGivenVisibleInsetsLw().top; |
| 3603 | if (mCurBottom > top) { |
| 3604 | mCurBottom = top; |
| 3605 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3606 | if (DEBUG_LAYOUT) Slog.v(TAG, "Input method: mDockBottom=" |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3607 | + mDockBottom + " mContentBottom=" |
| 3608 | + mContentBottom + " mCurBottom=" + mCurBottom); |
| 3609 | } |
| 3610 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3611 | private void offsetVoiceInputWindowLw(WindowState win) { |
| 3612 | final int gravity = win.getAttrs().gravity; |
| 3613 | switch (gravity&((Gravity.AXIS_PULL_BEFORE|Gravity.AXIS_PULL_AFTER) |
| 3614 | << Gravity.AXIS_X_SHIFT)) { |
| 3615 | case Gravity.AXIS_PULL_BEFORE<<Gravity.AXIS_X_SHIFT: { |
| 3616 | int right = win.getContentFrameLw().right - win.getGivenContentInsetsLw().right; |
| 3617 | if (mVoiceContentLeft < right) { |
| 3618 | mVoiceContentLeft = right; |
| 3619 | } |
| 3620 | } break; |
| 3621 | case Gravity.AXIS_PULL_AFTER<<Gravity.AXIS_X_SHIFT: { |
| 3622 | int left = win.getContentFrameLw().left - win.getGivenContentInsetsLw().left; |
| 3623 | if (mVoiceContentRight < left) { |
| 3624 | mVoiceContentRight = left; |
| 3625 | } |
| 3626 | } break; |
| 3627 | } |
| 3628 | switch (gravity&((Gravity.AXIS_PULL_BEFORE|Gravity.AXIS_PULL_AFTER) |
| 3629 | << Gravity.AXIS_Y_SHIFT)) { |
| 3630 | case Gravity.AXIS_PULL_BEFORE<<Gravity.AXIS_Y_SHIFT: { |
| 3631 | int bottom = win.getContentFrameLw().bottom - win.getGivenContentInsetsLw().bottom; |
| 3632 | if (mVoiceContentTop < bottom) { |
| 3633 | mVoiceContentTop = bottom; |
| 3634 | } |
| 3635 | } break; |
| 3636 | case Gravity.AXIS_PULL_AFTER<<Gravity.AXIS_Y_SHIFT: { |
| 3637 | int top = win.getContentFrameLw().top - win.getGivenContentInsetsLw().top; |
| 3638 | if (mVoiceContentBottom < top) { |
| 3639 | mVoiceContentBottom = top; |
| 3640 | } |
| 3641 | } break; |
| 3642 | } |
| 3643 | } |
| 3644 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3645 | /** {@inheritDoc} */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 3646 | @Override |
| 3647 | public void finishLayoutLw() { |
| 3648 | return; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3649 | } |
| 3650 | |
| 3651 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3652 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3653 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3654 | mTopFullscreenOpaqueWindowState = null; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3655 | mAppsToBeHidden.clear(); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3656 | mForceStatusBar = false; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3657 | mForceStatusBarFromKeyguard = false; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3658 | mForcingShowNavBar = false; |
| 3659 | mForcingShowNavBarLayer = -1; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3660 | |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3661 | mHideLockScreen = false; |
| 3662 | mAllowLockscreenWhenOn = false; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3663 | mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3664 | mShowingLockscreen = false; |
| 3665 | mShowingDream = false; |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3666 | mWinShowWhenLocked = null; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3667 | } |
| 3668 | |
| 3669 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3670 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3671 | public void applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams attrs) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3672 | if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw=" |
| 3673 | + win.isVisibleOrBehindKeyguardLw()); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3674 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3675 | if (mTopFullscreenOpaqueWindowState == null |
| 3676 | && win.isVisibleLw() && attrs.type == TYPE_INPUT_METHOD) { |
| 3677 | mForcingShowNavBar = true; |
| 3678 | mForcingShowNavBarLayer = win.getSurfaceLayer(); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3679 | } |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 3680 | if (attrs.type == TYPE_STATUS_BAR && (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 3681 | mForceStatusBarFromKeyguard = true; |
| 3682 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3683 | if (mTopFullscreenOpaqueWindowState == null && |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 3684 | win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3685 | if ((fl & FLAG_FORCE_NOT_FULLSCREEN) != 0) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3686 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3687 | mForceStatusBarFromKeyguard = true; |
| 3688 | } else { |
| 3689 | mForceStatusBar = true; |
| 3690 | } |
| 3691 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3692 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3693 | mShowingLockscreen = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3694 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3695 | boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3696 | && attrs.type <= LAST_APPLICATION_WINDOW; |
| 3697 | if (attrs.type == TYPE_DREAM) { |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3698 | // If the lockscreen was showing when the dream started then wait |
| 3699 | // for the dream to draw before hiding the lockscreen. |
| 3700 | if (!mDreamingLockscreen |
| 3701 | || (win.isVisibleLw() && win.hasDrawnLw())) { |
| 3702 | mShowingDream = true; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3703 | appWindow = true; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3704 | } |
| 3705 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3706 | |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 3707 | final boolean showWhenLocked = (fl & FLAG_SHOW_WHEN_LOCKED) != 0; |
Craig Mautner | 74ee938 | 2014-04-01 15:20:16 -0700 | [diff] [blame] | 3708 | final boolean dismissKeyguard = (fl & FLAG_DISMISS_KEYGUARD) != 0; |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3709 | final boolean secureKeyguard = isKeyguardSecure(); |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3710 | if (appWindow) { |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3711 | if (showWhenLocked || (dismissKeyguard && !secureKeyguard)) { |
| 3712 | // Remove any previous windows with the same appToken. |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3713 | mAppsToBeHidden.remove(win.getAppToken()); |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3714 | if (mAppsToBeHidden.isEmpty() && showWhenLocked && |
| 3715 | isKeyguardSecureIncludingHidden()) { |
| 3716 | mWinShowWhenLocked = win; |
| 3717 | mHideLockScreen = true; |
| 3718 | mForceStatusBarFromKeyguard = false; |
| 3719 | } |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3720 | } else { |
| 3721 | mAppsToBeHidden.add(win.getAppToken()); |
| 3722 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3723 | if (attrs.x == 0 && attrs.y == 0 |
| 3724 | && attrs.width == WindowManager.LayoutParams.MATCH_PARENT |
| 3725 | && attrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
| 3726 | if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win); |
| 3727 | mTopFullscreenOpaqueWindowState = win; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3728 | if (mAppsToBeHidden.isEmpty()) { |
Craig Mautner | da09ae3 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3729 | if (showWhenLocked) { |
| 3730 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 3731 | "Setting mHideLockScreen to true by win " + win); |
| 3732 | mHideLockScreen = true; |
| 3733 | mForceStatusBarFromKeyguard = false; |
| 3734 | } |
Craig Mautner | 4bdab6b | 2014-04-01 12:05:11 -0700 | [diff] [blame] | 3735 | if (dismissKeyguard && mDismissKeyguard == DISMISS_KEYGUARD_NONE) { |
Craig Mautner | da09ae3 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3736 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 3737 | "Setting mDismissKeyguard true by win " + win); |
| 3738 | mDismissKeyguard = mWinDismissingKeyguard == win ? |
| 3739 | DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START; |
| 3740 | mWinDismissingKeyguard = win; |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3741 | mForceStatusBarFromKeyguard = mShowingLockscreen && secureKeyguard; |
Craig Mautner | da09ae3 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3742 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3743 | } |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 3744 | if ((fl & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) { |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3745 | mAllowLockscreenWhenOn = true; |
| 3746 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3747 | } |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3748 | |
| 3749 | if (mWinShowWhenLocked != null && |
| 3750 | mWinShowWhenLocked.getAppToken() != win.getAppToken()) { |
| 3751 | win.hideLw(false); |
| 3752 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3753 | } |
| 3754 | } |
| 3755 | } |
| 3756 | |
| 3757 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3758 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3759 | public int finishPostLayoutPolicyLw() { |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3760 | if (mWinShowWhenLocked != null && |
| 3761 | mWinShowWhenLocked != mTopFullscreenOpaqueWindowState) { |
| 3762 | // A dialog is dismissing the keyguard. Put the wallpaper behind it and hide the |
| 3763 | // fullscreen window. |
| 3764 | // TODO: Make sure FLAG_SHOW_WALLPAPER is restored when dialog is dismissed. Or not. |
| 3765 | mWinShowWhenLocked.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 3766 | mTopFullscreenOpaqueWindowState.hideLw(false); |
| 3767 | mTopFullscreenOpaqueWindowState = mWinShowWhenLocked; |
| 3768 | } |
| 3769 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3770 | int changes = 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3771 | boolean topIsFullscreen = false; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3772 | |
| 3773 | final WindowManager.LayoutParams lp = (mTopFullscreenOpaqueWindowState != null) |
| 3774 | ? mTopFullscreenOpaqueWindowState.getAttrs() |
| 3775 | : null; |
| 3776 | |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3777 | // If we are not currently showing a dream then remember the current |
| 3778 | // lockscreen state. We will use this to determine whether the dream |
| 3779 | // started while the lockscreen was showing and remember this state |
| 3780 | // while the dream is showing. |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3781 | if (!mShowingDream) { |
| 3782 | mDreamingLockscreen = mShowingLockscreen; |
| 3783 | } |
| 3784 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3785 | if (mStatusBar != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3786 | if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3787 | + " forcefkg=" + mForceStatusBarFromKeyguard |
Dianne Hackborn | d70bc2f | 2009-10-06 23:25:51 -0700 | [diff] [blame] | 3788 | + " top=" + mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3789 | if (mForceStatusBar || mForceStatusBarFromKeyguard) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3790 | if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3791 | if (mStatusBarController.setBarShowingLw(true)) { |
| 3792 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3793 | } |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 3794 | // Maintain fullscreen layout until incoming animation is complete. |
| 3795 | topIsFullscreen = mTopIsFullscreen && mStatusBar.isAnimatingLw(); |
John Spurlock | f92b616 | 2013-11-11 15:01:16 -0500 | [diff] [blame] | 3796 | // Transient status bar on the lockscreen is not allowed |
| 3797 | if (mForceStatusBarFromKeyguard && mStatusBarController.isTransientShowing()) { |
| 3798 | mStatusBarController.updateVisibilityLw(false /*transientAllowed*/, |
| 3799 | mLastSystemUiFlags, mLastSystemUiFlags); |
| 3800 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3801 | } else if (mTopFullscreenOpaqueWindowState != null) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3802 | final int fl = PolicyControl.getWindowFlags(null, lp); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3803 | if (localLOGV) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3804 | Slog.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw() |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3805 | + " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw()); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3806 | Slog.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs() |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3807 | + " lp.flags=0x" + Integer.toHexString(fl)); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3808 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3809 | topIsFullscreen = (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0 |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3810 | || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3811 | // The subtle difference between the window for mTopFullscreenOpaqueWindowState |
| 3812 | // and mTopIsFullscreen is that that mTopIsFullscreen is set only if the window |
| 3813 | // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the |
| 3814 | // case though. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3815 | if (mStatusBarController.isTransientShowing()) { |
| 3816 | if (mStatusBarController.setBarShowingLw(true)) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3817 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3818 | } |
| 3819 | } else if (topIsFullscreen) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3820 | if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3821 | if (mStatusBarController.setBarShowingLw(false)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3822 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3823 | } else { |
Craig Mautner | c5a6e44 | 2013-06-05 17:22:35 -0700 | [diff] [blame] | 3824 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar already hiding"); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 3825 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3826 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3827 | 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] | 3828 | if (mStatusBarController.setBarShowingLw(true)) { |
| 3829 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3830 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3831 | } |
| 3832 | } |
| 3833 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3834 | |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 3835 | if (mTopIsFullscreen != topIsFullscreen) { |
| 3836 | if (!topIsFullscreen) { |
| 3837 | // Force another layout when status bar becomes fully shown. |
| 3838 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3839 | } |
| 3840 | mTopIsFullscreen = topIsFullscreen; |
| 3841 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3842 | |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3843 | // Hide the key guard if a visible window explicitly specifies that it wants to be |
| 3844 | // displayed when the screen is locked. |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3845 | if (mKeyguardDelegate != null && mStatusBar != null) { |
| 3846 | if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard=" |
| 3847 | + mHideLockScreen); |
| 3848 | if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !isKeyguardSecure()) { |
| 3849 | mKeyguardHidden = true; |
| 3850 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(true))) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3851 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3852 | | FINISH_LAYOUT_REDO_CONFIG |
| 3853 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3854 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3855 | if (mKeyguardDelegate.isShowing()) { |
| 3856 | mHandler.post(new Runnable() { |
| 3857 | @Override |
| 3858 | public void run() { |
| 3859 | mKeyguardDelegate.keyguardDone(false, false); |
| 3860 | } |
| 3861 | }); |
| 3862 | } |
| 3863 | } else if (mHideLockScreen) { |
| 3864 | mKeyguardHidden = true; |
| 3865 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(true))) { |
| 3866 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3867 | | FINISH_LAYOUT_REDO_CONFIG |
| 3868 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3869 | } |
| 3870 | } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) { |
| 3871 | // This is the case of keyguard isSecure() and not mHideLockScreen. |
| 3872 | if (mDismissKeyguard == DISMISS_KEYGUARD_START) { |
| 3873 | // Only launch the next keyguard unlock window once per window. |
| 3874 | mKeyguardHidden = false; |
| 3875 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(false))) { |
| 3876 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3877 | | FINISH_LAYOUT_REDO_CONFIG |
| 3878 | | FINISH_LAYOUT_REDO_WALLPAPER; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3879 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3880 | mHandler.post(new Runnable() { |
| 3881 | @Override |
| 3882 | public void run() { |
| 3883 | mKeyguardDelegate.dismiss(); |
| 3884 | } |
| 3885 | }); |
| 3886 | } |
| 3887 | } else { |
| 3888 | mWinDismissingKeyguard = null; |
| 3889 | mKeyguardHidden = false; |
| 3890 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(false))) { |
| 3891 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3892 | | FINISH_LAYOUT_REDO_CONFIG |
| 3893 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3894 | } |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 3895 | } |
| 3896 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3897 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3898 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3899 | // If the navigation bar has been hidden or shown, we need to do another |
| 3900 | // layout pass to update that window. |
| 3901 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3902 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3903 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3904 | // update since mAllowLockscreenWhenOn might have changed |
| 3905 | updateLockScreenTimeout(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3906 | return changes; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3907 | } |
| 3908 | |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3909 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3910 | * 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] | 3911 | * immediately need to put the wallpaper directly behind the Keyguard when a window with flag |
| 3912 | * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED} gets dismissed. If we |
| 3913 | * would wait for Keyguard to change the flags, that would be running asynchronously and thus be |
| 3914 | * too late so the user might see the window behind. |
| 3915 | * |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3916 | * @param setHiddenResult The result code from {@link IKeyguardService#setOccluded}. |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3917 | * @return Whether the flags have changed and we have to redo the layout. |
| 3918 | */ |
| 3919 | private boolean processKeyguardSetHiddenResultLw(int setHiddenResult) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3920 | if (setHiddenResult |
| 3921 | == IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_SET_FLAGS) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3922 | mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD; |
| 3923 | mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 3924 | return true; |
| 3925 | } else if (setHiddenResult |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3926 | == IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_UNSET_FLAGS) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3927 | mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD; |
| 3928 | mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER; |
| 3929 | return true; |
| 3930 | } else { |
| 3931 | return false; |
| 3932 | } |
| 3933 | } |
| 3934 | |
| 3935 | private boolean isStatusBarKeyguard() { |
| 3936 | return mStatusBar != null |
| 3937 | && (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
| 3938 | } |
| 3939 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 3940 | @Override |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3941 | public boolean allowAppAnimationsLw() { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3942 | if (isStatusBarKeyguard() || mShowingDream) { |
Craig Mautner | 2881630 | 2013-10-10 20:31:00 -0700 | [diff] [blame] | 3943 | // 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] | 3944 | return false; |
| 3945 | } |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3946 | return true; |
| 3947 | } |
| 3948 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 3949 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3950 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus) { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3951 | mFocusedWindow = newFocus; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3952 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3953 | // If the navigation bar has been hidden or shown, we need to do another |
| 3954 | // layout pass to update that window. |
| 3955 | return FINISH_LAYOUT_REDO_LAYOUT; |
| 3956 | } |
| 3957 | return 0; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3958 | } |
| 3959 | |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 3960 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 3961 | @Override |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3962 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
| 3963 | // lid changed state |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3964 | final int newLidState = lidOpen ? LID_OPEN : LID_CLOSED; |
| 3965 | if (newLidState == mLidState) { |
| 3966 | return; |
| 3967 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3968 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3969 | mLidState = newLidState; |
| 3970 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3971 | updateRotation(true); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3972 | |
| 3973 | if (lidOpen) { |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 3974 | mPowerManager.wakeUp(SystemClock.uptimeMillis()); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3975 | } else if (!mLidControlsSleep) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3976 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3977 | } |
| 3978 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3979 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3980 | void setHdmiPlugged(boolean plugged) { |
| 3981 | if (mHdmiPlugged != plugged) { |
| 3982 | mHdmiPlugged = plugged; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3983 | updateRotation(true, true); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3984 | Intent intent = new Intent(ACTION_HDMI_PLUGGED); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 3985 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3986 | intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 3987 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3988 | } |
| 3989 | } |
| 3990 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3991 | void initializeHdmiState() { |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 3992 | boolean plugged = false; |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3993 | // watch for HDMI plug messages if the hdmi switch exists |
| 3994 | if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) { |
| 3995 | mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi"); |
| 3996 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 3997 | final String filename = "/sys/class/switch/hdmi/state"; |
| 3998 | FileReader reader = null; |
| 3999 | try { |
| 4000 | reader = new FileReader(filename); |
| 4001 | char[] buf = new char[15]; |
| 4002 | int n = reader.read(buf); |
| 4003 | if (n > 1) { |
| 4004 | plugged = 0 != Integer.parseInt(new String(buf, 0, n-1)); |
| 4005 | } |
| 4006 | } catch (IOException ex) { |
| 4007 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 4008 | } catch (NumberFormatException ex) { |
| 4009 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 4010 | } finally { |
| 4011 | if (reader != null) { |
| 4012 | try { |
| 4013 | reader.close(); |
| 4014 | } catch (IOException ex) { |
| 4015 | } |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 4016 | } |
| 4017 | } |
| 4018 | } |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 4019 | // This dance forces the code in setHdmiPlugged to run. |
| 4020 | // Always do this so the sticky intent is stuck (to false) if there is no hdmi. |
| 4021 | mHdmiPlugged = !plugged; |
| 4022 | setHdmiPlugged(!mHdmiPlugged); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 4023 | } |
| 4024 | |
Dianne Hackborn | c0e3f24 | 2011-08-19 14:19:10 -0700 | [diff] [blame] | 4025 | final Object mScreenshotLock = new Object(); |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 4026 | ServiceConnection mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 4027 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4028 | final Runnable mScreenshotTimeout = new Runnable() { |
| 4029 | @Override public void run() { |
| 4030 | synchronized (mScreenshotLock) { |
| 4031 | if (mScreenshotConnection != null) { |
| 4032 | mContext.unbindService(mScreenshotConnection); |
| 4033 | mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 4034 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4035 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4036 | } |
| 4037 | }; |
| 4038 | |
| 4039 | // Assume this is called from the Handler thread. |
| 4040 | private void takeScreenshot() { |
| 4041 | synchronized (mScreenshotLock) { |
| 4042 | if (mScreenshotConnection != null) { |
| 4043 | return; |
| 4044 | } |
| 4045 | ComponentName cn = new ComponentName("com.android.systemui", |
| 4046 | "com.android.systemui.screenshot.TakeScreenshotService"); |
| 4047 | Intent intent = new Intent(); |
| 4048 | intent.setComponent(cn); |
| 4049 | ServiceConnection conn = new ServiceConnection() { |
| 4050 | @Override |
| 4051 | public void onServiceConnected(ComponentName name, IBinder service) { |
| 4052 | synchronized (mScreenshotLock) { |
| 4053 | if (mScreenshotConnection != this) { |
| 4054 | return; |
| 4055 | } |
| 4056 | Messenger messenger = new Messenger(service); |
| 4057 | Message msg = Message.obtain(null, 1); |
| 4058 | final ServiceConnection myConn = this; |
| 4059 | Handler h = new Handler(mHandler.getLooper()) { |
| 4060 | @Override |
| 4061 | public void handleMessage(Message msg) { |
| 4062 | synchronized (mScreenshotLock) { |
| 4063 | if (mScreenshotConnection == myConn) { |
| 4064 | mContext.unbindService(mScreenshotConnection); |
| 4065 | mScreenshotConnection = null; |
| 4066 | mHandler.removeCallbacks(mScreenshotTimeout); |
| 4067 | } |
| 4068 | } |
| 4069 | } |
| 4070 | }; |
| 4071 | msg.replyTo = new Messenger(h); |
Winson Chung | a63bb84 | 2011-10-17 10:26:28 -0700 | [diff] [blame] | 4072 | msg.arg1 = msg.arg2 = 0; |
| 4073 | if (mStatusBar != null && mStatusBar.isVisibleLw()) |
| 4074 | msg.arg1 = 1; |
| 4075 | if (mNavigationBar != null && mNavigationBar.isVisibleLw()) |
| 4076 | msg.arg2 = 1; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4077 | try { |
| 4078 | messenger.send(msg); |
| 4079 | } catch (RemoteException e) { |
| 4080 | } |
| 4081 | } |
| 4082 | } |
| 4083 | @Override |
| 4084 | public void onServiceDisconnected(ComponentName name) {} |
| 4085 | }; |
Amith Yamasani | 27b89e6 | 2013-01-16 12:30:11 -0800 | [diff] [blame] | 4086 | if (mContext.bindServiceAsUser( |
| 4087 | intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4088 | mScreenshotConnection = conn; |
| 4089 | mHandler.postDelayed(mScreenshotTimeout, 10000); |
| 4090 | } |
| 4091 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4092 | } |
| 4093 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4094 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4095 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4096 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 4097 | if (!mSystemBooted) { |
| 4098 | // If we have not yet booted, don't let key events do anything. |
| 4099 | return 0; |
| 4100 | } |
| 4101 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4102 | final boolean interactive = (policyFlags & FLAG_INTERACTIVE) != 0; |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 4103 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 4104 | final boolean canceled = event.isCanceled(); |
| 4105 | final int keyCode = event.getKeyCode(); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 4106 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4107 | final boolean isInjected = (policyFlags & WindowManagerPolicy.FLAG_INJECTED) != 0; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4108 | |
Mike Lockwood | c72b15f | 2009-11-28 20:58:22 -0500 | [diff] [blame] | 4109 | // If screen is off then we treat the case where the keyguard is open but hidden |
| 4110 | // the same as if it were open and in front. |
| 4111 | // This will prevent any keys other than the power button from waking the screen |
| 4112 | // when the keyguard is hidden by another activity. |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4113 | final boolean keyguardActive = (mKeyguardDelegate == null ? false : |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4114 | (interactive ? |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4115 | mKeyguardDelegate.isShowingAndNotOccluded() : |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4116 | mKeyguardDelegate.isShowing())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4117 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4118 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4119 | Log.d(TAG, "interceptKeyTq keycode=" + keyCode |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4120 | + " interactive=" + interactive + " keyguardActive=" + keyguardActive |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4121 | + " policyFlags=" + Integer.toHexString(policyFlags)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4122 | } |
| 4123 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4124 | // Basic policy based on interactive state. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4125 | int result; |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 4126 | boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0 |
| 4127 | || event.isWakeKey(); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4128 | if (interactive || (isInjected && !isWakeKey)) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4129 | // When the screen is on or if the key is injected pass the key to the application. |
| 4130 | result = ACTION_PASS_TO_USER; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4131 | isWakeKey = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4132 | } else { |
| 4133 | // When the screen is off and the key is not injected, determine whether |
| 4134 | // to wake the device but don't pass the key to the application. |
| 4135 | result = 0; |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4136 | if (isWakeKey && (!down || !isWakeKeyWhenScreenOff(keyCode))) { |
| 4137 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4138 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4139 | } |
| 4140 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 4141 | // If the key would be handled globally, just return the result, don't worry about special |
| 4142 | // key processing. |
| 4143 | if (mGlobalKeyManager.shouldHandleGlobalKey(keyCode, event)) { |
Michael Wright | 85b1af6 | 2014-06-04 14:51:58 -0700 | [diff] [blame] | 4144 | if (isWakeKey) { |
| 4145 | mPowerManager.wakeUp(event.getEventTime()); |
| 4146 | } |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 4147 | return result; |
| 4148 | } |
| 4149 | |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 4150 | boolean useHapticFeedback = down |
| 4151 | && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 |
| 4152 | && event.getRepeatCount() == 0; |
| 4153 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4154 | // Handle special keys. |
| 4155 | switch (keyCode) { |
| 4156 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 4157 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4158 | case KeyEvent.KEYCODE_VOLUME_MUTE: { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4159 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { |
| 4160 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4161 | if (interactive && !mVolumeDownKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4162 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4163 | mVolumeDownKeyTriggered = true; |
| 4164 | mVolumeDownKeyTime = event.getDownTime(); |
| 4165 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 4166 | cancelPendingPowerKeyAction(); |
| 4167 | interceptScreenshotChord(); |
| 4168 | } |
| 4169 | } else { |
| 4170 | mVolumeDownKeyTriggered = false; |
| 4171 | cancelPendingScreenshotChordAction(); |
| 4172 | } |
| 4173 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { |
| 4174 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4175 | if (interactive && !mVolumeUpKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4176 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4177 | mVolumeUpKeyTriggered = true; |
| 4178 | cancelPendingPowerKeyAction(); |
| 4179 | cancelPendingScreenshotChordAction(); |
| 4180 | } |
| 4181 | } else { |
| 4182 | mVolumeUpKeyTriggered = false; |
| 4183 | cancelPendingScreenshotChordAction(); |
| 4184 | } |
| 4185 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4186 | if (down) { |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4187 | TelecommManager telecommManager = getTelecommService(); |
| 4188 | if (telecommManager != null) { |
| 4189 | if (telecommManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4190 | // If an incoming call is ringing, either VOLUME key means |
| 4191 | // "silence ringer". We handle these keys here, rather than |
| 4192 | // in the InCallScreen, to make sure we'll respond to them |
| 4193 | // even if the InCallScreen hasn't come to the foreground yet. |
| 4194 | // Look for the DOWN event here, to agree with the "fallback" |
| 4195 | // behavior in the InCallScreen. |
| 4196 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4197 | + " VOLUME key-down while ringing: Silence ringer!"); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4198 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4199 | // Silence the ringer. (It's safe to call this |
| 4200 | // even if the ringer has already been silenced.) |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4201 | telecommManager.silenceRinger(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4202 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4203 | // And *don't* pass this key thru to the current activity |
| 4204 | // (which is probably the InCallScreen.) |
| 4205 | result &= ~ACTION_PASS_TO_USER; |
| 4206 | break; |
| 4207 | } |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4208 | if (telecommManager.isInAPhoneCall() |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4209 | && (result & ACTION_PASS_TO_USER) == 0) { |
| 4210 | // If we are in call but we decided not to pass the key to |
RoboErik | 430fc48 | 2014-06-12 15:49:20 -0700 | [diff] [blame] | 4211 | // the application, just pass it to the session service. |
| 4212 | |
| 4213 | MediaSessionLegacyHelper.getHelper(mContext) |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 4214 | .sendVolumeKeyEvent(event, false); |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4215 | break; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4216 | } |
| 4217 | } |
| 4218 | |
RoboErik | 430fc48 | 2014-06-12 15:49:20 -0700 | [diff] [blame] | 4219 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 4220 | // If we aren't passing to the user and no one else |
| 4221 | // handled it send it to the session manager to figure |
| 4222 | // out. |
| 4223 | MediaSessionLegacyHelper.getHelper(mContext) |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 4224 | .sendVolumeKeyEvent(event, true); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4225 | break; |
| 4226 | } |
| 4227 | } |
| 4228 | break; |
| 4229 | } |
| 4230 | |
| 4231 | case KeyEvent.KEYCODE_ENDCALL: { |
| 4232 | result &= ~ACTION_PASS_TO_USER; |
| 4233 | if (down) { |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4234 | TelecommManager telecommManager = getTelecommService(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4235 | boolean hungUp = false; |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4236 | if (telecommManager != null) { |
| 4237 | hungUp = telecommManager.endCall(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4238 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4239 | interceptPowerKeyDown(!interactive || hungUp); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4240 | } else { |
| 4241 | if (interceptPowerKeyUp(canceled)) { |
| 4242 | if ((mEndcallBehavior |
| 4243 | & Settings.System.END_BUTTON_BEHAVIOR_HOME) != 0) { |
| 4244 | if (goHome()) { |
| 4245 | break; |
Dianne Hackborn | 0041e97 | 2009-07-24 17:14:43 -0700 | [diff] [blame] | 4246 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4247 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4248 | if ((mEndcallBehavior |
| 4249 | & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4250 | mPowerManager.goToSleep(event.getEventTime()); |
| 4251 | isWakeKey = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4252 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4253 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4254 | } |
| 4255 | break; |
| 4256 | } |
| 4257 | |
| 4258 | case KeyEvent.KEYCODE_POWER: { |
| 4259 | result &= ~ACTION_PASS_TO_USER; |
| 4260 | if (down) { |
Jeff Brown | 26c6a50 | 2014-04-11 02:15:54 -0700 | [diff] [blame] | 4261 | boolean panic = mImmersiveModeConfirmation.onPowerKeyDown(interactive, |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 4262 | event.getDownTime(), isImmersiveMode(mLastSystemUiFlags)); |
| 4263 | if (panic) { |
| 4264 | mHandler.post(mRequestTransientNav); |
| 4265 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4266 | if (interactive && !mPowerKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4267 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4268 | mPowerKeyTriggered = true; |
| 4269 | mPowerKeyTime = event.getDownTime(); |
| 4270 | interceptScreenshotChord(); |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4271 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4272 | |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4273 | TelecommManager telecommManager = getTelecommService(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4274 | boolean hungUp = false; |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4275 | if (telecommManager != null) { |
| 4276 | if (telecommManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4277 | // Pressing Power while there's a ringing incoming |
| 4278 | // call should silence the ringer. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4279 | telecommManager.silenceRinger(); |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4280 | } else if ((mIncallPowerBehavior |
| 4281 | & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4282 | && telecommManager.isInAPhoneCall() && interactive) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4283 | // Otherwise, if "Power button ends call" is enabled, |
| 4284 | // the Power button will hang up any current active call. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4285 | hungUp = telecommManager.endCall(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4286 | } |
| 4287 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4288 | interceptPowerKeyDown(!interactive || hungUp |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4289 | || mVolumeDownKeyTriggered || mVolumeUpKeyTriggered); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4290 | } else { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4291 | mPowerKeyTriggered = false; |
| 4292 | cancelPendingScreenshotChordAction(); |
| 4293 | if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) { |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 4294 | powerShortPress(event.getEventTime()); |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4295 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4296 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4297 | mPendingPowerKeyUpCanceled = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4298 | } |
| 4299 | break; |
| 4300 | } |
| 4301 | |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4302 | case KeyEvent.KEYCODE_SLEEP: { |
| 4303 | result &= ~ACTION_PASS_TO_USER; |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 4304 | if (!mPowerManager.isInteractive()) { |
| 4305 | useHapticFeedback = false; // suppress feedback if already non-interactive |
| 4306 | } |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4307 | mPowerManager.goToSleep(event.getEventTime()); |
| 4308 | isWakeKey = false; |
| 4309 | break; |
| 4310 | } |
| 4311 | |
| 4312 | case KeyEvent.KEYCODE_WAKEUP: { |
| 4313 | result &= ~ACTION_PASS_TO_USER; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4314 | isWakeKey = true; |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4315 | break; |
| 4316 | } |
| 4317 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4318 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4319 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4320 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4321 | if (down) { |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4322 | TelecommManager telecommManager = getTelecommService(); |
| 4323 | if (telecommManager != null) { |
| 4324 | if (telecommManager.isInAPhoneCall()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4325 | // Suppress PLAY/PAUSE toggle when phone is ringing or in-call |
| 4326 | // to avoid music playback. |
| 4327 | break; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4328 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4329 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4330 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4331 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4332 | case KeyEvent.KEYCODE_MUTE: |
| 4333 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4334 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4335 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4336 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4337 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4338 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
| 4339 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4340 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 4341 | // Only do this if we would otherwise not pass it to the user. In that |
| 4342 | // case, the PhoneWindow class will do the same thing, except it will |
| 4343 | // 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] | 4344 | // Note that we need to make a copy of the key event here because the |
| 4345 | // original key event will be recycled when we return. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4346 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4347 | Message msg = mHandler.obtainMessage(MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK, |
| 4348 | new KeyEvent(event)); |
| 4349 | msg.setAsynchronous(true); |
| 4350 | msg.sendToTarget(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4351 | } |
| 4352 | break; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4353 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4354 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4355 | case KeyEvent.KEYCODE_CALL: { |
| 4356 | if (down) { |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4357 | TelecommManager telecommManager = getTelecommService(); |
| 4358 | if (telecommManager != null) { |
| 4359 | if (telecommManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4360 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4361 | + " CALL key-down while ringing: Answer the call!"); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4362 | telecommManager.acceptRingingCall(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4363 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4364 | // And *don't* pass this key thru to the current activity |
| 4365 | // (which is presumably the InCallScreen.) |
| 4366 | result &= ~ACTION_PASS_TO_USER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4367 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4368 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4369 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4370 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4371 | } |
| 4372 | } |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4373 | |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 4374 | if (useHapticFeedback) { |
| 4375 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
| 4376 | } |
| 4377 | |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4378 | if (isWakeKey) { |
| 4379 | mPowerManager.wakeUp(event.getEventTime()); |
| 4380 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4381 | return result; |
| 4382 | } |
| 4383 | |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4384 | /** |
| 4385 | * When the screen is off we ignore some keys that might otherwise typically |
| 4386 | * be considered wake keys. We filter them out here. |
| 4387 | * |
| 4388 | * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it |
| 4389 | * is always considered a wake key. |
| 4390 | */ |
| 4391 | private boolean isWakeKeyWhenScreenOff(int keyCode) { |
| 4392 | switch (keyCode) { |
| 4393 | // ignore volume keys unless docked |
| 4394 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4395 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 4396 | case KeyEvent.KEYCODE_VOLUME_MUTE: |
| 4397 | return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 4398 | |
| 4399 | // ignore media and camera keys |
| 4400 | case KeyEvent.KEYCODE_MUTE: |
| 4401 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4402 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4403 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4404 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4405 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4406 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4407 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4408 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4409 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
| 4410 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4411 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4412 | case KeyEvent.KEYCODE_CAMERA: |
| 4413 | return false; |
| 4414 | } |
| 4415 | return true; |
| 4416 | } |
| 4417 | |
| 4418 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4419 | /** {@inheritDoc} */ |
| 4420 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4421 | public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) { |
| 4422 | // We already know this is a wake motion so just wake up. |
| 4423 | // Note that we would observe policyFlags containing |
| 4424 | // FLAG_WAKE and FLAG_INTERACTIVE here. |
| 4425 | mPowerManager.wakeUp(whenNanos / 1000000); |
| 4426 | return 0; |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4427 | } |
| 4428 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4429 | void dispatchMediaKeyWithWakeLock(KeyEvent event) { |
| 4430 | if (DEBUG_INPUT) { |
| 4431 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: " + event); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4432 | } |
| 4433 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4434 | if (mHavePendingMediaKeyRepeatWithWakeLock) { |
| 4435 | if (DEBUG_INPUT) { |
| 4436 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: canceled repeat"); |
| 4437 | } |
| 4438 | |
| 4439 | mHandler.removeMessages(MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK); |
| 4440 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4441 | mBroadcastWakeLock.release(); // pending repeat was holding onto the wake lock |
| 4442 | } |
| 4443 | |
| 4444 | dispatchMediaKeyWithWakeLockToAudioService(event); |
| 4445 | |
| 4446 | if (event.getAction() == KeyEvent.ACTION_DOWN |
| 4447 | && event.getRepeatCount() == 0) { |
| 4448 | mHavePendingMediaKeyRepeatWithWakeLock = true; |
| 4449 | |
| 4450 | Message msg = mHandler.obtainMessage( |
| 4451 | MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK, event); |
| 4452 | msg.setAsynchronous(true); |
| 4453 | mHandler.sendMessageDelayed(msg, ViewConfiguration.getKeyRepeatTimeout()); |
| 4454 | } else { |
| 4455 | mBroadcastWakeLock.release(); |
| 4456 | } |
| 4457 | } |
| 4458 | |
| 4459 | void dispatchMediaKeyRepeatWithWakeLock(KeyEvent event) { |
| 4460 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4461 | |
| 4462 | KeyEvent repeatEvent = KeyEvent.changeTimeRepeat(event, |
| 4463 | SystemClock.uptimeMillis(), 1, event.getFlags() | KeyEvent.FLAG_LONG_PRESS); |
| 4464 | if (DEBUG_INPUT) { |
| 4465 | Slog.d(TAG, "dispatchMediaKeyRepeatWithWakeLock: " + repeatEvent); |
| 4466 | } |
| 4467 | |
| 4468 | dispatchMediaKeyWithWakeLockToAudioService(repeatEvent); |
| 4469 | mBroadcastWakeLock.release(); |
| 4470 | } |
| 4471 | |
| 4472 | void dispatchMediaKeyWithWakeLockToAudioService(KeyEvent event) { |
| 4473 | if (ActivityManagerNative.isSystemReady()) { |
RoboErik | 430fc48 | 2014-06-12 15:49:20 -0700 | [diff] [blame] | 4474 | MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(event, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4475 | } |
| 4476 | } |
| 4477 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4478 | BroadcastReceiver mDockReceiver = new BroadcastReceiver() { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4479 | @Override |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4480 | public void onReceive(Context context, Intent intent) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 4481 | if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { |
| 4482 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 4483 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4484 | } else { |
| 4485 | try { |
| 4486 | IUiModeManager uiModeService = IUiModeManager.Stub.asInterface( |
| 4487 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 4488 | mUiMode = uiModeService.getCurrentModeType(); |
| 4489 | } catch (RemoteException e) { |
| 4490 | } |
Dianne Hackborn | 80fa166 | 2009-10-07 14:02:10 -0700 | [diff] [blame] | 4491 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4492 | updateRotation(true); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4493 | synchronized (mLock) { |
| 4494 | updateOrientationListenerLp(); |
| 4495 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4496 | } |
| 4497 | }; |
| 4498 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4499 | BroadcastReceiver mDreamReceiver = new BroadcastReceiver() { |
| 4500 | @Override |
| 4501 | public void onReceive(Context context, Intent intent) { |
| 4502 | if (Intent.ACTION_DREAMING_STARTED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4503 | if (mKeyguardDelegate != null) { |
| 4504 | mKeyguardDelegate.onDreamingStarted(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4505 | } |
| 4506 | } else if (Intent.ACTION_DREAMING_STOPPED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4507 | if (mKeyguardDelegate != null) { |
| 4508 | mKeyguardDelegate.onDreamingStopped(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4509 | } |
| 4510 | } |
| 4511 | } |
| 4512 | }; |
| 4513 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4514 | BroadcastReceiver mMultiuserReceiver = new BroadcastReceiver() { |
| 4515 | @Override |
| 4516 | public void onReceive(Context context, Intent intent) { |
| 4517 | if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { |
| 4518 | // tickle the settings observer: this first ensures that we're |
| 4519 | // observing the relevant settings for the newly-active user, |
| 4520 | // and then updates our own bookkeeping based on the now- |
| 4521 | // current user. |
| 4522 | mSettingsObserver.onChange(false); |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4523 | |
| 4524 | // force a re-application of focused window sysui visibility. |
| 4525 | // the window may never have been shown for this user |
| 4526 | // e.g. the keyguard when going through the new-user setup flow |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4527 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4528 | mLastSystemUiFlags = 0; |
| 4529 | updateSystemUiVisibilityLw(); |
| 4530 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4531 | } |
| 4532 | } |
| 4533 | }; |
| 4534 | |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 4535 | private final Runnable mRequestTransientNav = new Runnable() { |
| 4536 | @Override |
| 4537 | public void run() { |
| 4538 | requestTransientBars(mNavigationBar); |
| 4539 | } |
| 4540 | }; |
| 4541 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 4542 | private void requestTransientBars(WindowState swipeTarget) { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4543 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 4544 | if (!isUserSetupComplete()) { |
| 4545 | // Swipe-up for navigation bar is disabled during setup |
| 4546 | return; |
| 4547 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4548 | boolean sb = mStatusBarController.checkShowTransientBarLw(); |
| 4549 | boolean nb = mNavigationBarController.checkShowTransientBarLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4550 | if (sb || nb) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 4551 | WindowState barTarget = sb ? mStatusBar : mNavigationBar; |
| 4552 | if (sb ^ nb && barTarget != swipeTarget) { |
| 4553 | if (DEBUG) Slog.d(TAG, "Not showing transient bar, wrong swipe target"); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4554 | return; |
| 4555 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4556 | if (sb) mStatusBarController.showTransient(); |
| 4557 | if (nb) mNavigationBarController.showTransient(); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 4558 | mImmersiveModeConfirmation.confirmCurrentPrompt(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4559 | updateSystemUiVisibilityLw(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 4560 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4561 | } |
| 4562 | } |
| 4563 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4564 | @Override |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 4565 | public void goingToSleep(int why) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4566 | EventLog.writeEvent(70000, 0); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4567 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4568 | mScreenOnEarly = false; |
| 4569 | mScreenOnFully = false; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4570 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4571 | if (mKeyguardDelegate != null) { |
| 4572 | mKeyguardDelegate.onScreenTurnedOff(why); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4573 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4574 | synchronized (mLock) { |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 4575 | updateWakeGestureListenerLp(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4576 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4577 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4578 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4579 | } |
| 4580 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4581 | @Override |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 4582 | public void wakingUp(final ScreenOnListener screenOnListener) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4583 | EventLog.writeEvent(70000, 1); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4584 | if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on...", |
| 4585 | new RuntimeException("here").fillInStackTrace()); |
| 4586 | mHandler.obtainMessage(MSG_WAKING_UP, screenOnListener).sendToTarget(); |
| 4587 | } |
| 4588 | |
| 4589 | // Called on the mHandler thread. |
| 4590 | private void handleWakingUp(final ScreenOnListener screenOnListener) { |
| 4591 | if (screenOnListener != null) { |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 4592 | mScreenOnListener = screenOnListener; |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 4593 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4594 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4595 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4596 | mScreenOnEarly = true; |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 4597 | updateWakeGestureListenerLp(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4598 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4599 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4600 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4601 | |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4602 | mKeyguardDrawComplete = false; |
| 4603 | mWindowManagerDrawComplete = false; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4604 | if (mKeyguardDelegate != null) { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4605 | mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT); |
| 4606 | mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT, 1000); |
| 4607 | mKeyguardDelegate.onScreenTurnedOn(mKeyguardDelegateCallback); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4608 | } else { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4609 | if (DEBUG_WAKEUP) Slog.d(TAG, "null mKeyguardDelegate: setting mKeyguardDrawComplete."); |
| 4610 | mKeyguardDrawComplete = true; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4611 | } |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4612 | mWindowManagerInternal.waitForAllWindowsDrawn(mWindowManagerDrawCallback, 500); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4613 | } |
| 4614 | |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4615 | // Called on the mHandler thread. |
| 4616 | private void finishScreenTurningOn() { |
| 4617 | if (DEBUG_WAKEUP) Slog.d(TAG, |
| 4618 | "finishScreenTurningOn: mKeyguardDrawComplete=" + mKeyguardDrawComplete |
| 4619 | + " mWindowManagerDrawComplete=" + mWindowManagerDrawComplete); |
| 4620 | if (!mKeyguardDrawComplete || !mWindowManagerDrawComplete) { |
| 4621 | return; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4622 | } |
| 4623 | |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 4624 | ScreenOnListener screenOnListener; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4625 | synchronized (mLock) { |
| 4626 | mScreenOnFully = true; |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 4627 | screenOnListener = mScreenOnListener; |
| 4628 | mScreenOnListener = null; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4629 | } |
| 4630 | |
Jeff Brown | 4fc4527 | 2012-10-10 18:28:14 -0700 | [diff] [blame] | 4631 | try { |
| 4632 | mWindowManager.setEventDispatching(true); |
| 4633 | } catch (RemoteException unhandled) { |
| 4634 | } |
| 4635 | |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 4636 | if (screenOnListener != null) { |
| 4637 | screenOnListener.onScreenOn(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4638 | } |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4639 | |
| 4640 | setKeyguardDrawn(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4641 | } |
| 4642 | |
| 4643 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4644 | public boolean isScreenOnEarly() { |
| 4645 | return mScreenOnEarly; |
| 4646 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4647 | |
| 4648 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4649 | public boolean isScreenOnFully() { |
| 4650 | return mScreenOnFully; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4651 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4652 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4653 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4654 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4655 | public void enableKeyguard(boolean enabled) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4656 | if (mKeyguardDelegate != null) { |
| 4657 | mKeyguardDelegate.setKeyguardEnabled(enabled); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4658 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4659 | } |
| 4660 | |
| 4661 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4662 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4663 | public void exitKeyguardSecurely(OnKeyguardExitResult callback) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4664 | if (mKeyguardDelegate != null) { |
| 4665 | mKeyguardDelegate.verifyUnlock(callback); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4666 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4667 | } |
| 4668 | |
Mike Lockwood | f791330 | 2009-11-28 22:27:10 -0500 | [diff] [blame] | 4669 | private boolean keyguardIsShowingTq() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4670 | if (mKeyguardDelegate == null) return false; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4671 | return mKeyguardDelegate.isShowingAndNotOccluded(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4672 | } |
| 4673 | |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4674 | |
| 4675 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4676 | @Override |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4677 | public boolean isKeyguardLocked() { |
| 4678 | return keyguardOn(); |
| 4679 | } |
| 4680 | |
| 4681 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4682 | @Override |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4683 | public boolean isKeyguardSecure() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4684 | if (mKeyguardDelegate == null) return false; |
| 4685 | return mKeyguardDelegate.isSecure(); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4686 | } |
| 4687 | |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4688 | // Returns true if keyguard is currently locked whether or not it is currently hidden. |
| 4689 | private boolean isKeyguardSecureIncludingHidden() { |
| 4690 | return mKeyguardDelegate.isSecure() && mKeyguardDelegate.isShowing(); |
| 4691 | } |
| 4692 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4693 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4694 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4695 | public boolean inKeyguardRestrictedKeyInputMode() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4696 | if (mKeyguardDelegate == null) return false; |
| 4697 | return mKeyguardDelegate.isInputRestricted(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4698 | } |
| 4699 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4700 | @Override |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4701 | public void dismissKeyguardLw() { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 4702 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4703 | mHandler.post(new Runnable() { |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4704 | @Override |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4705 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4706 | if (mKeyguardDelegate.isDismissable()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4707 | // Can we just finish the keyguard straight away? |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4708 | mKeyguardDelegate.keyguardDone(false, true); |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4709 | } else { |
| 4710 | // ask the keyguard to prompt the user to authenticate if necessary |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4711 | mKeyguardDelegate.dismiss(); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4712 | } |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4713 | } |
| 4714 | }); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4715 | } |
| 4716 | } |
| 4717 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 4718 | private void setKeyguardDrawn() { |
| 4719 | synchronized (mLock) { |
| 4720 | mKeyguardDrawn = true; |
| 4721 | } |
| 4722 | try { |
| 4723 | mWindowManager.enableScreenIfNeeded(); |
| 4724 | } catch (RemoteException unhandled) { |
| 4725 | } |
| 4726 | } |
| 4727 | |
| 4728 | @Override |
| 4729 | public boolean isKeyguardDrawnLw() { |
| 4730 | synchronized (mLock) { |
| 4731 | return mKeyguardDrawn; |
| 4732 | } |
| 4733 | } |
| 4734 | |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4735 | @Override |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 4736 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4737 | if (mKeyguardDelegate != null) { |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 4738 | mKeyguardDelegate.startKeyguardExitAnimation(startTime, fadeoutDuration); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4739 | } |
| 4740 | } |
| 4741 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4742 | void sendCloseSystemWindows() { |
| 4743 | sendCloseSystemWindows(mContext, null); |
| 4744 | } |
| 4745 | |
| 4746 | void sendCloseSystemWindows(String reason) { |
| 4747 | sendCloseSystemWindows(mContext, reason); |
| 4748 | } |
| 4749 | |
| 4750 | static void sendCloseSystemWindows(Context context, String reason) { |
| 4751 | if (ActivityManagerNative.isSystemReady()) { |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 4752 | try { |
| 4753 | ActivityManagerNative.getDefault().closeSystemDialogs(reason); |
| 4754 | } catch (RemoteException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4755 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4756 | } |
| 4757 | } |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 4758 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4759 | @Override |
| 4760 | public int rotationForOrientationLw(int orientation, int lastRotation) { |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4761 | if (false) { |
| 4762 | Slog.v(TAG, "rotationForOrientationLw(orient=" |
| 4763 | + orientation + ", last=" + lastRotation |
| 4764 | + "); user=" + mUserRotation + " " |
| 4765 | + ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) |
| 4766 | ? "USER_ROTATION_LOCKED" : "") |
| 4767 | ); |
| 4768 | } |
| 4769 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 4770 | if (mForceDefaultOrientation) { |
| 4771 | return Surface.ROTATION_0; |
| 4772 | } |
| 4773 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4774 | synchronized (mLock) { |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4775 | int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 |
| 4776 | if (sensorRotation < 0) { |
Jeff Brown | 0f862b4 | 2012-09-27 21:11:01 -0700 | [diff] [blame] | 4777 | sensorRotation = lastRotation; |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4778 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4779 | |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4780 | final int preferredRotation; |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 4781 | if (mLidState == LID_OPEN && mLidOpenRotation >= 0) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4782 | // Ignore sensor when lid switch is open and rotation is forced. |
| 4783 | preferredRotation = mLidOpenRotation; |
| 4784 | } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4785 | && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4786 | // Ignore sensor when in car dock unless explicitly enabled. |
| 4787 | // This case can override the behavior of NOSENSOR, and can also |
| 4788 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4789 | preferredRotation = mCarDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4790 | ? sensorRotation : mCarDockRotation; |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 4791 | } else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 4792 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 4793 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4794 | && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4795 | // Ignore sensor when in desk dock unless explicitly enabled. |
| 4796 | // This case can override the behavior of NOSENSOR, and can also |
| 4797 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4798 | preferredRotation = mDeskDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4799 | ? sensorRotation : mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4800 | } else if (mHdmiPlugged && mDemoHdmiRotationLock) { |
| 4801 | // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled. |
Jeff Brown | eb3e4b9 | 2011-12-06 19:54:24 -0800 | [diff] [blame] | 4802 | // Note that the dock orientation overrides the HDMI orientation. |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4803 | preferredRotation = mDemoHdmiRotation; |
| 4804 | } else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED |
| 4805 | && mUndockedHdmiRotation >= 0) { |
| 4806 | // Ignore sensor when plugged into HDMI and an undocked orientation has |
| 4807 | // been specified in the configuration (only for legacy devices without |
| 4808 | // full multi-display support). |
| 4809 | // Note that the dock orientation overrides the HDMI orientation. |
| 4810 | preferredRotation = mUndockedHdmiRotation; |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4811 | } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { |
| 4812 | // Application just wants to remain locked in the last rotation. |
| 4813 | preferredRotation = lastRotation; |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 4814 | } else if (!mSupportAutoRotation) { |
| 4815 | // If we don't support auto-rotation then bail out here and ignore |
| 4816 | // the sensor and any rotation lock settings. |
| 4817 | preferredRotation = -1; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4818 | } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4819 | && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4820 | || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED |
| 4821 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE |
| 4822 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT |
| 4823 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER)) |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4824 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 4825 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4826 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 4827 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { |
| 4828 | // Otherwise, use sensor only if requested by the application or enabled |
| 4829 | // by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR. |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4830 | if (mAllowAllRotations < 0) { |
| 4831 | // Can't read this during init() because the context doesn't |
| 4832 | // have display metrics at that time so we cannot determine |
| 4833 | // tablet vs. phone then. |
| 4834 | mAllowAllRotations = mContext.getResources().getBoolean( |
| 4835 | com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; |
| 4836 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4837 | if (sensorRotation != Surface.ROTATION_180 |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4838 | || mAllowAllRotations == 1 |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4839 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4840 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4841 | preferredRotation = sensorRotation; |
| 4842 | } else { |
| 4843 | preferredRotation = lastRotation; |
| 4844 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4845 | } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED |
| 4846 | && orientation != ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { |
| 4847 | // Apply rotation lock. Does not apply to NOSENSOR. |
| 4848 | // The idea is that the user rotation expresses a weak preference for the direction |
| 4849 | // of gravity and as NOSENSOR is never affected by gravity, then neither should |
| 4850 | // 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] | 4851 | preferredRotation = mUserRotation; |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4852 | } else { |
| 4853 | // No overriding preference. |
| 4854 | // We will do exactly what the application asked us to do. |
| 4855 | preferredRotation = -1; |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4856 | } |
| 4857 | |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4858 | switch (orientation) { |
| 4859 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4860 | // Return portrait unless overridden. |
| 4861 | if (isAnyPortrait(preferredRotation)) { |
| 4862 | return preferredRotation; |
| 4863 | } |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4864 | return mPortraitRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4865 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4866 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4867 | // Return landscape unless overridden. |
| 4868 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4869 | return preferredRotation; |
| 4870 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4871 | return mLandscapeRotation; |
| 4872 | |
| 4873 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4874 | // Return reverse portrait unless overridden. |
| 4875 | if (isAnyPortrait(preferredRotation)) { |
| 4876 | return preferredRotation; |
| 4877 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4878 | return mUpsideDownRotation; |
| 4879 | |
| 4880 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4881 | // Return seascape unless overridden. |
| 4882 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4883 | return preferredRotation; |
| 4884 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4885 | return mSeascapeRotation; |
| 4886 | |
| 4887 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4888 | case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4889 | // Return either landscape rotation. |
| 4890 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4891 | return preferredRotation; |
| 4892 | } |
| 4893 | if (isLandscapeOrSeascape(lastRotation)) { |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 4894 | return lastRotation; |
| 4895 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4896 | return mLandscapeRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4897 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4898 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4899 | case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4900 | // Return either portrait rotation. |
| 4901 | if (isAnyPortrait(preferredRotation)) { |
| 4902 | return preferredRotation; |
| 4903 | } |
| 4904 | if (isAnyPortrait(lastRotation)) { |
| 4905 | return lastRotation; |
| 4906 | } |
| 4907 | return mPortraitRotation; |
| 4908 | |
| 4909 | default: |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 4910 | // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, |
| 4911 | // just return the preferred orientation we already calculated. |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4912 | if (preferredRotation >= 0) { |
| 4913 | return preferredRotation; |
| 4914 | } |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 4915 | return Surface.ROTATION_0; |
Daniel Sandler | e7e5ac2 | 2011-02-22 16:10:21 -0500 | [diff] [blame] | 4916 | } |
| 4917 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4918 | } |
| 4919 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4920 | @Override |
| 4921 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation) { |
| 4922 | switch (orientation) { |
| 4923 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
| 4924 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
| 4925 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
| 4926 | return isAnyPortrait(rotation); |
| 4927 | |
| 4928 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
| 4929 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
| 4930 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
| 4931 | return isLandscapeOrSeascape(rotation); |
| 4932 | |
| 4933 | default: |
| 4934 | return true; |
| 4935 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4936 | } |
| 4937 | |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4938 | @Override |
| 4939 | public void setRotationLw(int rotation) { |
| 4940 | mOrientationListener.setCurrentRotation(rotation); |
| 4941 | } |
| 4942 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4943 | private boolean isLandscapeOrSeascape(int rotation) { |
| 4944 | return rotation == mLandscapeRotation || rotation == mSeascapeRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4945 | } |
| 4946 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4947 | private boolean isAnyPortrait(int rotation) { |
| 4948 | return rotation == mPortraitRotation || rotation == mUpsideDownRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4949 | } |
| 4950 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4951 | @Override |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4952 | public int getUserRotationMode() { |
| 4953 | return Settings.System.getIntForUser(mContext.getContentResolver(), |
Brett Chabot | 7e55c40 | 2013-05-16 19:38:08 -0700 | [diff] [blame] | 4954 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
| 4955 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 4956 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4957 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4958 | |
| 4959 | // User rotation: to be used when all else fails in assigning an orientation to the device |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4960 | @Override |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4961 | public void setUserRotationMode(int mode, int rot) { |
| 4962 | ContentResolver res = mContext.getContentResolver(); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4963 | |
| 4964 | // mUserRotationMode and mUserRotation will be assigned by the content observer |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4965 | if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4966 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4967 | Settings.System.USER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4968 | rot, |
| 4969 | UserHandle.USER_CURRENT); |
| 4970 | Settings.System.putIntForUser(res, |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4971 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4972 | 0, |
| 4973 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4974 | } else { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4975 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4976 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4977 | 1, |
| 4978 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4979 | } |
| 4980 | } |
| 4981 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4982 | @Override |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 4983 | public void setSafeMode(boolean safeMode) { |
| 4984 | mSafeMode = safeMode; |
| 4985 | performHapticFeedbackLw(null, safeMode |
| 4986 | ? HapticFeedbackConstants.SAFE_MODE_ENABLED |
| 4987 | : HapticFeedbackConstants.SAFE_MODE_DISABLED, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4988 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4989 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 4990 | static long[] getLongIntArray(Resources r, int resid) { |
| 4991 | int[] ar = r.getIntArray(resid); |
| 4992 | if (ar == null) { |
| 4993 | return null; |
| 4994 | } |
| 4995 | long[] out = new long[ar.length]; |
| 4996 | for (int i=0; i<ar.length; i++) { |
| 4997 | out[i] = ar[i]; |
| 4998 | } |
| 4999 | return out; |
| 5000 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5001 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5002 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5003 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5004 | public void systemReady() { |
Mike Lockwood | ed8902d | 2013-11-15 11:01:47 -0800 | [diff] [blame] | 5005 | mKeyguardDelegate = new KeyguardServiceDelegate(mContext, null); |
| 5006 | mKeyguardDelegate.onSystemReady(); |
| 5007 | |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 5008 | updateUiMode(); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5009 | synchronized (mLock) { |
| 5010 | updateOrientationListenerLp(); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 5011 | mSystemReady = true; |
| 5012 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5013 | @Override |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 5014 | public void run() { |
| 5015 | updateSettings(); |
| 5016 | } |
| 5017 | }); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5018 | } |
| 5019 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5020 | |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5021 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5022 | @Override |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5023 | public void systemBooted() { |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 5024 | if (mKeyguardDelegate != null) { |
| 5025 | mKeyguardDelegate.onBootCompleted(); |
| 5026 | } |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5027 | synchronized (mLock) { |
| 5028 | mSystemBooted = true; |
| 5029 | } |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 5030 | wakingUp(null); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5031 | } |
| 5032 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5033 | ProgressDialog mBootMsgDialog = null; |
| 5034 | |
| 5035 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5036 | @Override |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5037 | public void showBootMessage(final CharSequence msg, final boolean always) { |
| 5038 | mHandler.post(new Runnable() { |
| 5039 | @Override public void run() { |
| 5040 | if (mBootMsgDialog == null) { |
Craig Stout | 4c0cb8a | 2014-04-04 13:03:10 -0700 | [diff] [blame] | 5041 | int theme; |
| 5042 | if (mContext.getPackageManager().hasSystemFeature( |
| 5043 | PackageManager.FEATURE_WATCH)) { |
| 5044 | theme = com.android.internal.R.style.Theme_Micro_Dialog_Alert; |
| 5045 | } else if (mContext.getPackageManager().hasSystemFeature( |
| 5046 | PackageManager.FEATURE_TELEVISION)) { |
| 5047 | theme = com.android.internal.R.style.Theme_Leanback_Dialog_Alert; |
| 5048 | } else { |
| 5049 | theme = 0; |
| 5050 | } |
Vinod Krishnan | fa8fc41 | 2014-04-18 14:35:53 -0700 | [diff] [blame] | 5051 | |
| 5052 | mBootMsgDialog = new ProgressDialog(mContext, theme) { |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 5053 | // This dialog will consume all events coming in to |
| 5054 | // it, to avoid it trying to do things too early in boot. |
| 5055 | @Override public boolean dispatchKeyEvent(KeyEvent event) { |
| 5056 | return true; |
| 5057 | } |
| 5058 | @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 5059 | return true; |
| 5060 | } |
| 5061 | @Override public boolean dispatchTouchEvent(MotionEvent ev) { |
| 5062 | return true; |
| 5063 | } |
| 5064 | @Override public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 5065 | return true; |
| 5066 | } |
| 5067 | @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 5068 | return true; |
| 5069 | } |
| 5070 | @Override public boolean dispatchPopulateAccessibilityEvent( |
| 5071 | AccessibilityEvent event) { |
| 5072 | return true; |
| 5073 | } |
| 5074 | }; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5075 | mBootMsgDialog.setTitle(R.string.android_upgrading_title); |
| 5076 | mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); |
| 5077 | mBootMsgDialog.setIndeterminate(true); |
| 5078 | mBootMsgDialog.getWindow().setType( |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 5079 | WindowManager.LayoutParams.TYPE_BOOT_PROGRESS); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5080 | mBootMsgDialog.getWindow().addFlags( |
| 5081 | WindowManager.LayoutParams.FLAG_DIM_BEHIND |
| 5082 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); |
| 5083 | mBootMsgDialog.getWindow().setDimAmount(1); |
Dianne Hackborn | d9efb95 | 2011-12-07 14:56:51 -0800 | [diff] [blame] | 5084 | WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes(); |
| 5085 | lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 5086 | mBootMsgDialog.getWindow().setAttributes(lp); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5087 | mBootMsgDialog.setCancelable(false); |
| 5088 | mBootMsgDialog.show(); |
| 5089 | } |
| 5090 | mBootMsgDialog.setMessage(msg); |
| 5091 | } |
| 5092 | }); |
| 5093 | } |
| 5094 | |
| 5095 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5096 | @Override |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5097 | public void hideBootMessages() { |
| 5098 | mHandler.post(new Runnable() { |
| 5099 | @Override public void run() { |
| 5100 | if (mBootMsgDialog != null) { |
| 5101 | mBootMsgDialog.dismiss(); |
| 5102 | mBootMsgDialog = null; |
| 5103 | } |
| 5104 | } |
| 5105 | }); |
| 5106 | } |
| 5107 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5108 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5109 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5110 | public void userActivity() { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5111 | // *************************************** |
| 5112 | // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE |
| 5113 | // *************************************** |
| 5114 | // THIS IS CALLED FROM DEEP IN THE POWER MANAGER |
| 5115 | // WITH ITS LOCKS HELD. |
| 5116 | // |
| 5117 | // This code must be VERY careful about the locks |
| 5118 | // it acquires. |
| 5119 | // In fact, the current code acquires way too many, |
| 5120 | // and probably has lurking deadlocks. |
| 5121 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5122 | synchronized (mScreenLockTimeout) { |
| 5123 | if (mLockScreenTimerActive) { |
| 5124 | // reset the timer |
| 5125 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 5126 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 5127 | } |
| 5128 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 5129 | } |
| 5130 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5131 | class ScreenLockTimeout implements Runnable { |
| 5132 | Bundle options; |
| 5133 | |
| 5134 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5135 | public void run() { |
| 5136 | synchronized (this) { |
| 5137 | if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5138 | if (mKeyguardDelegate != null) { |
| 5139 | mKeyguardDelegate.doKeyguardTimeout(options); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 5140 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5141 | mLockScreenTimerActive = false; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5142 | options = null; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5143 | } |
| 5144 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5145 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5146 | public void setLockOptions(Bundle options) { |
| 5147 | this.options = options; |
| 5148 | } |
| 5149 | } |
| 5150 | |
| 5151 | ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout(); |
| 5152 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5153 | @Override |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5154 | public void lockNow(Bundle options) { |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 5155 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); |
| 5156 | mHandler.removeCallbacks(mScreenLockTimeout); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5157 | if (options != null) { |
| 5158 | // In case multiple calls are made to lockNow, we don't wipe out the options |
| 5159 | // until the runnable actually executes. |
| 5160 | mScreenLockTimeout.setLockOptions(options); |
| 5161 | } |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 5162 | mHandler.post(mScreenLockTimeout); |
| 5163 | } |
| 5164 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5165 | private void updateLockScreenTimeout() { |
| 5166 | synchronized (mScreenLockTimeout) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 5167 | boolean enable = (mAllowLockscreenWhenOn && mScreenOnEarly && |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5168 | mKeyguardDelegate != null && mKeyguardDelegate.isSecure()); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5169 | if (mLockScreenTimerActive != enable) { |
| 5170 | if (enable) { |
| 5171 | if (localLOGV) Log.v(TAG, "setting lockscreen timer"); |
| 5172 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 5173 | } else { |
| 5174 | if (localLOGV) Log.v(TAG, "clearing lockscreen timer"); |
| 5175 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 5176 | } |
| 5177 | mLockScreenTimerActive = enable; |
| 5178 | } |
| 5179 | } |
| 5180 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5181 | |
| 5182 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5183 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5184 | public void enableScreenAfterBoot() { |
| 5185 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5186 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5187 | updateRotation(true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5188 | } |
Dianne Hackborn | f54c8f9 | 2009-09-19 14:03:57 -0700 | [diff] [blame] | 5189 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5190 | private void applyLidSwitchState() { |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5191 | if (mLidState == LID_CLOSED && mLidControlsSleep) { |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 5192 | mPowerManager.goToSleep(SystemClock.uptimeMillis(), |
| 5193 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 5194 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5195 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5196 | |
| 5197 | synchronized (mLock) { |
| 5198 | updateWakeGestureListenerLp(); |
| 5199 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5200 | } |
| 5201 | |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 5202 | void updateUiMode() { |
| 5203 | if (mUiModeManager == null) { |
| 5204 | mUiModeManager = IUiModeManager.Stub.asInterface( |
| 5205 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 5206 | } |
| 5207 | try { |
| 5208 | mUiMode = mUiModeManager.getCurrentModeType(); |
| 5209 | } catch (RemoteException e) { |
| 5210 | } |
| 5211 | } |
| 5212 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5213 | void updateRotation(boolean alwaysSendConfiguration) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5214 | try { |
| 5215 | //set orientation on WindowManager |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 5216 | mWindowManager.updateRotation(alwaysSendConfiguration, false); |
| 5217 | } catch (RemoteException e) { |
| 5218 | // Ignore |
| 5219 | } |
| 5220 | } |
| 5221 | |
| 5222 | void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout) { |
| 5223 | try { |
| 5224 | //set orientation on WindowManager |
| 5225 | mWindowManager.updateRotation(alwaysSendConfiguration, forceRelayout); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5226 | } catch (RemoteException e) { |
| 5227 | // Ignore |
| 5228 | } |
| 5229 | } |
| 5230 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5231 | /** |
| 5232 | * Return an Intent to launch the currently active dock app as home. Returns |
| 5233 | * null if the standard home should be launched, which is the case if any of the following is |
| 5234 | * true: |
| 5235 | * <ul> |
| 5236 | * <li>The device is not in either car mode or desk mode |
| 5237 | * <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false |
| 5238 | * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false |
| 5239 | * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME |
| 5240 | * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME |
| 5241 | * </ul> |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5242 | * @return A dock intent. |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5243 | */ |
| 5244 | Intent createHomeDockIntent() { |
| 5245 | Intent intent = null; |
| 5246 | |
| 5247 | // What home does is based on the mode, not the dock state. That |
| 5248 | // is, when in car mode you should be taken to car home regardless |
| 5249 | // of whether we are actually in a car dock. |
| 5250 | if (mUiMode == Configuration.UI_MODE_TYPE_CAR) { |
| 5251 | if (ENABLE_CAR_DOCK_HOME_CAPTURE) { |
| 5252 | intent = mCarDockIntent; |
| 5253 | } |
| 5254 | } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { |
| 5255 | if (ENABLE_DESK_DOCK_HOME_CAPTURE) { |
| 5256 | intent = mDeskDockIntent; |
| 5257 | } |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 5258 | } else if (mUiMode == Configuration.UI_MODE_TYPE_WATCH |
| 5259 | && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 5260 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK |
| 5261 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK)) { |
| 5262 | // Always launch dock home from home when watch is docked, if it exists. |
| 5263 | intent = mDeskDockIntent; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5264 | } |
| 5265 | |
| 5266 | if (intent == null) { |
| 5267 | return null; |
| 5268 | } |
| 5269 | |
| 5270 | ActivityInfo ai = null; |
| 5271 | ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser( |
| 5272 | intent, |
John Spurlock | f56bef1 | 2013-07-09 09:51:46 -0400 | [diff] [blame] | 5273 | PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 5274 | mCurrentUserId); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5275 | if (info != null) { |
| 5276 | ai = info.activityInfo; |
| 5277 | } |
| 5278 | if (ai != null |
| 5279 | && ai.metaData != null |
| 5280 | && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { |
| 5281 | intent = new Intent(intent); |
| 5282 | intent.setClassName(ai.packageName, ai.name); |
| 5283 | return intent; |
| 5284 | } |
| 5285 | |
| 5286 | return null; |
| 5287 | } |
| 5288 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5289 | void startDockOrHome() { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 5290 | awakenDreams(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5291 | |
| 5292 | Intent dock = createHomeDockIntent(); |
| 5293 | if (dock != null) { |
| 5294 | try { |
| 5295 | mContext.startActivityAsUser(dock, UserHandle.CURRENT); |
| 5296 | return; |
| 5297 | } catch (ActivityNotFoundException e) { |
| 5298 | } |
| 5299 | } |
| 5300 | |
Dianne Hackborn | d888399 | 2012-09-07 15:58:52 -0700 | [diff] [blame] | 5301 | mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5302 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5303 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5304 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5305 | * goes to the home screen |
| 5306 | * @return whether it did anything |
| 5307 | */ |
| 5308 | boolean goHome() { |
| 5309 | if (false) { |
| 5310 | // This code always brings home to the front. |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 5311 | try { |
| 5312 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 5313 | } catch (RemoteException e) { |
| 5314 | } |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 5315 | sendCloseSystemWindows(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5316 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5317 | } else { |
| 5318 | // This code brings home to the front or, if it is already |
| 5319 | // at the front, puts the device to sleep. |
| 5320 | try { |
Wink Saville | d2e6a33 | 2010-02-12 12:12:06 -0800 | [diff] [blame] | 5321 | if (SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1) { |
| 5322 | /// Roll back EndcallBehavior as the cupcake design to pass P1 lab entry. |
| 5323 | Log.d(TAG, "UTS-TEST-MODE"); |
| 5324 | } else { |
| 5325 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 5326 | sendCloseSystemWindows(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5327 | Intent dock = createHomeDockIntent(); |
| 5328 | if (dock != null) { |
| 5329 | int result = ActivityManagerNative.getDefault() |
| 5330 | .startActivityAsUser(null, null, dock, |
| 5331 | dock.resolveTypeIfNeeded(mContext.getContentResolver()), |
| 5332 | null, null, 0, |
| 5333 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
| 5334 | null, null, null, UserHandle.USER_CURRENT); |
| 5335 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
| 5336 | return false; |
| 5337 | } |
| 5338 | } |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5339 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5340 | int result = ActivityManagerNative.getDefault() |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5341 | .startActivityAsUser(null, null, mHomeIntent, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5342 | mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 5343 | null, null, 0, |
| 5344 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
Dianne Hackborn | 5e03e2c | 2012-09-06 14:21:19 -0700 | [diff] [blame] | 5345 | null, null, null, UserHandle.USER_CURRENT); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 5346 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5347 | return false; |
| 5348 | } |
| 5349 | } catch (RemoteException ex) { |
| 5350 | // bummer, the activity manager, which is in this process, is dead |
| 5351 | } |
| 5352 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5353 | return true; |
| 5354 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5355 | |
| 5356 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5357 | public void setCurrentOrientationLw(int newOrientation) { |
| 5358 | synchronized (mLock) { |
| 5359 | if (newOrientation != mCurrentAppOrientation) { |
| 5360 | mCurrentAppOrientation = newOrientation; |
| 5361 | updateOrientationListenerLp(); |
| 5362 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5363 | } |
| 5364 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5365 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5366 | private void performAuditoryFeedbackForAccessibilityIfNeed() { |
| 5367 | if (!isGlobalAccessibilityGestureEnabled()) { |
| 5368 | return; |
| 5369 | } |
| 5370 | AudioManager audioManager = (AudioManager) mContext.getSystemService( |
| 5371 | Context.AUDIO_SERVICE); |
| 5372 | if (audioManager.isSilentMode()) { |
| 5373 | return; |
| 5374 | } |
| 5375 | Ringtone ringTone = RingtoneManager.getRingtone(mContext, |
| 5376 | Settings.System.DEFAULT_NOTIFICATION_URI); |
| 5377 | ringTone.setStreamType(AudioManager.STREAM_MUSIC); |
| 5378 | ringTone.play(); |
| 5379 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5380 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5381 | private boolean isGlobalAccessibilityGestureEnabled() { |
| 5382 | return Settings.Global.getInt(mContext.getContentResolver(), |
| 5383 | Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1; |
| 5384 | } |
| 5385 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5386 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5387 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { |
Svetoslav Ganov | 9617921 | 2012-10-10 14:17:45 -0700 | [diff] [blame] | 5388 | if (!mVibrator.hasVibrator()) { |
| 5389 | return false; |
| 5390 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5391 | final boolean hapticsDisabled = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 5392 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) == 0; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5393 | if (!always && (hapticsDisabled || mKeyguardDelegate.isShowingAndNotOccluded())) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5394 | return false; |
| 5395 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5396 | long[] pattern = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5397 | switch (effectId) { |
| 5398 | case HapticFeedbackConstants.LONG_PRESS: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5399 | pattern = mLongPressVibePattern; |
| 5400 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5401 | case HapticFeedbackConstants.VIRTUAL_KEY: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5402 | pattern = mVirtualKeyVibePattern; |
| 5403 | break; |
| 5404 | case HapticFeedbackConstants.KEYBOARD_TAP: |
| 5405 | pattern = mKeyboardTapVibePattern; |
| 5406 | break; |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 5407 | case HapticFeedbackConstants.CLOCK_TICK: |
| 5408 | pattern = mClockTickVibePattern; |
| 5409 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5410 | case HapticFeedbackConstants.SAFE_MODE_DISABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5411 | pattern = mSafeModeDisabledVibePattern; |
| 5412 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5413 | case HapticFeedbackConstants.SAFE_MODE_ENABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5414 | pattern = mSafeModeEnabledVibePattern; |
| 5415 | break; |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5416 | default: |
| 5417 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5418 | } |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5419 | int owningUid; |
| 5420 | String owningPackage; |
| 5421 | if (win != null) { |
| 5422 | owningUid = win.getOwningUid(); |
| 5423 | owningPackage = win.getOwningPackage(); |
| 5424 | } else { |
| 5425 | owningUid = android.os.Process.myUid(); |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 5426 | owningPackage = mContext.getOpPackageName(); |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5427 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5428 | if (pattern.length == 1) { |
| 5429 | // One-shot vibration |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 5430 | mVibrator.vibrate(owningUid, owningPackage, pattern[0], AudioManager.STREAM_SYSTEM); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5431 | } else { |
| 5432 | // Pattern vibration |
John Spurlock | 1af30c7 | 2014-03-10 08:33:35 -0400 | [diff] [blame] | 5433 | mVibrator.vibrate(owningUid, owningPackage, pattern, -1, AudioManager.STREAM_SYSTEM); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5434 | } |
| 5435 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5436 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5437 | |
| 5438 | @Override |
| 5439 | public void keepScreenOnStartedLw() { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 5440 | } |
| 5441 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5442 | @Override |
| 5443 | public void keepScreenOnStoppedLw() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5444 | if (mKeyguardDelegate != null && !mKeyguardDelegate.isShowingAndNotOccluded()) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 5445 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5446 | } |
| 5447 | } |
Mike Lockwood | fcb3924 | 2009-10-21 23:01:07 -0400 | [diff] [blame] | 5448 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5449 | private int updateSystemUiVisibilityLw() { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5450 | // If there is no window focused, there will be nobody to handle the events |
| 5451 | // 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] | 5452 | WindowState win = mFocusedWindow != null ? mFocusedWindow : mTopFullscreenOpaqueWindowState; |
| 5453 | if (win == null) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5454 | return 0; |
| 5455 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5456 | if ((win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 && mHideLockScreen == true) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5457 | // We are updating at a point where the keyguard has gotten |
| 5458 | // focus, but we were last in a state where the top window is |
| 5459 | // hiding it. This is probably because the keyguard as been |
| 5460 | // shown while the top window was displayed, so we want to ignore |
| 5461 | // it here because this is just a very transient change and it |
| 5462 | // will quickly lose focus once it correctly gets hidden. |
| 5463 | return 0; |
| 5464 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 5465 | |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 5466 | int tmpVisibility = PolicyControl.getSystemUiVisibility(win, null) |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5467 | & ~mResettingSystemUiFlags |
| 5468 | & ~mForceClearedSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5469 | if (mForcingShowNavBar && win.getSurfaceLayer() < mForcingShowNavBarLayer) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5470 | tmpVisibility &= ~PolicyControl.adjustClearableFlags(win, View.SYSTEM_UI_CLEARABLE_FLAGS); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5471 | } |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5472 | final int visibility = updateSystemBarsLw(win, mLastSystemUiFlags, tmpVisibility); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5473 | final int diff = visibility ^ mLastSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5474 | final boolean needsMenu = win.getNeedsMenuLw(mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 5475 | if (diff == 0 && mLastFocusNeedsMenu == needsMenu |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5476 | && mFocusedApp == win.getAppToken()) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5477 | return 0; |
| 5478 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5479 | mLastSystemUiFlags = visibility; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5480 | mLastFocusNeedsMenu = needsMenu; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5481 | mFocusedApp = win.getAppToken(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5482 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5483 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5484 | public void run() { |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5485 | try { |
| 5486 | IStatusBarService statusbar = getStatusBarService(); |
| 5487 | if (statusbar != null) { |
| 5488 | statusbar.setSystemUiVisibility(visibility, 0xffffffff); |
| 5489 | statusbar.topAppWindowChanged(needsMenu); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5490 | } |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5491 | } catch (RemoteException e) { |
| 5492 | // re-acquire status bar service next time it is needed. |
| 5493 | mStatusBarService = null; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5494 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5495 | } |
| 5496 | }); |
| 5497 | return diff; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5498 | } |
| 5499 | |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5500 | private int updateSystemBarsLw(WindowState win, int oldVis, int vis) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5501 | // apply translucent bar vis flags |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5502 | WindowState transWin = isStatusBarKeyguard() && !mHideLockScreen |
| 5503 | ? mStatusBar |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5504 | : mTopFullscreenOpaqueWindowState; |
| 5505 | vis = mStatusBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 5506 | vis = mNavigationBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 5507 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5508 | // prevent status bar interaction from clearing certain flags |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5509 | boolean statusBarHasFocus = win.getAttrs().type == TYPE_STATUS_BAR; |
John Spurlock | 08ffcf5 | 2014-07-11 10:13:46 -0400 | [diff] [blame] | 5510 | if (statusBarHasFocus && !isStatusBarKeyguard()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5511 | int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
| 5512 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 5513 | | View.SYSTEM_UI_FLAG_IMMERSIVE |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5514 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
John Spurlock | 08ffcf5 | 2014-07-11 10:13:46 -0400 | [diff] [blame] | 5515 | if (mHideLockScreen) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5516 | flags |= View.STATUS_BAR_TRANSLUCENT | View.NAVIGATION_BAR_TRANSLUCENT; |
| 5517 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5518 | vis = (vis & ~flags) | (oldVis & flags); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5519 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5520 | |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5521 | if (!areTranslucentBarsAllowed()) { |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 5522 | vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT |
| 5523 | | View.SYSTEM_UI_TRANSPARENT); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5524 | } |
| 5525 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5526 | // update status bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5527 | boolean immersiveSticky = |
| 5528 | (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5529 | boolean hideStatusBarWM = |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5530 | mTopFullscreenOpaqueWindowState != null && |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5531 | (PolicyControl.getWindowFlags(mTopFullscreenOpaqueWindowState, null) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5532 | & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; |
| 5533 | boolean hideStatusBarSysui = |
| 5534 | (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5535 | boolean hideNavBarSysui = |
| 5536 | (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5537 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5538 | boolean transientStatusBarAllowed = |
| 5539 | mStatusBar != null && ( |
| 5540 | hideStatusBarWM |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5541 | || (hideStatusBarSysui && immersiveSticky) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5542 | || statusBarHasFocus); |
| 5543 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5544 | boolean transientNavBarAllowed = |
| 5545 | mNavigationBar != null && |
| 5546 | hideNavBarSysui && immersiveSticky; |
| 5547 | |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 5548 | boolean denyTransientStatus = mStatusBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5549 | && !transientStatusBarAllowed && hideStatusBarSysui; |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 5550 | boolean denyTransientNav = mNavigationBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5551 | && !transientNavBarAllowed; |
| 5552 | if (denyTransientStatus || denyTransientNav) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5553 | // clear the clearable flags instead |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5554 | clearClearableFlagsLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5555 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5556 | |
| 5557 | vis = mStatusBarController.updateVisibilityLw(transientStatusBarAllowed, oldVis, vis); |
| 5558 | |
| 5559 | // update navigation bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5560 | boolean oldImmersiveMode = isImmersiveMode(oldVis); |
| 5561 | boolean newImmersiveMode = isImmersiveMode(vis); |
| 5562 | if (win != null && oldImmersiveMode != newImmersiveMode) { |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5563 | final String pkg = win.getOwningPackage(); |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 5564 | mImmersiveModeConfirmation.immersiveModeChanged(pkg, newImmersiveMode, |
| 5565 | isUserSetupComplete()); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5566 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5567 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5568 | vis = mNavigationBarController.updateVisibilityLw(transientNavBarAllowed, oldVis, vis); |
| 5569 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 5570 | return vis; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5571 | } |
| 5572 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5573 | private void clearClearableFlagsLw() { |
| 5574 | int newVal = mResettingSystemUiFlags | View.SYSTEM_UI_CLEARABLE_FLAGS; |
| 5575 | if (newVal != mResettingSystemUiFlags) { |
| 5576 | mResettingSystemUiFlags = newVal; |
| 5577 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 5578 | } |
| 5579 | } |
| 5580 | |
| 5581 | private boolean isImmersiveMode(int vis) { |
| 5582 | 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] | 5583 | return mNavigationBar != null |
| 5584 | && (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0 |
Daniel Sandler | 900ece5 | 2013-10-18 15:53:27 -0400 | [diff] [blame] | 5585 | && (vis & flags) != 0 |
| 5586 | && canHideNavigationBar(); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5587 | } |
| 5588 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5589 | /** |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5590 | * @return whether the navigation or status bar can be made translucent |
| 5591 | * |
| 5592 | * This should return true unless touch exploration is not enabled or |
| 5593 | * R.boolean.config_enableTranslucentDecor is false. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5594 | */ |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5595 | private boolean areTranslucentBarsAllowed() { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 5596 | return mTranslucentDecorEnabled |
| 5597 | && !mAccessibilityManager.isTouchExplorationEnabled(); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5598 | } |
| 5599 | |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5600 | // Use this instead of checking config_showNavigationBar so that it can be consistently |
| 5601 | // overridden by qemu.hw.mainkeys in the emulator. |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5602 | @Override |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5603 | public boolean hasNavigationBar() { |
| 5604 | return mHasNavigationBar; |
| 5605 | } |
| 5606 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 5607 | @Override |
| 5608 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target) { |
| 5609 | mLastInputMethodWindow = ime; |
| 5610 | mLastInputMethodTargetWindow = target; |
| 5611 | } |
| 5612 | |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5613 | @Override |
Satoshi Kataoka | 658c7b8 | 2013-10-10 17:03:51 +0900 | [diff] [blame] | 5614 | public int getInputMethodWindowVisibleHeightLw() { |
| 5615 | return mDockBottom - mCurBottom; |
| 5616 | } |
| 5617 | |
| 5618 | @Override |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5619 | public void setCurrentUserLw(int newUserId) { |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 5620 | mCurrentUserId = newUserId; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5621 | if (mKeyguardDelegate != null) { |
| 5622 | mKeyguardDelegate.setCurrentUser(newUserId); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5623 | } |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 5624 | if (mStatusBarService != null) { |
| 5625 | try { |
| 5626 | mStatusBarService.setCurrentUser(newUserId); |
| 5627 | } catch (RemoteException e) { |
| 5628 | // oh well |
| 5629 | } |
| 5630 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5631 | setLastInputMethodWindowLw(null, null); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5632 | } |
| 5633 | |
| 5634 | @Override |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 5635 | public boolean canMagnifyWindow(int windowType) { |
| 5636 | switch (windowType) { |
| 5637 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD: |
| 5638 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG: |
| 5639 | case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR: |
| 5640 | case WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY: { |
| 5641 | return false; |
| 5642 | } |
| 5643 | } |
| 5644 | return true; |
| 5645 | } |
| 5646 | |
| 5647 | @Override |
| 5648 | public boolean isTopLevelWindow(int windowType) { |
| 5649 | if (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW |
| 5650 | && windowType <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 5651 | return (windowType == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG); |
| 5652 | } |
| 5653 | return true; |
| 5654 | } |
| 5655 | |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 5656 | @Override |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 5657 | public void dump(String prefix, PrintWriter pw, String[] args) { |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5658 | pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5659 | pw.print(" mSystemReady="); pw.print(mSystemReady); |
| 5660 | pw.print(" mSystemBooted="); pw.println(mSystemBooted); |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 5661 | pw.print(prefix); pw.print("mLidState="); pw.print(mLidState); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5662 | pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); |
| 5663 | pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5664 | if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 |
| 5665 | || mForceClearedSystemUiFlags != 0) { |
| 5666 | pw.print(prefix); pw.print("mLastSystemUiFlags=0x"); |
| 5667 | pw.print(Integer.toHexString(mLastSystemUiFlags)); |
| 5668 | pw.print(" mResettingSystemUiFlags=0x"); |
| 5669 | pw.print(Integer.toHexString(mResettingSystemUiFlags)); |
| 5670 | pw.print(" mForceClearedSystemUiFlags=0x"); |
| 5671 | pw.println(Integer.toHexString(mForceClearedSystemUiFlags)); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5672 | } |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5673 | if (mLastFocusNeedsMenu) { |
| 5674 | pw.print(prefix); pw.print("mLastFocusNeedsMenu="); |
| 5675 | pw.println(mLastFocusNeedsMenu); |
| 5676 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5677 | pw.print(prefix); pw.print("mWakeGestureEnabledSetting="); |
| 5678 | pw.println(mWakeGestureEnabledSetting); |
| 5679 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 5680 | pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5681 | pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); |
| 5682 | pw.print(" mDockMode="); pw.print(mDockMode); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5683 | pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); |
| 5684 | pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); |
| 5685 | pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); |
| 5686 | pw.print(" mUserRotation="); pw.print(mUserRotation); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 5687 | pw.print(" mAllowAllRotations="); pw.println(mAllowAllRotations); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5688 | pw.print(prefix); pw.print("mCurrentAppOrientation="); pw.println(mCurrentAppOrientation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5689 | pw.print(prefix); pw.print("mCarDockEnablesAccelerometer="); |
| 5690 | pw.print(mCarDockEnablesAccelerometer); |
| 5691 | pw.print(" mDeskDockEnablesAccelerometer="); |
| 5692 | pw.println(mDeskDockEnablesAccelerometer); |
| 5693 | pw.print(prefix); pw.print("mLidKeyboardAccessibility="); |
| 5694 | pw.print(mLidKeyboardAccessibility); |
| 5695 | pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5696 | pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep); |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 5697 | pw.print(prefix); |
| 5698 | pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior); |
| 5699 | pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior); |
| 5700 | pw.print(prefix); pw.print("mHasSoftInput="); pw.println(mHasSoftInput); |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 5701 | pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly); |
| 5702 | pw.print(" mScreenOnFully="); pw.print(mScreenOnFully); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5703 | pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 5704 | pw.print(prefix); pw.print("mOverscanScreen=("); pw.print(mOverscanScreenLeft); |
| 5705 | pw.print(","); pw.print(mOverscanScreenTop); |
| 5706 | pw.print(") "); pw.print(mOverscanScreenWidth); |
| 5707 | pw.print("x"); pw.println(mOverscanScreenHeight); |
| 5708 | if (mOverscanLeft != 0 || mOverscanTop != 0 |
| 5709 | || mOverscanRight != 0 || mOverscanBottom != 0) { |
| 5710 | pw.print(prefix); pw.print("mOverscan left="); pw.print(mOverscanLeft); |
| 5711 | pw.print(" top="); pw.print(mOverscanTop); |
| 5712 | pw.print(" right="); pw.print(mOverscanRight); |
| 5713 | pw.print(" bottom="); pw.println(mOverscanBottom); |
| 5714 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 5715 | pw.print(prefix); pw.print("mRestrictedOverscanScreen=("); |
| 5716 | pw.print(mRestrictedOverscanScreenLeft); |
| 5717 | pw.print(","); pw.print(mRestrictedOverscanScreenTop); |
| 5718 | pw.print(") "); pw.print(mRestrictedOverscanScreenWidth); |
| 5719 | pw.print("x"); pw.println(mRestrictedOverscanScreenHeight); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5720 | pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft); |
| 5721 | pw.print(","); pw.print(mUnrestrictedScreenTop); |
| 5722 | pw.print(") "); pw.print(mUnrestrictedScreenWidth); |
| 5723 | pw.print("x"); pw.println(mUnrestrictedScreenHeight); |
| 5724 | pw.print(prefix); pw.print("mRestrictedScreen=("); pw.print(mRestrictedScreenLeft); |
| 5725 | pw.print(","); pw.print(mRestrictedScreenTop); |
| 5726 | pw.print(") "); pw.print(mRestrictedScreenWidth); |
| 5727 | pw.print("x"); pw.println(mRestrictedScreenHeight); |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 5728 | pw.print(prefix); pw.print("mStableFullscreen=("); pw.print(mStableFullscreenLeft); |
| 5729 | pw.print(","); pw.print(mStableFullscreenTop); |
| 5730 | pw.print(")-("); pw.print(mStableFullscreenRight); |
| 5731 | pw.print(","); pw.print(mStableFullscreenBottom); pw.println(")"); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 5732 | pw.print(prefix); pw.print("mStable=("); pw.print(mStableLeft); |
| 5733 | pw.print(","); pw.print(mStableTop); |
| 5734 | pw.print(")-("); pw.print(mStableRight); |
| 5735 | pw.print(","); pw.print(mStableBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5736 | pw.print(prefix); pw.print("mSystem=("); pw.print(mSystemLeft); |
| 5737 | pw.print(","); pw.print(mSystemTop); |
| 5738 | pw.print(")-("); pw.print(mSystemRight); |
| 5739 | pw.print(","); pw.print(mSystemBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5740 | pw.print(prefix); pw.print("mCur=("); pw.print(mCurLeft); |
| 5741 | pw.print(","); pw.print(mCurTop); |
| 5742 | pw.print(")-("); pw.print(mCurRight); |
| 5743 | pw.print(","); pw.print(mCurBottom); pw.println(")"); |
| 5744 | pw.print(prefix); pw.print("mContent=("); pw.print(mContentLeft); |
| 5745 | pw.print(","); pw.print(mContentTop); |
| 5746 | pw.print(")-("); pw.print(mContentRight); |
| 5747 | pw.print(","); pw.print(mContentBottom); pw.println(")"); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 5748 | pw.print(prefix); pw.print("mVoiceContent=("); pw.print(mVoiceContentLeft); |
| 5749 | pw.print(","); pw.print(mVoiceContentTop); |
| 5750 | pw.print(")-("); pw.print(mVoiceContentRight); |
| 5751 | pw.print(","); pw.print(mVoiceContentBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5752 | pw.print(prefix); pw.print("mDock=("); pw.print(mDockLeft); |
| 5753 | pw.print(","); pw.print(mDockTop); |
| 5754 | pw.print(")-("); pw.print(mDockRight); |
| 5755 | pw.print(","); pw.print(mDockBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5756 | pw.print(prefix); pw.print("mDockLayer="); pw.print(mDockLayer); |
| 5757 | pw.print(" mStatusBarLayer="); pw.println(mStatusBarLayer); |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5758 | pw.print(prefix); pw.print("mShowingLockscreen="); pw.print(mShowingLockscreen); |
| 5759 | pw.print(" mShowingDream="); pw.print(mShowingDream); |
| 5760 | pw.print(" mDreamingLockscreen="); pw.println(mDreamingLockscreen); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5761 | if (mLastInputMethodWindow != null) { |
| 5762 | pw.print(prefix); pw.print("mLastInputMethodWindow="); |
| 5763 | pw.println(mLastInputMethodWindow); |
| 5764 | } |
| 5765 | if (mLastInputMethodTargetWindow != null) { |
| 5766 | pw.print(prefix); pw.print("mLastInputMethodTargetWindow="); |
| 5767 | pw.println(mLastInputMethodTargetWindow); |
| 5768 | } |
| 5769 | if (mStatusBar != null) { |
| 5770 | pw.print(prefix); pw.print("mStatusBar="); |
| 5771 | pw.println(mStatusBar); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5772 | pw.print(prefix); pw.print("isStatusBarKeyguard="); |
| 5773 | pw.print(isStatusBarKeyguard()); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5774 | } |
| 5775 | if (mNavigationBar != null) { |
| 5776 | pw.print(prefix); pw.print("mNavigationBar="); |
| 5777 | pw.println(mNavigationBar); |
| 5778 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5779 | if (mFocusedWindow != null) { |
| 5780 | pw.print(prefix); pw.print("mFocusedWindow="); |
| 5781 | pw.println(mFocusedWindow); |
| 5782 | } |
| 5783 | if (mFocusedApp != null) { |
| 5784 | pw.print(prefix); pw.print("mFocusedApp="); |
| 5785 | pw.println(mFocusedApp); |
| 5786 | } |
| 5787 | if (mWinDismissingKeyguard != null) { |
| 5788 | pw.print(prefix); pw.print("mWinDismissingKeyguard="); |
| 5789 | pw.println(mWinDismissingKeyguard); |
| 5790 | } |
| 5791 | if (mTopFullscreenOpaqueWindowState != null) { |
| 5792 | pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); |
| 5793 | pw.println(mTopFullscreenOpaqueWindowState); |
| 5794 | } |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5795 | if (mForcingShowNavBar) { |
| 5796 | pw.print(prefix); pw.print("mForcingShowNavBar="); |
| 5797 | pw.println(mForcingShowNavBar); pw.print( "mForcingShowNavBarLayer="); |
| 5798 | pw.println(mForcingShowNavBarLayer); |
| 5799 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5800 | pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5801 | pw.print(" mHideLockScreen="); pw.println(mHideLockScreen); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5802 | pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); |
| 5803 | pw.print(" mForceStatusBarFromKeyguard="); |
| 5804 | pw.println(mForceStatusBarFromKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5805 | pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 5806 | pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5807 | pw.print(" mHomePressed="); pw.println(mHomePressed); |
| 5808 | pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); |
| 5809 | pw.print(" mLockScreenTimeout="); pw.print(mLockScreenTimeout); |
| 5810 | pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive); |
| 5811 | pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior); |
| 5812 | pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior); |
| 5813 | pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior); |
| 5814 | pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation); |
| 5815 | pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); |
| 5816 | pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); |
| 5817 | pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 5818 | pw.print(prefix); pw.print("mDemoHdmiRotation="); pw.print(mDemoHdmiRotation); |
| 5819 | pw.print(" mDemoHdmiRotationLock="); pw.println(mDemoHdmiRotationLock); |
| 5820 | pw.print(prefix); pw.print("mUndockedHdmiRotation="); pw.println(mUndockedHdmiRotation); |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 5821 | |
Tim Kilbourn | d7c0c2e | 2014-05-29 16:08:10 -0700 | [diff] [blame] | 5822 | mGlobalKeyManager.dump(prefix, pw); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5823 | mStatusBarController.dump(pw, prefix); |
| 5824 | mNavigationBarController.dump(pw, prefix); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5825 | PolicyControl.dump(prefix, pw); |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 5826 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5827 | if (mWakeGestureListener != null) { |
| 5828 | mWakeGestureListener.dump(pw, prefix); |
| 5829 | } |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 5830 | if (mOrientationListener != null) { |
| 5831 | mOrientationListener.dump(pw, prefix); |
| 5832 | } |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5833 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5834 | } |