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; |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 44 | import android.media.AudioAttributes; |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 45 | import android.media.AudioManager; |
| 46 | import android.media.IAudioService; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 47 | import android.media.Ringtone; |
| 48 | import android.media.RingtoneManager; |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 49 | import android.media.session.MediaController; |
| 50 | import android.media.session.MediaSession; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 51 | import android.media.session.MediaSessionLegacyHelper; |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 52 | import android.media.session.MediaSessionManager; |
| 53 | import android.media.session.PlaybackState; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 54 | import android.os.Bundle; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 55 | import android.os.FactoryTest; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 56 | import android.os.Handler; |
| 57 | import android.os.IBinder; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 58 | import android.os.Looper; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 59 | import android.os.Message; |
| 60 | import android.os.Messenger; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 61 | import android.os.PowerManager; |
| 62 | import android.os.RemoteException; |
| 63 | import android.os.ServiceManager; |
| 64 | import android.os.SystemClock; |
| 65 | import android.os.SystemProperties; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 66 | import android.os.UEventObserver; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 67 | import android.os.UserHandle; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 68 | import android.os.Vibrator; |
| 69 | import android.provider.Settings; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 70 | import android.service.dreams.DreamManagerInternal; |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 71 | import android.service.dreams.DreamService; |
| 72 | import android.service.dreams.IDreamManager; |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 73 | import android.telecomm.TelecommManager; |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 74 | import android.util.DisplayMetrics; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 75 | import android.util.EventLog; |
| 76 | import android.util.Log; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 77 | import android.util.Slog; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 78 | import android.util.SparseArray; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 79 | import android.view.Display; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 80 | import android.view.Gravity; |
| 81 | import android.view.HapticFeedbackConstants; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 82 | import android.view.IApplicationToken; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 83 | import android.view.IWindowManager; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 84 | import android.view.InputChannel; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 85 | import android.view.InputDevice; |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 86 | import android.view.InputEvent; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 87 | import android.view.InputEventReceiver; |
Jeff Brown | 6b53e8d | 2010-11-10 16:03:06 -0800 | [diff] [blame] | 88 | import android.view.KeyCharacterMap; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 89 | import android.view.KeyCharacterMap.FallbackAction; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 90 | import android.view.KeyEvent; |
| 91 | import android.view.MotionEvent; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 92 | import android.view.Surface; |
| 93 | import android.view.View; |
| 94 | import android.view.ViewConfiguration; |
| 95 | import android.view.Window; |
| 96 | import android.view.WindowManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 97 | import android.view.WindowManagerGlobal; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 98 | import android.view.WindowManagerInternal; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 99 | import android.view.WindowManagerPolicy; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 100 | import android.view.accessibility.AccessibilityEvent; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 101 | import android.view.accessibility.AccessibilityManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 102 | import android.view.animation.Animation; |
| 103 | import android.view.animation.AnimationUtils; |
| 104 | |
| 105 | import com.android.internal.R; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 106 | import com.android.internal.policy.IKeyguardService; |
| 107 | import com.android.internal.policy.IKeyguardServiceConstants; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 108 | import com.android.internal.policy.PolicyManager; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 109 | import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 110 | import com.android.internal.policy.impl.keyguard.KeyguardServiceDelegate.ShowListener; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 111 | import com.android.internal.statusbar.IStatusBarService; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 112 | import com.android.internal.widget.PointerLocationView; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 113 | import com.android.server.LocalServices; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 114 | |
| 115 | import java.io.File; |
| 116 | import java.io.FileReader; |
| 117 | import java.io.IOException; |
| 118 | import java.io.PrintWriter; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 119 | import java.util.ArrayList; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 120 | import java.util.HashSet; |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 121 | import java.util.List; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 122 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 123 | import static android.view.WindowManager.LayoutParams.*; |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 124 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; |
| 125 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; |
| 126 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 127 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 128 | /** |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 129 | * WindowManagerPolicy implementation for the Android phone UI. This |
| 130 | * introduces a new method suffix, Lp, for an internal lock of the |
| 131 | * PhoneWindowManager. This is used to protect some internal state, and |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 132 | * 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] | 133 | * of both of those when held. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 134 | */ |
| 135 | public class PhoneWindowManager implements WindowManagerPolicy { |
| 136 | static final String TAG = "WindowManager"; |
| 137 | static final boolean DEBUG = false; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 138 | static final boolean localLOGV = false; |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 139 | static final boolean DEBUG_LAYOUT = false; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 140 | static final boolean DEBUG_INPUT = false; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 141 | static final boolean DEBUG_STARTING_WINDOW = false; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 142 | static final boolean DEBUG_WAKEUP = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 143 | static final boolean SHOW_STARTING_ANIMATIONS = true; |
| 144 | static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 145 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 146 | // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. |
| 147 | // No longer recommended for desk docks; still useful in car docks. |
| 148 | static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; |
| 149 | static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; |
| 150 | |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 151 | static final int SHORT_PRESS_POWER_NOTHING = 0; |
| 152 | static final int SHORT_PRESS_POWER_GO_TO_SLEEP = 1; |
| 153 | static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP = 2; |
| 154 | static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME = 3; |
| 155 | |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 156 | static final int LONG_PRESS_POWER_NOTHING = 0; |
| 157 | static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; |
| 158 | static final int LONG_PRESS_POWER_SHUT_OFF = 2; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 159 | static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 160 | |
| 161 | // These need to match the documentation/constant in |
| 162 | // core/res/res/values/config.xml |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 163 | static final int LONG_PRESS_HOME_NOTHING = 0; |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 164 | static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 165 | static final int LONG_PRESS_HOME_ASSIST = 2; |
| 166 | |
| 167 | static final int DOUBLE_TAP_HOME_NOTHING = 0; |
| 168 | static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 169 | |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 170 | static final int APPLICATION_MEDIA_SUBLAYER = -2; |
| 171 | static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 172 | static final int APPLICATION_PANEL_SUBLAYER = 1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 173 | static final int APPLICATION_SUB_PANEL_SUBLAYER = 2; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 174 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 175 | static public final String SYSTEM_DIALOG_REASON_KEY = "reason"; |
| 176 | static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions"; |
| 177 | static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 178 | static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 179 | static public final String SYSTEM_DIALOG_REASON_ASSIST = "assist"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 180 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 181 | /** |
| 182 | * These are the system UI flags that, when changing, can cause the layout |
| 183 | * of the screen to change. |
| 184 | */ |
| 185 | static final int SYSTEM_UI_CHANGING_LAYOUT = |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 186 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | 7f4820a | 2013-10-08 12:54:35 -0400 | [diff] [blame] | 187 | | View.SYSTEM_UI_FLAG_FULLSCREEN |
| 188 | | View.STATUS_BAR_TRANSLUCENT |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 189 | | View.NAVIGATION_BAR_TRANSLUCENT |
| 190 | | View.SYSTEM_UI_TRANSPARENT; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 191 | |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 192 | private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() |
| 193 | .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
| 194 | .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) |
| 195 | .build(); |
| 196 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 197 | /** |
| 198 | * Keyguard stuff |
| 199 | */ |
| 200 | private WindowState mKeyguardScrim; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 201 | private boolean mKeyguardHidden; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 202 | private boolean mKeyguardDrawn; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 203 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 204 | /* Table of Application Launch keys. Maps from key codes to intent categories. |
| 205 | * |
| 206 | * These are special keys that are used to launch particular kinds of applications, |
| 207 | * such as a web browser. HID defines nearly a hundred of them in the Consumer (0x0C) |
| 208 | * usage page. We don't support quite that many yet... |
| 209 | */ |
| 210 | static SparseArray<String> sApplicationLaunchKeyCategories; |
| 211 | static { |
| 212 | sApplicationLaunchKeyCategories = new SparseArray<String>(); |
| 213 | sApplicationLaunchKeyCategories.append( |
| 214 | KeyEvent.KEYCODE_EXPLORER, Intent.CATEGORY_APP_BROWSER); |
| 215 | sApplicationLaunchKeyCategories.append( |
| 216 | KeyEvent.KEYCODE_ENVELOPE, Intent.CATEGORY_APP_EMAIL); |
| 217 | sApplicationLaunchKeyCategories.append( |
| 218 | KeyEvent.KEYCODE_CONTACTS, Intent.CATEGORY_APP_CONTACTS); |
| 219 | sApplicationLaunchKeyCategories.append( |
| 220 | KeyEvent.KEYCODE_CALENDAR, Intent.CATEGORY_APP_CALENDAR); |
| 221 | sApplicationLaunchKeyCategories.append( |
| 222 | KeyEvent.KEYCODE_MUSIC, Intent.CATEGORY_APP_MUSIC); |
| 223 | sApplicationLaunchKeyCategories.append( |
| 224 | KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); |
| 225 | } |
| 226 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 227 | /** |
| 228 | * Lock protecting internal state. Must not call out into window |
| 229 | * manager with lock held. (This lock will be acquired in places |
| 230 | * where the window manager is calling in with its own lock held.) |
| 231 | */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 232 | private final Object mLock = new Object(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 233 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 234 | Context mContext; |
| 235 | IWindowManager mWindowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 236 | WindowManagerFuncs mWindowManagerFuncs; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 237 | WindowManagerInternal mWindowManagerInternal; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 238 | PowerManager mPowerManager; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 239 | DreamManagerInternal mDreamManagerInternal; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 240 | IStatusBarService mStatusBarService; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 241 | boolean mPreloadedRecentApps; |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 242 | final Object mServiceAquireLock = new Object(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 243 | Vibrator mVibrator; // Vibrator for giving feedback of orientation changes |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 244 | SearchManager mSearchManager; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 245 | AccessibilityManager mAccessibilityManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 246 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 247 | // Vibrator pattern for haptic feedback of a long press. |
| 248 | long[] mLongPressVibePattern; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 249 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 250 | // Vibrator pattern for haptic feedback of virtual key press. |
| 251 | long[] mVirtualKeyVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 252 | |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 253 | // Vibrator pattern for a short vibration. |
| 254 | long[] mKeyboardTapVibePattern; |
| 255 | |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 256 | // Vibrator pattern for a short vibration when tapping on an hour/minute tick of a Clock. |
| 257 | long[] mClockTickVibePattern; |
| 258 | |
Fabrice Di Meglio | bd9152f | 2013-10-01 11:21:31 -0700 | [diff] [blame] | 259 | // Vibrator pattern for a short vibration when tapping on a day/month/year date of a Calendar. |
| 260 | long[] mCalendarDateVibePattern; |
| 261 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 262 | // Vibrator pattern for haptic feedback during boot when safe mode is disabled. |
| 263 | long[] mSafeModeDisabledVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 264 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 265 | // Vibrator pattern for haptic feedback during boot when safe mode is enabled. |
| 266 | long[] mSafeModeEnabledVibePattern; |
Romain Guy | 8154cd3 | 2010-03-29 14:41:15 -0700 | [diff] [blame] | 267 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 268 | /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */ |
| 269 | boolean mEnableShiftMenuBugReports = false; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 270 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 271 | boolean mSafeMode; |
| 272 | WindowState mStatusBar = null; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 273 | int mStatusBarHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 274 | WindowState mNavigationBar = null; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 275 | boolean mHasNavigationBar = false; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 276 | boolean mCanHideNavigationBar = false; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 277 | boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side? |
| 278 | boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*? |
| 279 | int[] mNavigationBarHeightForRotation = new int[4]; |
| 280 | int[] mNavigationBarWidthForRotation = new int[4]; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 281 | |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 282 | boolean mBootMessageNeedsHiding; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 283 | KeyguardServiceDelegate mKeyguardDelegate; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 284 | // The following are only accessed on the mHandler thread. |
| 285 | boolean mKeyguardDrawComplete; |
| 286 | boolean mWindowManagerDrawComplete; |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 287 | ScreenOnListener mScreenOnListener; |
| 288 | final Runnable mWindowManagerDrawCallback = new Runnable() { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 289 | @Override |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 290 | public void run() { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 291 | if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for display!"); |
| 292 | mHandler.sendEmptyMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE); |
| 293 | } |
| 294 | }; |
| 295 | final ShowListener mKeyguardDelegateCallback = new ShowListener() { |
| 296 | @Override |
| 297 | public void onShown(IBinder windowToken) { |
| 298 | if (DEBUG_WAKEUP) Slog.d(TAG, "mKeyguardDelegate.ShowListener.onShown."); |
| 299 | mHandler.sendEmptyMessage(MSG_KEYGUARD_DRAWN_COMPLETE); |
| 300 | } |
| 301 | }; |
| 302 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 303 | GlobalActions mGlobalActions; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 304 | volatile boolean mPowerKeyHandled; // accessed from input reader and handler thread |
| 305 | boolean mPendingPowerKeyUpCanceled; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 306 | Handler mHandler; |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 307 | WindowState mLastInputMethodWindow = null; |
| 308 | WindowState mLastInputMethodTargetWindow = null; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 309 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 310 | boolean mRecentsVisible; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 311 | int mRecentAppsHeldModifiers; |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 312 | boolean mLanguageSwitchKeyPressed; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 313 | |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 314 | int mLidState = LID_ABSENT; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 315 | boolean mHaveBuiltInKeyboard; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 316 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 317 | boolean mSystemReady; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 318 | boolean mSystemBooted; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 319 | boolean mHdmiPlugged; |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 320 | IUiModeManager mUiModeManager; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 321 | int mUiMode; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 322 | int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 323 | int mLidOpenRotation; |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 324 | int mCarDockRotation; |
| 325 | int mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 326 | int mUndockedHdmiRotation; |
| 327 | int mDemoHdmiRotation; |
| 328 | boolean mDemoHdmiRotationLock; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 329 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 330 | boolean mWakeGestureEnabledSetting; |
| 331 | MyWakeGestureListener mWakeGestureListener; |
| 332 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 333 | // Default display does not rotate, apps that require non-default orientation will have to |
| 334 | // have the orientation emulated. |
| 335 | private boolean mForceDefaultOrientation = false; |
| 336 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 337 | int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; |
| 338 | int mUserRotation = Surface.ROTATION_0; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 339 | boolean mAccelerometerDefault; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 340 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 341 | boolean mSupportAutoRotation; |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 342 | int mAllowAllRotations = -1; |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 343 | boolean mCarDockEnablesAccelerometer; |
| 344 | boolean mDeskDockEnablesAccelerometer; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 345 | int mLidKeyboardAccessibility; |
| 346 | int mLidNavigationAccessibility; |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 347 | boolean mLidControlsSleep; |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 348 | int mShortPressOnPowerBehavior = -1; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 349 | int mLongPressOnPowerBehavior = -1; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 350 | boolean mScreenOnEarly = false; |
| 351 | boolean mScreenOnFully = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 352 | boolean mOrientationSensorEnabled = false; |
| 353 | int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 354 | boolean mHasSoftInput = false; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 355 | boolean mTranslucentDecorEnabled = true; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 356 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 357 | int mPointerLocationMode = 0; // guarded by mLock |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 358 | |
| 359 | // The last window we were told about in focusChanged. |
| 360 | WindowState mFocusedWindow; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 361 | IApplicationToken mFocusedApp; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 362 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 363 | PointerLocationView mPointerLocationView; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 364 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 365 | // The current size of the screen; really; extends into the overscan area of |
| 366 | // the screen and doesn't account for any system elements like the status bar. |
| 367 | int mOverscanScreenLeft, mOverscanScreenTop; |
| 368 | int mOverscanScreenWidth, mOverscanScreenHeight; |
| 369 | // The current visible size of the screen; really; (ir)regardless of whether the status |
| 370 | // bar can be hidden but not extending into the overscan area. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 371 | int mUnrestrictedScreenLeft, mUnrestrictedScreenTop; |
| 372 | int mUnrestrictedScreenWidth, mUnrestrictedScreenHeight; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 373 | // Like mOverscanScreen*, but allowed to move into the overscan region where appropriate. |
| 374 | int mRestrictedOverscanScreenLeft, mRestrictedOverscanScreenTop; |
| 375 | int mRestrictedOverscanScreenWidth, mRestrictedOverscanScreenHeight; |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 376 | // The current size of the screen; these may be different than (0,0)-(dw,dh) |
| 377 | // if the status bar can't be hidden; in that case it effectively carves out |
| 378 | // that area of the display from all other windows. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 379 | int mRestrictedScreenLeft, mRestrictedScreenTop; |
| 380 | int mRestrictedScreenWidth, mRestrictedScreenHeight; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 381 | // During layout, the current screen borders accounting for any currently |
| 382 | // visible system UI elements. |
| 383 | int mSystemLeft, mSystemTop, mSystemRight, mSystemBottom; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 384 | // For applications requesting stable content insets, these are them. |
| 385 | int mStableLeft, mStableTop, mStableRight, mStableBottom; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 386 | // For applications requesting stable content insets but have also set the |
| 387 | // fullscreen window flag, these are the stable dimensions without the status bar. |
| 388 | int mStableFullscreenLeft, mStableFullscreenTop; |
| 389 | int mStableFullscreenRight, mStableFullscreenBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 390 | // During layout, the current screen borders with all outer decoration |
| 391 | // (status bar, input method dock) accounted for. |
| 392 | int mCurLeft, mCurTop, mCurRight, mCurBottom; |
| 393 | // During layout, the frame in which content should be displayed |
| 394 | // to the user, accounting for all screen decoration except for any |
| 395 | // space they deem as available for other content. This is usually |
| 396 | // the same as mCur*, but may be larger if the screen decor has supplied |
| 397 | // content insets. |
| 398 | int mContentLeft, mContentTop, mContentRight, mContentBottom; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 399 | // During layout, the frame in which voice content should be displayed |
| 400 | // to the user, accounting for all screen decoration except for any |
| 401 | // space they deem as available for other content. |
| 402 | int mVoiceContentLeft, mVoiceContentTop, mVoiceContentRight, mVoiceContentBottom; |
Dianne Hackborn | 8e11ef0 | 2010-11-18 19:47:42 -0800 | [diff] [blame] | 403 | // 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] | 404 | // windows are placed. |
| 405 | int mDockLeft, mDockTop, mDockRight, mDockBottom; |
| 406 | // During layout, the layer at which the doc window is placed. |
| 407 | int mDockLayer; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 408 | // During layout, this is the layer of the status bar. |
| 409 | int mStatusBarLayer; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 410 | int mLastSystemUiFlags; |
| 411 | // Bits that we are in the process of clearing, so we want to prevent |
| 412 | // them from being set by applications until everything has been updated |
| 413 | // to have them clear. |
| 414 | int mResettingSystemUiFlags = 0; |
| 415 | // Bits that we are currently always keeping cleared. |
| 416 | int mForceClearedSystemUiFlags = 0; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 417 | // What we last reported to system UI about whether the compatibility |
| 418 | // menu needs to be displayed. |
| 419 | boolean mLastFocusNeedsMenu = false; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 420 | |
| 421 | FakeWindow mHideNavFakeWindow = null; |
| 422 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 423 | static final Rect mTmpParentFrame = new Rect(); |
| 424 | static final Rect mTmpDisplayFrame = new Rect(); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 425 | static final Rect mTmpOverscanFrame = new Rect(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 426 | static final Rect mTmpContentFrame = new Rect(); |
| 427 | static final Rect mTmpVisibleFrame = new Rect(); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 428 | static final Rect mTmpDecorFrame = new Rect(); |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 429 | static final Rect mTmpStableFrame = new Rect(); |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 430 | static final Rect mTmpNavigationFrame = new Rect(); |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 431 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 432 | WindowState mTopFullscreenOpaqueWindowState; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 433 | HashSet<IApplicationToken> mAppsToBeHidden = new HashSet<IApplicationToken>(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 434 | boolean mTopIsFullscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 435 | boolean mForceStatusBar; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 436 | boolean mForceStatusBarFromKeyguard; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 437 | boolean mHideLockScreen; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 438 | boolean mForcingShowNavBar; |
| 439 | int mForcingShowNavBarLayer; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 440 | |
| 441 | // States of keyguard dismiss. |
| 442 | private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed. |
| 443 | private static final int DISMISS_KEYGUARD_START = 1; // Keyguard needs to be dismissed. |
| 444 | private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed. |
| 445 | int mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
| 446 | |
| 447 | /** The window that is currently dismissing the keyguard. Dismissing the keyguard must only |
| 448 | * be done once per window. */ |
| 449 | private WindowState mWinDismissingKeyguard; |
| 450 | |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 451 | /** The window that is currently showing "over" the keyguard. If there is an app window |
| 452 | * belonging to another app on top of this the keyguard shows. If there is a fullscreen |
| 453 | * app window under this, still dismiss the keyguard but don't show the app underneath. Show |
| 454 | * the wallpaper. */ |
| 455 | private WindowState mWinShowWhenLocked; |
| 456 | |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 457 | boolean mShowingLockscreen; |
| 458 | boolean mShowingDream; |
| 459 | boolean mDreamingLockscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 460 | boolean mHomePressed; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 461 | boolean mHomeConsumed; |
| 462 | boolean mHomeDoubleTapPending; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 463 | Intent mHomeIntent; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 464 | Intent mCarDockIntent; |
| 465 | Intent mDeskDockIntent; |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 466 | boolean mSearchKeyShortcutPending; |
| 467 | boolean mConsumeSearchKeyUp; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 468 | boolean mAssistKeyLongPressed; |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 469 | boolean mPendingMetaAction; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 470 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 471 | // support for activating the lock screen while the screen is on |
| 472 | boolean mAllowLockscreenWhenOn; |
| 473 | int mLockScreenTimeout; |
| 474 | boolean mLockScreenTimerActive; |
| 475 | |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 476 | // 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] | 477 | int mEndcallBehavior; |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 478 | |
| 479 | // Behavior of POWER button while in-call and screen on. |
| 480 | // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) |
| 481 | int mIncallPowerBehavior; |
| 482 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 483 | Display mDisplay; |
| 484 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 485 | int mLandscapeRotation = 0; // default landscape rotation |
| 486 | int mSeascapeRotation = 0; // "other" landscape rotation, 180 degrees from mLandscapeRotation |
| 487 | int mPortraitRotation = 0; // default portrait rotation |
| 488 | int mUpsideDownRotation = 0; // "other" portrait rotation |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 489 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 490 | int mOverscanLeft = 0; |
| 491 | int mOverscanTop = 0; |
| 492 | int mOverscanRight = 0; |
| 493 | int mOverscanBottom = 0; |
| 494 | |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 495 | // What we do when the user long presses on home |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 496 | private int mLongPressOnHomeBehavior; |
| 497 | |
| 498 | // What we do when the user double-taps on home |
| 499 | private int mDoubleTapOnHomeBehavior; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 500 | |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 501 | // Screenshot trigger states |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 502 | // Time to volume and power must be pressed within this interval of each other. |
| 503 | private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150; |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 504 | // Increase the chord delay when taking a screenshot from the keyguard |
| 505 | private static final float KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER = 2.5f; |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 506 | private boolean mScreenshotChordEnabled; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 507 | private boolean mVolumeDownKeyTriggered; |
| 508 | private long mVolumeDownKeyTime; |
| 509 | private boolean mVolumeDownKeyConsumedByScreenshotChord; |
| 510 | private boolean mVolumeUpKeyTriggered; |
| 511 | private boolean mPowerKeyTriggered; |
| 512 | private long mPowerKeyTime; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 513 | |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 514 | /* The number of steps between min and max brightness */ |
| 515 | private static final int BRIGHTNESS_STEPS = 10; |
| 516 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 517 | SettingsObserver mSettingsObserver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 518 | ShortcutManager mShortcutManager; |
| 519 | PowerManager.WakeLock mBroadcastWakeLock; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 520 | boolean mHavePendingMediaKeyRepeatWithWakeLock; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 521 | |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 522 | private int mCurrentUserId; |
| 523 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 524 | // Maps global key codes to the components that will handle them. |
| 525 | private GlobalKeyManager mGlobalKeyManager; |
| 526 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 527 | // Fallback actions by key code. |
| 528 | private final SparseArray<KeyCharacterMap.FallbackAction> mFallbackActions = |
| 529 | new SparseArray<KeyCharacterMap.FallbackAction>(); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 530 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 531 | private static final int MSG_ENABLE_POINTER_LOCATION = 1; |
| 532 | private static final int MSG_DISABLE_POINTER_LOCATION = 2; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 533 | private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; |
| 534 | 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] | 535 | private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5; |
| 536 | private static final int MSG_KEYGUARD_DRAWN_TIMEOUT = 6; |
| 537 | private static final int MSG_WINDOW_MANAGER_DRAWN_COMPLETE = 7; |
| 538 | private static final int MSG_WAKING_UP = 8; |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 539 | private static final int MSG_DISPATCH_SHOW_RECENTS = 9; |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 540 | private static final int MSG_DISPATCH_SHOW_GLOBAL_ACTIONS = 10; |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 541 | private static final int MSG_HIDE_BOOT_MESSAGE = 11; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 542 | |
| 543 | private class PolicyHandler extends Handler { |
| 544 | @Override |
| 545 | public void handleMessage(Message msg) { |
| 546 | switch (msg.what) { |
| 547 | case MSG_ENABLE_POINTER_LOCATION: |
| 548 | enablePointerLocation(); |
| 549 | break; |
| 550 | case MSG_DISABLE_POINTER_LOCATION: |
| 551 | disablePointerLocation(); |
| 552 | break; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 553 | case MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK: |
| 554 | dispatchMediaKeyWithWakeLock((KeyEvent)msg.obj); |
| 555 | break; |
| 556 | case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK: |
| 557 | dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj); |
| 558 | break; |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 559 | case MSG_DISPATCH_SHOW_RECENTS: |
| 560 | showRecentApps(false); |
| 561 | break; |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 562 | case MSG_DISPATCH_SHOW_GLOBAL_ACTIONS: |
| 563 | showGlobalActionsInternal(); |
| 564 | break; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 565 | case MSG_KEYGUARD_DRAWN_COMPLETE: |
| 566 | if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mKeyguardDrawComplete"); |
| 567 | mKeyguardDrawComplete = true; |
| 568 | finishScreenTurningOn(); |
| 569 | break; |
| 570 | case MSG_KEYGUARD_DRAWN_TIMEOUT: |
| 571 | Slog.w(TAG, "Keyguard drawn timeout. Setting mKeyguardDrawComplete"); |
| 572 | mKeyguardDrawComplete = true; |
| 573 | finishScreenTurningOn(); |
| 574 | break; |
| 575 | case MSG_WINDOW_MANAGER_DRAWN_COMPLETE: |
| 576 | if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mWindowManagerDrawComplete"); |
| 577 | mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT); |
| 578 | mWindowManagerDrawComplete = true; |
| 579 | finishScreenTurningOn(); |
| 580 | break; |
| 581 | case MSG_WAKING_UP: |
| 582 | handleWakingUp((ScreenOnListener) msg.obj); |
| 583 | break; |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 584 | case MSG_HIDE_BOOT_MESSAGE: |
| 585 | handleHideBootMessage(); |
| 586 | break; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 587 | } |
| 588 | } |
| 589 | } |
| 590 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 591 | private UEventObserver mHDMIObserver = new UEventObserver() { |
| 592 | @Override |
| 593 | public void onUEvent(UEventObserver.UEvent event) { |
| 594 | setHdmiPlugged("1".equals(event.get("SWITCH_STATE"))); |
| 595 | } |
| 596 | }; |
| 597 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 598 | class SettingsObserver extends ContentObserver { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 599 | SettingsObserver(Handler handler) { |
| 600 | super(handler); |
| 601 | } |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 602 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 603 | void observe() { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 604 | // Observe all users' changes |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 605 | ContentResolver resolver = mContext.getContentResolver(); |
| 606 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 607 | Settings.System.END_BUTTON_BEHAVIOR), false, this, |
| 608 | UserHandle.USER_ALL); |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 609 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 610 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this, |
| 611 | UserHandle.USER_ALL); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 612 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
| 613 | Settings.Secure.WAKE_GESTURE_ENABLED), false, this, |
| 614 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 615 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 616 | Settings.System.ACCELEROMETER_ROTATION), false, this, |
| 617 | UserHandle.USER_ALL); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 618 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 619 | Settings.System.USER_ROTATION), false, this, |
| 620 | UserHandle.USER_ALL); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 621 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 622 | Settings.System.SCREEN_OFF_TIMEOUT), false, this, |
| 623 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 624 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 625 | Settings.System.POINTER_LOCATION), false, this, |
| 626 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 627 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 628 | Settings.Secure.DEFAULT_INPUT_METHOD), false, this, |
| 629 | UserHandle.USER_ALL); |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 630 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 631 | Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS), false, this, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 632 | UserHandle.USER_ALL); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 633 | resolver.registerContentObserver(Settings.Global.getUriFor( |
| 634 | Settings.Global.POLICY_CONTROL), false, this, |
| 635 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 636 | updateSettings(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | @Override public void onChange(boolean selfChange) { |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 640 | updateSettings(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 641 | updateRotation(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 642 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 643 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 644 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 645 | class MyWakeGestureListener extends WakeGestureListener { |
| 646 | MyWakeGestureListener(Context context, Handler handler) { |
| 647 | super(context, handler); |
| 648 | } |
| 649 | |
| 650 | @Override |
| 651 | public void onWakeUp() { |
| 652 | synchronized (mLock) { |
| 653 | if (shouldEnableWakeGestureLp()) { |
Jeff Brown | e07b94b | 2014-06-18 15:56:27 -0700 | [diff] [blame] | 654 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 655 | mPowerManager.wakeUp(SystemClock.uptimeMillis()); |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | } |
| 660 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 661 | class MyOrientationListener extends WindowOrientationListener { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 662 | MyOrientationListener(Context context, Handler handler) { |
| 663 | super(context, handler); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 664 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 665 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 666 | @Override |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 667 | public void onProposedRotationChanged(int rotation) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 668 | if (localLOGV) Slog.v(TAG, "onProposedRotationChanged, rotation=" + rotation); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 669 | updateRotation(false); |
| 670 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 671 | } |
| 672 | MyOrientationListener mOrientationListener; |
| 673 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 674 | private final BarController mStatusBarController = new BarController("StatusBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 675 | View.STATUS_BAR_TRANSIENT, |
| 676 | View.STATUS_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 677 | View.STATUS_BAR_TRANSLUCENT, |
| 678 | StatusBarManager.WINDOW_STATUS_BAR, |
| 679 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 680 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 681 | private final BarController mNavigationBarController = new BarController("NavigationBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 682 | View.NAVIGATION_BAR_TRANSIENT, |
| 683 | View.NAVIGATION_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 684 | View.NAVIGATION_BAR_TRANSLUCENT, |
| 685 | StatusBarManager.WINDOW_NAVIGATION_BAR, |
| 686 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 687 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 688 | private ImmersiveModeConfirmation mImmersiveModeConfirmation; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 689 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 690 | private SystemGesturesPointerEventListener mSystemGestures; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 691 | |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 692 | IStatusBarService getStatusBarService() { |
| 693 | synchronized (mServiceAquireLock) { |
| 694 | if (mStatusBarService == null) { |
| 695 | mStatusBarService = IStatusBarService.Stub.asInterface( |
| 696 | ServiceManager.getService("statusbar")); |
| 697 | } |
| 698 | return mStatusBarService; |
| 699 | } |
| 700 | } |
| 701 | |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 702 | /* |
| 703 | * We always let the sensor be switched on by default except when |
| 704 | * the user has explicitly disabled sensor based rotation or when the |
| 705 | * screen is switched off. |
| 706 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 707 | boolean needSensorRunningLp() { |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 708 | if (mSupportAutoRotation) { |
| 709 | if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 710 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 711 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT |
| 712 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { |
| 713 | // If the application has explicitly requested to follow the |
| 714 | // orientation, then we need to turn the sensor on. |
| 715 | return true; |
| 716 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 717 | } |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 718 | if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 719 | (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 720 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 721 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK))) { |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 722 | // enable accelerometer if we are docked in a dock that enables accelerometer |
| 723 | // orientation management, |
| 724 | return true; |
| 725 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 726 | if (mUserRotationMode == USER_ROTATION_LOCKED) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 727 | // If the setting for using the sensor by default is enabled, then |
| 728 | // we will always leave it on. Note that the user could go to |
| 729 | // a window that forces an orientation that does not use the |
| 730 | // sensor and in theory we could turn it off... however, when next |
| 731 | // turning it on we won't have a good value for the current |
| 732 | // orientation for a little bit, which can cause orientation |
| 733 | // changes to lag, so we'd like to keep it always on. (It will |
| 734 | // still be turned off when the screen is off.) |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 735 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 736 | } |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 737 | return mSupportAutoRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 738 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 739 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 740 | /* |
| 741 | * Various use cases for invoking this function |
| 742 | * screen turning off, should always disable listeners if already enabled |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 743 | * 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] | 744 | * if not already enabled |
| 745 | * screen turned on and current app does not have sensor orientation, disable listeners if |
| 746 | * already enabled |
| 747 | * screen turning on and current app has sensor based orientation, enable listeners if needed |
| 748 | * screen turning on and current app has nosensor based orientation, do nothing |
| 749 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 750 | void updateOrientationListenerLp() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 751 | if (!mOrientationListener.canDetectOrientation()) { |
| 752 | // If sensor is turned off or nonexistent for some reason |
| 753 | return; |
| 754 | } |
| 755 | //Could have been invoked due to screen turning on or off or |
| 756 | //change of the currently visible window's orientation |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 757 | if (localLOGV) Slog.v(TAG, "Screen status="+mScreenOnEarly+ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 758 | ", current orientation="+mCurrentAppOrientation+ |
| 759 | ", SensorEnabled="+mOrientationSensorEnabled); |
| 760 | boolean disable = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 761 | if (mScreenOnEarly) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 762 | if (needSensorRunningLp()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 763 | disable = false; |
| 764 | //enable listener if not already enabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 765 | if (!mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 766 | mOrientationListener.enable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 767 | if(localLOGV) Slog.v(TAG, "Enabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 768 | mOrientationSensorEnabled = true; |
| 769 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 770 | } |
| 771 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 772 | //check if sensors need to be disabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 773 | if (disable && mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 774 | mOrientationListener.disable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 775 | if(localLOGV) Slog.v(TAG, "Disabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 776 | mOrientationSensorEnabled = false; |
| 777 | } |
| 778 | } |
| 779 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 780 | private void interceptPowerKeyDown(boolean handled) { |
| 781 | mPowerKeyHandled = handled; |
| 782 | if (!handled) { |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 783 | mHandler.postDelayed(mPowerLongPress, |
| 784 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 785 | } |
| 786 | } |
| 787 | |
| 788 | private boolean interceptPowerKeyUp(boolean canceled) { |
| 789 | if (!mPowerKeyHandled) { |
| 790 | mHandler.removeCallbacks(mPowerLongPress); |
| 791 | return !canceled; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 792 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 793 | return false; |
| 794 | } |
| 795 | |
| 796 | private void cancelPendingPowerKeyAction() { |
| 797 | if (!mPowerKeyHandled) { |
| 798 | mHandler.removeCallbacks(mPowerLongPress); |
| 799 | } |
Jeff Brown | ff20471 | 2011-10-25 21:27:54 -0700 | [diff] [blame] | 800 | if (mPowerKeyTriggered) { |
| 801 | mPendingPowerKeyUpCanceled = true; |
| 802 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 803 | } |
| 804 | |
| 805 | private void interceptScreenshotChord() { |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 806 | if (mScreenshotChordEnabled |
| 807 | && mVolumeDownKeyTriggered && mPowerKeyTriggered && !mVolumeUpKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 808 | final long now = SystemClock.uptimeMillis(); |
| 809 | if (now <= mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS |
| 810 | && now <= mPowerKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) { |
| 811 | mVolumeDownKeyConsumedByScreenshotChord = true; |
| 812 | cancelPendingPowerKeyAction(); |
| 813 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 814 | mHandler.postDelayed(mScreenshotRunnable, getScreenshotChordLongPressDelay()); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 815 | } |
| 816 | } |
| 817 | } |
| 818 | |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 819 | private long getScreenshotChordLongPressDelay() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 820 | if (mKeyguardDelegate.isShowing()) { |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 821 | // Double the time it takes to take a screenshot from the keyguard |
| 822 | return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER * |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 823 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 824 | } |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 825 | return ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout(); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 826 | } |
| 827 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 828 | private void cancelPendingScreenshotChordAction() { |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 829 | mHandler.removeCallbacks(mScreenshotRunnable); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 830 | } |
| 831 | |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 832 | private void powerShortPress(long eventTime) { |
| 833 | if (mShortPressOnPowerBehavior < 0) { |
| 834 | mShortPressOnPowerBehavior = mContext.getResources().getInteger( |
| 835 | com.android.internal.R.integer.config_shortPressOnPowerBehavior); |
| 836 | } |
| 837 | |
| 838 | switch (mShortPressOnPowerBehavior) { |
| 839 | case SHORT_PRESS_POWER_NOTHING: |
| 840 | break; |
| 841 | case SHORT_PRESS_POWER_GO_TO_SLEEP: |
| 842 | mPowerManager.goToSleep(eventTime, |
| 843 | PowerManager.GO_TO_SLEEP_REASON_USER, 0); |
| 844 | break; |
| 845 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP: |
| 846 | mPowerManager.goToSleep(eventTime, |
| 847 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 848 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 849 | break; |
| 850 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME: |
| 851 | mPowerManager.goToSleep(eventTime, |
| 852 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 853 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 854 | launchHomeFromHotKey(); |
| 855 | break; |
| 856 | } |
| 857 | } |
| 858 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 859 | private final Runnable mPowerLongPress = new Runnable() { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 860 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 861 | public void run() { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 862 | // The context isn't read |
| 863 | if (mLongPressOnPowerBehavior < 0) { |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 864 | mLongPressOnPowerBehavior = mContext.getResources().getInteger( |
| 865 | com.android.internal.R.integer.config_longPressOnPowerBehavior); |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 866 | } |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 867 | int resolvedBehavior = mLongPressOnPowerBehavior; |
| 868 | if (FactoryTest.isLongPressOnPowerOffEnabled()) { |
| 869 | resolvedBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM; |
| 870 | } |
| 871 | |
| 872 | switch (resolvedBehavior) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 873 | case LONG_PRESS_POWER_NOTHING: |
| 874 | break; |
| 875 | case LONG_PRESS_POWER_GLOBAL_ACTIONS: |
| 876 | mPowerKeyHandled = true; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 877 | if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) { |
| 878 | performAuditoryFeedbackForAccessibilityIfNeed(); |
| 879 | } |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 880 | showGlobalActionsInternal(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 881 | break; |
| 882 | case LONG_PRESS_POWER_SHUT_OFF: |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 883 | case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM: |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 884 | mPowerKeyHandled = true; |
| 885 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 886 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
Jeff Brown | 850c5b7 | 2012-10-01 15:17:22 -0700 | [diff] [blame] | 887 | mWindowManagerFuncs.shutdown(resolvedBehavior == LONG_PRESS_POWER_SHUT_OFF); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 888 | break; |
| 889 | } |
| 890 | } |
| 891 | }; |
| 892 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 893 | private final Runnable mScreenshotRunnable = new Runnable() { |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 894 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 895 | public void run() { |
| 896 | takeScreenshot(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 897 | } |
| 898 | }; |
| 899 | |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 900 | @Override |
| 901 | public void showGlobalActions() { |
| 902 | mHandler.removeMessages(MSG_DISPATCH_SHOW_GLOBAL_ACTIONS); |
| 903 | mHandler.sendEmptyMessage(MSG_DISPATCH_SHOW_GLOBAL_ACTIONS); |
| 904 | } |
| 905 | |
| 906 | void showGlobalActionsInternal() { |
| 907 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 908 | if (mGlobalActions == null) { |
Jeff Brown | 7304c34 | 2012-05-11 18:42:42 -0700 | [diff] [blame] | 909 | mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 910 | } |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 911 | final boolean keyguardShowing = keyguardIsShowingTq(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 912 | mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); |
| 913 | if (keyguardShowing) { |
| 914 | // since it took two seconds of long press to bring this up, |
| 915 | // 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] | 916 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 917 | } |
| 918 | } |
| 919 | |
| 920 | boolean isDeviceProvisioned() { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 921 | return Settings.Global.getInt( |
| 922 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 923 | } |
| 924 | |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 925 | boolean isUserSetupComplete() { |
| 926 | return Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 927 | Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; |
| 928 | } |
| 929 | |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 930 | private void handleLongPressOnHome() { |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 931 | if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 932 | mHomeConsumed = true; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 933 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 934 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 935 | if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) { |
| 936 | toggleRecentApps(); |
| 937 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_ASSIST) { |
| 938 | launchAssistAction(); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 939 | } |
| 940 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 941 | } |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 942 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 943 | private void handleDoubleTapOnHome() { |
| 944 | if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 945 | mHomeConsumed = true; |
| 946 | toggleRecentApps(); |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable() { |
| 951 | @Override |
| 952 | public void run() { |
| 953 | if (mHomeDoubleTapPending) { |
| 954 | mHomeDoubleTapPending = false; |
| 955 | launchHomeFromHotKey(); |
| 956 | } |
| 957 | } |
| 958 | }; |
| 959 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 960 | /** {@inheritDoc} */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 961 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 962 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 963 | WindowManagerFuncs windowManagerFuncs) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 964 | mContext = context; |
| 965 | mWindowManager = windowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 966 | mWindowManagerFuncs = windowManagerFuncs; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 967 | mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 968 | mDreamManagerInternal = LocalServices.getService(DreamManagerInternal.class); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 969 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 970 | mHandler = new PolicyHandler(); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 971 | mWakeGestureListener = new MyWakeGestureListener(mContext, mHandler); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 972 | mOrientationListener = new MyOrientationListener(mContext, mHandler); |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 973 | try { |
| 974 | mOrientationListener.setCurrentRotation(windowManager.getRotation()); |
| 975 | } catch (RemoteException ex) { } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 976 | mSettingsObserver = new SettingsObserver(mHandler); |
| 977 | mSettingsObserver.observe(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 978 | mShortcutManager = new ShortcutManager(context, mHandler); |
| 979 | mShortcutManager.observe(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 980 | mUiMode = context.getResources().getInteger( |
| 981 | com.android.internal.R.integer.config_defaultUiModeType); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 982 | mHomeIntent = new Intent(Intent.ACTION_MAIN, null); |
| 983 | mHomeIntent.addCategory(Intent.CATEGORY_HOME); |
| 984 | mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 985 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 986 | mCarDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 987 | mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK); |
| 988 | mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 989 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 990 | mDeskDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 991 | mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK); |
| 992 | mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 993 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 994 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 995 | mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 996 | mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 997 | "PhoneWindowManager.mBroadcastWakeLock"); |
| 998 | mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 999 | mSupportAutoRotation = mContext.getResources().getBoolean( |
| 1000 | com.android.internal.R.bool.config_supportAutoRotation); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1001 | mLidOpenRotation = readRotation( |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1002 | com.android.internal.R.integer.config_lidOpenRotation); |
| 1003 | mCarDockRotation = readRotation( |
| 1004 | com.android.internal.R.integer.config_carDockRotation); |
| 1005 | mDeskDockRotation = readRotation( |
| 1006 | com.android.internal.R.integer.config_deskDockRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1007 | mUndockedHdmiRotation = readRotation( |
| 1008 | com.android.internal.R.integer.config_undockedHdmiRotation); |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 1009 | mCarDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 1010 | com.android.internal.R.bool.config_carDockEnablesAccelerometer); |
| 1011 | mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 1012 | com.android.internal.R.bool.config_deskDockEnablesAccelerometer); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1013 | mLidKeyboardAccessibility = mContext.getResources().getInteger( |
| 1014 | com.android.internal.R.integer.config_lidKeyboardAccessibility); |
| 1015 | mLidNavigationAccessibility = mContext.getResources().getInteger( |
| 1016 | com.android.internal.R.integer.config_lidNavigationAccessibility); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1017 | mLidControlsSleep = mContext.getResources().getBoolean( |
| 1018 | com.android.internal.R.bool.config_lidControlsSleep); |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 1019 | mTranslucentDecorEnabled = mContext.getResources().getBoolean( |
| 1020 | com.android.internal.R.bool.config_enableTranslucentDecor); |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1021 | readConfigurationDependentBehaviors(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1022 | |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 1023 | mAccessibilityManager = (AccessibilityManager) context.getSystemService( |
| 1024 | Context.ACCESSIBILITY_SERVICE); |
| 1025 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1026 | // register for dock events |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 1027 | IntentFilter filter = new IntentFilter(); |
| 1028 | filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); |
| 1029 | filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE); |
| 1030 | filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); |
| 1031 | filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1032 | filter.addAction(Intent.ACTION_DOCK_EVENT); |
| 1033 | Intent intent = context.registerReceiver(mDockReceiver, filter); |
| 1034 | if (intent != null) { |
| 1035 | // Retrieve current sticky dock event broadcast. |
| 1036 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 1037 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 1038 | } |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 1039 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 1040 | // register for dream-related broadcasts |
| 1041 | filter = new IntentFilter(); |
| 1042 | filter.addAction(Intent.ACTION_DREAMING_STARTED); |
| 1043 | filter.addAction(Intent.ACTION_DREAMING_STOPPED); |
| 1044 | context.registerReceiver(mDreamReceiver, filter); |
| 1045 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1046 | // register for multiuser-relevant broadcasts |
| 1047 | filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); |
| 1048 | context.registerReceiver(mMultiuserReceiver, filter); |
| 1049 | |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 1050 | // monitor for system gestures |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1051 | mSystemGestures = new SystemGesturesPointerEventListener(context, |
| 1052 | new SystemGesturesPointerEventListener.Callbacks() { |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 1053 | @Override |
| 1054 | public void onSwipeFromTop() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1055 | if (mStatusBar != null) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1056 | requestTransientBars(mStatusBar); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1057 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1058 | } |
| 1059 | @Override |
| 1060 | public void onSwipeFromBottom() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1061 | if (mNavigationBar != null && mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1062 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1063 | } |
| 1064 | } |
| 1065 | @Override |
| 1066 | public void onSwipeFromRight() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1067 | if (mNavigationBar != null && !mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1068 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1069 | } |
| 1070 | } |
| 1071 | @Override |
| 1072 | public void onDebug() { |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1073 | // no-op |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1074 | } |
| 1075 | }); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1076 | mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1077 | mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 1078 | |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 1079 | mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 1080 | mLongPressVibePattern = getLongIntArray(mContext.getResources(), |
| 1081 | com.android.internal.R.array.config_longPressVibePattern); |
| 1082 | mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(), |
| 1083 | com.android.internal.R.array.config_virtualKeyVibePattern); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 1084 | mKeyboardTapVibePattern = getLongIntArray(mContext.getResources(), |
| 1085 | com.android.internal.R.array.config_keyboardTapVibePattern); |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 1086 | mClockTickVibePattern = getLongIntArray(mContext.getResources(), |
| 1087 | com.android.internal.R.array.config_clockTickVibePattern); |
Fabrice Di Meglio | bd9152f | 2013-10-01 11:21:31 -0700 | [diff] [blame] | 1088 | mCalendarDateVibePattern = getLongIntArray(mContext.getResources(), |
| 1089 | com.android.internal.R.array.config_calendarDateVibePattern); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 1090 | mSafeModeDisabledVibePattern = getLongIntArray(mContext.getResources(), |
| 1091 | com.android.internal.R.array.config_safeModeDisabledVibePattern); |
| 1092 | mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), |
| 1093 | com.android.internal.R.array.config_safeModeEnabledVibePattern); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 1094 | |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1095 | mScreenshotChordEnabled = mContext.getResources().getBoolean( |
| 1096 | com.android.internal.R.bool.config_enableScreenshotChord); |
| 1097 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 1098 | mGlobalKeyManager = new GlobalKeyManager(mContext); |
| 1099 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 1100 | // Controls rotation and the like. |
| 1101 | initializeHdmiState(); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1102 | |
| 1103 | // Match current screen state. |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 1104 | if (!mPowerManager.isInteractive()) { |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 1105 | goingToSleep(WindowManagerPolicy.OFF_BECAUSE_OF_USER); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1106 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1107 | } |
| 1108 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1109 | /** |
| 1110 | * Read values from config.xml that may be overridden depending on |
| 1111 | * the configuration of the device. |
| 1112 | * eg. Disable long press on home goes to recents on sw600dp. |
| 1113 | */ |
| 1114 | private void readConfigurationDependentBehaviors() { |
| 1115 | mLongPressOnHomeBehavior = mContext.getResources().getInteger( |
| 1116 | com.android.internal.R.integer.config_longPressOnHomeBehavior); |
| 1117 | if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING || |
| 1118 | mLongPressOnHomeBehavior > LONG_PRESS_HOME_ASSIST) { |
| 1119 | mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1120 | } |
| 1121 | |
| 1122 | mDoubleTapOnHomeBehavior = mContext.getResources().getInteger( |
| 1123 | com.android.internal.R.integer.config_doubleTapOnHomeBehavior); |
| 1124 | if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING || |
| 1125 | mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 1126 | mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1127 | } |
| 1128 | } |
| 1129 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1130 | @Override |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1131 | public void setInitialDisplaySize(Display display, int width, int height, int density) { |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 1132 | // This method might be called before the policy has been fully initialized |
| 1133 | // or for other displays we don't care about. |
| 1134 | if (mContext == null || display.getDisplayId() != Display.DEFAULT_DISPLAY) { |
| 1135 | return; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1136 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1137 | mDisplay = display; |
| 1138 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1139 | final Resources res = mContext.getResources(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1140 | int shortSize, longSize; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1141 | if (width > height) { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1142 | shortSize = height; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1143 | longSize = width; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1144 | mLandscapeRotation = Surface.ROTATION_0; |
| 1145 | mSeascapeRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1146 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1147 | mPortraitRotation = Surface.ROTATION_90; |
| 1148 | mUpsideDownRotation = Surface.ROTATION_270; |
| 1149 | } else { |
| 1150 | mPortraitRotation = Surface.ROTATION_270; |
| 1151 | mUpsideDownRotation = Surface.ROTATION_90; |
| 1152 | } |
| 1153 | } else { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1154 | shortSize = width; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1155 | longSize = height; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1156 | mPortraitRotation = Surface.ROTATION_0; |
| 1157 | mUpsideDownRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1158 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1159 | mLandscapeRotation = Surface.ROTATION_270; |
| 1160 | mSeascapeRotation = Surface.ROTATION_90; |
| 1161 | } else { |
| 1162 | mLandscapeRotation = Surface.ROTATION_90; |
| 1163 | mSeascapeRotation = Surface.ROTATION_270; |
| 1164 | } |
| 1165 | } |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1166 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1167 | mStatusBarHeight = |
| 1168 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1169 | |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1170 | // Height of the navigation bar when presented horizontally at bottom |
| 1171 | mNavigationBarHeightForRotation[mPortraitRotation] = |
| 1172 | mNavigationBarHeightForRotation[mUpsideDownRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1173 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1174 | mNavigationBarHeightForRotation[mLandscapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1175 | mNavigationBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize( |
| 1176 | com.android.internal.R.dimen.navigation_bar_height_landscape); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1177 | |
| 1178 | // Width of the navigation bar when presented vertically along one side |
| 1179 | mNavigationBarWidthForRotation[mPortraitRotation] = |
| 1180 | mNavigationBarWidthForRotation[mUpsideDownRotation] = |
| 1181 | mNavigationBarWidthForRotation[mLandscapeRotation] = |
| 1182 | mNavigationBarWidthForRotation[mSeascapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1183 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1184 | |
| 1185 | // SystemUI (status bar) layout policy |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1186 | int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1187 | int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1188 | |
Craig Mautner | d4ec3324 | 2013-07-22 10:37:43 -0700 | [diff] [blame] | 1189 | // Allow the navigation bar to move on small devices (phones). |
| 1190 | mNavigationBarCanMove = shortSizeDp < 600; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1191 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1192 | mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1193 | // Allow a system property to override this. Used by the emulator. |
| 1194 | // See also hasNavigationBar(). |
| 1195 | String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); |
| 1196 | if ("1".equals(navBarOverride)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1197 | mHasNavigationBar = false; |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1198 | } else if ("0".equals(navBarOverride)) { |
| 1199 | mHasNavigationBar = true; |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1200 | } |
| 1201 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 1202 | // For demo purposes, allow the rotation of the HDMI display to be controlled. |
| 1203 | // By default, HDMI locks rotation to landscape. |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1204 | if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1205 | mDemoHdmiRotation = mPortraitRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1206 | } else { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1207 | mDemoHdmiRotation = mLandscapeRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1208 | } |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1209 | mDemoHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1210 | |
| 1211 | // Only force the default orientation if the screen is xlarge, at least 960dp x 720dp, per |
| 1212 | // http://developer.android.com/guide/practices/screens_support.html#range |
| 1213 | mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 && |
| 1214 | res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) && |
| 1215 | // For debug purposes the next line turns this feature off with: |
| 1216 | // $ adb shell setprop config.override_forced_orient true |
| 1217 | // $ adb shell wm size reset |
| 1218 | !"true".equals(SystemProperties.get("config.override_forced_orient")); |
| 1219 | } |
| 1220 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1221 | /** |
| 1222 | * @return whether the navigation bar can be hidden, e.g. the device has a |
| 1223 | * navigation bar and touch exploration is not enabled |
| 1224 | */ |
| 1225 | private boolean canHideNavigationBar() { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 1226 | return mHasNavigationBar |
| 1227 | && !mAccessibilityManager.isTouchExplorationEnabled(); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1228 | } |
| 1229 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1230 | @Override |
| 1231 | public boolean isDefaultOrientationForced() { |
| 1232 | return mForceDefaultOrientation; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1233 | } |
| 1234 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1235 | @Override |
| 1236 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom) { |
| 1237 | if (display.getDisplayId() == Display.DEFAULT_DISPLAY) { |
| 1238 | mOverscanLeft = left; |
| 1239 | mOverscanTop = top; |
| 1240 | mOverscanRight = right; |
| 1241 | mOverscanBottom = bottom; |
| 1242 | } |
| 1243 | } |
| 1244 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1245 | public void updateSettings() { |
| 1246 | ContentResolver resolver = mContext.getContentResolver(); |
| 1247 | boolean updateRotation = false; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1248 | synchronized (mLock) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1249 | mEndcallBehavior = Settings.System.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1250 | Settings.System.END_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1251 | Settings.System.END_BUTTON_BEHAVIOR_DEFAULT, |
| 1252 | UserHandle.USER_CURRENT); |
| 1253 | mIncallPowerBehavior = Settings.Secure.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1254 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1255 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT, |
| 1256 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1257 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1258 | // Configure wake gesture. |
| 1259 | boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver, |
| 1260 | Settings.Secure.WAKE_GESTURE_ENABLED, 0, |
| 1261 | UserHandle.USER_CURRENT) != 0; |
| 1262 | if (mWakeGestureEnabledSetting != wakeGestureEnabledSetting) { |
| 1263 | mWakeGestureEnabledSetting = wakeGestureEnabledSetting; |
| 1264 | updateWakeGestureListenerLp(); |
| 1265 | } |
| 1266 | |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1267 | // Configure rotation lock. |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1268 | int userRotation = Settings.System.getIntForUser(resolver, |
| 1269 | Settings.System.USER_ROTATION, Surface.ROTATION_0, |
| 1270 | UserHandle.USER_CURRENT); |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1271 | if (mUserRotation != userRotation) { |
| 1272 | mUserRotation = userRotation; |
| 1273 | updateRotation = true; |
| 1274 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1275 | int userRotationMode = Settings.System.getIntForUser(resolver, |
| 1276 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1277 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 1278 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
| 1279 | if (mUserRotationMode != userRotationMode) { |
| 1280 | mUserRotationMode = userRotationMode; |
| 1281 | updateRotation = true; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1282 | updateOrientationListenerLp(); |
| 1283 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1284 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1285 | if (mSystemReady) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1286 | int pointerLocation = Settings.System.getIntForUser(resolver, |
| 1287 | Settings.System.POINTER_LOCATION, 0, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1288 | if (mPointerLocationMode != pointerLocation) { |
| 1289 | mPointerLocationMode = pointerLocation; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1290 | mHandler.sendEmptyMessage(pointerLocation != 0 ? |
| 1291 | MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1292 | } |
| 1293 | } |
| 1294 | // use screen off timeout setting as the timeout for the lockscreen |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1295 | mLockScreenTimeout = Settings.System.getIntForUser(resolver, |
| 1296 | Settings.System.SCREEN_OFF_TIMEOUT, 0, UserHandle.USER_CURRENT); |
| 1297 | String imId = Settings.Secure.getStringForUser(resolver, |
| 1298 | Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1299 | boolean hasSoftInput = imId != null && imId.length() > 0; |
| 1300 | if (mHasSoftInput != hasSoftInput) { |
| 1301 | mHasSoftInput = hasSoftInput; |
| 1302 | updateRotation = true; |
| 1303 | } |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1304 | if (mImmersiveModeConfirmation != null) { |
John Spurlock | 4355a53 | 2014-02-19 09:49:25 -0500 | [diff] [blame] | 1305 | mImmersiveModeConfirmation.loadSetting(mCurrentUserId); |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1306 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 1307 | PolicyControl.reloadFromSetting(mContext); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1308 | } |
| 1309 | if (updateRotation) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1310 | updateRotation(true); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1311 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1312 | } |
| 1313 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1314 | private void updateWakeGestureListenerLp() { |
| 1315 | if (shouldEnableWakeGestureLp()) { |
| 1316 | mWakeGestureListener.requestWakeUpTrigger(); |
| 1317 | } else { |
| 1318 | mWakeGestureListener.cancelWakeUpTrigger(); |
| 1319 | } |
| 1320 | } |
| 1321 | |
| 1322 | private boolean shouldEnableWakeGestureLp() { |
| 1323 | return mWakeGestureEnabledSetting && !mScreenOnEarly |
| 1324 | && (!mLidControlsSleep || mLidState != LID_CLOSED) |
| 1325 | && mWakeGestureListener.isSupported(); |
| 1326 | } |
| 1327 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1328 | private void enablePointerLocation() { |
| 1329 | if (mPointerLocationView == null) { |
| 1330 | mPointerLocationView = new PointerLocationView(mContext); |
| 1331 | mPointerLocationView.setPrintCoords(false); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1332 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 1333 | WindowManager.LayoutParams.MATCH_PARENT, |
| 1334 | WindowManager.LayoutParams.MATCH_PARENT); |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1335 | lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1336 | lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
| 1337 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
| 1338 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1339 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
Jeff Brown | 90fc905 | 2012-10-01 14:44:24 -0700 | [diff] [blame] | 1340 | if (ActivityManager.isHighEndGfx()) { |
| 1341 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1342 | lp.privateFlags |= |
| 1343 | WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; |
| 1344 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1345 | lp.format = PixelFormat.TRANSLUCENT; |
| 1346 | lp.setTitle("PointerLocation"); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1347 | WindowManager wm = (WindowManager) |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1348 | mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1349 | lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1350 | wm.addView(mPointerLocationView, lp); |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1351 | mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1352 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1353 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1354 | |
| 1355 | private void disablePointerLocation() { |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1356 | if (mPointerLocationView != null) { |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1357 | mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView); |
| 1358 | WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1359 | wm.removeView(mPointerLocationView); |
| 1360 | mPointerLocationView = null; |
| 1361 | } |
| 1362 | } |
| 1363 | |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1364 | private int readRotation(int resID) { |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1365 | try { |
| 1366 | int rotation = mContext.getResources().getInteger(resID); |
| 1367 | switch (rotation) { |
| 1368 | case 0: |
| 1369 | return Surface.ROTATION_0; |
| 1370 | case 90: |
| 1371 | return Surface.ROTATION_90; |
| 1372 | case 180: |
| 1373 | return Surface.ROTATION_180; |
| 1374 | case 270: |
| 1375 | return Surface.ROTATION_270; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1376 | } |
| 1377 | } catch (Resources.NotFoundException e) { |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1378 | // fall through |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1379 | } |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1380 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | /** {@inheritDoc} */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1384 | @Override |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1385 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1386 | int type = attrs.type; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1387 | |
| 1388 | outAppOp[0] = AppOpsManager.OP_NONE; |
| 1389 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1390 | if (type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW |
| 1391 | || type > WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1392 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1393 | } |
| 1394 | String permission = null; |
| 1395 | switch (type) { |
| 1396 | case TYPE_TOAST: |
| 1397 | // XXX right now the app process has complete control over |
| 1398 | // this... should introduce a token to let the system |
| 1399 | // monitor/control what they are doing. |
Jason Monk | 1c7c319 | 2014-06-26 12:52:18 -0400 | [diff] [blame] | 1400 | outAppOp[0] = AppOpsManager.OP_TOAST_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1401 | break; |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 1402 | case TYPE_DREAM: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1403 | case TYPE_INPUT_METHOD: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1404 | case TYPE_WALLPAPER: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1405 | case TYPE_PRIVATE_PRESENTATION: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1406 | case TYPE_VOICE_INTERACTION: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1407 | // The window manager will check these. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1408 | break; |
| 1409 | case TYPE_PHONE: |
| 1410 | case TYPE_PRIORITY_PHONE: |
| 1411 | case TYPE_SYSTEM_ALERT: |
| 1412 | case TYPE_SYSTEM_ERROR: |
| 1413 | case TYPE_SYSTEM_OVERLAY: |
| 1414 | permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1415 | outAppOp[0] = AppOpsManager.OP_SYSTEM_ALERT_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1416 | break; |
| 1417 | default: |
| 1418 | permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; |
| 1419 | } |
| 1420 | if (permission != null) { |
| 1421 | if (mContext.checkCallingOrSelfPermission(permission) |
| 1422 | != PackageManager.PERMISSION_GRANTED) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1423 | return WindowManagerGlobal.ADD_PERMISSION_DENIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1424 | } |
| 1425 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1426 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1427 | } |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1428 | |
| 1429 | @Override |
| 1430 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs) { |
| 1431 | |
| 1432 | // If this switch statement is modified, modify the comment in the declarations of |
| 1433 | // the type in {@link WindowManager.LayoutParams} as well. |
| 1434 | switch (attrs.type) { |
| 1435 | default: |
| 1436 | // These are the windows that by default are shown only to the user that created |
| 1437 | // them. If this needs to be overridden, set |
| 1438 | // {@link WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS} in |
| 1439 | // {@link WindowManager.LayoutParams}. Note that permission |
| 1440 | // {@link android.Manifest.permission.INTERNAL_SYSTEM_WINDOW} is required as well. |
| 1441 | if ((attrs.privateFlags & PRIVATE_FLAG_SHOW_FOR_ALL_USERS) == 0) { |
| 1442 | return true; |
| 1443 | } |
| 1444 | break; |
| 1445 | |
| 1446 | // These are the windows that by default are shown to all users. However, to |
| 1447 | // protect against spoofing, check permissions below. |
| 1448 | case TYPE_APPLICATION_STARTING: |
| 1449 | case TYPE_BOOT_PROGRESS: |
| 1450 | case TYPE_DISPLAY_OVERLAY: |
| 1451 | case TYPE_HIDDEN_NAV_CONSUMER: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1452 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1453 | case TYPE_KEYGUARD_DIALOG: |
| 1454 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1455 | case TYPE_NAVIGATION_BAR: |
| 1456 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1457 | case TYPE_PHONE: |
| 1458 | case TYPE_POINTER: |
| 1459 | case TYPE_PRIORITY_PHONE: |
| 1460 | case TYPE_RECENTS_OVERLAY: |
| 1461 | case TYPE_SEARCH_BAR: |
| 1462 | case TYPE_STATUS_BAR: |
| 1463 | case TYPE_STATUS_BAR_PANEL: |
| 1464 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1465 | case TYPE_SYSTEM_DIALOG: |
| 1466 | case TYPE_UNIVERSE_BACKGROUND: |
| 1467 | case TYPE_VOLUME_OVERLAY: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1468 | case TYPE_PRIVATE_PRESENTATION: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1469 | break; |
| 1470 | } |
| 1471 | |
| 1472 | // Check if third party app has set window to system window type. |
| 1473 | return mContext.checkCallingOrSelfPermission( |
| 1474 | android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) |
| 1475 | != PackageManager.PERMISSION_GRANTED; |
| 1476 | } |
| 1477 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1478 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1479 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) { |
| 1480 | switch (attrs.type) { |
| 1481 | case TYPE_SYSTEM_OVERLAY: |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1482 | case TYPE_SECURE_SYSTEM_OVERLAY: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1483 | // These types of windows can't receive input events. |
| 1484 | attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1485 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1486 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1487 | break; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1488 | case TYPE_STATUS_BAR: |
| 1489 | |
| 1490 | // If the Keyguard is in a hidden state (occluded by another window), we force to |
| 1491 | // remove the wallpaper and keyguard flag so that any change in-flight after setting |
| 1492 | // the keyguard as occluded wouldn't set these flags again. |
| 1493 | // See {@link #processKeyguardSetHiddenResultLw}. |
| 1494 | if (mKeyguardHidden) { |
| 1495 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 1496 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 1497 | } |
| 1498 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1499 | } |
Adrian Roos | 3850211 | 2014-04-09 21:04:11 +0200 | [diff] [blame] | 1500 | |
| 1501 | if (attrs.type != TYPE_STATUS_BAR) { |
| 1502 | // The status bar is the only window allowed to exhibit keyguard behavior. |
| 1503 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 1504 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1505 | |
| 1506 | if (ActivityManager.isHighEndGfx() |
| 1507 | && (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) { |
| 1508 | attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
| 1509 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 1510 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; |
| 1511 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1512 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1513 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1514 | void readLidState() { |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 1515 | mLidState = mWindowManagerFuncs.getLidState(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1516 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1517 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1518 | private boolean isHidden(int accessibilityMode) { |
| 1519 | switch (accessibilityMode) { |
| 1520 | case 1: |
| 1521 | return mLidState == LID_CLOSED; |
| 1522 | case 2: |
| 1523 | return mLidState == LID_OPEN; |
| 1524 | default: |
| 1525 | return false; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1526 | } |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1527 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1528 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1529 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1530 | @Override |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1531 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 1532 | int navigationPresence) { |
| 1533 | mHaveBuiltInKeyboard = (keyboardPresence & PRESENCE_INTERNAL) != 0; |
| 1534 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1535 | readConfigurationDependentBehaviors(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1536 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1537 | applyLidSwitchState(); |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1538 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1539 | if (config.keyboard == Configuration.KEYBOARD_NOKEYS |
| 1540 | || (keyboardPresence == PRESENCE_INTERNAL |
| 1541 | && isHidden(mLidKeyboardAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1542 | config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1543 | if (!mHasSoftInput) { |
| 1544 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; |
| 1545 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1546 | } |
| 1547 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1548 | if (config.navigation == Configuration.NAVIGATION_NONAV |
| 1549 | || (navigationPresence == PRESENCE_INTERNAL |
| 1550 | && isHidden(mLidNavigationAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1551 | config.navigationHidden = Configuration.NAVIGATIONHIDDEN_YES; |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1552 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1553 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1554 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1555 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1556 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1557 | public int windowTypeToLayerLw(int type) { |
| 1558 | if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1559 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1560 | } |
| 1561 | switch (type) { |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1562 | case TYPE_UNIVERSE_BACKGROUND: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1563 | return 1; |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1564 | case TYPE_PRIVATE_PRESENTATION: |
| 1565 | return 2; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1566 | case TYPE_WALLPAPER: |
| 1567 | // wallpaper is at the bottom, though the window manager may move it. |
| 1568 | return 2; |
| 1569 | case TYPE_PHONE: |
| 1570 | return 3; |
| 1571 | case TYPE_SEARCH_BAR: |
| 1572 | return 4; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1573 | case TYPE_VOICE_INTERACTION: |
| 1574 | // voice interaction layer is almost immediately above apps. |
| 1575 | return 5; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1576 | case TYPE_RECENTS_OVERLAY: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1577 | case TYPE_SYSTEM_DIALOG: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1578 | return 6; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1579 | case TYPE_TOAST: |
| 1580 | // toasts and the plugged-in battery thing |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1581 | return 7; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1582 | case TYPE_PRIORITY_PHONE: |
| 1583 | // 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] | 1584 | return 8; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1585 | case TYPE_DREAM: |
| 1586 | // used for Dreams (screensavers with TYPE_DREAM windows) |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1587 | return 9; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1588 | case TYPE_SYSTEM_ALERT: |
| 1589 | // like the ANR / app crashed dialogs |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1590 | return 10; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1591 | case TYPE_INPUT_METHOD: |
| 1592 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1593 | return 11; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1594 | case TYPE_INPUT_METHOD_DIALOG: |
| 1595 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1596 | return 12; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1597 | case TYPE_KEYGUARD_SCRIM: |
| 1598 | // the safety window that shows behind keyguard while keyguard is starting |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1599 | return 13; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1600 | case TYPE_STATUS_BAR_SUB_PANEL: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1601 | return 14; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1602 | case TYPE_STATUS_BAR: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1603 | return 15; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1604 | case TYPE_STATUS_BAR_PANEL: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1605 | return 16; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1606 | case TYPE_KEYGUARD_DIALOG: |
| 1607 | return 17; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1608 | case TYPE_VOLUME_OVERLAY: |
| 1609 | // the on-screen volume indicator and controller shown when the user |
| 1610 | // changes the device volume |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1611 | return 18; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1612 | case TYPE_SYSTEM_OVERLAY: |
| 1613 | // the on-screen volume indicator and controller shown when the user |
| 1614 | // changes the device volume |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1615 | return 19; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1616 | case TYPE_NAVIGATION_BAR: |
| 1617 | // the navigation bar, if available, shows atop most things |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1618 | return 20; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1619 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1620 | // 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] | 1621 | return 21; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1622 | case TYPE_SYSTEM_ERROR: |
| 1623 | // system-level error dialogs |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1624 | return 22; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1625 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1626 | // used to highlight the magnified portion of a display |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1627 | return 23; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1628 | case TYPE_DISPLAY_OVERLAY: |
| 1629 | // used to simulate secondary display devices |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1630 | return 24; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1631 | case TYPE_DRAG: |
| 1632 | // the drag layer: input for drag-and-drop is associated with this window, |
| 1633 | // which sits above all other focusable windows |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1634 | return 25; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1635 | case TYPE_SECURE_SYSTEM_OVERLAY: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1636 | return 26; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1637 | case TYPE_BOOT_PROGRESS: |
| 1638 | return 27; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1639 | case TYPE_POINTER: |
| 1640 | // the (mouse) pointer layer |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1641 | return 28; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1642 | case TYPE_HIDDEN_NAV_CONSUMER: |
| 1643 | return 29; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1644 | } |
| 1645 | Log.e(TAG, "Unknown window type: " + type); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1646 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1647 | } |
| 1648 | |
| 1649 | /** {@inheritDoc} */ |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1650 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1651 | public int subWindowTypeToLayerLw(int type) { |
| 1652 | switch (type) { |
| 1653 | case TYPE_APPLICATION_PANEL: |
| 1654 | case TYPE_APPLICATION_ATTACHED_DIALOG: |
| 1655 | return APPLICATION_PANEL_SUBLAYER; |
| 1656 | case TYPE_APPLICATION_MEDIA: |
| 1657 | return APPLICATION_MEDIA_SUBLAYER; |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 1658 | case TYPE_APPLICATION_MEDIA_OVERLAY: |
| 1659 | return APPLICATION_MEDIA_OVERLAY_SUBLAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1660 | case TYPE_APPLICATION_SUB_PANEL: |
| 1661 | return APPLICATION_SUB_PANEL_SUBLAYER; |
| 1662 | } |
| 1663 | Log.e(TAG, "Unknown sub-window type: " + type); |
| 1664 | return 0; |
| 1665 | } |
| 1666 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1667 | @Override |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1668 | public int getMaxWallpaperLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1669 | return windowTypeToLayerLw(TYPE_STATUS_BAR); |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1670 | } |
| 1671 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1672 | @Override |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1673 | public int getAboveUniverseLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1674 | return windowTypeToLayerLw(TYPE_SYSTEM_ERROR); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 1675 | } |
| 1676 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1677 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1678 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1679 | if (mHasNavigationBar) { |
| 1680 | // For a basic navigation bar, when we are in landscape mode we place |
| 1681 | // the navigation bar to the side. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1682 | if (mNavigationBarCanMove && fullWidth > fullHeight) { |
| 1683 | return fullWidth - mNavigationBarWidthForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1684 | } |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1685 | } |
| 1686 | return fullWidth; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1687 | } |
| 1688 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1689 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1690 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1691 | if (mHasNavigationBar) { |
| 1692 | // For a basic navigation bar, when we are in portrait mode we place |
| 1693 | // the navigation bar to the bottom. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1694 | if (!mNavigationBarCanMove || fullWidth < fullHeight) { |
| 1695 | return fullHeight - mNavigationBarHeightForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1696 | } |
| 1697 | } |
| 1698 | return fullHeight; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1699 | } |
| 1700 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1701 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1702 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
| 1703 | return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1704 | } |
| 1705 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1706 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1707 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1708 | // There is a separate status bar at the top of the display. We don't count that as part |
| 1709 | // 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] | 1710 | // we do want to exclude it since applications can't generally use that part |
| 1711 | // of the screen. |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1712 | return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation) - mStatusBarHeight; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1713 | } |
| 1714 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1715 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 1716 | public boolean isForceHiding(WindowManager.LayoutParams attrs) { |
| 1717 | return (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 || |
Adrian Roos | 69e510d | 2014-07-13 14:57:59 +0200 | [diff] [blame] | 1718 | (isKeyguardHostWindow(attrs) && isKeyguardSecureIncludingHidden()) || |
| 1719 | (attrs.type == TYPE_KEYGUARD_SCRIM); |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1720 | } |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1721 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1722 | @Override |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1723 | public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs) { |
| 1724 | return attrs.type == TYPE_STATUS_BAR; |
| 1725 | } |
| 1726 | |
| 1727 | @Override |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1728 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs) { |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1729 | switch (attrs.type) { |
| 1730 | case TYPE_STATUS_BAR: |
| 1731 | case TYPE_NAVIGATION_BAR: |
| 1732 | case TYPE_WALLPAPER: |
| 1733 | case TYPE_DREAM: |
| 1734 | case TYPE_UNIVERSE_BACKGROUND: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1735 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1736 | return false; |
| 1737 | default: |
| 1738 | return true; |
| 1739 | } |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1740 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1741 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1742 | /** {@inheritDoc} */ |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1743 | @Override |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1744 | public View addStartingWindow(IBinder appToken, String packageName, int theme, |
| 1745 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1746 | int icon, int logo, int windowFlags) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1747 | if (!SHOW_STARTING_ANIMATIONS) { |
| 1748 | return null; |
| 1749 | } |
| 1750 | if (packageName == null) { |
| 1751 | return null; |
| 1752 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1753 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1754 | WindowManager wm = null; |
| 1755 | View view = null; |
| 1756 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1757 | try { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1758 | Context context = mContext; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1759 | if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow " + packageName |
| 1760 | + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" |
| 1761 | + Integer.toHexString(theme)); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1762 | if (theme != context.getThemeResId() || labelRes != 0) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1763 | try { |
| 1764 | context = context.createPackageContext(packageName, 0); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1765 | context.setTheme(theme); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1766 | } catch (PackageManager.NameNotFoundException e) { |
| 1767 | // Ignore |
| 1768 | } |
| 1769 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1770 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1771 | Window win = PolicyManager.makeNewWindow(context); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1772 | final TypedArray ta = win.getWindowStyle(); |
| 1773 | if (ta.getBoolean( |
| 1774 | com.android.internal.R.styleable.Window_windowDisablePreview, false) |
| 1775 | || ta.getBoolean( |
| 1776 | com.android.internal.R.styleable.Window_windowShowWallpaper,false)) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1777 | return null; |
| 1778 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1779 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1780 | Resources r = context.getResources(); |
| 1781 | win.setTitle(r.getText(labelRes, nonLocalizedLabel)); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1782 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1783 | win.setType( |
| 1784 | WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); |
| 1785 | // Force the window flags: this is a fake window, so it is not really |
| 1786 | // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM |
| 1787 | // flag because we do know that the next window will take input |
| 1788 | // focus, so we want to get the IME window up on top of us right away. |
| 1789 | win.setFlags( |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1790 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1791 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1792 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1793 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1794 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1795 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1796 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1797 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1798 | |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 1799 | win.setDefaultIcon(icon); |
| 1800 | win.setDefaultLogo(logo); |
| 1801 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1802 | win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1803 | WindowManager.LayoutParams.MATCH_PARENT); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1804 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1805 | final WindowManager.LayoutParams params = win.getAttributes(); |
| 1806 | params.token = appToken; |
| 1807 | params.packageName = packageName; |
| 1808 | params.windowAnimations = win.getWindowStyle().getResourceId( |
| 1809 | com.android.internal.R.styleable.Window_windowAnimationStyle, 0); |
Dianne Hackborn | 5d927c2 | 2011-09-02 12:22:18 -0700 | [diff] [blame] | 1810 | params.privateFlags |= |
| 1811 | WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1812 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 1813 | |
| 1814 | if (!compatInfo.supportsScreen()) { |
| 1815 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; |
| 1816 | } |
| 1817 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1818 | params.setTitle("Starting " + packageName); |
| 1819 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1820 | wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
| 1821 | view = win.getDecorView(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1822 | |
| 1823 | if (win.isFloating()) { |
| 1824 | // Whoops, there is no way to display an animation/preview |
| 1825 | // of such a thing! After all that work... let's skip it. |
| 1826 | // (Note that we must do this here because it is in |
| 1827 | // getDecorView() where the theme is evaluated... maybe |
| 1828 | // we should peek the floating attribute from the theme |
| 1829 | // earlier.) |
| 1830 | return null; |
| 1831 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 1832 | |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1833 | if (DEBUG_STARTING_WINDOW) Slog.d( |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1834 | TAG, "Adding starting window for " + packageName |
| 1835 | + " / " + appToken + ": " |
| 1836 | + (view.getParent() != null ? view : null)); |
| 1837 | |
| 1838 | wm.addView(view, params); |
| 1839 | |
| 1840 | // Only return the view if it was successfully added to the |
| 1841 | // window manager... which we can tell by it having a parent. |
| 1842 | return view.getParent() != null ? view : null; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1843 | } catch (WindowManager.BadTokenException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1844 | // ignore |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 1845 | Log.w(TAG, appToken + " already running, starting window not displayed. " + |
| 1846 | e.getMessage()); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1847 | } catch (RuntimeException e) { |
| 1848 | // don't crash if something else bad happens, for example a |
| 1849 | // failure loading resources because we are loading from an app |
| 1850 | // on external storage that has been unmounted. |
| 1851 | Log.w(TAG, appToken + " failed creating starting window", e); |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 1852 | } finally { |
| 1853 | if (view != null && view.getParent() == null) { |
| 1854 | Log.w(TAG, "view not successfully added to wm, removing view"); |
| 1855 | wm.removeViewImmediate(view); |
| 1856 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1857 | } |
| 1858 | |
| 1859 | return null; |
| 1860 | } |
| 1861 | |
| 1862 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1863 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1864 | public void removeStartingWindow(IBinder appToken, View window) { |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 1865 | if (DEBUG_STARTING_WINDOW) { |
| 1866 | RuntimeException e = new RuntimeException("here"); |
| 1867 | e.fillInStackTrace(); |
| 1868 | Log.v(TAG, "Removing starting window for " + appToken + ": " + window, e); |
| 1869 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1870 | |
| 1871 | if (window != null) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1872 | WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1873 | wm.removeView(window); |
| 1874 | } |
| 1875 | } |
| 1876 | |
| 1877 | /** |
| 1878 | * Preflight adding a window to the system. |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1879 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1880 | * Currently enforces that three window types are singletons: |
| 1881 | * <ul> |
| 1882 | * <li>STATUS_BAR_TYPE</li> |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1883 | * <li>KEYGUARD_TYPE</li> |
| 1884 | * </ul> |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1885 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1886 | * @param win The window to be added |
| 1887 | * @param attrs Information about the window to be added |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1888 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1889 | * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, |
| 1890 | * WindowManagerImpl.ADD_MULTIPLE_SINGLETON |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1891 | */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1892 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1893 | public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) { |
| 1894 | switch (attrs.type) { |
| 1895 | case TYPE_STATUS_BAR: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1896 | mContext.enforceCallingOrSelfPermission( |
| 1897 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1898 | "PhoneWindowManager"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1899 | if (mStatusBar != null) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1900 | if (mStatusBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1901 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1902 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1903 | } |
| 1904 | mStatusBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1905 | mStatusBarController.setWindow(win); |
John Spurlock | 8fdfe62 | 2014-05-21 17:10:10 -0400 | [diff] [blame] | 1906 | mKeyguardDelegate.hideScrim(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1907 | break; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1908 | case TYPE_NAVIGATION_BAR: |
| 1909 | mContext.enforceCallingOrSelfPermission( |
| 1910 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1911 | "PhoneWindowManager"); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1912 | if (mNavigationBar != null) { |
| 1913 | if (mNavigationBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1914 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1915 | } |
| 1916 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1917 | mNavigationBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1918 | mNavigationBarController.setWindow(win); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 1919 | if (DEBUG_LAYOUT) Slog.i(TAG, "NAVIGATION BAR: " + mNavigationBar); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1920 | break; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1921 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1922 | mContext.enforceCallingOrSelfPermission( |
| 1923 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1924 | "PhoneWindowManager"); |
| 1925 | break; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1926 | case TYPE_STATUS_BAR_PANEL: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1927 | mContext.enforceCallingOrSelfPermission( |
| 1928 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1929 | "PhoneWindowManager"); |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1930 | break; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1931 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1932 | mContext.enforceCallingOrSelfPermission( |
| 1933 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1934 | "PhoneWindowManager"); |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1935 | break; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1936 | case TYPE_KEYGUARD_SCRIM: |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1937 | if (mKeyguardScrim != null) { |
| 1938 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
| 1939 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1940 | mKeyguardScrim = win; |
| 1941 | break; |
| 1942 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1943 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1944 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1945 | } |
| 1946 | |
| 1947 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1948 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1949 | public void removeWindowLw(WindowState win) { |
| 1950 | if (mStatusBar == win) { |
| 1951 | mStatusBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1952 | mStatusBarController.setWindow(null); |
Jim Miller | c0b676d | 2013-03-22 16:11:08 -0700 | [diff] [blame] | 1953 | mKeyguardDelegate.showScrim(); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1954 | } else if (mKeyguardScrim == win) { |
| 1955 | Log.v(TAG, "Removing keyguard scrim"); |
| 1956 | mKeyguardScrim = null; |
| 1957 | } if (mNavigationBar == win) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1958 | mNavigationBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1959 | mNavigationBarController.setWindow(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1960 | } |
| 1961 | } |
| 1962 | |
| 1963 | static final boolean PRINT_ANIM = false; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1964 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1965 | /** {@inheritDoc} */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1966 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1967 | public int selectAnimationLw(WindowState win, int transit) { |
| 1968 | if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win |
| 1969 | + ": transit=" + transit); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1970 | if (win == mStatusBar) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1971 | boolean isKeyguard = (win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1972 | if (transit == TRANSIT_EXIT |
| 1973 | || transit == TRANSIT_HIDE) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1974 | return isKeyguard ? -1 : R.anim.dock_top_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1975 | } else if (transit == TRANSIT_ENTER |
| 1976 | || transit == TRANSIT_SHOW) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1977 | return isKeyguard ? -1 : R.anim.dock_top_enter; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1978 | } |
| 1979 | } else if (win == mNavigationBar) { |
| 1980 | // This can be on either the bottom or the right. |
| 1981 | if (mNavigationBarOnBottom) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1982 | if (transit == TRANSIT_EXIT |
| 1983 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1984 | return R.anim.dock_bottom_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1985 | } else if (transit == TRANSIT_ENTER |
| 1986 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1987 | return R.anim.dock_bottom_enter; |
| 1988 | } |
| 1989 | } else { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1990 | if (transit == TRANSIT_EXIT |
| 1991 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1992 | return R.anim.dock_right_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1993 | } else if (transit == TRANSIT_ENTER |
| 1994 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1995 | return R.anim.dock_right_enter; |
| 1996 | } |
| 1997 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 1998 | } |
| 1999 | |
| 2000 | if (transit == TRANSIT_PREVIEW_DONE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2001 | if (win.hasAppShownWindows()) { |
| 2002 | if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT"); |
| 2003 | return com.android.internal.R.anim.app_starting_exit; |
| 2004 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 2005 | } else if (win.getAttrs().type == TYPE_DREAM && mDreamingLockscreen |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2006 | && transit == TRANSIT_ENTER) { |
| 2007 | // Special case: we are animating in a dream, while the keyguard |
| 2008 | // is shown. We don't want an animation on the dream, because |
| 2009 | // we need it shown immediately with the keyguard animating away |
| 2010 | // to reveal it. |
| 2011 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2012 | } |
| 2013 | |
| 2014 | return 0; |
| 2015 | } |
| 2016 | |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 2017 | @Override |
| 2018 | public void selectRotationAnimationLw(int anim[]) { |
| 2019 | if (PRINT_ANIM) Slog.i(TAG, "selectRotationAnimation mTopFullscreen=" |
| 2020 | + mTopFullscreenOpaqueWindowState + " rotationAnimation=" |
| 2021 | + (mTopFullscreenOpaqueWindowState == null ? |
| 2022 | "0" : mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation)); |
| 2023 | if (mTopFullscreenOpaqueWindowState != null && mTopIsFullscreen) { |
| 2024 | switch (mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation) { |
| 2025 | case ROTATION_ANIMATION_CROSSFADE: |
| 2026 | anim[0] = R.anim.rotation_animation_xfade_exit; |
| 2027 | anim[1] = R.anim.rotation_animation_enter; |
| 2028 | break; |
| 2029 | case ROTATION_ANIMATION_JUMPCUT: |
| 2030 | anim[0] = R.anim.rotation_animation_jump_exit; |
| 2031 | anim[1] = R.anim.rotation_animation_enter; |
| 2032 | break; |
| 2033 | case ROTATION_ANIMATION_ROTATE: |
| 2034 | default: |
| 2035 | anim[0] = anim[1] = 0; |
| 2036 | break; |
| 2037 | } |
| 2038 | } else { |
| 2039 | anim[0] = anim[1] = 0; |
| 2040 | } |
| 2041 | } |
| 2042 | |
| 2043 | @Override |
| 2044 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 2045 | boolean forceDefault) { |
| 2046 | switch (exitAnimId) { |
| 2047 | case R.anim.rotation_animation_xfade_exit: |
| 2048 | case R.anim.rotation_animation_jump_exit: |
| 2049 | // These are the only cases that matter. |
| 2050 | if (forceDefault) { |
| 2051 | return false; |
| 2052 | } |
| 2053 | int anim[] = new int[2]; |
| 2054 | selectRotationAnimationLw(anim); |
| 2055 | return (exitAnimId == anim[0] && enterAnimId == anim[1]); |
| 2056 | default: |
| 2057 | return true; |
| 2058 | } |
| 2059 | } |
| 2060 | |
| 2061 | @Override |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 2062 | public Animation createForceHideEnterAnimation(boolean onWallpaper) { |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 2063 | return AnimationUtils.loadAnimation(mContext, |
| 2064 | com.android.internal.R.anim.lock_screen_behind_enter); |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 2065 | } |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 2066 | |
| 2067 | private static void awakenDreams() { |
| 2068 | IDreamManager dreamManager = getDreamManager(); |
| 2069 | if (dreamManager != null) { |
| 2070 | try { |
| 2071 | dreamManager.awaken(); |
| 2072 | } catch (RemoteException e) { |
| 2073 | // fine, stay asleep then |
| 2074 | } |
| 2075 | } |
| 2076 | } |
| 2077 | |
| 2078 | static IDreamManager getDreamManager() { |
| 2079 | return IDreamManager.Stub.asInterface( |
| 2080 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
| 2081 | } |
| 2082 | |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2083 | TelecommManager getTelecommService() { |
| 2084 | return (TelecommManager) mContext.getSystemService(Context.TELECOMM_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2085 | } |
| 2086 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 2087 | static IAudioService getAudioService() { |
| 2088 | IAudioService audioService = IAudioService.Stub.asInterface( |
| 2089 | ServiceManager.checkService(Context.AUDIO_SERVICE)); |
| 2090 | if (audioService == null) { |
| 2091 | Log.w(TAG, "Unable to find IAudioService interface."); |
| 2092 | } |
| 2093 | return audioService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2094 | } |
| 2095 | |
| 2096 | boolean keyguardOn() { |
| 2097 | return keyguardIsShowingTq() || inKeyguardRestrictedKeyInputMode(); |
| 2098 | } |
| 2099 | |
| 2100 | private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { |
| 2101 | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, |
| 2102 | WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, |
| 2103 | }; |
| 2104 | |
| 2105 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2106 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2107 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2108 | final boolean keyguardOn = keyguardOn(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2109 | final int keyCode = event.getKeyCode(); |
| 2110 | final int repeatCount = event.getRepeatCount(); |
| 2111 | final int metaState = event.getMetaState(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2112 | final int flags = event.getFlags(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2113 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 2114 | final boolean canceled = event.isCanceled(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2115 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2116 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2117 | Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount=" |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2118 | + repeatCount + " keyguardOn=" + keyguardOn + " mHomePressed=" + mHomePressed |
| 2119 | + " canceled=" + canceled); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2120 | } |
| 2121 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2122 | // If we think we might have a volume down & power key chord on the way |
| 2123 | // but we're not sure, then tell the dispatcher to wait a little while and |
| 2124 | // try again later before dispatching. |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 2125 | if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2126 | if (mVolumeDownKeyTriggered && !mPowerKeyTriggered) { |
| 2127 | final long now = SystemClock.uptimeMillis(); |
| 2128 | final long timeoutTime = mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS; |
| 2129 | if (now < timeoutTime) { |
| 2130 | return timeoutTime - now; |
| 2131 | } |
| 2132 | } |
| 2133 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN |
| 2134 | && mVolumeDownKeyConsumedByScreenshotChord) { |
| 2135 | if (!down) { |
| 2136 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 2137 | } |
| 2138 | return -1; |
| 2139 | } |
| 2140 | } |
| 2141 | |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2142 | // Cancel any pending meta actions if we see any other keys being pressed between the down |
| 2143 | // of the meta key and its corresponding up. |
Michael Wright | ce0c13a | 2014-07-30 10:49:21 -0700 | [diff] [blame] | 2144 | if (mPendingMetaAction && KeyEvent.isMetaKey(keyCode)) { |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2145 | mPendingMetaAction = false; |
| 2146 | } |
| 2147 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2148 | // First we always handle the home key here, so applications |
| 2149 | // can never break it, although if keyguard is on, we do let |
| 2150 | // it handle it, because that gives us the correct 5 second |
| 2151 | // timeout. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2152 | if (keyCode == KeyEvent.KEYCODE_HOME) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2153 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2154 | // If we have released the home key, and didn't do anything else |
| 2155 | // while it was pressed, then it is time to go home! |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2156 | if (!down) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2157 | cancelPreloadRecentApps(); |
| 2158 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2159 | mHomePressed = false; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2160 | if (mHomeConsumed) { |
| 2161 | mHomeConsumed = false; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2162 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2163 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2164 | |
| 2165 | if (canceled) { |
| 2166 | Log.i(TAG, "Ignoring HOME; event canceled."); |
| 2167 | return -1; |
| 2168 | } |
| 2169 | |
| 2170 | // If an incoming call is ringing, HOME is totally disabled. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2171 | // (The user is already on the InCallUI at this point, |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2172 | // and his ONLY options are to answer or reject the call.) |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 2173 | TelecommManager telecommManager = getTelecommService(); |
| 2174 | if (telecommManager != null && telecommManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 2175 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); |
| 2176 | return -1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2177 | } |
| 2178 | |
| 2179 | // Delay handling home if a double-tap is possible. |
| 2180 | if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) { |
| 2181 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case |
| 2182 | mHomeDoubleTapPending = true; |
| 2183 | mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable, |
| 2184 | ViewConfiguration.getDoubleTapTimeout()); |
| 2185 | return -1; |
| 2186 | } |
| 2187 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2188 | // If there's a dream running then use home to escape the dream |
| 2189 | // but don't actually go home. |
| 2190 | if (mDreamManagerInternal != null && mDreamManagerInternal.isDreaming()) { |
Jeff Brown | f6d4668 | 2014-07-17 22:44:20 -0700 | [diff] [blame] | 2191 | mDreamManagerInternal.stopDream(false /*immediate*/); |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2192 | return -1; |
| 2193 | } |
| 2194 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2195 | // Go home! |
| 2196 | launchHomeFromHotKey(); |
| 2197 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2198 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2199 | |
| 2200 | // If a system window has focus, then it doesn't make sense |
| 2201 | // right now to interact with applications. |
| 2202 | WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null; |
| 2203 | if (attrs != null) { |
| 2204 | final int type = attrs.type; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2205 | if (type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM |
| 2206 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG |
| 2207 | || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2208 | // the "app" is keyguard, so give it the key |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2209 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2210 | } |
| 2211 | final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length; |
| 2212 | for (int i=0; i<typeCount; i++) { |
| 2213 | if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) { |
| 2214 | // 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] | 2215 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2216 | } |
| 2217 | } |
| 2218 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2219 | |
| 2220 | // Remember that home is pressed and handle special actions. |
| 2221 | if (repeatCount == 0) { |
| 2222 | mHomePressed = true; |
| 2223 | if (mHomeDoubleTapPending) { |
| 2224 | mHomeDoubleTapPending = false; |
| 2225 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); |
| 2226 | handleDoubleTapOnHome(); |
| 2227 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI |
| 2228 | || mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 2229 | preloadRecentApps(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2230 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2231 | } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { |
| 2232 | if (!keyguardOn) { |
| 2233 | handleLongPressOnHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2234 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2235 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2236 | return -1; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2237 | } else if (keyCode == KeyEvent.KEYCODE_MENU) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2238 | // Hijack modified menu keys for debugging features |
| 2239 | final int chordBug = KeyEvent.META_SHIFT_ON; |
| 2240 | |
| 2241 | if (down && repeatCount == 0) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2242 | if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2243 | Intent intent = new Intent(Intent.ACTION_BUG_REPORT); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2244 | mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, |
| 2245 | null, null, null, 0, null, null); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2246 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2247 | } else if (SHOW_PROCESSES_ON_ALT_MENU && |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2248 | (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2249 | Intent service = new Intent(); |
| 2250 | service.setClassName(mContext, "com.android.server.LoadAverageService"); |
| 2251 | ContentResolver res = mContext.getContentResolver(); |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2252 | boolean shown = Settings.Global.getInt( |
| 2253 | res, Settings.Global.SHOW_PROCESSES, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2254 | if (!shown) { |
| 2255 | mContext.startService(service); |
| 2256 | } else { |
| 2257 | mContext.stopService(service); |
| 2258 | } |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2259 | Settings.Global.putInt( |
| 2260 | res, Settings.Global.SHOW_PROCESSES, shown ? 0 : 1); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2261 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2262 | } |
| 2263 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2264 | } else if (keyCode == KeyEvent.KEYCODE_SEARCH) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2265 | if (down) { |
| 2266 | if (repeatCount == 0) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2267 | mSearchKeyShortcutPending = true; |
| 2268 | mConsumeSearchKeyUp = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2269 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2270 | } else { |
| 2271 | mSearchKeyShortcutPending = false; |
| 2272 | if (mConsumeSearchKeyUp) { |
| 2273 | mConsumeSearchKeyUp = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2274 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2275 | } |
| 2276 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2277 | return 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2278 | } else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) { |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2279 | if (!keyguardOn) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2280 | if (down && repeatCount == 0) { |
| 2281 | preloadRecentApps(); |
| 2282 | } else if (!down) { |
| 2283 | toggleRecentApps(); |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2284 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2285 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2286 | return -1; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2287 | } else if (keyCode == KeyEvent.KEYCODE_ASSIST) { |
| 2288 | if (down) { |
| 2289 | if (repeatCount == 0) { |
| 2290 | mAssistKeyLongPressed = false; |
| 2291 | } else if (repeatCount == 1) { |
| 2292 | mAssistKeyLongPressed = true; |
| 2293 | if (!keyguardOn) { |
| 2294 | launchAssistLongPressAction(); |
| 2295 | } |
| 2296 | } |
| 2297 | } else { |
| 2298 | if (mAssistKeyLongPressed) { |
| 2299 | mAssistKeyLongPressed = false; |
| 2300 | } else { |
| 2301 | if (!keyguardOn) { |
| 2302 | launchAssistAction(); |
| 2303 | } |
| 2304 | } |
| 2305 | } |
| 2306 | return -1; |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 2307 | } else if (keyCode == KeyEvent.KEYCODE_SYSRQ) { |
| 2308 | if (down && repeatCount == 0) { |
| 2309 | mHandler.post(mScreenshotRunnable); |
| 2310 | } |
| 2311 | return -1; |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 2312 | } else if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP |
| 2313 | || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) { |
| 2314 | if (down) { |
| 2315 | int direction = keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP ? 1 : -1; |
| 2316 | |
| 2317 | // Disable autobrightness if it's on |
| 2318 | int auto = Settings.System.getIntForUser( |
| 2319 | mContext.getContentResolver(), |
| 2320 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2321 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2322 | UserHandle.USER_CURRENT_OR_SELF); |
| 2323 | if (auto != 0) { |
| 2324 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2325 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2326 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2327 | UserHandle.USER_CURRENT_OR_SELF); |
| 2328 | } |
| 2329 | |
| 2330 | int min = mPowerManager.getMinimumScreenBrightnessSetting(); |
| 2331 | int max = mPowerManager.getMaximumScreenBrightnessSetting(); |
| 2332 | int step = (max - min + BRIGHTNESS_STEPS - 1) / BRIGHTNESS_STEPS * direction; |
| 2333 | int brightness = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 2334 | Settings.System.SCREEN_BRIGHTNESS, |
| 2335 | mPowerManager.getDefaultScreenBrightnessSetting(), |
| 2336 | UserHandle.USER_CURRENT_OR_SELF); |
| 2337 | brightness += step; |
| 2338 | // Make sure we don't go beyond the limits. |
| 2339 | brightness = Math.min(max, brightness); |
| 2340 | brightness = Math.max(min, brightness); |
| 2341 | |
| 2342 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2343 | Settings.System.SCREEN_BRIGHTNESS, brightness, |
| 2344 | UserHandle.USER_CURRENT_OR_SELF); |
Alan Viverette | 5a39949 | 2014-07-14 16:19:38 -0700 | [diff] [blame] | 2345 | mContext.startActivityAsUser(new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG), |
| 2346 | UserHandle.CURRENT_OR_SELF); |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 2347 | } |
| 2348 | return -1; |
Michael Wright | ce0c13a | 2014-07-30 10:49:21 -0700 | [diff] [blame] | 2349 | } else if (KeyEvent.isMetaKey(keyCode)) { |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2350 | if (down) { |
| 2351 | mPendingMetaAction = true; |
| 2352 | } else if (mPendingMetaAction) { |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2353 | launchAssistAction(); |
| 2354 | } |
| 2355 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2356 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2357 | |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2358 | // Shortcuts are invoked through Search+key, so intercept those here |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2359 | // Any printing key that is chorded with Search should be consumed |
| 2360 | // even if no shortcut was invoked. This prevents text from being |
| 2361 | // inadvertently inserted when using a keyboard that has built-in macro |
| 2362 | // 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] | 2363 | if (mSearchKeyShortcutPending) { |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2364 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
| 2365 | if (kcm.isPrintingKey(keyCode)) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2366 | mConsumeSearchKeyUp = true; |
| 2367 | mSearchKeyShortcutPending = false; |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2368 | if (down && repeatCount == 0 && !keyguardOn) { |
| 2369 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState); |
| 2370 | if (shortcutIntent != null) { |
| 2371 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2372 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2373 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2374 | } catch (ActivityNotFoundException ex) { |
| 2375 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2376 | + "the activity to which it is registered was not found: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2377 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode), ex); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2378 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2379 | } else { |
| 2380 | Slog.i(TAG, "Dropping unregistered shortcut key combination: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2381 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2382 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2383 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2384 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2385 | } |
| 2386 | } |
| 2387 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2388 | // Invoke shortcuts using Meta. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2389 | if (down && repeatCount == 0 && !keyguardOn |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2390 | && (metaState & KeyEvent.META_META_ON) != 0) { |
| 2391 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2392 | if (kcm.isPrintingKey(keyCode)) { |
| 2393 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, |
| 2394 | metaState & ~(KeyEvent.META_META_ON |
| 2395 | | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON)); |
| 2396 | if (shortcutIntent != null) { |
| 2397 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2398 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2399 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2400 | } catch (ActivityNotFoundException ex) { |
| 2401 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2402 | + "the activity to which it is registered was not found: " |
| 2403 | + "META+" + KeyEvent.keyCodeToString(keyCode), ex); |
| 2404 | } |
| 2405 | return -1; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2406 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2407 | } |
| 2408 | } |
| 2409 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2410 | // Handle application launch keys. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2411 | if (down && repeatCount == 0 && !keyguardOn) { |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2412 | String category = sApplicationLaunchKeyCategories.get(keyCode); |
| 2413 | if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 2414 | Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2415 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2416 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2417 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2418 | } catch (ActivityNotFoundException ex) { |
| 2419 | Slog.w(TAG, "Dropping application launch key because " |
| 2420 | + "the activity to which it is registered was not found: " |
| 2421 | + "keyCode=" + keyCode + ", category=" + category, ex); |
| 2422 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2423 | return -1; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2424 | } |
| 2425 | } |
| 2426 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2427 | // Display task switcher for ALT-TAB or Meta-TAB. |
| 2428 | if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2429 | if (mRecentAppsHeldModifiers == 0 && !keyguardOn) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2430 | final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK; |
Michael Wright | ce0c13a | 2014-07-30 10:49:21 -0700 | [diff] [blame] | 2431 | if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON) |
| 2432 | || KeyEvent.metaStateHasModifiers( |
| 2433 | shiftlessModifiers, KeyEvent.META_META_ON)) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2434 | mRecentAppsHeldModifiers = shiftlessModifiers; |
| 2435 | showRecentApps(true); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2436 | return -1; |
| 2437 | } |
| 2438 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2439 | } else if (!down && mRecentAppsHeldModifiers != 0 |
| 2440 | && (metaState & mRecentAppsHeldModifiers) == 0) { |
| 2441 | mRecentAppsHeldModifiers = 0; |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame^] | 2442 | hideRecentApps(true, false); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2443 | } |
| 2444 | |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 2445 | // Handle keyboard language switching. |
| 2446 | if (down && repeatCount == 0 |
| 2447 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2448 | || (keyCode == KeyEvent.KEYCODE_SPACE |
| 2449 | && (metaState & KeyEvent.META_CTRL_MASK) != 0))) { |
| 2450 | int direction = (metaState & KeyEvent.META_SHIFT_MASK) != 0 ? -1 : 1; |
| 2451 | mWindowManagerFuncs.switchKeyboardLayout(event.getDeviceId(), direction); |
| 2452 | return -1; |
| 2453 | } |
| 2454 | if (mLanguageSwitchKeyPressed && !down |
| 2455 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2456 | || keyCode == KeyEvent.KEYCODE_SPACE)) { |
| 2457 | mLanguageSwitchKeyPressed = false; |
| 2458 | return -1; |
| 2459 | } |
| 2460 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 2461 | if (mGlobalKeyManager.handleGlobalKey(mContext, keyCode, event)) { |
| 2462 | return -1; |
| 2463 | } |
| 2464 | |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2465 | // Reserve all the META modifier combos for system behavior |
Michael Wright | ce0c13a | 2014-07-30 10:49:21 -0700 | [diff] [blame] | 2466 | if ((metaState & KeyEvent.META_META_ON) != 0) { |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2467 | return -1; |
| 2468 | } |
| 2469 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2470 | // Let the application handle the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2471 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2472 | } |
| 2473 | |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2474 | /** {@inheritDoc} */ |
| 2475 | @Override |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2476 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2477 | // Note: This method is only called if the initial down was unhandled. |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2478 | if (DEBUG_INPUT) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2479 | Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction() |
| 2480 | + ", flags=" + event.getFlags() |
| 2481 | + ", keyCode=" + event.getKeyCode() |
| 2482 | + ", scanCode=" + event.getScanCode() |
| 2483 | + ", metaState=" + event.getMetaState() |
| 2484 | + ", repeatCount=" + event.getRepeatCount() |
| 2485 | + ", policyFlags=" + policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2486 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2487 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2488 | KeyEvent fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2489 | if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 2490 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2491 | final int keyCode = event.getKeyCode(); |
| 2492 | final int metaState = event.getMetaState(); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2493 | final boolean initialDown = event.getAction() == KeyEvent.ACTION_DOWN |
| 2494 | && event.getRepeatCount() == 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2495 | |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2496 | // Check for fallback actions specified by the key character map. |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2497 | final FallbackAction fallbackAction; |
| 2498 | if (initialDown) { |
| 2499 | fallbackAction = kcm.getFallbackAction(keyCode, metaState); |
| 2500 | } else { |
| 2501 | fallbackAction = mFallbackActions.get(keyCode); |
| 2502 | } |
| 2503 | |
| 2504 | if (fallbackAction != null) { |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2505 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2506 | Slog.d(TAG, "Fallback: keyCode=" + fallbackAction.keyCode |
| 2507 | + " metaState=" + Integer.toHexString(fallbackAction.metaState)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2508 | } |
| 2509 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2510 | final int flags = event.getFlags() | KeyEvent.FLAG_FALLBACK; |
| 2511 | fallbackEvent = KeyEvent.obtain( |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2512 | event.getDownTime(), event.getEventTime(), |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2513 | event.getAction(), fallbackAction.keyCode, |
| 2514 | event.getRepeatCount(), fallbackAction.metaState, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2515 | event.getDeviceId(), event.getScanCode(), |
| 2516 | flags, event.getSource(), null); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2517 | |
| 2518 | if (!interceptFallback(win, fallbackEvent, policyFlags)) { |
| 2519 | fallbackEvent.recycle(); |
| 2520 | fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2521 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2522 | |
| 2523 | if (initialDown) { |
| 2524 | mFallbackActions.put(keyCode, fallbackAction); |
| 2525 | } else if (event.getAction() == KeyEvent.ACTION_UP) { |
| 2526 | mFallbackActions.remove(keyCode); |
| 2527 | fallbackAction.recycle(); |
| 2528 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2529 | } |
| 2530 | } |
| 2531 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2532 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2533 | if (fallbackEvent == null) { |
| 2534 | Slog.d(TAG, "No fallback."); |
| 2535 | } else { |
| 2536 | Slog.d(TAG, "Performing fallback: " + fallbackEvent); |
| 2537 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2538 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2539 | return fallbackEvent; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2540 | } |
| 2541 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2542 | private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2543 | int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2544 | if ((actions & ACTION_PASS_TO_USER) != 0) { |
| 2545 | long delayMillis = interceptKeyBeforeDispatching( |
| 2546 | win, fallbackEvent, policyFlags); |
| 2547 | if (delayMillis == 0) { |
| 2548 | return true; |
| 2549 | } |
| 2550 | } |
| 2551 | return false; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 2552 | } |
| 2553 | |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2554 | private void launchAssistLongPressAction() { |
| 2555 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 2556 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
| 2557 | |
| 2558 | // launch the search activity |
| 2559 | Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); |
| 2560 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2561 | try { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2562 | // TODO: This only stops the factory-installed search manager. |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2563 | // Need to formalize an API to handle others |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2564 | SearchManager searchManager = getSearchManager(); |
| 2565 | if (searchManager != null) { |
| 2566 | searchManager.stopSearch(); |
| 2567 | } |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2568 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2569 | } catch (ActivityNotFoundException e) { |
| 2570 | Slog.w(TAG, "No activity to handle assist long press action.", e); |
| 2571 | } |
| 2572 | } |
| 2573 | |
| 2574 | private void launchAssistAction() { |
| 2575 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 2576 | Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 2577 | .getAssistIntent(mContext, true, UserHandle.USER_CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2578 | if (intent != null) { |
| 2579 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 2580 | | Intent.FLAG_ACTIVITY_SINGLE_TOP |
| 2581 | | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 2582 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2583 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2584 | } catch (ActivityNotFoundException e) { |
| 2585 | Slog.w(TAG, "No activity to handle assist action.", e); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2586 | } |
| 2587 | } |
| 2588 | } |
| 2589 | |
| 2590 | private SearchManager getSearchManager() { |
| 2591 | if (mSearchManager == null) { |
| 2592 | mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); |
| 2593 | } |
| 2594 | return mSearchManager; |
| 2595 | } |
| 2596 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2597 | private void preloadRecentApps() { |
| 2598 | mPreloadedRecentApps = true; |
| 2599 | try { |
| 2600 | IStatusBarService statusbar = getStatusBarService(); |
| 2601 | if (statusbar != null) { |
| 2602 | statusbar.preloadRecentApps(); |
| 2603 | } |
| 2604 | } catch (RemoteException e) { |
| 2605 | Slog.e(TAG, "RemoteException when preloading recent apps", e); |
| 2606 | // re-acquire status bar service next time it is needed. |
| 2607 | mStatusBarService = null; |
| 2608 | } |
| 2609 | } |
| 2610 | |
| 2611 | private void cancelPreloadRecentApps() { |
| 2612 | if (mPreloadedRecentApps) { |
| 2613 | mPreloadedRecentApps = false; |
| 2614 | try { |
| 2615 | IStatusBarService statusbar = getStatusBarService(); |
| 2616 | if (statusbar != null) { |
| 2617 | statusbar.cancelPreloadRecentApps(); |
| 2618 | } |
| 2619 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2620 | Slog.e(TAG, "RemoteException when cancelling recent apps preload", e); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2621 | // re-acquire status bar service next time it is needed. |
| 2622 | mStatusBarService = null; |
| 2623 | } |
| 2624 | } |
| 2625 | } |
| 2626 | |
| 2627 | private void toggleRecentApps() { |
| 2628 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2629 | try { |
| 2630 | IStatusBarService statusbar = getStatusBarService(); |
| 2631 | if (statusbar != null) { |
| 2632 | statusbar.toggleRecentApps(); |
| 2633 | } |
| 2634 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2635 | Slog.e(TAG, "RemoteException when toggling recent apps", e); |
| 2636 | // re-acquire status bar service next time it is needed. |
| 2637 | mStatusBarService = null; |
| 2638 | } |
| 2639 | } |
| 2640 | |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 2641 | @Override |
| 2642 | public void showRecentApps() { |
| 2643 | mHandler.removeMessages(MSG_DISPATCH_SHOW_RECENTS); |
| 2644 | mHandler.sendEmptyMessage(MSG_DISPATCH_SHOW_RECENTS); |
| 2645 | } |
| 2646 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2647 | private void showRecentApps(boolean triggeredFromAltTab) { |
| 2648 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2649 | try { |
| 2650 | IStatusBarService statusbar = getStatusBarService(); |
| 2651 | if (statusbar != null) { |
| 2652 | statusbar.showRecentApps(triggeredFromAltTab); |
| 2653 | } |
| 2654 | } catch (RemoteException e) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2655 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
| 2656 | // re-acquire status bar service next time it is needed. |
| 2657 | mStatusBarService = null; |
| 2658 | } |
| 2659 | } |
| 2660 | |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame^] | 2661 | private void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHome) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2662 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2663 | try { |
| 2664 | IStatusBarService statusbar = getStatusBarService(); |
| 2665 | if (statusbar != null) { |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame^] | 2666 | statusbar.hideRecentApps(triggeredFromAltTab, triggeredFromHome); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2667 | } |
| 2668 | } catch (RemoteException e) { |
| 2669 | Slog.e(TAG, "RemoteException when closing recent apps", e); |
| 2670 | // re-acquire status bar service next time it is needed. |
| 2671 | mStatusBarService = null; |
| 2672 | } |
| 2673 | } |
| 2674 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2675 | /** |
| 2676 | * A home key -> launch home action was detected. Take the appropriate action |
| 2677 | * given the situation with the keyguard. |
| 2678 | */ |
| 2679 | void launchHomeFromHotKey() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2680 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowingAndNotOccluded()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2681 | // don't launch home if keyguard showing |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2682 | } else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2683 | // when in keyguard restricted mode, must first verify unlock |
| 2684 | // before launching home |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2685 | mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() { |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2686 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2687 | public void onKeyguardExitResult(boolean success) { |
| 2688 | if (success) { |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2689 | try { |
| 2690 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2691 | } catch (RemoteException e) { |
| 2692 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2693 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2694 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2695 | } |
| 2696 | } |
| 2697 | }); |
| 2698 | } else { |
| 2699 | // no keyguard stuff to worry about, just launch home! |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2700 | try { |
| 2701 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2702 | } catch (RemoteException e) { |
| 2703 | } |
Winson Chung | d543c1b | 2014-06-23 15:06:45 -0700 | [diff] [blame] | 2704 | if (mRecentsVisible) { |
| 2705 | // Hide Recents and notify it to launch Home |
| 2706 | awakenDreams(); |
| 2707 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame^] | 2708 | hideRecentApps(false, true); |
Winson Chung | d543c1b | 2014-06-23 15:06:45 -0700 | [diff] [blame] | 2709 | } else { |
| 2710 | // Otherwise, just launch Home |
| 2711 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
| 2712 | startDockOrHome(); |
| 2713 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2714 | } |
| 2715 | } |
| 2716 | |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2717 | private final Runnable mClearHideNavigationFlag = new Runnable() { |
| 2718 | @Override |
| 2719 | public void run() { |
| 2720 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
| 2721 | // Clear flags. |
| 2722 | mForceClearedSystemUiFlags &= |
| 2723 | ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 2724 | } |
| 2725 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2726 | } |
| 2727 | }; |
| 2728 | |
| 2729 | /** |
| 2730 | * Input handler used while nav bar is hidden. Captures any touch on the screen, |
| 2731 | * to determine when the nav bar should be shown and prevent applications from |
| 2732 | * receiving those touches. |
| 2733 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2734 | final class HideNavInputEventReceiver extends InputEventReceiver { |
| 2735 | public HideNavInputEventReceiver(InputChannel inputChannel, Looper looper) { |
| 2736 | super(inputChannel, looper); |
| 2737 | } |
| 2738 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2739 | @Override |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2740 | public void onInputEvent(InputEvent event) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2741 | boolean handled = false; |
| 2742 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 2743 | if (event instanceof MotionEvent |
| 2744 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 2745 | final MotionEvent motionEvent = (MotionEvent)event; |
| 2746 | if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2747 | // When the user taps down, we re-show the nav bar. |
| 2748 | boolean changed = false; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2749 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2750 | // Any user activity always causes us to show the |
| 2751 | // navigation controls, if they had been hidden. |
| 2752 | // We also clear the low profile and only content |
| 2753 | // flags so that tapping on the screen will atomically |
| 2754 | // restore all currently hidden screen decorations. |
| 2755 | int newVal = mResettingSystemUiFlags | |
| 2756 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| 2757 | View.SYSTEM_UI_FLAG_LOW_PROFILE | |
| 2758 | View.SYSTEM_UI_FLAG_FULLSCREEN; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2759 | if (mResettingSystemUiFlags != newVal) { |
| 2760 | mResettingSystemUiFlags = newVal; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2761 | changed = true; |
| 2762 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2763 | // We don't allow the system's nav bar to be hidden |
| 2764 | // again for 1 second, to prevent applications from |
| 2765 | // spamming us and keeping it from being shown. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2766 | newVal = mForceClearedSystemUiFlags | |
| 2767 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2768 | if (mForceClearedSystemUiFlags != newVal) { |
| 2769 | mForceClearedSystemUiFlags = newVal; |
| 2770 | changed = true; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 2771 | mHandler.postDelayed(mClearHideNavigationFlag, 1000); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2772 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2773 | } |
| 2774 | if (changed) { |
| 2775 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 2776 | } |
| 2777 | } |
| 2778 | } |
| 2779 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2780 | finishInputEvent(event, handled); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2781 | } |
| 2782 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2783 | } |
| 2784 | final InputEventReceiver.Factory mHideNavInputEventReceiverFactory = |
| 2785 | new InputEventReceiver.Factory() { |
| 2786 | @Override |
| 2787 | public InputEventReceiver createInputEventReceiver( |
| 2788 | InputChannel inputChannel, Looper looper) { |
| 2789 | return new HideNavInputEventReceiver(inputChannel, looper); |
| 2790 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2791 | }; |
| 2792 | |
| 2793 | @Override |
| 2794 | public int adjustSystemUiVisibilityLw(int visibility) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 2795 | mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
| 2796 | mNavigationBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 2797 | mRecentsVisible = (visibility & View.RECENT_APPS_VISIBLE) > 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2798 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2799 | // Reset any bits in mForceClearingStatusBarVisibility that |
| 2800 | // are now clear. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2801 | mResettingSystemUiFlags &= visibility; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2802 | // Clear any bits in the new visibility that are currently being |
| 2803 | // force cleared, before reporting it. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2804 | return visibility & ~mResettingSystemUiFlags |
| 2805 | & ~mForceClearedSystemUiFlags; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2806 | } |
| 2807 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2808 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2809 | public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 2810 | final int fl = PolicyControl.getWindowFlags(null, attrs); |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 2811 | final int sysuiVis = PolicyControl.getSystemUiVisibility(null, attrs); |
| 2812 | final int systemUiVisibility = (sysuiVis | attrs.subtreeSystemUiVisibility); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2813 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2814 | 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] | 2815 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2816 | int availRight, availBottom; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 2817 | if (canHideNavigationBar() && |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2818 | (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2819 | availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 2820 | availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
| 2821 | } else { |
| 2822 | availRight = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 2823 | availBottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
| 2824 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2825 | if ((systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2826 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 2827 | contentInset.set(mStableFullscreenLeft, mStableFullscreenTop, |
| 2828 | availRight - mStableFullscreenRight, |
| 2829 | availBottom - mStableFullscreenBottom); |
| 2830 | } else { |
| 2831 | contentInset.set(mStableLeft, mStableTop, |
| 2832 | availRight - mStableRight, availBottom - mStableBottom); |
| 2833 | } |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2834 | } else if ((fl & FLAG_FULLSCREEN) != 0 || (fl & FLAG_LAYOUT_IN_OVERSCAN) != 0) { |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 2835 | contentInset.setEmpty(); |
| 2836 | } else if ((systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2837 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) { |
| 2838 | contentInset.set(mCurLeft, mCurTop, |
| 2839 | availRight - mCurRight, availBottom - mCurBottom); |
| 2840 | } else { |
| 2841 | contentInset.set(mCurLeft, mCurTop, |
| 2842 | availRight - mCurRight, availBottom - mCurBottom); |
| 2843 | } |
| 2844 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2845 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2846 | contentInset.setEmpty(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2847 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2848 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2849 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2850 | @Override |
| 2851 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
| 2852 | int displayRotation) { |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2853 | final int overscanLeft, overscanTop, overscanRight, overscanBottom; |
| 2854 | if (isDefaultDisplay) { |
| 2855 | switch (displayRotation) { |
| 2856 | case Surface.ROTATION_90: |
| 2857 | overscanLeft = mOverscanTop; |
| 2858 | overscanTop = mOverscanRight; |
| 2859 | overscanRight = mOverscanBottom; |
| 2860 | overscanBottom = mOverscanLeft; |
| 2861 | break; |
| 2862 | case Surface.ROTATION_180: |
| 2863 | overscanLeft = mOverscanRight; |
| 2864 | overscanTop = mOverscanBottom; |
| 2865 | overscanRight = mOverscanLeft; |
| 2866 | overscanBottom = mOverscanTop; |
| 2867 | break; |
| 2868 | case Surface.ROTATION_270: |
| 2869 | overscanLeft = mOverscanBottom; |
| 2870 | overscanTop = mOverscanLeft; |
| 2871 | overscanRight = mOverscanTop; |
| 2872 | overscanBottom = mOverscanRight; |
| 2873 | break; |
| 2874 | default: |
| 2875 | overscanLeft = mOverscanLeft; |
| 2876 | overscanTop = mOverscanTop; |
| 2877 | overscanRight = mOverscanRight; |
| 2878 | overscanBottom = mOverscanBottom; |
| 2879 | break; |
| 2880 | } |
| 2881 | } else { |
| 2882 | overscanLeft = 0; |
| 2883 | overscanTop = 0; |
| 2884 | overscanRight = 0; |
| 2885 | overscanBottom = 0; |
| 2886 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2887 | mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0; |
| 2888 | mOverscanScreenTop = mRestrictedOverscanScreenTop = 0; |
| 2889 | mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth; |
| 2890 | mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2891 | mSystemLeft = 0; |
| 2892 | mSystemTop = 0; |
| 2893 | mSystemRight = displayWidth; |
| 2894 | mSystemBottom = displayHeight; |
| 2895 | mUnrestrictedScreenLeft = overscanLeft; |
| 2896 | mUnrestrictedScreenTop = overscanTop; |
| 2897 | mUnrestrictedScreenWidth = displayWidth - overscanLeft - overscanRight; |
| 2898 | mUnrestrictedScreenHeight = displayHeight - overscanTop - overscanBottom; |
| 2899 | mRestrictedScreenLeft = mUnrestrictedScreenLeft; |
| 2900 | mRestrictedScreenTop = mUnrestrictedScreenTop; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2901 | mRestrictedScreenWidth = mSystemGestures.screenWidth = mUnrestrictedScreenWidth; |
| 2902 | mRestrictedScreenHeight = mSystemGestures.screenHeight = mUnrestrictedScreenHeight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2903 | mDockLeft = mContentLeft = mVoiceContentLeft = mStableLeft = mStableFullscreenLeft |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2904 | = mCurLeft = mUnrestrictedScreenLeft; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2905 | mDockTop = mContentTop = mVoiceContentTop = mStableTop = mStableFullscreenTop |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2906 | = mCurTop = mUnrestrictedScreenTop; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2907 | mDockRight = mContentRight = mVoiceContentRight = mStableRight = mStableFullscreenRight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2908 | = mCurRight = displayWidth - overscanRight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2909 | mDockBottom = mContentBottom = mVoiceContentBottom = mStableBottom = mStableFullscreenBottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2910 | = mCurBottom = displayHeight - overscanBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2911 | mDockLayer = 0x10000000; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 2912 | mStatusBarLayer = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2913 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2914 | // start with the current dock rect, which will be (0,0,displayWidth,displayHeight) |
| 2915 | final Rect pf = mTmpParentFrame; |
| 2916 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2917 | final Rect of = mTmpOverscanFrame; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2918 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2919 | final Rect dcf = mTmpDecorFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 2920 | pf.left = df.left = of.left = vf.left = mDockLeft; |
| 2921 | pf.top = df.top = of.top = vf.top = mDockTop; |
| 2922 | pf.right = df.right = of.right = vf.right = mDockRight; |
| 2923 | pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 2924 | dcf.setEmpty(); // Decor frame N/A for system bars. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2925 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2926 | if (isDefaultDisplay) { |
| 2927 | // For purposes of putting out fake window up to steal focus, we will |
| 2928 | // drive nav being hidden only by whether it is requested. |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2929 | final int sysui = mLastSystemUiFlags; |
| 2930 | boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 2931 | boolean navTranslucent = (sysui |
| 2932 | & (View.NAVIGATION_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 2933 | boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0; |
| 2934 | boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
| 2935 | boolean navAllowedHidden = immersive || immersiveSticky; |
| 2936 | navTranslucent &= !immersiveSticky; // transient trumps translucent |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 2937 | navTranslucent &= areTranslucentBarsAllowed(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2938 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2939 | // When the navigation bar isn't visible, we put up a fake |
| 2940 | // input window to catch all touch events. This way we can |
| 2941 | // detect when the user presses anywhere to bring back the nav |
| 2942 | // bar and ensure the application doesn't see the event. |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 2943 | if (navVisible || navAllowedHidden) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2944 | if (mHideNavFakeWindow != null) { |
| 2945 | mHideNavFakeWindow.dismiss(); |
| 2946 | mHideNavFakeWindow = null; |
| 2947 | } |
| 2948 | } else if (mHideNavFakeWindow == null) { |
| 2949 | mHideNavFakeWindow = mWindowManagerFuncs.addFakeWindow( |
| 2950 | mHandler.getLooper(), mHideNavInputEventReceiverFactory, |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 2951 | "hidden nav", WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER, 0, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2952 | 0, false, false, true); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2953 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2954 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2955 | // For purposes of positioning and showing the nav bar, if we have |
| 2956 | // decided that it can't be hidden (because of the screen aspect ratio), |
| 2957 | // then take that into account. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 2958 | navVisible |= !canHideNavigationBar(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2959 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2960 | boolean updateSysUiVisibility = false; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2961 | if (mNavigationBar != null) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2962 | boolean transientNavBarShowing = mNavigationBarController.isTransientShowing(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2963 | // Force the navigation bar to its appropriate place and |
| 2964 | // size. We need to do this directly, instead of relying on |
| 2965 | // it to bubble up from the nav bar, because this needs to |
| 2966 | // change atomically with screen rotations. |
| 2967 | mNavigationBarOnBottom = (!mNavigationBarCanMove || displayWidth < displayHeight); |
| 2968 | if (mNavigationBarOnBottom) { |
| 2969 | // 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] | 2970 | int top = displayHeight - overscanBottom |
| 2971 | - mNavigationBarHeightForRotation[displayRotation]; |
| 2972 | mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2973 | mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 2974 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2975 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 2976 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2977 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2978 | mDockBottom = mTmpNavigationFrame.top; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 2979 | mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop; |
| 2980 | mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2981 | } else { |
| 2982 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2983 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2984 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 2985 | if (navVisible && !navTranslucent && !navAllowedHidden |
| 2986 | && !mNavigationBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 2987 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 2988 | // If the opaque nav bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2989 | // and not in the process of animating on or off, then |
| 2990 | // we can tell the app that it is covered by it. |
| 2991 | mSystemBottom = mTmpNavigationFrame.top; |
| 2992 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2993 | } else { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2994 | // Landscape screen; nav bar goes to the right. |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 2995 | int left = displayWidth - overscanRight |
| 2996 | - mNavigationBarWidthForRotation[displayRotation]; |
| 2997 | mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 2998 | mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 2999 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3000 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3001 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3002 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3003 | mDockRight = mTmpNavigationFrame.left; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3004 | mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft; |
| 3005 | mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3006 | } else { |
| 3007 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3008 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3009 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3010 | if (navVisible && !navTranslucent && !mNavigationBar.isAnimatingLw() |
| 3011 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3012 | // If the nav bar is currently requested to be visible, |
| 3013 | // and not in the process of animating on or off, then |
| 3014 | // we can tell the app that it is covered by it. |
| 3015 | mSystemRight = mTmpNavigationFrame.left; |
| 3016 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3017 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3018 | // Make sure the content and current rectangles are updated to |
| 3019 | // account for the restrictions from the navigation bar. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3020 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 3021 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 3022 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 3023 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3024 | mStatusBarLayer = mNavigationBar.getSurfaceLayer(); |
| 3025 | // And compute the final frame. |
| 3026 | mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3027 | mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf, |
| 3028 | mTmpNavigationFrame); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3029 | if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3030 | if (mNavigationBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3031 | updateSysUiVisibility = true; |
| 3032 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3033 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3034 | 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] | 3035 | mDockLeft, mDockTop, mDockRight, mDockBottom)); |
| 3036 | |
| 3037 | // decide where the status bar goes ahead of time |
| 3038 | if (mStatusBar != null) { |
| 3039 | // apply any navigation bar insets |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3040 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3041 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3042 | pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft; |
| 3043 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight |
| 3044 | + mUnrestrictedScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3045 | vf.left = mStableLeft; |
| 3046 | vf.top = mStableTop; |
| 3047 | vf.right = mStableRight; |
| 3048 | vf.bottom = mStableBottom; |
| 3049 | |
| 3050 | mStatusBarLayer = mStatusBar.getSurfaceLayer(); |
| 3051 | |
| 3052 | // Let the status bar determine its size. |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3053 | mStatusBar.computeFrameLw(pf, df, vf, vf, vf, dcf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3054 | |
| 3055 | // For layout, the status bar is always at the top with our fixed height. |
| 3056 | mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3057 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3058 | boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3059 | boolean statusBarTranslucent = (sysui |
| 3060 | & (View.STATUS_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 3061 | statusBarTranslucent &= areTranslucentBarsAllowed(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3062 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3063 | // If the status bar is hidden, we don't want to cause |
| 3064 | // windows behind it to scroll. |
John Spurlock | eda1f69 | 2013-09-16 11:38:44 -0400 | [diff] [blame] | 3065 | if (mStatusBar.isVisibleLw() && !statusBarTransient) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3066 | // Status bar may go away, so the screen area it occupies |
| 3067 | // is available to apps but just covering them when the |
| 3068 | // status bar is visible. |
| 3069 | mDockTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3070 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3071 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 3072 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 3073 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 3074 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3075 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3076 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar: " + |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3077 | String.format( |
| 3078 | "dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]", |
| 3079 | mDockLeft, mDockTop, mDockRight, mDockBottom, |
| 3080 | mContentLeft, mContentTop, mContentRight, mContentBottom, |
| 3081 | mCurLeft, mCurTop, mCurRight, mCurBottom)); |
| 3082 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3083 | if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3084 | && !statusBarTransient && !statusBarTranslucent |
| 3085 | && !mStatusBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3086 | // If the opaque status bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3087 | // and not in the process of animating on or off, then |
| 3088 | // we can tell the app that it is covered by it. |
| 3089 | mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3090 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3091 | if (mStatusBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3092 | updateSysUiVisibility = true; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3093 | } |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 3094 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3095 | if (updateSysUiVisibility) { |
| 3096 | updateSystemUiVisibilityLw(); |
| 3097 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3098 | } |
| 3099 | } |
| 3100 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 3101 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 3102 | @Override |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3103 | public int getSystemDecorLayerLw() { |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 3104 | if (mStatusBar != null) return mStatusBar.getSurfaceLayer(); |
| 3105 | if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer(); |
| 3106 | return 0; |
| 3107 | } |
| 3108 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 3109 | @Override |
| 3110 | public void getContentRectLw(Rect r) { |
| 3111 | r.set(mContentLeft, mContentTop, mContentRight, mContentBottom); |
| 3112 | } |
| 3113 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3114 | void setAttachedWindowFrames(WindowState win, int fl, int adjust, WindowState attached, |
| 3115 | 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] | 3116 | if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) { |
| 3117 | // Here's a special case: if this attached window is a panel that is |
| 3118 | // above the dock window, and the window it is attached to is below |
| 3119 | // the dock window, then the frames we computed for the window it is |
| 3120 | // attached to can not be used because the dock is effectively part |
| 3121 | // of the underlying window and the attached window is floating on top |
| 3122 | // of the whole thing. So, we ignore the attached window and explicitly |
| 3123 | // compute the frames that would be appropriate without the dock. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3124 | df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3125 | df.top = of.top = cf.top = vf.top = mDockTop; |
| 3126 | df.right = of.right = cf.right = vf.right = mDockRight; |
| 3127 | df.bottom = of.bottom = cf.bottom = vf.bottom = mDockBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3128 | } else { |
| 3129 | // The effective display frame of the attached window depends on |
| 3130 | // whether it is taking care of insetting its content. If not, |
| 3131 | // we need to use the parent's content frame so that the entire |
| 3132 | // window is positioned within that content. Otherwise we can use |
| 3133 | // the display frame and let the attached window take care of |
| 3134 | // positioning its content appropriately. |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3135 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3136 | cf.set(attached.getOverscanFrameLw()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3137 | } else { |
| 3138 | // If the window is resizing, then we want to base the content |
| 3139 | // frame on our attached content frame to resize... however, |
| 3140 | // things can be tricky if the attached window is NOT in resize |
| 3141 | // mode, in which case its content frame will be larger. |
| 3142 | // Ungh. So to deal with that, make sure the content frame |
| 3143 | // we end up using is not covering the IM dock. |
| 3144 | cf.set(attached.getContentFrameLw()); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3145 | if (attached.isVoiceInteraction()) { |
| 3146 | if (cf.left < mVoiceContentLeft) cf.left = mVoiceContentLeft; |
| 3147 | if (cf.top < mVoiceContentTop) cf.top = mVoiceContentTop; |
| 3148 | if (cf.right > mVoiceContentRight) cf.right = mVoiceContentRight; |
| 3149 | if (cf.bottom > mVoiceContentBottom) cf.bottom = mVoiceContentBottom; |
| 3150 | } else if (attached.getSurfaceLayer() < mDockLayer) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3151 | if (cf.left < mContentLeft) cf.left = mContentLeft; |
| 3152 | if (cf.top < mContentTop) cf.top = mContentTop; |
| 3153 | if (cf.right > mContentRight) cf.right = mContentRight; |
| 3154 | if (cf.bottom > mContentBottom) cf.bottom = mContentBottom; |
| 3155 | } |
| 3156 | } |
| 3157 | df.set(insetDecors ? attached.getDisplayFrameLw() : cf); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3158 | of.set(insetDecors ? attached.getOverscanFrameLw() : cf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3159 | vf.set(attached.getVisibleFrameLw()); |
| 3160 | } |
| 3161 | // The LAYOUT_IN_SCREEN flag is used to determine whether the attached |
| 3162 | // window should be positioned relative to its parent or the entire |
| 3163 | // screen. |
| 3164 | pf.set((fl & FLAG_LAYOUT_IN_SCREEN) == 0 |
| 3165 | ? attached.getFrameLw() : df); |
| 3166 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3167 | |
| 3168 | private void applyStableConstraints(int sysui, int fl, Rect r) { |
| 3169 | if ((sysui & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 3170 | // If app is requesting a stable layout, don't let the |
| 3171 | // content insets go below the stable values. |
| 3172 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 3173 | if (r.left < mStableFullscreenLeft) r.left = mStableFullscreenLeft; |
| 3174 | if (r.top < mStableFullscreenTop) r.top = mStableFullscreenTop; |
| 3175 | if (r.right > mStableFullscreenRight) r.right = mStableFullscreenRight; |
| 3176 | if (r.bottom > mStableFullscreenBottom) r.bottom = mStableFullscreenBottom; |
| 3177 | } else { |
| 3178 | if (r.left < mStableLeft) r.left = mStableLeft; |
| 3179 | if (r.top < mStableTop) r.top = mStableTop; |
| 3180 | if (r.right > mStableRight) r.right = mStableRight; |
| 3181 | if (r.bottom > mStableBottom) r.bottom = mStableBottom; |
| 3182 | } |
| 3183 | } |
| 3184 | } |
| 3185 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3186 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3187 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3188 | public void layoutWindowLw(WindowState win, WindowState attached) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3189 | // we've already done the status bar |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3190 | final WindowManager.LayoutParams attrs = win.getAttrs(); |
| 3191 | if ((win == mStatusBar && (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) == 0) || |
| 3192 | win == mNavigationBar) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3193 | return; |
| 3194 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3195 | final boolean isDefaultDisplay = win.isDefaultDisplay(); |
| 3196 | final boolean needsToOffsetInputMethodTarget = isDefaultDisplay && |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3197 | (win == mLastInputMethodTargetWindow && mLastInputMethodWindow != null); |
| 3198 | if (needsToOffsetInputMethodTarget) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3199 | 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] | 3200 | offsetInputMethodWindowLw(mLastInputMethodWindow); |
| 3201 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3202 | |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3203 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3204 | final int sim = attrs.softInputMode; |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 3205 | final int sysUiFl = PolicyControl.getSystemUiVisibility(win, null); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3206 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3207 | final Rect pf = mTmpParentFrame; |
| 3208 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3209 | final Rect of = mTmpOverscanFrame; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3210 | final Rect cf = mTmpContentFrame; |
| 3211 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3212 | final Rect dcf = mTmpDecorFrame; |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3213 | final Rect sf = mTmpStableFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3214 | dcf.setEmpty(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3215 | |
| 3216 | final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3217 | && mNavigationBar != null && mNavigationBar.isVisibleLw()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3218 | |
Craig Mautner | f683b56 | 2012-10-02 11:10:57 -0700 | [diff] [blame] | 3219 | final int adjust = sim & SOFT_INPUT_MASK_ADJUST; |
| 3220 | |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3221 | if (isDefaultDisplay) { |
| 3222 | sf.set(mStableLeft, mStableTop, mStableRight, mStableBottom); |
| 3223 | } else { |
| 3224 | sf.set(mOverscanLeft, mOverscanTop, mOverscanRight, mOverscanBottom); |
| 3225 | } |
| 3226 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3227 | if (!isDefaultDisplay) { |
| 3228 | if (attached != null) { |
| 3229 | // If this window is attached to another, our display |
| 3230 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3231 | setAttachedWindowFrames(win, fl, adjust, attached, true, pf, df, of, cf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3232 | } else { |
| 3233 | // Give the window full screen. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3234 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3235 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3236 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3237 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3238 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3239 | = mOverscanScreenTop + mOverscanScreenHeight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3240 | } |
| 3241 | } else if (attrs.type == TYPE_INPUT_METHOD) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3242 | pf.left = df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3243 | pf.top = df.top = of.top = cf.top = vf.top = mDockTop; |
| 3244 | pf.right = df.right = of.right = cf.right = vf.right = mDockRight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3245 | // IM dock windows layout below the nav bar... |
John Spurlock | 57beb3b | 2013-10-10 10:27:44 -0400 | [diff] [blame] | 3246 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3247 | // ...with content insets above the nav bar |
| 3248 | cf.bottom = vf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3249 | // IM dock windows always go to the bottom of the screen. |
| 3250 | attrs.gravity = Gravity.BOTTOM; |
| 3251 | mDockLayer = win.getSurfaceLayer(); |
| 3252 | } else { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3253 | |
| 3254 | // Default policy decor for the default display |
| 3255 | dcf.left = mSystemLeft; |
| 3256 | dcf.top = mSystemTop; |
| 3257 | dcf.right = mSystemRight; |
| 3258 | dcf.bottom = mSystemBottom; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3259 | final boolean inheritTranslucentDecor = (attrs.privateFlags |
| 3260 | & WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR) != 0; |
John Spurlock | 65567d4 | 2013-10-08 10:08:32 -0400 | [diff] [blame] | 3261 | final boolean isAppWindow = |
| 3262 | attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW && |
| 3263 | attrs.type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 3264 | final boolean topAtRest = |
| 3265 | win == mTopFullscreenOpaqueWindowState && !win.isAnimatingLw(); |
| 3266 | if (isAppWindow && !inheritTranslucentDecor && !topAtRest) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3267 | if ((sysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 |
| 3268 | && (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3269 | && (fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == 0 |
| 3270 | && (fl & WindowManager.LayoutParams. |
| 3271 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3272 | // Ensure policy decor includes status bar |
| 3273 | dcf.top = mStableTop; |
| 3274 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3275 | if ((fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3276 | && (sysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0 |
| 3277 | && (fl & WindowManager.LayoutParams. |
| 3278 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3279 | // Ensure policy decor includes navigation bar |
| 3280 | dcf.bottom = mStableBottom; |
| 3281 | dcf.right = mStableRight; |
| 3282 | } |
| 3283 | } |
| 3284 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3285 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) |
| 3286 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3287 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3288 | + "): IN_SCREEN, INSET_DECOR"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3289 | // This is the case for a normal activity window: we want it |
| 3290 | // to cover all of the screen space, and it can take care of |
| 3291 | // moving its contents to account for screen decorations that |
| 3292 | // intrude into that space. |
| 3293 | if (attached != null) { |
| 3294 | // If this window is attached to another, our display |
| 3295 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3296 | 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] | 3297 | } else { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3298 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3299 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3300 | // Status bar panels are the only windows who can go on top of |
| 3301 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3302 | // permission, so they have the same privileges as the status |
| 3303 | // bar itself. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3304 | // |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3305 | // However, they should still dodge the navigation bar if it exists. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3306 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3307 | pf.left = df.left = of.left = hasNavBar |
| 3308 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3309 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3310 | pf.right = df.right = of.right = hasNavBar |
| 3311 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
| 3312 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3313 | pf.bottom = df.bottom = of.bottom = hasNavBar |
| 3314 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
| 3315 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3316 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3317 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3318 | "Laying out status bar window: (%d,%d - %d,%d)", |
| 3319 | pf.left, pf.top, pf.right, pf.bottom)); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3320 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3321 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3322 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3323 | // Asking to layout into the overscan region, so give it that pure |
| 3324 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3325 | pf.left = df.left = of.left = mOverscanScreenLeft; |
| 3326 | pf.top = df.top = of.top = mOverscanScreenTop; |
| 3327 | pf.right = df.right = of.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3328 | pf.bottom = df.bottom = of.bottom = mOverscanScreenTop |
| 3329 | + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3330 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3331 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3332 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3333 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3334 | // Asking for layout as if the nav bar is hidden, lets the |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3335 | // application extend into the unrestricted overscan screen area. We |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3336 | // only do this for application windows to ensure no window that |
| 3337 | // can be above the nav bar can do this. |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3338 | pf.left = df.left = mOverscanScreenLeft; |
| 3339 | pf.top = df.top = mOverscanScreenTop; |
| 3340 | pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3341 | pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3342 | // We need to tell the app about where the frame inside the overscan |
| 3343 | // is, so it can inset its content by that amount -- it didn't ask |
| 3344 | // to actually extend itself into the overscan region. |
| 3345 | of.left = mUnrestrictedScreenLeft; |
| 3346 | of.top = mUnrestrictedScreenTop; |
| 3347 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3348 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3349 | } else { |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3350 | pf.left = df.left = mRestrictedOverscanScreenLeft; |
| 3351 | pf.top = df.top = mRestrictedOverscanScreenTop; |
| 3352 | pf.right = df.right = mRestrictedOverscanScreenLeft |
| 3353 | + mRestrictedOverscanScreenWidth; |
| 3354 | pf.bottom = df.bottom = mRestrictedOverscanScreenTop |
| 3355 | + mRestrictedOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3356 | // We need to tell the app about where the frame inside the overscan |
| 3357 | // is, so it can inset its content by that amount -- it didn't ask |
| 3358 | // to actually extend itself into the overscan region. |
| 3359 | of.left = mUnrestrictedScreenLeft; |
| 3360 | of.top = mUnrestrictedScreenTop; |
| 3361 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3362 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3363 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3364 | |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3365 | if ((fl & FLAG_FULLSCREEN) == 0) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3366 | if (win.isVoiceInteraction()) { |
| 3367 | cf.left = mVoiceContentLeft; |
| 3368 | cf.top = mVoiceContentTop; |
| 3369 | cf.right = mVoiceContentRight; |
| 3370 | cf.bottom = mVoiceContentBottom; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3371 | } else { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3372 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
| 3373 | cf.left = mDockLeft; |
| 3374 | cf.top = mDockTop; |
| 3375 | cf.right = mDockRight; |
| 3376 | cf.bottom = mDockBottom; |
| 3377 | } else { |
| 3378 | cf.left = mContentLeft; |
| 3379 | cf.top = mContentTop; |
| 3380 | cf.right = mContentRight; |
| 3381 | cf.bottom = mContentBottom; |
| 3382 | } |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3383 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3384 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3385 | // Full screen windows are always given a layout that is as if the |
| 3386 | // status bar and other transient decors are gone. This is to avoid |
| 3387 | // bad states when moving from a window that is not hding the |
| 3388 | // status bar to one that is. |
| 3389 | cf.left = mRestrictedScreenLeft; |
| 3390 | cf.top = mRestrictedScreenTop; |
| 3391 | cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 3392 | cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3393 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3394 | applyStableConstraints(sysUiFl, fl, cf); |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3395 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3396 | vf.left = mCurLeft; |
| 3397 | vf.top = mCurTop; |
| 3398 | vf.right = mCurRight; |
| 3399 | vf.bottom = mCurBottom; |
| 3400 | } else { |
| 3401 | vf.set(cf); |
| 3402 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3403 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3404 | } else if ((fl & FLAG_LAYOUT_IN_SCREEN) != 0 || (sysUiFl |
| 3405 | & (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 3406 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3407 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3408 | "): IN_SCREEN"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3409 | // A window that has requested to fill the entire screen just |
| 3410 | // gets everything, period. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3411 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3412 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3413 | pf.left = df.left = of.left = cf.left = hasNavBar |
| 3414 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3415 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3416 | pf.right = df.right = of.right = cf.right = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3417 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3418 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3419 | pf.bottom = df.bottom = of.bottom = cf.bottom = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3420 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3421 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3422 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3423 | "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)", |
| 3424 | pf.left, pf.top, pf.right, pf.bottom)); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 3425 | } else if (attrs.type == TYPE_NAVIGATION_BAR |
| 3426 | || attrs.type == TYPE_NAVIGATION_BAR_PANEL) { |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3427 | // The navigation bar has Real Ultimate Power. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3428 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3429 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3430 | pf.right = df.right = of.right = mUnrestrictedScreenLeft |
| 3431 | + mUnrestrictedScreenWidth; |
| 3432 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop |
| 3433 | + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3434 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3435 | "Laying out navigation bar window: (%d,%d - %d,%d)", |
| 3436 | pf.left, pf.top, pf.right, pf.bottom)); |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3437 | } else if ((attrs.type == TYPE_SECURE_SYSTEM_OVERLAY |
| 3438 | || attrs.type == TYPE_BOOT_PROGRESS) |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 3439 | && ((fl & FLAG_FULLSCREEN) != 0)) { |
| 3440 | // Fullscreen secure system overlays get what they ask for. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3441 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3442 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3443 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3444 | + mOverscanScreenWidth; |
| 3445 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3446 | + mOverscanScreenHeight; |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 3447 | } else if (attrs.type == TYPE_BOOT_PROGRESS |
| 3448 | || attrs.type == TYPE_UNIVERSE_BACKGROUND) { |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3449 | // Boot progress screen always covers entire display. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3450 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3451 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3452 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3453 | + mOverscanScreenWidth; |
| 3454 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3455 | + mOverscanScreenHeight; |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3456 | } else if (attrs.type == TYPE_WALLPAPER) { |
| 3457 | // The wallpaper also has Real Ultimate Power. |
| 3458 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3459 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3460 | pf.right = df.right = of.right = cf.right |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3461 | = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3462 | pf.bottom = df.bottom = of.bottom = cf.bottom |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3463 | = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3464 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3465 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3466 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3467 | // Asking to layout into the overscan region, so give it that pure |
| 3468 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3469 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3470 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3471 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3472 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3473 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3474 | = mOverscanScreenTop + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3475 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3476 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Craig Mautner | beac106 | 2014-06-03 14:38:57 -0700 | [diff] [blame] | 3477 | && (attrs.type == TYPE_STATUS_BAR |
| 3478 | || attrs.type == TYPE_TOAST |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3479 | || (attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3480 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW))) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3481 | // Asking for layout as if the nav bar is hidden, lets the |
| 3482 | // application extend into the unrestricted screen area. We |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3483 | // 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] | 3484 | // can be above the nav bar can do this. |
| 3485 | // XXX This assumes that an app asking for this will also |
| 3486 | // ask for layout in only content. We can't currently figure out |
| 3487 | // 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] | 3488 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3489 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3490 | pf.right = df.right = of.right = cf.right = mUnrestrictedScreenLeft |
| 3491 | + mUnrestrictedScreenWidth; |
| 3492 | pf.bottom = df.bottom = of.bottom = cf.bottom = mUnrestrictedScreenTop |
| 3493 | + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3494 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3495 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3496 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3497 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3498 | + mRestrictedScreenWidth; |
| 3499 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3500 | + mRestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3501 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3502 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3503 | applyStableConstraints(sysUiFl, fl, cf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3504 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3505 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3506 | vf.left = mCurLeft; |
| 3507 | vf.top = mCurTop; |
| 3508 | vf.right = mCurRight; |
| 3509 | vf.bottom = mCurBottom; |
| 3510 | } else { |
| 3511 | vf.set(cf); |
| 3512 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3513 | } else if (attached != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3514 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3515 | "): attached to " + attached); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3516 | // A child window should be placed inside of the same visible |
| 3517 | // frame that its parent had. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3518 | 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] | 3519 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3520 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3521 | "): normal window"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3522 | // Otherwise, a normal window must be placed inside the content |
| 3523 | // of all screen decorations. |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3524 | if (attrs.type == TYPE_STATUS_BAR_PANEL) { |
| 3525 | // Status bar panels are the only windows who can go on top of |
| 3526 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3527 | // permission, so they have the same privileges as the status |
| 3528 | // bar itself. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3529 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3530 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3531 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3532 | + mRestrictedScreenWidth; |
| 3533 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3534 | + mRestrictedScreenHeight; |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3535 | } else if (attrs.type == TYPE_TOAST || attrs.type == TYPE_SYSTEM_ALERT |
| 3536 | || attrs.type == TYPE_VOLUME_OVERLAY) { |
| 3537 | // These dialogs are stable to interim decor changes. |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3538 | pf.left = df.left = of.left = cf.left = mStableLeft; |
| 3539 | pf.top = df.top = of.top = cf.top = mStableTop; |
| 3540 | pf.right = df.right = of.right = cf.right = mStableRight; |
| 3541 | pf.bottom = df.bottom = of.bottom = cf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3542 | } else { |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3543 | pf.left = mContentLeft; |
| 3544 | pf.top = mContentTop; |
| 3545 | pf.right = mContentRight; |
| 3546 | pf.bottom = mContentBottom; |
Dianne Hackborn | 20d9474 | 2014-05-29 18:35:45 -0700 | [diff] [blame] | 3547 | if (win.isVoiceInteraction()) { |
| 3548 | df.left = of.left = cf.left = mVoiceContentLeft; |
| 3549 | df.top = of.top = cf.top = mVoiceContentTop; |
| 3550 | df.right = of.right = cf.right = mVoiceContentRight; |
| 3551 | df.bottom = of.bottom = cf.bottom = mVoiceContentBottom; |
| 3552 | } else if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3553 | df.left = of.left = cf.left = mDockLeft; |
| 3554 | df.top = of.top = cf.top = mDockTop; |
| 3555 | df.right = of.right = cf.right = mDockRight; |
| 3556 | df.bottom = of.bottom = cf.bottom = mDockBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3557 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3558 | df.left = of.left = cf.left = mContentLeft; |
| 3559 | df.top = of.top = cf.top = mContentTop; |
| 3560 | df.right = of.right = cf.right = mContentRight; |
| 3561 | df.bottom = of.bottom = cf.bottom = mContentBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3562 | } |
| 3563 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3564 | vf.left = mCurLeft; |
| 3565 | vf.top = mCurTop; |
| 3566 | vf.right = mCurRight; |
| 3567 | vf.bottom = mCurBottom; |
| 3568 | } else { |
| 3569 | vf.set(cf); |
| 3570 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3571 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3572 | } |
| 3573 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3574 | |
Craig Mautner | b816bed | 2013-07-23 10:26:17 -0700 | [diff] [blame] | 3575 | // TYPE_SYSTEM_ERROR is above the NavigationBar so it can't be allowed to extend over it. |
| 3576 | if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0 && attrs.type != TYPE_SYSTEM_ERROR) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3577 | df.left = df.top = of.left = of.top = cf.left = cf.top = vf.left = vf.top = -10000; |
| 3578 | df.right = df.bottom = of.right = of.bottom = cf.right = cf.bottom |
| 3579 | = vf.right = vf.bottom = 10000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3580 | } |
| 3581 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3582 | 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] | 3583 | + ": sim=#" + Integer.toHexString(sim) |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3584 | + " attach=" + attached + " type=" + attrs.type |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3585 | + String.format(" flags=0x%08x", fl) |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 3586 | + " pf=" + pf.toShortString() + " df=" + df.toShortString() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3587 | + " of=" + of.toShortString() |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3588 | + " cf=" + cf.toShortString() + " vf=" + vf.toShortString() |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3589 | + " dcf=" + dcf.toShortString() |
| 3590 | + " sf=" + sf.toShortString()); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3591 | |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3592 | win.computeFrameLw(pf, df, of, cf, vf, dcf, sf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3593 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3594 | // Dock windows carve out the bottom of the screen, so normal windows |
| 3595 | // can't appear underneath them. |
Craig Mautner | 8bd206b | 2012-10-03 10:32:02 -0700 | [diff] [blame] | 3596 | if (attrs.type == TYPE_INPUT_METHOD && win.isVisibleOrBehindKeyguardLw() |
| 3597 | && !win.getGivenInsetsPendingLw()) { |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3598 | setLastInputMethodWindowLw(null, null); |
| 3599 | offsetInputMethodWindowLw(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3600 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3601 | if (attrs.type == TYPE_VOICE_INTERACTION && win.isVisibleOrBehindKeyguardLw() |
| 3602 | && !win.getGivenInsetsPendingLw()) { |
| 3603 | offsetVoiceInputWindowLw(win); |
| 3604 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3605 | } |
| 3606 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3607 | private void offsetInputMethodWindowLw(WindowState win) { |
| 3608 | int top = win.getContentFrameLw().top; |
| 3609 | top += win.getGivenContentInsetsLw().top; |
| 3610 | if (mContentBottom > top) { |
| 3611 | mContentBottom = top; |
| 3612 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3613 | if (mVoiceContentBottom > top) { |
| 3614 | mVoiceContentBottom = top; |
| 3615 | } |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3616 | top = win.getVisibleFrameLw().top; |
| 3617 | top += win.getGivenVisibleInsetsLw().top; |
| 3618 | if (mCurBottom > top) { |
| 3619 | mCurBottom = top; |
| 3620 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3621 | if (DEBUG_LAYOUT) Slog.v(TAG, "Input method: mDockBottom=" |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3622 | + mDockBottom + " mContentBottom=" |
| 3623 | + mContentBottom + " mCurBottom=" + mCurBottom); |
| 3624 | } |
| 3625 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3626 | private void offsetVoiceInputWindowLw(WindowState win) { |
| 3627 | final int gravity = win.getAttrs().gravity; |
| 3628 | switch (gravity&((Gravity.AXIS_PULL_BEFORE|Gravity.AXIS_PULL_AFTER) |
| 3629 | << Gravity.AXIS_X_SHIFT)) { |
| 3630 | case Gravity.AXIS_PULL_BEFORE<<Gravity.AXIS_X_SHIFT: { |
| 3631 | int right = win.getContentFrameLw().right - win.getGivenContentInsetsLw().right; |
| 3632 | if (mVoiceContentLeft < right) { |
| 3633 | mVoiceContentLeft = right; |
| 3634 | } |
| 3635 | } break; |
| 3636 | case Gravity.AXIS_PULL_AFTER<<Gravity.AXIS_X_SHIFT: { |
| 3637 | int left = win.getContentFrameLw().left - win.getGivenContentInsetsLw().left; |
| 3638 | if (mVoiceContentRight < left) { |
| 3639 | mVoiceContentRight = left; |
| 3640 | } |
| 3641 | } break; |
| 3642 | } |
| 3643 | switch (gravity&((Gravity.AXIS_PULL_BEFORE|Gravity.AXIS_PULL_AFTER) |
| 3644 | << Gravity.AXIS_Y_SHIFT)) { |
| 3645 | case Gravity.AXIS_PULL_BEFORE<<Gravity.AXIS_Y_SHIFT: { |
| 3646 | int bottom = win.getContentFrameLw().bottom - win.getGivenContentInsetsLw().bottom; |
| 3647 | if (mVoiceContentTop < bottom) { |
| 3648 | mVoiceContentTop = bottom; |
| 3649 | } |
| 3650 | } break; |
| 3651 | case Gravity.AXIS_PULL_AFTER<<Gravity.AXIS_Y_SHIFT: { |
| 3652 | int top = win.getContentFrameLw().top - win.getGivenContentInsetsLw().top; |
| 3653 | if (mVoiceContentBottom < top) { |
| 3654 | mVoiceContentBottom = top; |
| 3655 | } |
| 3656 | } break; |
| 3657 | } |
| 3658 | } |
| 3659 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3660 | /** {@inheritDoc} */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 3661 | @Override |
| 3662 | public void finishLayoutLw() { |
| 3663 | return; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3664 | } |
| 3665 | |
| 3666 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3667 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3668 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3669 | mTopFullscreenOpaqueWindowState = null; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3670 | mAppsToBeHidden.clear(); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3671 | mForceStatusBar = false; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3672 | mForceStatusBarFromKeyguard = false; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3673 | mForcingShowNavBar = false; |
| 3674 | mForcingShowNavBarLayer = -1; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3675 | |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3676 | mHideLockScreen = false; |
| 3677 | mAllowLockscreenWhenOn = false; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3678 | mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3679 | mShowingLockscreen = false; |
| 3680 | mShowingDream = false; |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3681 | mWinShowWhenLocked = null; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3682 | } |
| 3683 | |
| 3684 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3685 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3686 | public void applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams attrs) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3687 | if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw=" |
| 3688 | + win.isVisibleOrBehindKeyguardLw()); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3689 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3690 | if (mTopFullscreenOpaqueWindowState == null |
| 3691 | && win.isVisibleLw() && attrs.type == TYPE_INPUT_METHOD) { |
| 3692 | mForcingShowNavBar = true; |
| 3693 | mForcingShowNavBarLayer = win.getSurfaceLayer(); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3694 | } |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 3695 | if (attrs.type == TYPE_STATUS_BAR && (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 3696 | mForceStatusBarFromKeyguard = true; |
| 3697 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3698 | if (mTopFullscreenOpaqueWindowState == null && |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 3699 | win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3700 | if ((fl & FLAG_FORCE_NOT_FULLSCREEN) != 0) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3701 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3702 | mForceStatusBarFromKeyguard = true; |
| 3703 | } else { |
| 3704 | mForceStatusBar = true; |
| 3705 | } |
| 3706 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3707 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3708 | mShowingLockscreen = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3709 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3710 | boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3711 | && attrs.type <= LAST_APPLICATION_WINDOW; |
| 3712 | if (attrs.type == TYPE_DREAM) { |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3713 | // If the lockscreen was showing when the dream started then wait |
| 3714 | // for the dream to draw before hiding the lockscreen. |
| 3715 | if (!mDreamingLockscreen |
| 3716 | || (win.isVisibleLw() && win.hasDrawnLw())) { |
| 3717 | mShowingDream = true; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3718 | appWindow = true; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3719 | } |
| 3720 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3721 | |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 3722 | final boolean showWhenLocked = (fl & FLAG_SHOW_WHEN_LOCKED) != 0; |
Craig Mautner | 74ee938 | 2014-04-01 15:20:16 -0700 | [diff] [blame] | 3723 | final boolean dismissKeyguard = (fl & FLAG_DISMISS_KEYGUARD) != 0; |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3724 | final boolean secureKeyguard = isKeyguardSecure(); |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3725 | if (appWindow) { |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3726 | if (showWhenLocked || (dismissKeyguard && !secureKeyguard)) { |
| 3727 | // Remove any previous windows with the same appToken. |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3728 | mAppsToBeHidden.remove(win.getAppToken()); |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3729 | if (mAppsToBeHidden.isEmpty() && showWhenLocked && |
| 3730 | isKeyguardSecureIncludingHidden()) { |
| 3731 | mWinShowWhenLocked = win; |
| 3732 | mHideLockScreen = true; |
| 3733 | mForceStatusBarFromKeyguard = false; |
| 3734 | } |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3735 | } else { |
| 3736 | mAppsToBeHidden.add(win.getAppToken()); |
| 3737 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3738 | if (attrs.x == 0 && attrs.y == 0 |
| 3739 | && attrs.width == WindowManager.LayoutParams.MATCH_PARENT |
| 3740 | && attrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
| 3741 | if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win); |
| 3742 | mTopFullscreenOpaqueWindowState = win; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3743 | if (mAppsToBeHidden.isEmpty()) { |
Craig Mautner | da09ae3 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3744 | if (showWhenLocked) { |
| 3745 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 3746 | "Setting mHideLockScreen to true by win " + win); |
| 3747 | mHideLockScreen = true; |
| 3748 | mForceStatusBarFromKeyguard = false; |
| 3749 | } |
Craig Mautner | 4bdab6b | 2014-04-01 12:05:11 -0700 | [diff] [blame] | 3750 | if (dismissKeyguard && mDismissKeyguard == DISMISS_KEYGUARD_NONE) { |
Craig Mautner | da09ae3 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3751 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 3752 | "Setting mDismissKeyguard true by win " + win); |
| 3753 | mDismissKeyguard = mWinDismissingKeyguard == win ? |
| 3754 | DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START; |
| 3755 | mWinDismissingKeyguard = win; |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3756 | mForceStatusBarFromKeyguard = mShowingLockscreen && secureKeyguard; |
Craig Mautner | da09ae3 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3757 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3758 | } |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 3759 | if ((fl & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) { |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 3760 | mAllowLockscreenWhenOn = true; |
| 3761 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3762 | } |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3763 | |
| 3764 | if (mWinShowWhenLocked != null && |
| 3765 | mWinShowWhenLocked.getAppToken() != win.getAppToken()) { |
| 3766 | win.hideLw(false); |
| 3767 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3768 | } |
| 3769 | } |
| 3770 | } |
| 3771 | |
| 3772 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3773 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3774 | public int finishPostLayoutPolicyLw() { |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3775 | if (mWinShowWhenLocked != null && |
| 3776 | mWinShowWhenLocked != mTopFullscreenOpaqueWindowState) { |
| 3777 | // A dialog is dismissing the keyguard. Put the wallpaper behind it and hide the |
| 3778 | // fullscreen window. |
| 3779 | // TODO: Make sure FLAG_SHOW_WALLPAPER is restored when dialog is dismissed. Or not. |
| 3780 | mWinShowWhenLocked.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 3781 | mTopFullscreenOpaqueWindowState.hideLw(false); |
| 3782 | mTopFullscreenOpaqueWindowState = mWinShowWhenLocked; |
| 3783 | } |
| 3784 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3785 | int changes = 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3786 | boolean topIsFullscreen = false; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3787 | |
| 3788 | final WindowManager.LayoutParams lp = (mTopFullscreenOpaqueWindowState != null) |
| 3789 | ? mTopFullscreenOpaqueWindowState.getAttrs() |
| 3790 | : null; |
| 3791 | |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 3792 | // If we are not currently showing a dream then remember the current |
| 3793 | // lockscreen state. We will use this to determine whether the dream |
| 3794 | // started while the lockscreen was showing and remember this state |
| 3795 | // while the dream is showing. |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3796 | if (!mShowingDream) { |
| 3797 | mDreamingLockscreen = mShowingLockscreen; |
| 3798 | } |
| 3799 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3800 | if (mStatusBar != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3801 | if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3802 | + " forcefkg=" + mForceStatusBarFromKeyguard |
Dianne Hackborn | d70bc2f | 2009-10-06 23:25:51 -0700 | [diff] [blame] | 3803 | + " top=" + mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3804 | if (mForceStatusBar || mForceStatusBarFromKeyguard) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3805 | if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3806 | if (mStatusBarController.setBarShowingLw(true)) { |
| 3807 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3808 | } |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 3809 | // Maintain fullscreen layout until incoming animation is complete. |
| 3810 | topIsFullscreen = mTopIsFullscreen && mStatusBar.isAnimatingLw(); |
John Spurlock | f92b616 | 2013-11-11 15:01:16 -0500 | [diff] [blame] | 3811 | // Transient status bar on the lockscreen is not allowed |
| 3812 | if (mForceStatusBarFromKeyguard && mStatusBarController.isTransientShowing()) { |
| 3813 | mStatusBarController.updateVisibilityLw(false /*transientAllowed*/, |
| 3814 | mLastSystemUiFlags, mLastSystemUiFlags); |
| 3815 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3816 | } else if (mTopFullscreenOpaqueWindowState != null) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3817 | final int fl = PolicyControl.getWindowFlags(null, lp); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3818 | if (localLOGV) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3819 | Slog.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw() |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3820 | + " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw()); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3821 | Slog.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs() |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3822 | + " lp.flags=0x" + Integer.toHexString(fl)); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3823 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3824 | topIsFullscreen = (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0 |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3825 | || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 3826 | // The subtle difference between the window for mTopFullscreenOpaqueWindowState |
| 3827 | // and mTopIsFullscreen is that that mTopIsFullscreen is set only if the window |
| 3828 | // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the |
| 3829 | // case though. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3830 | if (mStatusBarController.isTransientShowing()) { |
| 3831 | if (mStatusBarController.setBarShowingLw(true)) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3832 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3833 | } |
| 3834 | } else if (topIsFullscreen) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3835 | if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3836 | if (mStatusBarController.setBarShowingLw(false)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3837 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3838 | } else { |
Craig Mautner | c5a6e44 | 2013-06-05 17:22:35 -0700 | [diff] [blame] | 3839 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar already hiding"); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 3840 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3841 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3842 | 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] | 3843 | if (mStatusBarController.setBarShowingLw(true)) { |
| 3844 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3845 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3846 | } |
| 3847 | } |
| 3848 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3849 | |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 3850 | if (mTopIsFullscreen != topIsFullscreen) { |
| 3851 | if (!topIsFullscreen) { |
| 3852 | // Force another layout when status bar becomes fully shown. |
| 3853 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3854 | } |
| 3855 | mTopIsFullscreen = topIsFullscreen; |
| 3856 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 3857 | |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3858 | // Hide the key guard if a visible window explicitly specifies that it wants to be |
| 3859 | // displayed when the screen is locked. |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3860 | if (mKeyguardDelegate != null && mStatusBar != null) { |
| 3861 | if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard=" |
| 3862 | + mHideLockScreen); |
| 3863 | if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !isKeyguardSecure()) { |
| 3864 | mKeyguardHidden = true; |
| 3865 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(true))) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3866 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3867 | | FINISH_LAYOUT_REDO_CONFIG |
| 3868 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3869 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3870 | if (mKeyguardDelegate.isShowing()) { |
| 3871 | mHandler.post(new Runnable() { |
| 3872 | @Override |
| 3873 | public void run() { |
| 3874 | mKeyguardDelegate.keyguardDone(false, false); |
| 3875 | } |
| 3876 | }); |
| 3877 | } |
| 3878 | } else if (mHideLockScreen) { |
| 3879 | mKeyguardHidden = true; |
| 3880 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(true))) { |
| 3881 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3882 | | FINISH_LAYOUT_REDO_CONFIG |
| 3883 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3884 | } |
| 3885 | } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) { |
| 3886 | // This is the case of keyguard isSecure() and not mHideLockScreen. |
| 3887 | if (mDismissKeyguard == DISMISS_KEYGUARD_START) { |
| 3888 | // Only launch the next keyguard unlock window once per window. |
| 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; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3894 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3895 | mHandler.post(new Runnable() { |
| 3896 | @Override |
| 3897 | public void run() { |
| 3898 | mKeyguardDelegate.dismiss(); |
| 3899 | } |
| 3900 | }); |
| 3901 | } |
| 3902 | } else { |
| 3903 | mWinDismissingKeyguard = null; |
| 3904 | mKeyguardHidden = false; |
| 3905 | if (processKeyguardSetHiddenResultLw(mKeyguardDelegate.setOccluded(false))) { |
| 3906 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 3907 | | FINISH_LAYOUT_REDO_CONFIG |
| 3908 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 3909 | } |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 3910 | } |
| 3911 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3912 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3913 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3914 | // If the navigation bar has been hidden or shown, we need to do another |
| 3915 | // layout pass to update that window. |
| 3916 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 3917 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3918 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3919 | // update since mAllowLockscreenWhenOn might have changed |
| 3920 | updateLockScreenTimeout(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3921 | return changes; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3922 | } |
| 3923 | |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3924 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3925 | * 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] | 3926 | * immediately need to put the wallpaper directly behind the Keyguard when a window with flag |
| 3927 | * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED} gets dismissed. If we |
| 3928 | * would wait for Keyguard to change the flags, that would be running asynchronously and thus be |
| 3929 | * too late so the user might see the window behind. |
| 3930 | * |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3931 | * @param setHiddenResult The result code from {@link IKeyguardService#setOccluded}. |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3932 | * @return Whether the flags have changed and we have to redo the layout. |
| 3933 | */ |
| 3934 | private boolean processKeyguardSetHiddenResultLw(int setHiddenResult) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3935 | if (setHiddenResult |
| 3936 | == IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_SET_FLAGS) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3937 | mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD; |
| 3938 | mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 3939 | return true; |
| 3940 | } else if (setHiddenResult |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 3941 | == IKeyguardServiceConstants.KEYGUARD_SERVICE_SET_OCCLUDED_RESULT_UNSET_FLAGS) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3942 | mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD; |
| 3943 | mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER; |
| 3944 | return true; |
| 3945 | } else { |
| 3946 | return false; |
| 3947 | } |
| 3948 | } |
| 3949 | |
| 3950 | private boolean isStatusBarKeyguard() { |
| 3951 | return mStatusBar != null |
| 3952 | && (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
| 3953 | } |
| 3954 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 3955 | @Override |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3956 | public boolean allowAppAnimationsLw() { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3957 | if (isStatusBarKeyguard() || mShowingDream) { |
Craig Mautner | 2881630 | 2013-10-10 20:31:00 -0700 | [diff] [blame] | 3958 | // 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] | 3959 | return false; |
| 3960 | } |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3961 | return true; |
| 3962 | } |
| 3963 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 3964 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3965 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus) { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3966 | mFocusedWindow = newFocus; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3967 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3968 | // If the navigation bar has been hidden or shown, we need to do another |
| 3969 | // layout pass to update that window. |
| 3970 | return FINISH_LAYOUT_REDO_LAYOUT; |
| 3971 | } |
| 3972 | return 0; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 3973 | } |
| 3974 | |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 3975 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 3976 | @Override |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3977 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
| 3978 | // lid changed state |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3979 | final int newLidState = lidOpen ? LID_OPEN : LID_CLOSED; |
| 3980 | if (newLidState == mLidState) { |
| 3981 | return; |
| 3982 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3983 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3984 | mLidState = newLidState; |
| 3985 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3986 | updateRotation(true); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3987 | |
| 3988 | if (lidOpen) { |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 3989 | mPowerManager.wakeUp(SystemClock.uptimeMillis()); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 3990 | } else if (!mLidControlsSleep) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 3991 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 3992 | } |
| 3993 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3994 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3995 | void setHdmiPlugged(boolean plugged) { |
| 3996 | if (mHdmiPlugged != plugged) { |
| 3997 | mHdmiPlugged = plugged; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3998 | updateRotation(true, true); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 3999 | Intent intent = new Intent(ACTION_HDMI_PLUGGED); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 4000 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 4001 | intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 4002 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 4003 | } |
| 4004 | } |
| 4005 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 4006 | void initializeHdmiState() { |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 4007 | boolean plugged = false; |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 4008 | // watch for HDMI plug messages if the hdmi switch exists |
| 4009 | if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) { |
| 4010 | mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi"); |
| 4011 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 4012 | final String filename = "/sys/class/switch/hdmi/state"; |
| 4013 | FileReader reader = null; |
| 4014 | try { |
| 4015 | reader = new FileReader(filename); |
| 4016 | char[] buf = new char[15]; |
| 4017 | int n = reader.read(buf); |
| 4018 | if (n > 1) { |
| 4019 | plugged = 0 != Integer.parseInt(new String(buf, 0, n-1)); |
| 4020 | } |
| 4021 | } catch (IOException ex) { |
| 4022 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 4023 | } catch (NumberFormatException ex) { |
| 4024 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 4025 | } finally { |
| 4026 | if (reader != null) { |
| 4027 | try { |
| 4028 | reader.close(); |
| 4029 | } catch (IOException ex) { |
| 4030 | } |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 4031 | } |
| 4032 | } |
| 4033 | } |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 4034 | // This dance forces the code in setHdmiPlugged to run. |
| 4035 | // Always do this so the sticky intent is stuck (to false) if there is no hdmi. |
| 4036 | mHdmiPlugged = !plugged; |
| 4037 | setHdmiPlugged(!mHdmiPlugged); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 4038 | } |
| 4039 | |
Dianne Hackborn | c0e3f24 | 2011-08-19 14:19:10 -0700 | [diff] [blame] | 4040 | final Object mScreenshotLock = new Object(); |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 4041 | ServiceConnection mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 4042 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4043 | final Runnable mScreenshotTimeout = new Runnable() { |
| 4044 | @Override public void run() { |
| 4045 | synchronized (mScreenshotLock) { |
| 4046 | if (mScreenshotConnection != null) { |
| 4047 | mContext.unbindService(mScreenshotConnection); |
| 4048 | mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 4049 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4050 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4051 | } |
| 4052 | }; |
| 4053 | |
| 4054 | // Assume this is called from the Handler thread. |
| 4055 | private void takeScreenshot() { |
| 4056 | synchronized (mScreenshotLock) { |
| 4057 | if (mScreenshotConnection != null) { |
| 4058 | return; |
| 4059 | } |
| 4060 | ComponentName cn = new ComponentName("com.android.systemui", |
| 4061 | "com.android.systemui.screenshot.TakeScreenshotService"); |
| 4062 | Intent intent = new Intent(); |
| 4063 | intent.setComponent(cn); |
| 4064 | ServiceConnection conn = new ServiceConnection() { |
| 4065 | @Override |
| 4066 | public void onServiceConnected(ComponentName name, IBinder service) { |
| 4067 | synchronized (mScreenshotLock) { |
| 4068 | if (mScreenshotConnection != this) { |
| 4069 | return; |
| 4070 | } |
| 4071 | Messenger messenger = new Messenger(service); |
| 4072 | Message msg = Message.obtain(null, 1); |
| 4073 | final ServiceConnection myConn = this; |
| 4074 | Handler h = new Handler(mHandler.getLooper()) { |
| 4075 | @Override |
| 4076 | public void handleMessage(Message msg) { |
| 4077 | synchronized (mScreenshotLock) { |
| 4078 | if (mScreenshotConnection == myConn) { |
| 4079 | mContext.unbindService(mScreenshotConnection); |
| 4080 | mScreenshotConnection = null; |
| 4081 | mHandler.removeCallbacks(mScreenshotTimeout); |
| 4082 | } |
| 4083 | } |
| 4084 | } |
| 4085 | }; |
| 4086 | msg.replyTo = new Messenger(h); |
Winson Chung | a63bb84 | 2011-10-17 10:26:28 -0700 | [diff] [blame] | 4087 | msg.arg1 = msg.arg2 = 0; |
| 4088 | if (mStatusBar != null && mStatusBar.isVisibleLw()) |
| 4089 | msg.arg1 = 1; |
| 4090 | if (mNavigationBar != null && mNavigationBar.isVisibleLw()) |
| 4091 | msg.arg2 = 1; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4092 | try { |
| 4093 | messenger.send(msg); |
| 4094 | } catch (RemoteException e) { |
| 4095 | } |
| 4096 | } |
| 4097 | } |
| 4098 | @Override |
| 4099 | public void onServiceDisconnected(ComponentName name) {} |
| 4100 | }; |
Amith Yamasani | 27b89e6 | 2013-01-16 12:30:11 -0800 | [diff] [blame] | 4101 | if (mContext.bindServiceAsUser( |
| 4102 | intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4103 | mScreenshotConnection = conn; |
| 4104 | mHandler.postDelayed(mScreenshotTimeout, 10000); |
| 4105 | } |
| 4106 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4107 | } |
| 4108 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4109 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4110 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4111 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 4112 | if (!mSystemBooted) { |
| 4113 | // If we have not yet booted, don't let key events do anything. |
| 4114 | return 0; |
| 4115 | } |
| 4116 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4117 | final boolean interactive = (policyFlags & FLAG_INTERACTIVE) != 0; |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 4118 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 4119 | final boolean canceled = event.isCanceled(); |
| 4120 | final int keyCode = event.getKeyCode(); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 4121 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4122 | final boolean isInjected = (policyFlags & WindowManagerPolicy.FLAG_INJECTED) != 0; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4123 | |
Mike Lockwood | c72b15f | 2009-11-28 20:58:22 -0500 | [diff] [blame] | 4124 | // If screen is off then we treat the case where the keyguard is open but hidden |
| 4125 | // the same as if it were open and in front. |
| 4126 | // This will prevent any keys other than the power button from waking the screen |
| 4127 | // when the keyguard is hidden by another activity. |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4128 | final boolean keyguardActive = (mKeyguardDelegate == null ? false : |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4129 | (interactive ? |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4130 | mKeyguardDelegate.isShowingAndNotOccluded() : |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4131 | mKeyguardDelegate.isShowing())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4132 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4133 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4134 | Log.d(TAG, "interceptKeyTq keycode=" + keyCode |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4135 | + " interactive=" + interactive + " keyguardActive=" + keyguardActive |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4136 | + " policyFlags=" + Integer.toHexString(policyFlags)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4137 | } |
| 4138 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4139 | // Basic policy based on interactive state. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4140 | int result; |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 4141 | boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0 |
| 4142 | || event.isWakeKey(); |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4143 | if (interactive || (isInjected && !isWakeKey)) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4144 | // When the screen is on or if the key is injected pass the key to the application. |
| 4145 | result = ACTION_PASS_TO_USER; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4146 | isWakeKey = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4147 | } else { |
| 4148 | // When the screen is off and the key is not injected, determine whether |
| 4149 | // to wake the device but don't pass the key to the application. |
| 4150 | result = 0; |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4151 | if (isWakeKey && (!down || !isWakeKeyWhenScreenOff(keyCode))) { |
| 4152 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4153 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4154 | } |
| 4155 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 4156 | // If the key would be handled globally, just return the result, don't worry about special |
| 4157 | // key processing. |
| 4158 | if (mGlobalKeyManager.shouldHandleGlobalKey(keyCode, event)) { |
Michael Wright | 85b1af6 | 2014-06-04 14:51:58 -0700 | [diff] [blame] | 4159 | if (isWakeKey) { |
| 4160 | mPowerManager.wakeUp(event.getEventTime()); |
| 4161 | } |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 4162 | return result; |
| 4163 | } |
| 4164 | |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 4165 | boolean useHapticFeedback = down |
| 4166 | && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 |
| 4167 | && event.getRepeatCount() == 0; |
| 4168 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4169 | // Handle special keys. |
| 4170 | switch (keyCode) { |
| 4171 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 4172 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4173 | case KeyEvent.KEYCODE_VOLUME_MUTE: { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4174 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { |
| 4175 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4176 | if (interactive && !mVolumeDownKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4177 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4178 | mVolumeDownKeyTriggered = true; |
| 4179 | mVolumeDownKeyTime = event.getDownTime(); |
| 4180 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 4181 | cancelPendingPowerKeyAction(); |
| 4182 | interceptScreenshotChord(); |
| 4183 | } |
| 4184 | } else { |
| 4185 | mVolumeDownKeyTriggered = false; |
| 4186 | cancelPendingScreenshotChordAction(); |
| 4187 | } |
| 4188 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { |
| 4189 | if (down) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4190 | if (interactive && !mVolumeUpKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4191 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4192 | mVolumeUpKeyTriggered = true; |
| 4193 | cancelPendingPowerKeyAction(); |
| 4194 | cancelPendingScreenshotChordAction(); |
| 4195 | } |
| 4196 | } else { |
| 4197 | mVolumeUpKeyTriggered = false; |
| 4198 | cancelPendingScreenshotChordAction(); |
| 4199 | } |
| 4200 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4201 | if (down) { |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4202 | TelecommManager telecommManager = getTelecommService(); |
| 4203 | if (telecommManager != null) { |
| 4204 | if (telecommManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4205 | // If an incoming call is ringing, either VOLUME key means |
| 4206 | // "silence ringer". We handle these keys here, rather than |
| 4207 | // in the InCallScreen, to make sure we'll respond to them |
| 4208 | // even if the InCallScreen hasn't come to the foreground yet. |
| 4209 | // Look for the DOWN event here, to agree with the "fallback" |
| 4210 | // behavior in the InCallScreen. |
| 4211 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4212 | + " VOLUME key-down while ringing: Silence ringer!"); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4213 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4214 | // Silence the ringer. (It's safe to call this |
| 4215 | // even if the ringer has already been silenced.) |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4216 | telecommManager.silenceRinger(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4217 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4218 | // And *don't* pass this key thru to the current activity |
| 4219 | // (which is probably the InCallScreen.) |
| 4220 | result &= ~ACTION_PASS_TO_USER; |
| 4221 | break; |
| 4222 | } |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4223 | if (telecommManager.isInAPhoneCall() |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4224 | && (result & ACTION_PASS_TO_USER) == 0) { |
| 4225 | // 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] | 4226 | // the application, just pass it to the session service. |
| 4227 | |
| 4228 | MediaSessionLegacyHelper.getHelper(mContext) |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 4229 | .sendVolumeKeyEvent(event, false); |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4230 | break; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4231 | } |
| 4232 | } |
| 4233 | |
RoboErik | 430fc48 | 2014-06-12 15:49:20 -0700 | [diff] [blame] | 4234 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 4235 | // If we aren't passing to the user and no one else |
| 4236 | // handled it send it to the session manager to figure |
| 4237 | // out. |
| 4238 | MediaSessionLegacyHelper.getHelper(mContext) |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 4239 | .sendVolumeKeyEvent(event, true); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4240 | break; |
| 4241 | } |
| 4242 | } |
| 4243 | break; |
| 4244 | } |
| 4245 | |
| 4246 | case KeyEvent.KEYCODE_ENDCALL: { |
| 4247 | result &= ~ACTION_PASS_TO_USER; |
| 4248 | if (down) { |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4249 | TelecommManager telecommManager = getTelecommService(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4250 | boolean hungUp = false; |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4251 | if (telecommManager != null) { |
| 4252 | hungUp = telecommManager.endCall(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4253 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4254 | interceptPowerKeyDown(!interactive || hungUp); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4255 | } else { |
| 4256 | if (interceptPowerKeyUp(canceled)) { |
| 4257 | if ((mEndcallBehavior |
| 4258 | & Settings.System.END_BUTTON_BEHAVIOR_HOME) != 0) { |
| 4259 | if (goHome()) { |
| 4260 | break; |
Dianne Hackborn | 0041e97 | 2009-07-24 17:14:43 -0700 | [diff] [blame] | 4261 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4262 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4263 | if ((mEndcallBehavior |
| 4264 | & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4265 | mPowerManager.goToSleep(event.getEventTime()); |
| 4266 | isWakeKey = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4267 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4268 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4269 | } |
| 4270 | break; |
| 4271 | } |
| 4272 | |
| 4273 | case KeyEvent.KEYCODE_POWER: { |
| 4274 | result &= ~ACTION_PASS_TO_USER; |
| 4275 | if (down) { |
Jeff Brown | 26c6a50 | 2014-04-11 02:15:54 -0700 | [diff] [blame] | 4276 | boolean panic = mImmersiveModeConfirmation.onPowerKeyDown(interactive, |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 4277 | event.getDownTime(), isImmersiveMode(mLastSystemUiFlags)); |
| 4278 | if (panic) { |
| 4279 | mHandler.post(mRequestTransientNav); |
| 4280 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4281 | if (interactive && !mPowerKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4282 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 4283 | mPowerKeyTriggered = true; |
| 4284 | mPowerKeyTime = event.getDownTime(); |
| 4285 | interceptScreenshotChord(); |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4286 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4287 | |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4288 | TelecommManager telecommManager = getTelecommService(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4289 | boolean hungUp = false; |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4290 | if (telecommManager != null) { |
| 4291 | if (telecommManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4292 | // Pressing Power while there's a ringing incoming |
| 4293 | // call should silence the ringer. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4294 | telecommManager.silenceRinger(); |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4295 | } else if ((mIncallPowerBehavior |
| 4296 | & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4297 | && telecommManager.isInAPhoneCall() && interactive) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4298 | // Otherwise, if "Power button ends call" is enabled, |
| 4299 | // the Power button will hang up any current active call. |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4300 | hungUp = telecommManager.endCall(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4301 | } |
| 4302 | } |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4303 | interceptPowerKeyDown(!interactive || hungUp |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4304 | || mVolumeDownKeyTriggered || mVolumeUpKeyTriggered); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4305 | } else { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4306 | mPowerKeyTriggered = false; |
| 4307 | cancelPendingScreenshotChordAction(); |
| 4308 | if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) { |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 4309 | powerShortPress(event.getEventTime()); |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4310 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4311 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4312 | mPendingPowerKeyUpCanceled = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4313 | } |
| 4314 | break; |
| 4315 | } |
| 4316 | |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4317 | case KeyEvent.KEYCODE_SLEEP: { |
| 4318 | result &= ~ACTION_PASS_TO_USER; |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 4319 | if (!mPowerManager.isInteractive()) { |
| 4320 | useHapticFeedback = false; // suppress feedback if already non-interactive |
| 4321 | } |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4322 | mPowerManager.goToSleep(event.getEventTime()); |
| 4323 | isWakeKey = false; |
| 4324 | break; |
| 4325 | } |
| 4326 | |
| 4327 | case KeyEvent.KEYCODE_WAKEUP: { |
| 4328 | result &= ~ACTION_PASS_TO_USER; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4329 | isWakeKey = true; |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4330 | break; |
| 4331 | } |
| 4332 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4333 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4334 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4335 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4336 | if (down) { |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4337 | TelecommManager telecommManager = getTelecommService(); |
| 4338 | if (telecommManager != null) { |
| 4339 | if (telecommManager.isInAPhoneCall()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4340 | // Suppress PLAY/PAUSE toggle when phone is ringing or in-call |
| 4341 | // to avoid music playback. |
| 4342 | break; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4343 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4344 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4345 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4346 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4347 | case KeyEvent.KEYCODE_MUTE: |
| 4348 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4349 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4350 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4351 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4352 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4353 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
| 4354 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4355 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 4356 | // Only do this if we would otherwise not pass it to the user. In that |
| 4357 | // case, the PhoneWindow class will do the same thing, except it will |
| 4358 | // 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] | 4359 | // Note that we need to make a copy of the key event here because the |
| 4360 | // original key event will be recycled when we return. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4361 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4362 | Message msg = mHandler.obtainMessage(MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK, |
| 4363 | new KeyEvent(event)); |
| 4364 | msg.setAsynchronous(true); |
| 4365 | msg.sendToTarget(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4366 | } |
| 4367 | break; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4368 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4369 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4370 | case KeyEvent.KEYCODE_CALL: { |
| 4371 | if (down) { |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4372 | TelecommManager telecommManager = getTelecommService(); |
| 4373 | if (telecommManager != null) { |
| 4374 | if (telecommManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4375 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4376 | + " CALL key-down while ringing: Answer the call!"); |
Santos Cordon | 9eb4593 | 2014-06-27 12:28:43 -0700 | [diff] [blame] | 4377 | telecommManager.acceptRingingCall(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4378 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4379 | // And *don't* pass this key thru to the current activity |
| 4380 | // (which is presumably the InCallScreen.) |
| 4381 | result &= ~ACTION_PASS_TO_USER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4382 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4383 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4384 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4385 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4386 | } |
| 4387 | } |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4388 | |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 4389 | if (useHapticFeedback) { |
| 4390 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
| 4391 | } |
| 4392 | |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4393 | if (isWakeKey) { |
| 4394 | mPowerManager.wakeUp(event.getEventTime()); |
| 4395 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4396 | return result; |
| 4397 | } |
| 4398 | |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4399 | /** |
| 4400 | * When the screen is off we ignore some keys that might otherwise typically |
| 4401 | * be considered wake keys. We filter them out here. |
| 4402 | * |
| 4403 | * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it |
| 4404 | * is always considered a wake key. |
| 4405 | */ |
| 4406 | private boolean isWakeKeyWhenScreenOff(int keyCode) { |
| 4407 | switch (keyCode) { |
| 4408 | // ignore volume keys unless docked |
| 4409 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4410 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 4411 | case KeyEvent.KEYCODE_VOLUME_MUTE: |
| 4412 | return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 4413 | |
| 4414 | // ignore media and camera keys |
| 4415 | case KeyEvent.KEYCODE_MUTE: |
| 4416 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4417 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4418 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4419 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4420 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4421 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4422 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4423 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4424 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
| 4425 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4426 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4427 | case KeyEvent.KEYCODE_CAMERA: |
| 4428 | return false; |
| 4429 | } |
| 4430 | return true; |
| 4431 | } |
| 4432 | |
| 4433 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4434 | /** {@inheritDoc} */ |
| 4435 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4436 | public int interceptWakeMotionBeforeQueueing(long whenNanos, int policyFlags) { |
| 4437 | // We already know this is a wake motion so just wake up. |
| 4438 | // Note that we would observe policyFlags containing |
| 4439 | // FLAG_WAKE and FLAG_INTERACTIVE here. |
| 4440 | mPowerManager.wakeUp(whenNanos / 1000000); |
| 4441 | return 0; |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4442 | } |
| 4443 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4444 | void dispatchMediaKeyWithWakeLock(KeyEvent event) { |
| 4445 | if (DEBUG_INPUT) { |
| 4446 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: " + event); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4447 | } |
| 4448 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4449 | if (mHavePendingMediaKeyRepeatWithWakeLock) { |
| 4450 | if (DEBUG_INPUT) { |
| 4451 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: canceled repeat"); |
| 4452 | } |
| 4453 | |
| 4454 | mHandler.removeMessages(MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK); |
| 4455 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4456 | mBroadcastWakeLock.release(); // pending repeat was holding onto the wake lock |
| 4457 | } |
| 4458 | |
| 4459 | dispatchMediaKeyWithWakeLockToAudioService(event); |
| 4460 | |
| 4461 | if (event.getAction() == KeyEvent.ACTION_DOWN |
| 4462 | && event.getRepeatCount() == 0) { |
| 4463 | mHavePendingMediaKeyRepeatWithWakeLock = true; |
| 4464 | |
| 4465 | Message msg = mHandler.obtainMessage( |
| 4466 | MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK, event); |
| 4467 | msg.setAsynchronous(true); |
| 4468 | mHandler.sendMessageDelayed(msg, ViewConfiguration.getKeyRepeatTimeout()); |
| 4469 | } else { |
| 4470 | mBroadcastWakeLock.release(); |
| 4471 | } |
| 4472 | } |
| 4473 | |
| 4474 | void dispatchMediaKeyRepeatWithWakeLock(KeyEvent event) { |
| 4475 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4476 | |
| 4477 | KeyEvent repeatEvent = KeyEvent.changeTimeRepeat(event, |
| 4478 | SystemClock.uptimeMillis(), 1, event.getFlags() | KeyEvent.FLAG_LONG_PRESS); |
| 4479 | if (DEBUG_INPUT) { |
| 4480 | Slog.d(TAG, "dispatchMediaKeyRepeatWithWakeLock: " + repeatEvent); |
| 4481 | } |
| 4482 | |
| 4483 | dispatchMediaKeyWithWakeLockToAudioService(repeatEvent); |
| 4484 | mBroadcastWakeLock.release(); |
| 4485 | } |
| 4486 | |
| 4487 | void dispatchMediaKeyWithWakeLockToAudioService(KeyEvent event) { |
| 4488 | if (ActivityManagerNative.isSystemReady()) { |
RoboErik | 430fc48 | 2014-06-12 15:49:20 -0700 | [diff] [blame] | 4489 | MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(event, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4490 | } |
| 4491 | } |
| 4492 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4493 | BroadcastReceiver mDockReceiver = new BroadcastReceiver() { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4494 | @Override |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4495 | public void onReceive(Context context, Intent intent) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 4496 | if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { |
| 4497 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 4498 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4499 | } else { |
| 4500 | try { |
| 4501 | IUiModeManager uiModeService = IUiModeManager.Stub.asInterface( |
| 4502 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 4503 | mUiMode = uiModeService.getCurrentModeType(); |
| 4504 | } catch (RemoteException e) { |
| 4505 | } |
Dianne Hackborn | 80fa166 | 2009-10-07 14:02:10 -0700 | [diff] [blame] | 4506 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4507 | updateRotation(true); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4508 | synchronized (mLock) { |
| 4509 | updateOrientationListenerLp(); |
| 4510 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4511 | } |
| 4512 | }; |
| 4513 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4514 | BroadcastReceiver mDreamReceiver = new BroadcastReceiver() { |
| 4515 | @Override |
| 4516 | public void onReceive(Context context, Intent intent) { |
| 4517 | if (Intent.ACTION_DREAMING_STARTED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4518 | if (mKeyguardDelegate != null) { |
| 4519 | mKeyguardDelegate.onDreamingStarted(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4520 | } |
| 4521 | } else if (Intent.ACTION_DREAMING_STOPPED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4522 | if (mKeyguardDelegate != null) { |
| 4523 | mKeyguardDelegate.onDreamingStopped(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4524 | } |
| 4525 | } |
| 4526 | } |
| 4527 | }; |
| 4528 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4529 | BroadcastReceiver mMultiuserReceiver = new BroadcastReceiver() { |
| 4530 | @Override |
| 4531 | public void onReceive(Context context, Intent intent) { |
| 4532 | if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { |
| 4533 | // tickle the settings observer: this first ensures that we're |
| 4534 | // observing the relevant settings for the newly-active user, |
| 4535 | // and then updates our own bookkeeping based on the now- |
| 4536 | // current user. |
| 4537 | mSettingsObserver.onChange(false); |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4538 | |
| 4539 | // force a re-application of focused window sysui visibility. |
| 4540 | // the window may never have been shown for this user |
| 4541 | // e.g. the keyguard when going through the new-user setup flow |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4542 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 4543 | mLastSystemUiFlags = 0; |
| 4544 | updateSystemUiVisibilityLw(); |
| 4545 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4546 | } |
| 4547 | } |
| 4548 | }; |
| 4549 | |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 4550 | private final Runnable mRequestTransientNav = new Runnable() { |
| 4551 | @Override |
| 4552 | public void run() { |
| 4553 | requestTransientBars(mNavigationBar); |
| 4554 | } |
| 4555 | }; |
| 4556 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 4557 | private void requestTransientBars(WindowState swipeTarget) { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 4558 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 4559 | if (!isUserSetupComplete()) { |
| 4560 | // Swipe-up for navigation bar is disabled during setup |
| 4561 | return; |
| 4562 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4563 | boolean sb = mStatusBarController.checkShowTransientBarLw(); |
| 4564 | boolean nb = mNavigationBarController.checkShowTransientBarLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4565 | if (sb || nb) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 4566 | WindowState barTarget = sb ? mStatusBar : mNavigationBar; |
| 4567 | if (sb ^ nb && barTarget != swipeTarget) { |
| 4568 | if (DEBUG) Slog.d(TAG, "Not showing transient bar, wrong swipe target"); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4569 | return; |
| 4570 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4571 | if (sb) mStatusBarController.showTransient(); |
| 4572 | if (nb) mNavigationBarController.showTransient(); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 4573 | mImmersiveModeConfirmation.confirmCurrentPrompt(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4574 | updateSystemUiVisibilityLw(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 4575 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 4576 | } |
| 4577 | } |
| 4578 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4579 | @Override |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 4580 | public void goingToSleep(int why) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4581 | EventLog.writeEvent(70000, 0); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4582 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4583 | mScreenOnEarly = false; |
| 4584 | mScreenOnFully = false; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4585 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4586 | if (mKeyguardDelegate != null) { |
| 4587 | mKeyguardDelegate.onScreenTurnedOff(why); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4588 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 4589 | synchronized (mLock) { |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 4590 | updateWakeGestureListenerLp(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4591 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4592 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4593 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4594 | } |
| 4595 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4596 | @Override |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 4597 | public void wakingUp(final ScreenOnListener screenOnListener) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 4598 | EventLog.writeEvent(70000, 1); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4599 | if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on...", |
| 4600 | new RuntimeException("here").fillInStackTrace()); |
| 4601 | mHandler.obtainMessage(MSG_WAKING_UP, screenOnListener).sendToTarget(); |
| 4602 | } |
| 4603 | |
| 4604 | // Called on the mHandler thread. |
| 4605 | private void handleWakingUp(final ScreenOnListener screenOnListener) { |
| 4606 | if (screenOnListener != null) { |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 4607 | mScreenOnListener = screenOnListener; |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 4608 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4609 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4610 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4611 | mScreenOnEarly = true; |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 4612 | updateWakeGestureListenerLp(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4613 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4614 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4615 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4616 | |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4617 | mKeyguardDrawComplete = false; |
| 4618 | mWindowManagerDrawComplete = false; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4619 | if (mKeyguardDelegate != null) { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4620 | mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT); |
| 4621 | mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT, 1000); |
| 4622 | mKeyguardDelegate.onScreenTurnedOn(mKeyguardDelegateCallback); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4623 | } else { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4624 | if (DEBUG_WAKEUP) Slog.d(TAG, "null mKeyguardDelegate: setting mKeyguardDrawComplete."); |
| 4625 | mKeyguardDrawComplete = true; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4626 | } |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4627 | mWindowManagerInternal.waitForAllWindowsDrawn(mWindowManagerDrawCallback, 500); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4628 | } |
| 4629 | |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4630 | // Called on the mHandler thread. |
| 4631 | private void finishScreenTurningOn() { |
| 4632 | if (DEBUG_WAKEUP) Slog.d(TAG, |
| 4633 | "finishScreenTurningOn: mKeyguardDrawComplete=" + mKeyguardDrawComplete |
| 4634 | + " mWindowManagerDrawComplete=" + mWindowManagerDrawComplete); |
| 4635 | if (!mKeyguardDrawComplete || !mWindowManagerDrawComplete) { |
| 4636 | return; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4637 | } |
| 4638 | |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 4639 | ScreenOnListener screenOnListener; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4640 | synchronized (mLock) { |
| 4641 | mScreenOnFully = true; |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 4642 | screenOnListener = mScreenOnListener; |
| 4643 | mScreenOnListener = null; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4644 | } |
| 4645 | |
Jeff Brown | 4fc4527 | 2012-10-10 18:28:14 -0700 | [diff] [blame] | 4646 | try { |
| 4647 | mWindowManager.setEventDispatching(true); |
| 4648 | } catch (RemoteException unhandled) { |
| 4649 | } |
| 4650 | |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 4651 | if (screenOnListener != null) { |
| 4652 | screenOnListener.onScreenOn(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4653 | } |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 4654 | |
| 4655 | setKeyguardDrawn(); |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 4656 | |
| 4657 | if (mBootMessageNeedsHiding) { |
| 4658 | handleHideBootMessage(); |
| 4659 | mBootMessageNeedsHiding = false; |
| 4660 | } |
| 4661 | } |
| 4662 | |
| 4663 | private void handleHideBootMessage() { |
| 4664 | if (mBootMsgDialog == null) { |
| 4665 | if (DEBUG_WAKEUP) Slog.d(TAG, "handleHideBootMessage: boot message not up"); |
| 4666 | return; |
| 4667 | } |
| 4668 | if (!mKeyguardDrawComplete || !mWindowManagerDrawComplete) { |
| 4669 | if (DEBUG_WAKEUP) Slog.d(TAG, "handleHideBootMessage: deferring until keyguard ready"); |
| 4670 | mBootMessageNeedsHiding = true; |
| 4671 | return; |
| 4672 | } |
| 4673 | if (DEBUG_WAKEUP) Slog.d(TAG, "handleHideBootMessage: dismissing"); |
| 4674 | mBootMsgDialog.dismiss(); |
| 4675 | mBootMsgDialog = null; |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4676 | } |
| 4677 | |
| 4678 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4679 | public boolean isScreenOnEarly() { |
| 4680 | return mScreenOnEarly; |
| 4681 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4682 | |
| 4683 | @Override |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4684 | public boolean isScreenOnFully() { |
| 4685 | return mScreenOnFully; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4686 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 4687 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4688 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4689 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4690 | public void enableKeyguard(boolean enabled) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4691 | if (mKeyguardDelegate != null) { |
| 4692 | mKeyguardDelegate.setKeyguardEnabled(enabled); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4693 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4694 | } |
| 4695 | |
| 4696 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4697 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4698 | public void exitKeyguardSecurely(OnKeyguardExitResult callback) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4699 | if (mKeyguardDelegate != null) { |
| 4700 | mKeyguardDelegate.verifyUnlock(callback); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4701 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4702 | } |
| 4703 | |
Mike Lockwood | f791330 | 2009-11-28 22:27:10 -0500 | [diff] [blame] | 4704 | private boolean keyguardIsShowingTq() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4705 | if (mKeyguardDelegate == null) return false; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4706 | return mKeyguardDelegate.isShowingAndNotOccluded(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4707 | } |
| 4708 | |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4709 | |
| 4710 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4711 | @Override |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4712 | public boolean isKeyguardLocked() { |
| 4713 | return keyguardOn(); |
| 4714 | } |
| 4715 | |
| 4716 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4717 | @Override |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4718 | public boolean isKeyguardSecure() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4719 | if (mKeyguardDelegate == null) return false; |
| 4720 | return mKeyguardDelegate.isSecure(); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 4721 | } |
| 4722 | |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4723 | // Returns true if keyguard is currently locked whether or not it is currently hidden. |
| 4724 | private boolean isKeyguardSecureIncludingHidden() { |
| 4725 | return mKeyguardDelegate.isSecure() && mKeyguardDelegate.isShowing(); |
| 4726 | } |
| 4727 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4728 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4729 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4730 | public boolean inKeyguardRestrictedKeyInputMode() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4731 | if (mKeyguardDelegate == null) return false; |
| 4732 | return mKeyguardDelegate.isInputRestricted(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4733 | } |
| 4734 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4735 | @Override |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4736 | public void dismissKeyguardLw() { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 4737 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4738 | mHandler.post(new Runnable() { |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4739 | @Override |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4740 | public void run() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4741 | if (mKeyguardDelegate.isDismissable()) { |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4742 | // Can we just finish the keyguard straight away? |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4743 | mKeyguardDelegate.keyguardDone(false, true); |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4744 | } else { |
| 4745 | // ask the keyguard to prompt the user to authenticate if necessary |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4746 | mKeyguardDelegate.dismiss(); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4747 | } |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 4748 | } |
| 4749 | }); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 4750 | } |
| 4751 | } |
| 4752 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 4753 | private void setKeyguardDrawn() { |
| 4754 | synchronized (mLock) { |
| 4755 | mKeyguardDrawn = true; |
| 4756 | } |
| 4757 | try { |
| 4758 | mWindowManager.enableScreenIfNeeded(); |
| 4759 | } catch (RemoteException unhandled) { |
| 4760 | } |
| 4761 | } |
| 4762 | |
| 4763 | @Override |
| 4764 | public boolean isKeyguardDrawnLw() { |
| 4765 | synchronized (mLock) { |
| 4766 | return mKeyguardDrawn; |
| 4767 | } |
| 4768 | } |
| 4769 | |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4770 | @Override |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 4771 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4772 | if (mKeyguardDelegate != null) { |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 4773 | mKeyguardDelegate.startKeyguardExitAnimation(startTime, fadeoutDuration); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 4774 | } |
| 4775 | } |
| 4776 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4777 | void sendCloseSystemWindows() { |
| 4778 | sendCloseSystemWindows(mContext, null); |
| 4779 | } |
| 4780 | |
| 4781 | void sendCloseSystemWindows(String reason) { |
| 4782 | sendCloseSystemWindows(mContext, reason); |
| 4783 | } |
| 4784 | |
| 4785 | static void sendCloseSystemWindows(Context context, String reason) { |
| 4786 | if (ActivityManagerNative.isSystemReady()) { |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 4787 | try { |
| 4788 | ActivityManagerNative.getDefault().closeSystemDialogs(reason); |
| 4789 | } catch (RemoteException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4790 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4791 | } |
| 4792 | } |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 4793 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4794 | @Override |
| 4795 | public int rotationForOrientationLw(int orientation, int lastRotation) { |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4796 | if (false) { |
| 4797 | Slog.v(TAG, "rotationForOrientationLw(orient=" |
| 4798 | + orientation + ", last=" + lastRotation |
| 4799 | + "); user=" + mUserRotation + " " |
| 4800 | + ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) |
| 4801 | ? "USER_ROTATION_LOCKED" : "") |
| 4802 | ); |
| 4803 | } |
| 4804 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 4805 | if (mForceDefaultOrientation) { |
| 4806 | return Surface.ROTATION_0; |
| 4807 | } |
| 4808 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4809 | synchronized (mLock) { |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4810 | int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 |
| 4811 | if (sensorRotation < 0) { |
Jeff Brown | 0f862b4 | 2012-09-27 21:11:01 -0700 | [diff] [blame] | 4812 | sensorRotation = lastRotation; |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4813 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4814 | |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4815 | final int preferredRotation; |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 4816 | if (mLidState == LID_OPEN && mLidOpenRotation >= 0) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4817 | // Ignore sensor when lid switch is open and rotation is forced. |
| 4818 | preferredRotation = mLidOpenRotation; |
| 4819 | } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4820 | && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4821 | // Ignore sensor when in car dock unless explicitly enabled. |
| 4822 | // This case can override the behavior of NOSENSOR, and can also |
| 4823 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4824 | preferredRotation = mCarDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4825 | ? sensorRotation : mCarDockRotation; |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 4826 | } else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 4827 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 4828 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4829 | && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4830 | // Ignore sensor when in desk dock unless explicitly enabled. |
| 4831 | // This case can override the behavior of NOSENSOR, and can also |
| 4832 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4833 | preferredRotation = mDeskDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4834 | ? sensorRotation : mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4835 | } else if (mHdmiPlugged && mDemoHdmiRotationLock) { |
| 4836 | // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled. |
Jeff Brown | eb3e4b9 | 2011-12-06 19:54:24 -0800 | [diff] [blame] | 4837 | // Note that the dock orientation overrides the HDMI orientation. |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 4838 | preferredRotation = mDemoHdmiRotation; |
| 4839 | } else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED |
| 4840 | && mUndockedHdmiRotation >= 0) { |
| 4841 | // Ignore sensor when plugged into HDMI and an undocked orientation has |
| 4842 | // been specified in the configuration (only for legacy devices without |
| 4843 | // full multi-display support). |
| 4844 | // Note that the dock orientation overrides the HDMI orientation. |
| 4845 | preferredRotation = mUndockedHdmiRotation; |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4846 | } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { |
| 4847 | // Application just wants to remain locked in the last rotation. |
| 4848 | preferredRotation = lastRotation; |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 4849 | } else if (!mSupportAutoRotation) { |
| 4850 | // If we don't support auto-rotation then bail out here and ignore |
| 4851 | // the sensor and any rotation lock settings. |
| 4852 | preferredRotation = -1; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4853 | } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4854 | && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4855 | || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED |
| 4856 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE |
| 4857 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT |
| 4858 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER)) |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4859 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 4860 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4861 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 4862 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { |
| 4863 | // Otherwise, use sensor only if requested by the application or enabled |
| 4864 | // by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR. |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4865 | if (mAllowAllRotations < 0) { |
| 4866 | // Can't read this during init() because the context doesn't |
| 4867 | // have display metrics at that time so we cannot determine |
| 4868 | // tablet vs. phone then. |
| 4869 | mAllowAllRotations = mContext.getResources().getBoolean( |
| 4870 | com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; |
| 4871 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4872 | if (sensorRotation != Surface.ROTATION_180 |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 4873 | || mAllowAllRotations == 1 |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4874 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 4875 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4876 | preferredRotation = sensorRotation; |
| 4877 | } else { |
| 4878 | preferredRotation = lastRotation; |
| 4879 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 4880 | } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED |
| 4881 | && orientation != ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { |
| 4882 | // Apply rotation lock. Does not apply to NOSENSOR. |
| 4883 | // The idea is that the user rotation expresses a weak preference for the direction |
| 4884 | // of gravity and as NOSENSOR is never affected by gravity, then neither should |
| 4885 | // 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] | 4886 | preferredRotation = mUserRotation; |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4887 | } else { |
| 4888 | // No overriding preference. |
| 4889 | // We will do exactly what the application asked us to do. |
| 4890 | preferredRotation = -1; |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4891 | } |
| 4892 | |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4893 | switch (orientation) { |
| 4894 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4895 | // Return portrait unless overridden. |
| 4896 | if (isAnyPortrait(preferredRotation)) { |
| 4897 | return preferredRotation; |
| 4898 | } |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4899 | return mPortraitRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4900 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4901 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4902 | // Return landscape unless overridden. |
| 4903 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4904 | return preferredRotation; |
| 4905 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4906 | return mLandscapeRotation; |
| 4907 | |
| 4908 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4909 | // Return reverse portrait unless overridden. |
| 4910 | if (isAnyPortrait(preferredRotation)) { |
| 4911 | return preferredRotation; |
| 4912 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4913 | return mUpsideDownRotation; |
| 4914 | |
| 4915 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 4916 | // Return seascape unless overridden. |
| 4917 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4918 | return preferredRotation; |
| 4919 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4920 | return mSeascapeRotation; |
| 4921 | |
| 4922 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4923 | case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4924 | // Return either landscape rotation. |
| 4925 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 4926 | return preferredRotation; |
| 4927 | } |
| 4928 | if (isLandscapeOrSeascape(lastRotation)) { |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 4929 | return lastRotation; |
| 4930 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4931 | return mLandscapeRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4932 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4933 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 4934 | case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4935 | // Return either portrait rotation. |
| 4936 | if (isAnyPortrait(preferredRotation)) { |
| 4937 | return preferredRotation; |
| 4938 | } |
| 4939 | if (isAnyPortrait(lastRotation)) { |
| 4940 | return lastRotation; |
| 4941 | } |
| 4942 | return mPortraitRotation; |
| 4943 | |
| 4944 | default: |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 4945 | // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, |
| 4946 | // just return the preferred orientation we already calculated. |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4947 | if (preferredRotation >= 0) { |
| 4948 | return preferredRotation; |
| 4949 | } |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 4950 | return Surface.ROTATION_0; |
Daniel Sandler | e7e5ac2 | 2011-02-22 16:10:21 -0500 | [diff] [blame] | 4951 | } |
| 4952 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4953 | } |
| 4954 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4955 | @Override |
| 4956 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation) { |
| 4957 | switch (orientation) { |
| 4958 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
| 4959 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
| 4960 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
| 4961 | return isAnyPortrait(rotation); |
| 4962 | |
| 4963 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
| 4964 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
| 4965 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
| 4966 | return isLandscapeOrSeascape(rotation); |
| 4967 | |
| 4968 | default: |
| 4969 | return true; |
| 4970 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 4971 | } |
| 4972 | |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 4973 | @Override |
| 4974 | public void setRotationLw(int rotation) { |
| 4975 | mOrientationListener.setCurrentRotation(rotation); |
| 4976 | } |
| 4977 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4978 | private boolean isLandscapeOrSeascape(int rotation) { |
| 4979 | return rotation == mLandscapeRotation || rotation == mSeascapeRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4980 | } |
| 4981 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4982 | private boolean isAnyPortrait(int rotation) { |
| 4983 | return rotation == mPortraitRotation || rotation == mUpsideDownRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 4984 | } |
| 4985 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4986 | @Override |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4987 | public int getUserRotationMode() { |
| 4988 | return Settings.System.getIntForUser(mContext.getContentResolver(), |
Brett Chabot | 7e55c40 | 2013-05-16 19:38:08 -0700 | [diff] [blame] | 4989 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
| 4990 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 4991 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 4992 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4993 | |
| 4994 | // 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] | 4995 | @Override |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 4996 | public void setUserRotationMode(int mode, int rot) { |
| 4997 | ContentResolver res = mContext.getContentResolver(); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4998 | |
| 4999 | // mUserRotationMode and mUserRotation will be assigned by the content observer |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5000 | if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5001 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5002 | Settings.System.USER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5003 | rot, |
| 5004 | UserHandle.USER_CURRENT); |
| 5005 | Settings.System.putIntForUser(res, |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 5006 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5007 | 0, |
| 5008 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5009 | } else { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5010 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5011 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5012 | 1, |
| 5013 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5014 | } |
| 5015 | } |
| 5016 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5017 | @Override |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 5018 | public void setSafeMode(boolean safeMode) { |
| 5019 | mSafeMode = safeMode; |
| 5020 | performHapticFeedbackLw(null, safeMode |
| 5021 | ? HapticFeedbackConstants.SAFE_MODE_ENABLED |
| 5022 | : HapticFeedbackConstants.SAFE_MODE_DISABLED, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5023 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5024 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 5025 | static long[] getLongIntArray(Resources r, int resid) { |
| 5026 | int[] ar = r.getIntArray(resid); |
| 5027 | if (ar == null) { |
| 5028 | return null; |
| 5029 | } |
| 5030 | long[] out = new long[ar.length]; |
| 5031 | for (int i=0; i<ar.length; i++) { |
| 5032 | out[i] = ar[i]; |
| 5033 | } |
| 5034 | return out; |
| 5035 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5036 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5037 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5038 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5039 | public void systemReady() { |
Mike Lockwood | ed8902d | 2013-11-15 11:01:47 -0800 | [diff] [blame] | 5040 | mKeyguardDelegate = new KeyguardServiceDelegate(mContext, null); |
| 5041 | mKeyguardDelegate.onSystemReady(); |
| 5042 | |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 5043 | updateUiMode(); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5044 | synchronized (mLock) { |
| 5045 | updateOrientationListenerLp(); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 5046 | mSystemReady = true; |
| 5047 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5048 | @Override |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 5049 | public void run() { |
| 5050 | updateSettings(); |
| 5051 | } |
| 5052 | }); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5053 | } |
| 5054 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5055 | |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5056 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5057 | @Override |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5058 | public void systemBooted() { |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 5059 | if (mKeyguardDelegate != null) { |
| 5060 | mKeyguardDelegate.onBootCompleted(); |
| 5061 | } |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5062 | synchronized (mLock) { |
| 5063 | mSystemBooted = true; |
| 5064 | } |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 5065 | wakingUp(null); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5066 | } |
| 5067 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5068 | ProgressDialog mBootMsgDialog = null; |
| 5069 | |
| 5070 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5071 | @Override |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5072 | public void showBootMessage(final CharSequence msg, final boolean always) { |
| 5073 | mHandler.post(new Runnable() { |
| 5074 | @Override public void run() { |
| 5075 | if (mBootMsgDialog == null) { |
Craig Stout | 4c0cb8a | 2014-04-04 13:03:10 -0700 | [diff] [blame] | 5076 | int theme; |
| 5077 | if (mContext.getPackageManager().hasSystemFeature( |
| 5078 | PackageManager.FEATURE_WATCH)) { |
| 5079 | theme = com.android.internal.R.style.Theme_Micro_Dialog_Alert; |
| 5080 | } else if (mContext.getPackageManager().hasSystemFeature( |
| 5081 | PackageManager.FEATURE_TELEVISION)) { |
| 5082 | theme = com.android.internal.R.style.Theme_Leanback_Dialog_Alert; |
| 5083 | } else { |
| 5084 | theme = 0; |
| 5085 | } |
Vinod Krishnan | fa8fc41 | 2014-04-18 14:35:53 -0700 | [diff] [blame] | 5086 | |
| 5087 | mBootMsgDialog = new ProgressDialog(mContext, theme) { |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 5088 | // This dialog will consume all events coming in to |
| 5089 | // it, to avoid it trying to do things too early in boot. |
| 5090 | @Override public boolean dispatchKeyEvent(KeyEvent event) { |
| 5091 | return true; |
| 5092 | } |
| 5093 | @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 5094 | return true; |
| 5095 | } |
| 5096 | @Override public boolean dispatchTouchEvent(MotionEvent ev) { |
| 5097 | return true; |
| 5098 | } |
| 5099 | @Override public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 5100 | return true; |
| 5101 | } |
| 5102 | @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 5103 | return true; |
| 5104 | } |
| 5105 | @Override public boolean dispatchPopulateAccessibilityEvent( |
| 5106 | AccessibilityEvent event) { |
| 5107 | return true; |
| 5108 | } |
| 5109 | }; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5110 | mBootMsgDialog.setTitle(R.string.android_upgrading_title); |
| 5111 | mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); |
| 5112 | mBootMsgDialog.setIndeterminate(true); |
| 5113 | mBootMsgDialog.getWindow().setType( |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 5114 | WindowManager.LayoutParams.TYPE_BOOT_PROGRESS); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5115 | mBootMsgDialog.getWindow().addFlags( |
| 5116 | WindowManager.LayoutParams.FLAG_DIM_BEHIND |
| 5117 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); |
| 5118 | mBootMsgDialog.getWindow().setDimAmount(1); |
Dianne Hackborn | d9efb95 | 2011-12-07 14:56:51 -0800 | [diff] [blame] | 5119 | WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes(); |
| 5120 | lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 5121 | mBootMsgDialog.getWindow().setAttributes(lp); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5122 | mBootMsgDialog.setCancelable(false); |
| 5123 | mBootMsgDialog.show(); |
| 5124 | } |
| 5125 | mBootMsgDialog.setMessage(msg); |
| 5126 | } |
| 5127 | }); |
| 5128 | } |
| 5129 | |
| 5130 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5131 | @Override |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5132 | public void hideBootMessages() { |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 5133 | mHandler.sendEmptyMessage(MSG_HIDE_BOOT_MESSAGE); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5134 | } |
| 5135 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5136 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5137 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5138 | public void userActivity() { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5139 | // *************************************** |
| 5140 | // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE |
| 5141 | // *************************************** |
| 5142 | // THIS IS CALLED FROM DEEP IN THE POWER MANAGER |
| 5143 | // WITH ITS LOCKS HELD. |
| 5144 | // |
| 5145 | // This code must be VERY careful about the locks |
| 5146 | // it acquires. |
| 5147 | // In fact, the current code acquires way too many, |
| 5148 | // and probably has lurking deadlocks. |
| 5149 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5150 | synchronized (mScreenLockTimeout) { |
| 5151 | if (mLockScreenTimerActive) { |
| 5152 | // reset the timer |
| 5153 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 5154 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 5155 | } |
| 5156 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 5157 | } |
| 5158 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5159 | class ScreenLockTimeout implements Runnable { |
| 5160 | Bundle options; |
| 5161 | |
| 5162 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5163 | public void run() { |
| 5164 | synchronized (this) { |
| 5165 | if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5166 | if (mKeyguardDelegate != null) { |
| 5167 | mKeyguardDelegate.doKeyguardTimeout(options); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 5168 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5169 | mLockScreenTimerActive = false; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5170 | options = null; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5171 | } |
| 5172 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5173 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5174 | public void setLockOptions(Bundle options) { |
| 5175 | this.options = options; |
| 5176 | } |
| 5177 | } |
| 5178 | |
| 5179 | ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout(); |
| 5180 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5181 | @Override |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5182 | public void lockNow(Bundle options) { |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 5183 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); |
| 5184 | mHandler.removeCallbacks(mScreenLockTimeout); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5185 | if (options != null) { |
| 5186 | // In case multiple calls are made to lockNow, we don't wipe out the options |
| 5187 | // until the runnable actually executes. |
| 5188 | mScreenLockTimeout.setLockOptions(options); |
| 5189 | } |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 5190 | mHandler.post(mScreenLockTimeout); |
| 5191 | } |
| 5192 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5193 | private void updateLockScreenTimeout() { |
| 5194 | synchronized (mScreenLockTimeout) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 5195 | boolean enable = (mAllowLockscreenWhenOn && mScreenOnEarly && |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5196 | mKeyguardDelegate != null && mKeyguardDelegate.isSecure()); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5197 | if (mLockScreenTimerActive != enable) { |
| 5198 | if (enable) { |
| 5199 | if (localLOGV) Log.v(TAG, "setting lockscreen timer"); |
| 5200 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 5201 | } else { |
| 5202 | if (localLOGV) Log.v(TAG, "clearing lockscreen timer"); |
| 5203 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 5204 | } |
| 5205 | mLockScreenTimerActive = enable; |
| 5206 | } |
| 5207 | } |
| 5208 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5209 | |
| 5210 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5211 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5212 | public void enableScreenAfterBoot() { |
| 5213 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5214 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5215 | updateRotation(true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5216 | } |
Dianne Hackborn | f54c8f9 | 2009-09-19 14:03:57 -0700 | [diff] [blame] | 5217 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5218 | private void applyLidSwitchState() { |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5219 | if (mLidState == LID_CLOSED && mLidControlsSleep) { |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 5220 | mPowerManager.goToSleep(SystemClock.uptimeMillis(), |
| 5221 | PowerManager.GO_TO_SLEEP_REASON_USER, |
| 5222 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5223 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5224 | |
| 5225 | synchronized (mLock) { |
| 5226 | updateWakeGestureListenerLp(); |
| 5227 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5228 | } |
| 5229 | |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 5230 | void updateUiMode() { |
| 5231 | if (mUiModeManager == null) { |
| 5232 | mUiModeManager = IUiModeManager.Stub.asInterface( |
| 5233 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 5234 | } |
| 5235 | try { |
| 5236 | mUiMode = mUiModeManager.getCurrentModeType(); |
| 5237 | } catch (RemoteException e) { |
| 5238 | } |
| 5239 | } |
| 5240 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5241 | void updateRotation(boolean alwaysSendConfiguration) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5242 | try { |
| 5243 | //set orientation on WindowManager |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 5244 | mWindowManager.updateRotation(alwaysSendConfiguration, false); |
| 5245 | } catch (RemoteException e) { |
| 5246 | // Ignore |
| 5247 | } |
| 5248 | } |
| 5249 | |
| 5250 | void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout) { |
| 5251 | try { |
| 5252 | //set orientation on WindowManager |
| 5253 | mWindowManager.updateRotation(alwaysSendConfiguration, forceRelayout); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5254 | } catch (RemoteException e) { |
| 5255 | // Ignore |
| 5256 | } |
| 5257 | } |
| 5258 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5259 | /** |
| 5260 | * Return an Intent to launch the currently active dock app as home. Returns |
| 5261 | * null if the standard home should be launched, which is the case if any of the following is |
| 5262 | * true: |
| 5263 | * <ul> |
| 5264 | * <li>The device is not in either car mode or desk mode |
| 5265 | * <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false |
| 5266 | * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false |
| 5267 | * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME |
| 5268 | * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME |
| 5269 | * </ul> |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5270 | * @return A dock intent. |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5271 | */ |
| 5272 | Intent createHomeDockIntent() { |
| 5273 | Intent intent = null; |
| 5274 | |
| 5275 | // What home does is based on the mode, not the dock state. That |
| 5276 | // is, when in car mode you should be taken to car home regardless |
| 5277 | // of whether we are actually in a car dock. |
| 5278 | if (mUiMode == Configuration.UI_MODE_TYPE_CAR) { |
| 5279 | if (ENABLE_CAR_DOCK_HOME_CAPTURE) { |
| 5280 | intent = mCarDockIntent; |
| 5281 | } |
| 5282 | } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { |
| 5283 | if (ENABLE_DESK_DOCK_HOME_CAPTURE) { |
| 5284 | intent = mDeskDockIntent; |
| 5285 | } |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 5286 | } else if (mUiMode == Configuration.UI_MODE_TYPE_WATCH |
| 5287 | && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 5288 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK |
| 5289 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK)) { |
| 5290 | // Always launch dock home from home when watch is docked, if it exists. |
| 5291 | intent = mDeskDockIntent; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5292 | } |
| 5293 | |
| 5294 | if (intent == null) { |
| 5295 | return null; |
| 5296 | } |
| 5297 | |
| 5298 | ActivityInfo ai = null; |
| 5299 | ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser( |
| 5300 | intent, |
John Spurlock | f56bef1 | 2013-07-09 09:51:46 -0400 | [diff] [blame] | 5301 | PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 5302 | mCurrentUserId); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5303 | if (info != null) { |
| 5304 | ai = info.activityInfo; |
| 5305 | } |
| 5306 | if (ai != null |
| 5307 | && ai.metaData != null |
| 5308 | && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { |
| 5309 | intent = new Intent(intent); |
| 5310 | intent.setClassName(ai.packageName, ai.name); |
| 5311 | return intent; |
| 5312 | } |
| 5313 | |
| 5314 | return null; |
| 5315 | } |
| 5316 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5317 | void startDockOrHome() { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 5318 | awakenDreams(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5319 | |
| 5320 | Intent dock = createHomeDockIntent(); |
| 5321 | if (dock != null) { |
| 5322 | try { |
| 5323 | mContext.startActivityAsUser(dock, UserHandle.CURRENT); |
| 5324 | return; |
| 5325 | } catch (ActivityNotFoundException e) { |
| 5326 | } |
| 5327 | } |
| 5328 | |
Dianne Hackborn | d888399 | 2012-09-07 15:58:52 -0700 | [diff] [blame] | 5329 | mContext.startActivityAsUser(mHomeIntent, UserHandle.CURRENT); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5330 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5331 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5332 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5333 | * goes to the home screen |
| 5334 | * @return whether it did anything |
| 5335 | */ |
| 5336 | boolean goHome() { |
| 5337 | if (false) { |
| 5338 | // This code always brings home to the front. |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 5339 | try { |
| 5340 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 5341 | } catch (RemoteException e) { |
| 5342 | } |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 5343 | sendCloseSystemWindows(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5344 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5345 | } else { |
| 5346 | // This code brings home to the front or, if it is already |
| 5347 | // at the front, puts the device to sleep. |
| 5348 | try { |
Wink Saville | d2e6a33 | 2010-02-12 12:12:06 -0800 | [diff] [blame] | 5349 | if (SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1) { |
| 5350 | /// Roll back EndcallBehavior as the cupcake design to pass P1 lab entry. |
| 5351 | Log.d(TAG, "UTS-TEST-MODE"); |
| 5352 | } else { |
| 5353 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 5354 | sendCloseSystemWindows(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5355 | Intent dock = createHomeDockIntent(); |
| 5356 | if (dock != null) { |
| 5357 | int result = ActivityManagerNative.getDefault() |
| 5358 | .startActivityAsUser(null, null, dock, |
| 5359 | dock.resolveTypeIfNeeded(mContext.getContentResolver()), |
| 5360 | null, null, 0, |
| 5361 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
| 5362 | null, null, null, UserHandle.USER_CURRENT); |
| 5363 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
| 5364 | return false; |
| 5365 | } |
| 5366 | } |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5367 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5368 | int result = ActivityManagerNative.getDefault() |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5369 | .startActivityAsUser(null, null, mHomeIntent, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5370 | mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 5371 | null, null, 0, |
| 5372 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
Dianne Hackborn | 5e03e2c | 2012-09-06 14:21:19 -0700 | [diff] [blame] | 5373 | null, null, null, UserHandle.USER_CURRENT); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 5374 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5375 | return false; |
| 5376 | } |
| 5377 | } catch (RemoteException ex) { |
| 5378 | // bummer, the activity manager, which is in this process, is dead |
| 5379 | } |
| 5380 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5381 | return true; |
| 5382 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5383 | |
| 5384 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5385 | public void setCurrentOrientationLw(int newOrientation) { |
| 5386 | synchronized (mLock) { |
| 5387 | if (newOrientation != mCurrentAppOrientation) { |
| 5388 | mCurrentAppOrientation = newOrientation; |
| 5389 | updateOrientationListenerLp(); |
| 5390 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5391 | } |
| 5392 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5393 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5394 | private void performAuditoryFeedbackForAccessibilityIfNeed() { |
| 5395 | if (!isGlobalAccessibilityGestureEnabled()) { |
| 5396 | return; |
| 5397 | } |
| 5398 | AudioManager audioManager = (AudioManager) mContext.getSystemService( |
| 5399 | Context.AUDIO_SERVICE); |
| 5400 | if (audioManager.isSilentMode()) { |
| 5401 | return; |
| 5402 | } |
| 5403 | Ringtone ringTone = RingtoneManager.getRingtone(mContext, |
| 5404 | Settings.System.DEFAULT_NOTIFICATION_URI); |
| 5405 | ringTone.setStreamType(AudioManager.STREAM_MUSIC); |
| 5406 | ringTone.play(); |
| 5407 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5408 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5409 | private boolean isGlobalAccessibilityGestureEnabled() { |
| 5410 | return Settings.Global.getInt(mContext.getContentResolver(), |
| 5411 | Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1; |
| 5412 | } |
| 5413 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5414 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5415 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { |
Svetoslav Ganov | 9617921 | 2012-10-10 14:17:45 -0700 | [diff] [blame] | 5416 | if (!mVibrator.hasVibrator()) { |
| 5417 | return false; |
| 5418 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5419 | final boolean hapticsDisabled = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 5420 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) == 0; |
Jeff Brown | 82379ba | 2014-07-25 19:03:28 -0700 | [diff] [blame] | 5421 | if (hapticsDisabled && !always) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5422 | return false; |
| 5423 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5424 | long[] pattern = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5425 | switch (effectId) { |
| 5426 | case HapticFeedbackConstants.LONG_PRESS: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5427 | pattern = mLongPressVibePattern; |
| 5428 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5429 | case HapticFeedbackConstants.VIRTUAL_KEY: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5430 | pattern = mVirtualKeyVibePattern; |
| 5431 | break; |
| 5432 | case HapticFeedbackConstants.KEYBOARD_TAP: |
| 5433 | pattern = mKeyboardTapVibePattern; |
| 5434 | break; |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 5435 | case HapticFeedbackConstants.CLOCK_TICK: |
| 5436 | pattern = mClockTickVibePattern; |
| 5437 | break; |
Fabrice Di Meglio | bd9152f | 2013-10-01 11:21:31 -0700 | [diff] [blame] | 5438 | case HapticFeedbackConstants.CALENDAR_DATE: |
| 5439 | pattern = mCalendarDateVibePattern; |
| 5440 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5441 | case HapticFeedbackConstants.SAFE_MODE_DISABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5442 | pattern = mSafeModeDisabledVibePattern; |
| 5443 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5444 | case HapticFeedbackConstants.SAFE_MODE_ENABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5445 | pattern = mSafeModeEnabledVibePattern; |
| 5446 | break; |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5447 | default: |
| 5448 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5449 | } |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5450 | int owningUid; |
| 5451 | String owningPackage; |
| 5452 | if (win != null) { |
| 5453 | owningUid = win.getOwningUid(); |
| 5454 | owningPackage = win.getOwningPackage(); |
| 5455 | } else { |
| 5456 | owningUid = android.os.Process.myUid(); |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 5457 | owningPackage = mContext.getOpPackageName(); |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5458 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5459 | if (pattern.length == 1) { |
| 5460 | // One-shot vibration |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 5461 | mVibrator.vibrate(owningUid, owningPackage, pattern[0], VIBRATION_ATTRIBUTES); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5462 | } else { |
| 5463 | // Pattern vibration |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 5464 | mVibrator.vibrate(owningUid, owningPackage, pattern, -1, VIBRATION_ATTRIBUTES); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5465 | } |
| 5466 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5467 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5468 | |
| 5469 | @Override |
| 5470 | public void keepScreenOnStartedLw() { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 5471 | } |
| 5472 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5473 | @Override |
| 5474 | public void keepScreenOnStoppedLw() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5475 | if (mKeyguardDelegate != null && !mKeyguardDelegate.isShowingAndNotOccluded()) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 5476 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5477 | } |
| 5478 | } |
Mike Lockwood | fcb3924 | 2009-10-21 23:01:07 -0400 | [diff] [blame] | 5479 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5480 | private int updateSystemUiVisibilityLw() { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5481 | // If there is no window focused, there will be nobody to handle the events |
| 5482 | // 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] | 5483 | WindowState win = mFocusedWindow != null ? mFocusedWindow : mTopFullscreenOpaqueWindowState; |
| 5484 | if (win == null) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5485 | return 0; |
| 5486 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5487 | if ((win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 && mHideLockScreen == true) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5488 | // We are updating at a point where the keyguard has gotten |
| 5489 | // focus, but we were last in a state where the top window is |
| 5490 | // hiding it. This is probably because the keyguard as been |
| 5491 | // shown while the top window was displayed, so we want to ignore |
| 5492 | // it here because this is just a very transient change and it |
| 5493 | // will quickly lose focus once it correctly gets hidden. |
| 5494 | return 0; |
| 5495 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 5496 | |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 5497 | int tmpVisibility = PolicyControl.getSystemUiVisibility(win, null) |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5498 | & ~mResettingSystemUiFlags |
| 5499 | & ~mForceClearedSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5500 | if (mForcingShowNavBar && win.getSurfaceLayer() < mForcingShowNavBarLayer) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5501 | tmpVisibility &= ~PolicyControl.adjustClearableFlags(win, View.SYSTEM_UI_CLEARABLE_FLAGS); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5502 | } |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5503 | final int visibility = updateSystemBarsLw(win, mLastSystemUiFlags, tmpVisibility); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5504 | final int diff = visibility ^ mLastSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5505 | final boolean needsMenu = win.getNeedsMenuLw(mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 5506 | if (diff == 0 && mLastFocusNeedsMenu == needsMenu |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5507 | && mFocusedApp == win.getAppToken()) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5508 | return 0; |
| 5509 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5510 | mLastSystemUiFlags = visibility; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5511 | mLastFocusNeedsMenu = needsMenu; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5512 | mFocusedApp = win.getAppToken(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5513 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5514 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5515 | public void run() { |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5516 | try { |
| 5517 | IStatusBarService statusbar = getStatusBarService(); |
| 5518 | if (statusbar != null) { |
| 5519 | statusbar.setSystemUiVisibility(visibility, 0xffffffff); |
| 5520 | statusbar.topAppWindowChanged(needsMenu); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5521 | } |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 5522 | } catch (RemoteException e) { |
| 5523 | // re-acquire status bar service next time it is needed. |
| 5524 | mStatusBarService = null; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5525 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5526 | } |
| 5527 | }); |
| 5528 | return diff; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 5529 | } |
| 5530 | |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5531 | private int updateSystemBarsLw(WindowState win, int oldVis, int vis) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5532 | // apply translucent bar vis flags |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5533 | WindowState transWin = isStatusBarKeyguard() && !mHideLockScreen |
| 5534 | ? mStatusBar |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5535 | : mTopFullscreenOpaqueWindowState; |
| 5536 | vis = mStatusBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 5537 | vis = mNavigationBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 5538 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5539 | // prevent status bar interaction from clearing certain flags |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5540 | boolean statusBarHasFocus = win.getAttrs().type == TYPE_STATUS_BAR; |
John Spurlock | 08ffcf5 | 2014-07-11 10:13:46 -0400 | [diff] [blame] | 5541 | if (statusBarHasFocus && !isStatusBarKeyguard()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5542 | int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
| 5543 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 5544 | | View.SYSTEM_UI_FLAG_IMMERSIVE |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5545 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
John Spurlock | 08ffcf5 | 2014-07-11 10:13:46 -0400 | [diff] [blame] | 5546 | if (mHideLockScreen) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 5547 | flags |= View.STATUS_BAR_TRANSLUCENT | View.NAVIGATION_BAR_TRANSLUCENT; |
| 5548 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5549 | vis = (vis & ~flags) | (oldVis & flags); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5550 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5551 | |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5552 | if (!areTranslucentBarsAllowed()) { |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 5553 | vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT |
| 5554 | | View.SYSTEM_UI_TRANSPARENT); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5555 | } |
| 5556 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5557 | // update status bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5558 | boolean immersiveSticky = |
| 5559 | (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5560 | boolean hideStatusBarWM = |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 5561 | mTopFullscreenOpaqueWindowState != null && |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5562 | (PolicyControl.getWindowFlags(mTopFullscreenOpaqueWindowState, null) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5563 | & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; |
| 5564 | boolean hideStatusBarSysui = |
| 5565 | (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5566 | boolean hideNavBarSysui = |
| 5567 | (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5568 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5569 | boolean transientStatusBarAllowed = |
| 5570 | mStatusBar != null && ( |
| 5571 | hideStatusBarWM |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5572 | || (hideStatusBarSysui && immersiveSticky) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5573 | || statusBarHasFocus); |
| 5574 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5575 | boolean transientNavBarAllowed = |
| 5576 | mNavigationBar != null && |
| 5577 | hideNavBarSysui && immersiveSticky; |
| 5578 | |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 5579 | boolean denyTransientStatus = mStatusBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5580 | && !transientStatusBarAllowed && hideStatusBarSysui; |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 5581 | boolean denyTransientNav = mNavigationBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5582 | && !transientNavBarAllowed; |
| 5583 | if (denyTransientStatus || denyTransientNav) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5584 | // clear the clearable flags instead |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5585 | clearClearableFlagsLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5586 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5587 | |
| 5588 | vis = mStatusBarController.updateVisibilityLw(transientStatusBarAllowed, oldVis, vis); |
| 5589 | |
| 5590 | // update navigation bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5591 | boolean oldImmersiveMode = isImmersiveMode(oldVis); |
| 5592 | boolean newImmersiveMode = isImmersiveMode(vis); |
| 5593 | if (win != null && oldImmersiveMode != newImmersiveMode) { |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 5594 | final String pkg = win.getOwningPackage(); |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 5595 | mImmersiveModeConfirmation.immersiveModeChanged(pkg, newImmersiveMode, |
| 5596 | isUserSetupComplete()); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5597 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5598 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5599 | vis = mNavigationBarController.updateVisibilityLw(transientNavBarAllowed, oldVis, vis); |
| 5600 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 5601 | return vis; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5602 | } |
| 5603 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5604 | private void clearClearableFlagsLw() { |
| 5605 | int newVal = mResettingSystemUiFlags | View.SYSTEM_UI_CLEARABLE_FLAGS; |
| 5606 | if (newVal != mResettingSystemUiFlags) { |
| 5607 | mResettingSystemUiFlags = newVal; |
| 5608 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 5609 | } |
| 5610 | } |
| 5611 | |
| 5612 | private boolean isImmersiveMode(int vis) { |
| 5613 | 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] | 5614 | return mNavigationBar != null |
| 5615 | && (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0 |
Daniel Sandler | 900ece5 | 2013-10-18 15:53:27 -0400 | [diff] [blame] | 5616 | && (vis & flags) != 0 |
| 5617 | && canHideNavigationBar(); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 5618 | } |
| 5619 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5620 | /** |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5621 | * @return whether the navigation or status bar can be made translucent |
| 5622 | * |
| 5623 | * This should return true unless touch exploration is not enabled or |
| 5624 | * R.boolean.config_enableTranslucentDecor is false. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5625 | */ |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 5626 | private boolean areTranslucentBarsAllowed() { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 5627 | return mTranslucentDecorEnabled |
| 5628 | && !mAccessibilityManager.isTouchExplorationEnabled(); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 5629 | } |
| 5630 | |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5631 | // Use this instead of checking config_showNavigationBar so that it can be consistently |
| 5632 | // overridden by qemu.hw.mainkeys in the emulator. |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5633 | @Override |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 5634 | public boolean hasNavigationBar() { |
| 5635 | return mHasNavigationBar; |
| 5636 | } |
| 5637 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 5638 | @Override |
| 5639 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target) { |
| 5640 | mLastInputMethodWindow = ime; |
| 5641 | mLastInputMethodTargetWindow = target; |
| 5642 | } |
| 5643 | |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5644 | @Override |
Satoshi Kataoka | 658c7b8 | 2013-10-10 17:03:51 +0900 | [diff] [blame] | 5645 | public int getInputMethodWindowVisibleHeightLw() { |
| 5646 | return mDockBottom - mCurBottom; |
| 5647 | } |
| 5648 | |
| 5649 | @Override |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5650 | public void setCurrentUserLw(int newUserId) { |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 5651 | mCurrentUserId = newUserId; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5652 | if (mKeyguardDelegate != null) { |
| 5653 | mKeyguardDelegate.setCurrentUser(newUserId); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5654 | } |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 5655 | if (mStatusBarService != null) { |
| 5656 | try { |
| 5657 | mStatusBarService.setCurrentUser(newUserId); |
| 5658 | } catch (RemoteException e) { |
| 5659 | // oh well |
| 5660 | } |
| 5661 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5662 | setLastInputMethodWindowLw(null, null); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 5663 | } |
| 5664 | |
| 5665 | @Override |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 5666 | public boolean canMagnifyWindow(int windowType) { |
| 5667 | switch (windowType) { |
| 5668 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD: |
| 5669 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG: |
| 5670 | case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR: |
| 5671 | case WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY: { |
| 5672 | return false; |
| 5673 | } |
| 5674 | } |
| 5675 | return true; |
| 5676 | } |
| 5677 | |
| 5678 | @Override |
| 5679 | public boolean isTopLevelWindow(int windowType) { |
| 5680 | if (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW |
| 5681 | && windowType <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 5682 | return (windowType == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG); |
| 5683 | } |
| 5684 | return true; |
| 5685 | } |
| 5686 | |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 5687 | @Override |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 5688 | public void dump(String prefix, PrintWriter pw, String[] args) { |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5689 | pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5690 | pw.print(" mSystemReady="); pw.print(mSystemReady); |
| 5691 | pw.print(" mSystemBooted="); pw.println(mSystemBooted); |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 5692 | pw.print(prefix); pw.print("mLidState="); pw.print(mLidState); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5693 | pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); |
| 5694 | pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 5695 | if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 |
| 5696 | || mForceClearedSystemUiFlags != 0) { |
| 5697 | pw.print(prefix); pw.print("mLastSystemUiFlags=0x"); |
| 5698 | pw.print(Integer.toHexString(mLastSystemUiFlags)); |
| 5699 | pw.print(" mResettingSystemUiFlags=0x"); |
| 5700 | pw.print(Integer.toHexString(mResettingSystemUiFlags)); |
| 5701 | pw.print(" mForceClearedSystemUiFlags=0x"); |
| 5702 | pw.println(Integer.toHexString(mForceClearedSystemUiFlags)); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5703 | } |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 5704 | if (mLastFocusNeedsMenu) { |
| 5705 | pw.print(prefix); pw.print("mLastFocusNeedsMenu="); |
| 5706 | pw.println(mLastFocusNeedsMenu); |
| 5707 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5708 | pw.print(prefix); pw.print("mWakeGestureEnabledSetting="); |
| 5709 | pw.println(mWakeGestureEnabledSetting); |
| 5710 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 5711 | pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5712 | pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); |
| 5713 | pw.print(" mDockMode="); pw.print(mDockMode); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5714 | pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); |
| 5715 | pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); |
| 5716 | pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); |
| 5717 | pw.print(" mUserRotation="); pw.print(mUserRotation); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 5718 | pw.print(" mAllowAllRotations="); pw.println(mAllowAllRotations); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5719 | pw.print(prefix); pw.print("mCurrentAppOrientation="); pw.println(mCurrentAppOrientation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5720 | pw.print(prefix); pw.print("mCarDockEnablesAccelerometer="); |
| 5721 | pw.print(mCarDockEnablesAccelerometer); |
| 5722 | pw.print(" mDeskDockEnablesAccelerometer="); |
| 5723 | pw.println(mDeskDockEnablesAccelerometer); |
| 5724 | pw.print(prefix); pw.print("mLidKeyboardAccessibility="); |
| 5725 | pw.print(mLidKeyboardAccessibility); |
| 5726 | pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5727 | pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep); |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 5728 | pw.print(prefix); |
| 5729 | pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior); |
| 5730 | pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior); |
| 5731 | pw.print(prefix); pw.print("mHasSoftInput="); pw.println(mHasSoftInput); |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 5732 | pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly); |
| 5733 | pw.print(" mScreenOnFully="); pw.print(mScreenOnFully); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 5734 | pw.print(" mOrientationSensorEnabled="); pw.println(mOrientationSensorEnabled); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 5735 | pw.print(prefix); pw.print("mOverscanScreen=("); pw.print(mOverscanScreenLeft); |
| 5736 | pw.print(","); pw.print(mOverscanScreenTop); |
| 5737 | pw.print(") "); pw.print(mOverscanScreenWidth); |
| 5738 | pw.print("x"); pw.println(mOverscanScreenHeight); |
| 5739 | if (mOverscanLeft != 0 || mOverscanTop != 0 |
| 5740 | || mOverscanRight != 0 || mOverscanBottom != 0) { |
| 5741 | pw.print(prefix); pw.print("mOverscan left="); pw.print(mOverscanLeft); |
| 5742 | pw.print(" top="); pw.print(mOverscanTop); |
| 5743 | pw.print(" right="); pw.print(mOverscanRight); |
| 5744 | pw.print(" bottom="); pw.println(mOverscanBottom); |
| 5745 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 5746 | pw.print(prefix); pw.print("mRestrictedOverscanScreen=("); |
| 5747 | pw.print(mRestrictedOverscanScreenLeft); |
| 5748 | pw.print(","); pw.print(mRestrictedOverscanScreenTop); |
| 5749 | pw.print(") "); pw.print(mRestrictedOverscanScreenWidth); |
| 5750 | pw.print("x"); pw.println(mRestrictedOverscanScreenHeight); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5751 | pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft); |
| 5752 | pw.print(","); pw.print(mUnrestrictedScreenTop); |
| 5753 | pw.print(") "); pw.print(mUnrestrictedScreenWidth); |
| 5754 | pw.print("x"); pw.println(mUnrestrictedScreenHeight); |
| 5755 | pw.print(prefix); pw.print("mRestrictedScreen=("); pw.print(mRestrictedScreenLeft); |
| 5756 | pw.print(","); pw.print(mRestrictedScreenTop); |
| 5757 | pw.print(") "); pw.print(mRestrictedScreenWidth); |
| 5758 | pw.print("x"); pw.println(mRestrictedScreenHeight); |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 5759 | pw.print(prefix); pw.print("mStableFullscreen=("); pw.print(mStableFullscreenLeft); |
| 5760 | pw.print(","); pw.print(mStableFullscreenTop); |
| 5761 | pw.print(")-("); pw.print(mStableFullscreenRight); |
| 5762 | pw.print(","); pw.print(mStableFullscreenBottom); pw.println(")"); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 5763 | pw.print(prefix); pw.print("mStable=("); pw.print(mStableLeft); |
| 5764 | pw.print(","); pw.print(mStableTop); |
| 5765 | pw.print(")-("); pw.print(mStableRight); |
| 5766 | pw.print(","); pw.print(mStableBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5767 | pw.print(prefix); pw.print("mSystem=("); pw.print(mSystemLeft); |
| 5768 | pw.print(","); pw.print(mSystemTop); |
| 5769 | pw.print(")-("); pw.print(mSystemRight); |
| 5770 | pw.print(","); pw.print(mSystemBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5771 | pw.print(prefix); pw.print("mCur=("); pw.print(mCurLeft); |
| 5772 | pw.print(","); pw.print(mCurTop); |
| 5773 | pw.print(")-("); pw.print(mCurRight); |
| 5774 | pw.print(","); pw.print(mCurBottom); pw.println(")"); |
| 5775 | pw.print(prefix); pw.print("mContent=("); pw.print(mContentLeft); |
| 5776 | pw.print(","); pw.print(mContentTop); |
| 5777 | pw.print(")-("); pw.print(mContentRight); |
| 5778 | pw.print(","); pw.print(mContentBottom); pw.println(")"); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 5779 | pw.print(prefix); pw.print("mVoiceContent=("); pw.print(mVoiceContentLeft); |
| 5780 | pw.print(","); pw.print(mVoiceContentTop); |
| 5781 | pw.print(")-("); pw.print(mVoiceContentRight); |
| 5782 | pw.print(","); pw.print(mVoiceContentBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5783 | pw.print(prefix); pw.print("mDock=("); pw.print(mDockLeft); |
| 5784 | pw.print(","); pw.print(mDockTop); |
| 5785 | pw.print(")-("); pw.print(mDockRight); |
| 5786 | pw.print(","); pw.print(mDockBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 5787 | pw.print(prefix); pw.print("mDockLayer="); pw.print(mDockLayer); |
| 5788 | pw.print(" mStatusBarLayer="); pw.println(mStatusBarLayer); |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5789 | pw.print(prefix); pw.print("mShowingLockscreen="); pw.print(mShowingLockscreen); |
| 5790 | pw.print(" mShowingDream="); pw.print(mShowingDream); |
| 5791 | pw.print(" mDreamingLockscreen="); pw.println(mDreamingLockscreen); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5792 | if (mLastInputMethodWindow != null) { |
| 5793 | pw.print(prefix); pw.print("mLastInputMethodWindow="); |
| 5794 | pw.println(mLastInputMethodWindow); |
| 5795 | } |
| 5796 | if (mLastInputMethodTargetWindow != null) { |
| 5797 | pw.print(prefix); pw.print("mLastInputMethodTargetWindow="); |
| 5798 | pw.println(mLastInputMethodTargetWindow); |
| 5799 | } |
| 5800 | if (mStatusBar != null) { |
| 5801 | pw.print(prefix); pw.print("mStatusBar="); |
| 5802 | pw.println(mStatusBar); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 5803 | pw.print(prefix); pw.print("isStatusBarKeyguard="); |
| 5804 | pw.print(isStatusBarKeyguard()); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5805 | } |
| 5806 | if (mNavigationBar != null) { |
| 5807 | pw.print(prefix); pw.print("mNavigationBar="); |
| 5808 | pw.println(mNavigationBar); |
| 5809 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 5810 | if (mFocusedWindow != null) { |
| 5811 | pw.print(prefix); pw.print("mFocusedWindow="); |
| 5812 | pw.println(mFocusedWindow); |
| 5813 | } |
| 5814 | if (mFocusedApp != null) { |
| 5815 | pw.print(prefix); pw.print("mFocusedApp="); |
| 5816 | pw.println(mFocusedApp); |
| 5817 | } |
| 5818 | if (mWinDismissingKeyguard != null) { |
| 5819 | pw.print(prefix); pw.print("mWinDismissingKeyguard="); |
| 5820 | pw.println(mWinDismissingKeyguard); |
| 5821 | } |
| 5822 | if (mTopFullscreenOpaqueWindowState != null) { |
| 5823 | pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); |
| 5824 | pw.println(mTopFullscreenOpaqueWindowState); |
| 5825 | } |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 5826 | if (mForcingShowNavBar) { |
| 5827 | pw.print(prefix); pw.print("mForcingShowNavBar="); |
| 5828 | pw.println(mForcingShowNavBar); pw.print( "mForcingShowNavBarLayer="); |
| 5829 | pw.println(mForcingShowNavBarLayer); |
| 5830 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 5831 | pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5832 | pw.print(" mHideLockScreen="); pw.println(mHideLockScreen); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 5833 | pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); |
| 5834 | pw.print(" mForceStatusBarFromKeyguard="); |
| 5835 | pw.println(mForceStatusBarFromKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5836 | pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 5837 | pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5838 | pw.print(" mHomePressed="); pw.println(mHomePressed); |
| 5839 | pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); |
| 5840 | pw.print(" mLockScreenTimeout="); pw.print(mLockScreenTimeout); |
| 5841 | pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive); |
| 5842 | pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior); |
| 5843 | pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior); |
| 5844 | pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior); |
| 5845 | pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation); |
| 5846 | pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); |
| 5847 | pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); |
| 5848 | pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 5849 | pw.print(prefix); pw.print("mDemoHdmiRotation="); pw.print(mDemoHdmiRotation); |
| 5850 | pw.print(" mDemoHdmiRotationLock="); pw.println(mDemoHdmiRotationLock); |
| 5851 | pw.print(prefix); pw.print("mUndockedHdmiRotation="); pw.println(mUndockedHdmiRotation); |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 5852 | |
Tim Kilbourn | d7c0c2e | 2014-05-29 16:08:10 -0700 | [diff] [blame] | 5853 | mGlobalKeyManager.dump(prefix, pw); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5854 | mStatusBarController.dump(pw, prefix); |
| 5855 | mNavigationBarController.dump(pw, prefix); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 5856 | PolicyControl.dump(prefix, pw); |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 5857 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5858 | if (mWakeGestureListener != null) { |
| 5859 | mWakeGestureListener.dump(pw, prefix); |
| 5860 | } |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 5861 | if (mOrientationListener != null) { |
| 5862 | mOrientationListener.dump(pw, prefix); |
| 5863 | } |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 5864 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5865 | } |