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 | |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 16 | package com.android.server.policy; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 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; |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 46 | import android.media.AudioSystem; |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 47 | import android.media.IAudioService; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 48 | import android.media.Ringtone; |
| 49 | import android.media.RingtoneManager; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 50 | import android.media.session.MediaSessionLegacyHelper; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 51 | import android.os.Bundle; |
Craig Mautner | 276a6eb | 2014-11-04 15:32:57 -0800 | [diff] [blame] | 52 | import android.os.Debug; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 53 | import android.os.FactoryTest; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 54 | import android.os.Handler; |
| 55 | import android.os.IBinder; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 56 | import android.os.Looper; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 57 | import android.os.Message; |
| 58 | import android.os.Messenger; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 59 | import android.os.PowerManager; |
| 60 | import android.os.RemoteException; |
| 61 | import android.os.ServiceManager; |
| 62 | import android.os.SystemClock; |
| 63 | import android.os.SystemProperties; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 64 | import android.os.UEventObserver; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 65 | import android.os.UserHandle; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 66 | import android.os.Vibrator; |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 67 | import android.provider.MediaStore; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 68 | import android.provider.Settings; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 69 | import android.service.dreams.DreamManagerInternal; |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 70 | import android.service.dreams.DreamService; |
| 71 | import android.service.dreams.IDreamManager; |
Michael Wright | dc63f7b | 2014-08-21 19:05:21 -0700 | [diff] [blame] | 72 | import android.speech.RecognizerIntent; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 73 | import android.telecom.TelecomManager; |
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; |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 92 | import android.view.PhoneWindow; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 93 | import android.view.Surface; |
| 94 | import android.view.View; |
| 95 | import android.view.ViewConfiguration; |
| 96 | import android.view.Window; |
| 97 | import android.view.WindowManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 98 | import android.view.WindowManagerGlobal; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 99 | import android.view.WindowManagerInternal; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 100 | import android.view.WindowManagerPolicy; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 101 | import android.view.accessibility.AccessibilityEvent; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 102 | import android.view.accessibility.AccessibilityManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 103 | import android.view.animation.Animation; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 104 | import android.view.animation.AnimationSet; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 105 | import android.view.animation.AnimationUtils; |
| 106 | |
| 107 | import com.android.internal.R; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 108 | import com.android.internal.statusbar.IStatusBarService; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 109 | import com.android.internal.widget.PointerLocationView; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 110 | import com.android.server.LocalServices; |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 111 | import com.android.server.policy.keyguard.KeyguardServiceDelegate; |
| 112 | import com.android.server.policy.keyguard.KeyguardServiceDelegate.ShowListener; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 113 | |
| 114 | import java.io.File; |
| 115 | import java.io.FileReader; |
| 116 | import java.io.IOException; |
| 117 | import java.io.PrintWriter; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 118 | import java.util.HashSet; |
Craig Mautner | 276a6eb | 2014-11-04 15:32:57 -0800 | [diff] [blame] | 119 | import java.util.List; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 120 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 121 | import static android.view.WindowManager.LayoutParams.*; |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 122 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; |
| 123 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; |
| 124 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 125 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVER_ABSENT; |
| 126 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_UNCOVERED; |
| 127 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVERED; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 128 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 129 | /** |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 130 | * WindowManagerPolicy implementation for the Android phone UI. This |
| 131 | * introduces a new method suffix, Lp, for an internal lock of the |
| 132 | * PhoneWindowManager. This is used to protect some internal state, and |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 133 | * 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] | 134 | * of both of those when held. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 135 | */ |
| 136 | public class PhoneWindowManager implements WindowManagerPolicy { |
| 137 | static final String TAG = "WindowManager"; |
| 138 | static final boolean DEBUG = false; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 139 | static final boolean localLOGV = false; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 140 | static final boolean DEBUG_INPUT = false; |
Craig Mautner | c0d2d0a | 2014-10-31 16:25:15 -0700 | [diff] [blame] | 141 | static final boolean DEBUG_KEYGUARD = false; |
| 142 | static final boolean DEBUG_LAYOUT = false; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 143 | static final boolean DEBUG_STARTING_WINDOW = false; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 144 | static final boolean DEBUG_WAKEUP = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 145 | static final boolean SHOW_STARTING_ANIMATIONS = true; |
| 146 | static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 147 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 148 | // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. |
| 149 | // No longer recommended for desk docks; still useful in car docks. |
| 150 | static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; |
| 151 | static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; |
| 152 | |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 153 | static final int SHORT_PRESS_POWER_NOTHING = 0; |
| 154 | static final int SHORT_PRESS_POWER_GO_TO_SLEEP = 1; |
| 155 | static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP = 2; |
| 156 | static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME = 3; |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 157 | static final int SHORT_PRESS_POWER_GO_HOME = 4; |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 158 | |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 159 | static final int LONG_PRESS_POWER_NOTHING = 0; |
| 160 | static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; |
| 161 | static final int LONG_PRESS_POWER_SHUT_OFF = 2; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 162 | static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 163 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 164 | static final int MULTI_PRESS_POWER_NOTHING = 0; |
| 165 | static final int MULTI_PRESS_POWER_THEATER_MODE = 1; |
| 166 | static final int MULTI_PRESS_POWER_BRIGHTNESS_BOOST = 2; |
| 167 | |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 168 | // These need to match the documentation/constant in |
| 169 | // core/res/res/values/config.xml |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 170 | static final int LONG_PRESS_HOME_NOTHING = 0; |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 171 | static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 172 | static final int LONG_PRESS_HOME_ASSIST = 2; |
| 173 | |
| 174 | static final int DOUBLE_TAP_HOME_NOTHING = 0; |
| 175 | static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 176 | |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 177 | static final int APPLICATION_MEDIA_SUBLAYER = -2; |
| 178 | static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 179 | static final int APPLICATION_PANEL_SUBLAYER = 1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 180 | static final int APPLICATION_SUB_PANEL_SUBLAYER = 2; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 181 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 182 | static public final String SYSTEM_DIALOG_REASON_KEY = "reason"; |
| 183 | static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions"; |
| 184 | static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 185 | static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 186 | static public final String SYSTEM_DIALOG_REASON_ASSIST = "assist"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 187 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 188 | /** |
| 189 | * These are the system UI flags that, when changing, can cause the layout |
| 190 | * of the screen to change. |
| 191 | */ |
| 192 | static final int SYSTEM_UI_CHANGING_LAYOUT = |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 193 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | 7f4820a | 2013-10-08 12:54:35 -0400 | [diff] [blame] | 194 | | View.SYSTEM_UI_FLAG_FULLSCREEN |
| 195 | | View.STATUS_BAR_TRANSLUCENT |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 196 | | View.NAVIGATION_BAR_TRANSLUCENT |
| 197 | | View.SYSTEM_UI_TRANSPARENT; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 198 | |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 199 | private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() |
| 200 | .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
| 201 | .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) |
| 202 | .build(); |
| 203 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 204 | /** |
| 205 | * Keyguard stuff |
| 206 | */ |
| 207 | private WindowState mKeyguardScrim; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 208 | private boolean mKeyguardHidden; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 209 | private boolean mKeyguardDrawnOnce; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 210 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 211 | /* Table of Application Launch keys. Maps from key codes to intent categories. |
| 212 | * |
| 213 | * These are special keys that are used to launch particular kinds of applications, |
| 214 | * such as a web browser. HID defines nearly a hundred of them in the Consumer (0x0C) |
| 215 | * usage page. We don't support quite that many yet... |
| 216 | */ |
| 217 | static SparseArray<String> sApplicationLaunchKeyCategories; |
| 218 | static { |
| 219 | sApplicationLaunchKeyCategories = new SparseArray<String>(); |
| 220 | sApplicationLaunchKeyCategories.append( |
| 221 | KeyEvent.KEYCODE_EXPLORER, Intent.CATEGORY_APP_BROWSER); |
| 222 | sApplicationLaunchKeyCategories.append( |
| 223 | KeyEvent.KEYCODE_ENVELOPE, Intent.CATEGORY_APP_EMAIL); |
| 224 | sApplicationLaunchKeyCategories.append( |
| 225 | KeyEvent.KEYCODE_CONTACTS, Intent.CATEGORY_APP_CONTACTS); |
| 226 | sApplicationLaunchKeyCategories.append( |
| 227 | KeyEvent.KEYCODE_CALENDAR, Intent.CATEGORY_APP_CALENDAR); |
| 228 | sApplicationLaunchKeyCategories.append( |
| 229 | KeyEvent.KEYCODE_MUSIC, Intent.CATEGORY_APP_MUSIC); |
| 230 | sApplicationLaunchKeyCategories.append( |
| 231 | KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); |
| 232 | } |
| 233 | |
Craig Mautner | c3daedd | 2014-09-13 11:17:23 -0700 | [diff] [blame] | 234 | /** Amount of time (in milliseconds) to wait for windows drawn before powering on. */ |
| 235 | static final int WAITING_FOR_DRAWN_TIMEOUT = 1000; |
| 236 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 237 | /** |
| 238 | * Lock protecting internal state. Must not call out into window |
| 239 | * manager with lock held. (This lock will be acquired in places |
| 240 | * where the window manager is calling in with its own lock held.) |
| 241 | */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 242 | private final Object mLock = new Object(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 243 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 244 | Context mContext; |
| 245 | IWindowManager mWindowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 246 | WindowManagerFuncs mWindowManagerFuncs; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 247 | WindowManagerInternal mWindowManagerInternal; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 248 | PowerManager mPowerManager; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 249 | DreamManagerInternal mDreamManagerInternal; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 250 | IStatusBarService mStatusBarService; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 251 | boolean mPreloadedRecentApps; |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 252 | final Object mServiceAquireLock = new Object(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 253 | Vibrator mVibrator; // Vibrator for giving feedback of orientation changes |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 254 | SearchManager mSearchManager; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 255 | AccessibilityManager mAccessibilityManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 256 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 257 | // Vibrator pattern for haptic feedback of a long press. |
| 258 | long[] mLongPressVibePattern; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 259 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 260 | // Vibrator pattern for haptic feedback of virtual key press. |
| 261 | long[] mVirtualKeyVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 262 | |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 263 | // Vibrator pattern for a short vibration. |
| 264 | long[] mKeyboardTapVibePattern; |
| 265 | |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 266 | // Vibrator pattern for a short vibration when tapping on an hour/minute tick of a Clock. |
| 267 | long[] mClockTickVibePattern; |
| 268 | |
Fabrice Di Meglio | bd9152f | 2013-10-01 11:21:31 -0700 | [diff] [blame] | 269 | // Vibrator pattern for a short vibration when tapping on a day/month/year date of a Calendar. |
| 270 | long[] mCalendarDateVibePattern; |
| 271 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 272 | // Vibrator pattern for haptic feedback during boot when safe mode is disabled. |
| 273 | long[] mSafeModeDisabledVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 274 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 275 | // Vibrator pattern for haptic feedback during boot when safe mode is enabled. |
| 276 | long[] mSafeModeEnabledVibePattern; |
Romain Guy | 8154cd3 | 2010-03-29 14:41:15 -0700 | [diff] [blame] | 277 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 278 | /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */ |
| 279 | boolean mEnableShiftMenuBugReports = false; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 280 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 281 | boolean mSafeMode; |
| 282 | WindowState mStatusBar = null; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 283 | int mStatusBarHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 284 | WindowState mNavigationBar = null; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 285 | boolean mHasNavigationBar = false; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 286 | boolean mCanHideNavigationBar = false; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 287 | boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side? |
| 288 | boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*? |
| 289 | int[] mNavigationBarHeightForRotation = new int[4]; |
| 290 | int[] mNavigationBarWidthForRotation = new int[4]; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 291 | |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 292 | boolean mBootMessageNeedsHiding; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 293 | KeyguardServiceDelegate mKeyguardDelegate; |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 294 | final Runnable mWindowManagerDrawCallback = new Runnable() { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 295 | @Override |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 296 | public void run() { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 297 | if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for display!"); |
| 298 | mHandler.sendEmptyMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE); |
| 299 | } |
| 300 | }; |
| 301 | final ShowListener mKeyguardDelegateCallback = new ShowListener() { |
| 302 | @Override |
| 303 | public void onShown(IBinder windowToken) { |
| 304 | if (DEBUG_WAKEUP) Slog.d(TAG, "mKeyguardDelegate.ShowListener.onShown."); |
| 305 | mHandler.sendEmptyMessage(MSG_KEYGUARD_DRAWN_COMPLETE); |
| 306 | } |
| 307 | }; |
| 308 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 309 | GlobalActions mGlobalActions; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 310 | Handler mHandler; |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 311 | WindowState mLastInputMethodWindow = null; |
| 312 | WindowState mLastInputMethodTargetWindow = null; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 313 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 314 | // FIXME This state is shared between the input reader and handler thread. |
| 315 | // Technically it's broken and buggy but it has been like this for many years |
| 316 | // and we have not yet seen any problems. Someday we'll rewrite this logic |
| 317 | // so that only one thread is involved in handling input policy. Unfortunately |
| 318 | // it's on a critical path for power management so we can't just post the work to the |
| 319 | // handler thread. We'll need to resolve this someday by teaching the input dispatcher |
| 320 | // to hold wakelocks during dispatch and eliminating the critical path. |
| 321 | volatile boolean mPowerKeyHandled; |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 322 | volatile boolean mBeganFromNonInteractive; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 323 | volatile int mPowerKeyPressCounter; |
| 324 | volatile boolean mEndCallKeyHandled; |
| 325 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 326 | boolean mRecentsVisible; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 327 | int mRecentAppsHeldModifiers; |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 328 | boolean mLanguageSwitchKeyPressed; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 329 | |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 330 | int mLidState = LID_ABSENT; |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 331 | int mCameraLensCoverState = CAMERA_LENS_COVER_ABSENT; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 332 | boolean mHaveBuiltInKeyboard; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 333 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 334 | boolean mSystemReady; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 335 | boolean mSystemBooted; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 336 | boolean mHdmiPlugged; |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 337 | IUiModeManager mUiModeManager; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 338 | int mUiMode; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 339 | int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 340 | int mLidOpenRotation; |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 341 | int mCarDockRotation; |
| 342 | int mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 343 | int mUndockedHdmiRotation; |
| 344 | int mDemoHdmiRotation; |
| 345 | boolean mDemoHdmiRotationLock; |
Chong Zhang | ae6119ff | 2014-11-11 18:54:39 -0800 | [diff] [blame] | 346 | int mDemoRotation; |
| 347 | boolean mDemoRotationLock; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 348 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 349 | boolean mWakeGestureEnabledSetting; |
| 350 | MyWakeGestureListener mWakeGestureListener; |
| 351 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 352 | // Default display does not rotate, apps that require non-default orientation will have to |
| 353 | // have the orientation emulated. |
| 354 | private boolean mForceDefaultOrientation = false; |
| 355 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 356 | int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; |
| 357 | int mUserRotation = Surface.ROTATION_0; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 358 | boolean mAccelerometerDefault; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 359 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 360 | boolean mSupportAutoRotation; |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 361 | int mAllowAllRotations = -1; |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 362 | boolean mCarDockEnablesAccelerometer; |
| 363 | boolean mDeskDockEnablesAccelerometer; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 364 | int mLidKeyboardAccessibility; |
| 365 | int mLidNavigationAccessibility; |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 366 | boolean mLidControlsSleep; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 367 | int mShortPressOnPowerBehavior; |
| 368 | int mLongPressOnPowerBehavior; |
| 369 | int mDoublePressOnPowerBehavior; |
| 370 | int mTriplePressOnPowerBehavior; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 371 | boolean mAwake; |
| 372 | boolean mScreenOnEarly; |
| 373 | boolean mScreenOnFully; |
| 374 | ScreenOnListener mScreenOnListener; |
| 375 | boolean mKeyguardDrawComplete; |
| 376 | boolean mWindowManagerDrawComplete; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 377 | boolean mOrientationSensorEnabled = false; |
| 378 | int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 379 | boolean mHasSoftInput = false; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 380 | boolean mTranslucentDecorEnabled = true; |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 381 | boolean mUseTvRouting; |
| 382 | boolean mUseMasterVolume; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 383 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 384 | int mPointerLocationMode = 0; // guarded by mLock |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 385 | |
| 386 | // The last window we were told about in focusChanged. |
| 387 | WindowState mFocusedWindow; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 388 | IApplicationToken mFocusedApp; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 389 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 390 | PointerLocationView mPointerLocationView; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 391 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 392 | // The current size of the screen; really; extends into the overscan area of |
| 393 | // the screen and doesn't account for any system elements like the status bar. |
| 394 | int mOverscanScreenLeft, mOverscanScreenTop; |
| 395 | int mOverscanScreenWidth, mOverscanScreenHeight; |
| 396 | // The current visible size of the screen; really; (ir)regardless of whether the status |
| 397 | // bar can be hidden but not extending into the overscan area. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 398 | int mUnrestrictedScreenLeft, mUnrestrictedScreenTop; |
| 399 | int mUnrestrictedScreenWidth, mUnrestrictedScreenHeight; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 400 | // Like mOverscanScreen*, but allowed to move into the overscan region where appropriate. |
| 401 | int mRestrictedOverscanScreenLeft, mRestrictedOverscanScreenTop; |
| 402 | int mRestrictedOverscanScreenWidth, mRestrictedOverscanScreenHeight; |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 403 | // The current size of the screen; these may be different than (0,0)-(dw,dh) |
| 404 | // if the status bar can't be hidden; in that case it effectively carves out |
| 405 | // that area of the display from all other windows. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 406 | int mRestrictedScreenLeft, mRestrictedScreenTop; |
| 407 | int mRestrictedScreenWidth, mRestrictedScreenHeight; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 408 | // During layout, the current screen borders accounting for any currently |
| 409 | // visible system UI elements. |
| 410 | int mSystemLeft, mSystemTop, mSystemRight, mSystemBottom; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 411 | // For applications requesting stable content insets, these are them. |
| 412 | int mStableLeft, mStableTop, mStableRight, mStableBottom; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 413 | // For applications requesting stable content insets but have also set the |
| 414 | // fullscreen window flag, these are the stable dimensions without the status bar. |
| 415 | int mStableFullscreenLeft, mStableFullscreenTop; |
| 416 | int mStableFullscreenRight, mStableFullscreenBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 417 | // During layout, the current screen borders with all outer decoration |
| 418 | // (status bar, input method dock) accounted for. |
| 419 | int mCurLeft, mCurTop, mCurRight, mCurBottom; |
| 420 | // During layout, the frame in which content should be displayed |
| 421 | // to the user, accounting for all screen decoration except for any |
| 422 | // space they deem as available for other content. This is usually |
| 423 | // the same as mCur*, but may be larger if the screen decor has supplied |
| 424 | // content insets. |
| 425 | int mContentLeft, mContentTop, mContentRight, mContentBottom; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 426 | // During layout, the frame in which voice content should be displayed |
| 427 | // to the user, accounting for all screen decoration except for any |
| 428 | // space they deem as available for other content. |
| 429 | int mVoiceContentLeft, mVoiceContentTop, mVoiceContentRight, mVoiceContentBottom; |
Dianne Hackborn | 8e11ef0 | 2010-11-18 19:47:42 -0800 | [diff] [blame] | 430 | // 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] | 431 | // windows are placed. |
| 432 | int mDockLeft, mDockTop, mDockRight, mDockBottom; |
| 433 | // During layout, the layer at which the doc window is placed. |
| 434 | int mDockLayer; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 435 | // During layout, this is the layer of the status bar. |
| 436 | int mStatusBarLayer; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 437 | int mLastSystemUiFlags; |
| 438 | // Bits that we are in the process of clearing, so we want to prevent |
| 439 | // them from being set by applications until everything has been updated |
| 440 | // to have them clear. |
| 441 | int mResettingSystemUiFlags = 0; |
| 442 | // Bits that we are currently always keeping cleared. |
| 443 | int mForceClearedSystemUiFlags = 0; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 444 | // What we last reported to system UI about whether the compatibility |
| 445 | // menu needs to be displayed. |
| 446 | boolean mLastFocusNeedsMenu = false; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 447 | |
| 448 | FakeWindow mHideNavFakeWindow = null; |
| 449 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 450 | static final Rect mTmpParentFrame = new Rect(); |
| 451 | static final Rect mTmpDisplayFrame = new Rect(); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 452 | static final Rect mTmpOverscanFrame = new Rect(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 453 | static final Rect mTmpContentFrame = new Rect(); |
| 454 | static final Rect mTmpVisibleFrame = new Rect(); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 455 | static final Rect mTmpDecorFrame = new Rect(); |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 456 | static final Rect mTmpStableFrame = new Rect(); |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 457 | static final Rect mTmpNavigationFrame = new Rect(); |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 458 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 459 | WindowState mTopFullscreenOpaqueWindowState; |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame^] | 460 | WindowState mTopFullscreenOpaqueOrDimmingWindowState; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 461 | HashSet<IApplicationToken> mAppsToBeHidden = new HashSet<IApplicationToken>(); |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 462 | HashSet<IApplicationToken> mAppsThatDismissKeyguard = new HashSet<IApplicationToken>(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 463 | boolean mTopIsFullscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 464 | boolean mForceStatusBar; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 465 | boolean mForceStatusBarFromKeyguard; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 466 | boolean mHideLockScreen; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 467 | boolean mForcingShowNavBar; |
| 468 | int mForcingShowNavBarLayer; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 469 | |
| 470 | // States of keyguard dismiss. |
| 471 | private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed. |
| 472 | private static final int DISMISS_KEYGUARD_START = 1; // Keyguard needs to be dismissed. |
| 473 | private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed. |
| 474 | int mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
| 475 | |
| 476 | /** The window that is currently dismissing the keyguard. Dismissing the keyguard must only |
| 477 | * be done once per window. */ |
| 478 | private WindowState mWinDismissingKeyguard; |
| 479 | |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 480 | /** The window that is currently showing "over" the keyguard. If there is an app window |
| 481 | * belonging to another app on top of this the keyguard shows. If there is a fullscreen |
| 482 | * app window under this, still dismiss the keyguard but don't show the app underneath. Show |
| 483 | * the wallpaper. */ |
| 484 | private WindowState mWinShowWhenLocked; |
| 485 | |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 486 | boolean mShowingLockscreen; |
| 487 | boolean mShowingDream; |
| 488 | boolean mDreamingLockscreen; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 489 | boolean mKeyguardSecure; |
| 490 | boolean mKeyguardSecureIncludingHidden; |
| 491 | volatile boolean mKeyguardOccluded; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 492 | boolean mHomePressed; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 493 | boolean mHomeConsumed; |
| 494 | boolean mHomeDoubleTapPending; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 495 | Intent mHomeIntent; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 496 | Intent mCarDockIntent; |
| 497 | Intent mDeskDockIntent; |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 498 | boolean mSearchKeyShortcutPending; |
| 499 | boolean mConsumeSearchKeyUp; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 500 | boolean mAssistKeyLongPressed; |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 501 | boolean mPendingMetaAction; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 502 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 503 | // support for activating the lock screen while the screen is on |
| 504 | boolean mAllowLockscreenWhenOn; |
| 505 | int mLockScreenTimeout; |
| 506 | boolean mLockScreenTimerActive; |
| 507 | |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 508 | // 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] | 509 | int mEndcallBehavior; |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 510 | |
| 511 | // Behavior of POWER button while in-call and screen on. |
| 512 | // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) |
| 513 | int mIncallPowerBehavior; |
| 514 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 515 | Display mDisplay; |
| 516 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 517 | int mLandscapeRotation = 0; // default landscape rotation |
| 518 | int mSeascapeRotation = 0; // "other" landscape rotation, 180 degrees from mLandscapeRotation |
| 519 | int mPortraitRotation = 0; // default portrait rotation |
| 520 | int mUpsideDownRotation = 0; // "other" portrait rotation |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 521 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 522 | int mOverscanLeft = 0; |
| 523 | int mOverscanTop = 0; |
| 524 | int mOverscanRight = 0; |
| 525 | int mOverscanBottom = 0; |
| 526 | |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 527 | // What we do when the user long presses on home |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 528 | private int mLongPressOnHomeBehavior; |
| 529 | |
| 530 | // What we do when the user double-taps on home |
| 531 | private int mDoubleTapOnHomeBehavior; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 532 | |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 533 | // Allowed theater mode wake actions |
| 534 | private boolean mAllowTheaterModeWakeFromKey; |
| 535 | private boolean mAllowTheaterModeWakeFromPowerKey; |
| 536 | private boolean mAllowTheaterModeWakeFromMotion; |
Bryce Lee | 812d702 | 2014-11-10 13:33:28 -0800 | [diff] [blame] | 537 | private boolean mAllowTheaterModeWakeFromMotionWhenNotDreaming; |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 538 | private boolean mAllowTheaterModeWakeFromCameraLens; |
| 539 | private boolean mAllowTheaterModeWakeFromLidSwitch; |
| 540 | private boolean mAllowTheaterModeWakeFromWakeGesture; |
| 541 | |
Bryce Lee | 55e846d | 2014-11-04 12:43:44 -0800 | [diff] [blame] | 542 | // Whether to go to sleep entering theater mode from power button |
| 543 | private boolean mGoToSleepOnButtonPressTheaterMode; |
| 544 | |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 545 | // Screenshot trigger states |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 546 | // Time to volume and power must be pressed within this interval of each other. |
| 547 | private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150; |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 548 | // Increase the chord delay when taking a screenshot from the keyguard |
| 549 | private static final float KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER = 2.5f; |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 550 | private boolean mScreenshotChordEnabled; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 551 | private boolean mScreenshotChordVolumeDownKeyTriggered; |
| 552 | private long mScreenshotChordVolumeDownKeyTime; |
| 553 | private boolean mScreenshotChordVolumeDownKeyConsumed; |
| 554 | private boolean mScreenshotChordVolumeUpKeyTriggered; |
| 555 | private boolean mScreenshotChordPowerKeyTriggered; |
| 556 | private long mScreenshotChordPowerKeyTime; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 557 | |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 558 | /* The number of steps between min and max brightness */ |
| 559 | private static final int BRIGHTNESS_STEPS = 10; |
| 560 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 561 | SettingsObserver mSettingsObserver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 562 | ShortcutManager mShortcutManager; |
| 563 | PowerManager.WakeLock mBroadcastWakeLock; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 564 | PowerManager.WakeLock mPowerKeyWakeLock; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 565 | boolean mHavePendingMediaKeyRepeatWithWakeLock; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 566 | |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 567 | private int mCurrentUserId; |
| 568 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 569 | // Maps global key codes to the components that will handle them. |
| 570 | private GlobalKeyManager mGlobalKeyManager; |
| 571 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 572 | // Fallback actions by key code. |
| 573 | private final SparseArray<KeyCharacterMap.FallbackAction> mFallbackActions = |
| 574 | new SparseArray<KeyCharacterMap.FallbackAction>(); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 575 | |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 576 | private final LogDecelerateInterpolator mLogDecelerateInterpolator |
| 577 | = new LogDecelerateInterpolator(100, 0); |
| 578 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 579 | private static final int MSG_ENABLE_POINTER_LOCATION = 1; |
| 580 | private static final int MSG_DISABLE_POINTER_LOCATION = 2; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 581 | private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; |
| 582 | 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] | 583 | private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5; |
| 584 | private static final int MSG_KEYGUARD_DRAWN_TIMEOUT = 6; |
| 585 | private static final int MSG_WINDOW_MANAGER_DRAWN_COMPLETE = 7; |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 586 | private static final int MSG_DISPATCH_SHOW_RECENTS = 9; |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 587 | private static final int MSG_DISPATCH_SHOW_GLOBAL_ACTIONS = 10; |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 588 | private static final int MSG_HIDE_BOOT_MESSAGE = 11; |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 589 | private static final int MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK = 12; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 590 | private static final int MSG_POWER_DELAYED_PRESS = 13; |
| 591 | private static final int MSG_POWER_LONG_PRESS = 14; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 592 | |
| 593 | private class PolicyHandler extends Handler { |
| 594 | @Override |
| 595 | public void handleMessage(Message msg) { |
| 596 | switch (msg.what) { |
| 597 | case MSG_ENABLE_POINTER_LOCATION: |
| 598 | enablePointerLocation(); |
| 599 | break; |
| 600 | case MSG_DISABLE_POINTER_LOCATION: |
| 601 | disablePointerLocation(); |
| 602 | break; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 603 | case MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK: |
| 604 | dispatchMediaKeyWithWakeLock((KeyEvent)msg.obj); |
| 605 | break; |
| 606 | case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK: |
| 607 | dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj); |
| 608 | break; |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 609 | case MSG_DISPATCH_SHOW_RECENTS: |
| 610 | showRecentApps(false); |
| 611 | break; |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 612 | case MSG_DISPATCH_SHOW_GLOBAL_ACTIONS: |
| 613 | showGlobalActionsInternal(); |
| 614 | break; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 615 | case MSG_KEYGUARD_DRAWN_COMPLETE: |
| 616 | if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mKeyguardDrawComplete"); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 617 | finishKeyguardDrawn(); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 618 | break; |
| 619 | case MSG_KEYGUARD_DRAWN_TIMEOUT: |
| 620 | Slog.w(TAG, "Keyguard drawn timeout. Setting mKeyguardDrawComplete"); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 621 | finishKeyguardDrawn(); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 622 | break; |
| 623 | case MSG_WINDOW_MANAGER_DRAWN_COMPLETE: |
| 624 | if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mWindowManagerDrawComplete"); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 625 | finishWindowsDrawn(); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 626 | break; |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 627 | case MSG_HIDE_BOOT_MESSAGE: |
| 628 | handleHideBootMessage(); |
| 629 | break; |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 630 | case MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK: |
| 631 | launchVoiceAssistWithWakeLock(msg.arg1 != 0); |
| 632 | break; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 633 | case MSG_POWER_DELAYED_PRESS: |
| 634 | powerPress((Long)msg.obj, msg.arg1 != 0, msg.arg2); |
| 635 | finishPowerKeyPress(); |
| 636 | break; |
| 637 | case MSG_POWER_LONG_PRESS: |
| 638 | powerLongPress(); |
| 639 | break; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 640 | } |
| 641 | } |
| 642 | } |
| 643 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 644 | private UEventObserver mHDMIObserver = new UEventObserver() { |
| 645 | @Override |
| 646 | public void onUEvent(UEventObserver.UEvent event) { |
| 647 | setHdmiPlugged("1".equals(event.get("SWITCH_STATE"))); |
| 648 | } |
| 649 | }; |
| 650 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 651 | class SettingsObserver extends ContentObserver { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 652 | SettingsObserver(Handler handler) { |
| 653 | super(handler); |
| 654 | } |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 655 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 656 | void observe() { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 657 | // Observe all users' changes |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 658 | ContentResolver resolver = mContext.getContentResolver(); |
| 659 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 660 | Settings.System.END_BUTTON_BEHAVIOR), false, this, |
| 661 | UserHandle.USER_ALL); |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 662 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 663 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this, |
| 664 | UserHandle.USER_ALL); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 665 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
| 666 | Settings.Secure.WAKE_GESTURE_ENABLED), false, this, |
| 667 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 668 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 669 | Settings.System.ACCELEROMETER_ROTATION), false, this, |
| 670 | UserHandle.USER_ALL); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 671 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 672 | Settings.System.USER_ROTATION), false, this, |
| 673 | UserHandle.USER_ALL); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 674 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 675 | Settings.System.SCREEN_OFF_TIMEOUT), false, this, |
| 676 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 677 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 678 | Settings.System.POINTER_LOCATION), false, this, |
| 679 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 680 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 681 | Settings.Secure.DEFAULT_INPUT_METHOD), false, this, |
| 682 | UserHandle.USER_ALL); |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 683 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 684 | Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS), false, this, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 685 | UserHandle.USER_ALL); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 686 | resolver.registerContentObserver(Settings.Global.getUriFor( |
| 687 | Settings.Global.POLICY_CONTROL), false, this, |
| 688 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 689 | updateSettings(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | @Override public void onChange(boolean selfChange) { |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 693 | updateSettings(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 694 | updateRotation(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 695 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 696 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 697 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 698 | class MyWakeGestureListener extends WakeGestureListener { |
| 699 | MyWakeGestureListener(Context context, Handler handler) { |
| 700 | super(context, handler); |
| 701 | } |
| 702 | |
| 703 | @Override |
| 704 | public void onWakeUp() { |
| 705 | synchronized (mLock) { |
| 706 | if (shouldEnableWakeGestureLp()) { |
Jeff Brown | e07b94b | 2014-06-18 15:56:27 -0700 | [diff] [blame] | 707 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 708 | wakeUp(SystemClock.uptimeMillis(), mAllowTheaterModeWakeFromWakeGesture); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 709 | } |
| 710 | } |
| 711 | } |
| 712 | } |
| 713 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 714 | class MyOrientationListener extends WindowOrientationListener { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 715 | MyOrientationListener(Context context, Handler handler) { |
| 716 | super(context, handler); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 717 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 718 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 719 | @Override |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 720 | public void onProposedRotationChanged(int rotation) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 721 | if (localLOGV) Slog.v(TAG, "onProposedRotationChanged, rotation=" + rotation); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 722 | updateRotation(false); |
| 723 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 724 | } |
| 725 | MyOrientationListener mOrientationListener; |
| 726 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 727 | private final BarController mStatusBarController = new BarController("StatusBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 728 | View.STATUS_BAR_TRANSIENT, |
| 729 | View.STATUS_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 730 | View.STATUS_BAR_TRANSLUCENT, |
| 731 | StatusBarManager.WINDOW_STATUS_BAR, |
| 732 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 733 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 734 | private final BarController mNavigationBarController = new BarController("NavigationBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 735 | View.NAVIGATION_BAR_TRANSIENT, |
| 736 | View.NAVIGATION_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 737 | View.NAVIGATION_BAR_TRANSLUCENT, |
| 738 | StatusBarManager.WINDOW_NAVIGATION_BAR, |
| 739 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 740 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 741 | private ImmersiveModeConfirmation mImmersiveModeConfirmation; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 742 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 743 | private SystemGesturesPointerEventListener mSystemGestures; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 744 | |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 745 | IStatusBarService getStatusBarService() { |
| 746 | synchronized (mServiceAquireLock) { |
| 747 | if (mStatusBarService == null) { |
| 748 | mStatusBarService = IStatusBarService.Stub.asInterface( |
| 749 | ServiceManager.getService("statusbar")); |
| 750 | } |
| 751 | return mStatusBarService; |
| 752 | } |
| 753 | } |
| 754 | |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 755 | /* |
| 756 | * We always let the sensor be switched on by default except when |
| 757 | * the user has explicitly disabled sensor based rotation or when the |
| 758 | * screen is switched off. |
| 759 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 760 | boolean needSensorRunningLp() { |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 761 | if (mSupportAutoRotation) { |
| 762 | if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 763 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 764 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT |
| 765 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { |
| 766 | // If the application has explicitly requested to follow the |
| 767 | // orientation, then we need to turn the sensor on. |
| 768 | return true; |
| 769 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 770 | } |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 771 | if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 772 | (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 773 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 774 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK))) { |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 775 | // enable accelerometer if we are docked in a dock that enables accelerometer |
| 776 | // orientation management, |
| 777 | return true; |
| 778 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 779 | if (mUserRotationMode == USER_ROTATION_LOCKED) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 780 | // If the setting for using the sensor by default is enabled, then |
| 781 | // we will always leave it on. Note that the user could go to |
| 782 | // a window that forces an orientation that does not use the |
| 783 | // sensor and in theory we could turn it off... however, when next |
| 784 | // turning it on we won't have a good value for the current |
| 785 | // orientation for a little bit, which can cause orientation |
| 786 | // changes to lag, so we'd like to keep it always on. (It will |
| 787 | // still be turned off when the screen is off.) |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 788 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 789 | } |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 790 | return mSupportAutoRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 791 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 792 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 793 | /* |
| 794 | * Various use cases for invoking this function |
| 795 | * screen turning off, should always disable listeners if already enabled |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 796 | * 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] | 797 | * if not already enabled |
| 798 | * screen turned on and current app does not have sensor orientation, disable listeners if |
| 799 | * already enabled |
| 800 | * screen turning on and current app has sensor based orientation, enable listeners if needed |
| 801 | * screen turning on and current app has nosensor based orientation, do nothing |
| 802 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 803 | void updateOrientationListenerLp() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 804 | if (!mOrientationListener.canDetectOrientation()) { |
| 805 | // If sensor is turned off or nonexistent for some reason |
| 806 | return; |
| 807 | } |
| 808 | //Could have been invoked due to screen turning on or off or |
| 809 | //change of the currently visible window's orientation |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 810 | if (localLOGV) Slog.v(TAG, "mScreenOnEarly=" + mScreenOnEarly |
| 811 | + ", mAwake=" + mAwake + ", mCurrentAppOrientation=" + mCurrentAppOrientation |
| 812 | + ", mOrientationSensorEnabled=" + mOrientationSensorEnabled); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 813 | boolean disable = true; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 814 | if (mScreenOnEarly && mAwake) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 815 | if (needSensorRunningLp()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 816 | disable = false; |
| 817 | //enable listener if not already enabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 818 | if (!mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 819 | mOrientationListener.enable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 820 | if(localLOGV) Slog.v(TAG, "Enabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 821 | mOrientationSensorEnabled = true; |
| 822 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 823 | } |
| 824 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 825 | //check if sensors need to be disabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 826 | if (disable && mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 827 | mOrientationListener.disable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 828 | if(localLOGV) Slog.v(TAG, "Disabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 829 | mOrientationSensorEnabled = false; |
| 830 | } |
| 831 | } |
| 832 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 833 | private void interceptPowerKeyDown(KeyEvent event, boolean interactive) { |
| 834 | // Hold a wake lock until the power key is released. |
| 835 | if (!mPowerKeyWakeLock.isHeld()) { |
| 836 | mPowerKeyWakeLock.acquire(); |
| 837 | } |
| 838 | |
| 839 | // Cancel multi-press detection timeout. |
| 840 | if (mPowerKeyPressCounter != 0) { |
| 841 | mHandler.removeMessages(MSG_POWER_DELAYED_PRESS); |
| 842 | } |
| 843 | |
| 844 | // Detect user pressing the power button in panic when an application has |
| 845 | // taken over the whole screen. |
| 846 | boolean panic = mImmersiveModeConfirmation.onPowerKeyDown(interactive, |
Craig Mautner | 0124980e9 | 2014-11-30 21:15:34 -0800 | [diff] [blame] | 847 | SystemClock.elapsedRealtime(), isImmersiveMode(mLastSystemUiFlags)); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 848 | if (panic) { |
| 849 | mHandler.post(mRequestTransientNav); |
| 850 | } |
| 851 | |
| 852 | // Latch power key state to detect screenshot chord. |
| 853 | if (interactive && !mScreenshotChordPowerKeyTriggered |
| 854 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 855 | mScreenshotChordPowerKeyTriggered = true; |
| 856 | mScreenshotChordPowerKeyTime = event.getDownTime(); |
| 857 | interceptScreenshotChord(); |
| 858 | } |
| 859 | |
| 860 | // Stop ringing or end call if configured to do so when power is pressed. |
| 861 | TelecomManager telecomManager = getTelecommService(); |
| 862 | boolean hungUp = false; |
| 863 | if (telecomManager != null) { |
| 864 | if (telecomManager.isRinging()) { |
| 865 | // Pressing Power while there's a ringing incoming |
| 866 | // call should silence the ringer. |
| 867 | telecomManager.silenceRinger(); |
| 868 | } else if ((mIncallPowerBehavior |
| 869 | & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 |
| 870 | && telecomManager.isInCall() && interactive) { |
| 871 | // Otherwise, if "Power button ends call" is enabled, |
| 872 | // the Power button will hang up any current active call. |
| 873 | hungUp = telecomManager.endCall(); |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | // If the power key has still not yet been handled, then detect short |
| 878 | // press, long press, or multi press and decide what to do. |
| 879 | mPowerKeyHandled = hungUp || mScreenshotChordVolumeDownKeyTriggered |
| 880 | || mScreenshotChordVolumeUpKeyTriggered; |
| 881 | if (!mPowerKeyHandled) { |
| 882 | if (interactive) { |
| 883 | // When interactive, we're already awake. |
| 884 | // Wait for a long press or for the button to be released to decide what to do. |
| 885 | if (hasLongPressOnPowerBehavior()) { |
| 886 | Message msg = mHandler.obtainMessage(MSG_POWER_LONG_PRESS); |
| 887 | msg.setAsynchronous(true); |
| 888 | mHandler.sendMessageDelayed(msg, |
| 889 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
| 890 | } |
| 891 | } else { |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 892 | wakeUpFromPowerKey(event.getDownTime()); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 893 | final int maxCount = getMaxMultiPressPowerCount(); |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 894 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 895 | if (maxCount <= 1) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 896 | mPowerKeyHandled = true; |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 897 | } else { |
| 898 | mBeganFromNonInteractive = true; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 899 | } |
| 900 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 901 | } |
| 902 | } |
| 903 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 904 | private void interceptPowerKeyUp(KeyEvent event, boolean interactive, boolean canceled) { |
| 905 | final boolean handled = canceled || mPowerKeyHandled; |
| 906 | mScreenshotChordPowerKeyTriggered = false; |
| 907 | cancelPendingScreenshotChordAction(); |
| 908 | cancelPendingPowerKeyAction(); |
| 909 | |
| 910 | if (!handled) { |
| 911 | // Figure out how to handle the key now that it has been released. |
| 912 | mPowerKeyPressCounter += 1; |
| 913 | |
| 914 | final int maxCount = getMaxMultiPressPowerCount(); |
| 915 | final long eventTime = event.getDownTime(); |
| 916 | if (mPowerKeyPressCounter < maxCount) { |
| 917 | // This could be a multi-press. Wait a little bit longer to confirm. |
| 918 | // Continue holding the wake lock. |
| 919 | Message msg = mHandler.obtainMessage(MSG_POWER_DELAYED_PRESS, |
| 920 | interactive ? 1 : 0, mPowerKeyPressCounter, eventTime); |
| 921 | msg.setAsynchronous(true); |
| 922 | mHandler.sendMessageDelayed(msg, ViewConfiguration.getDoubleTapTimeout()); |
| 923 | return; |
| 924 | } |
| 925 | |
| 926 | // No other actions. Handle it immediately. |
| 927 | powerPress(eventTime, interactive, mPowerKeyPressCounter); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 928 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 929 | |
| 930 | // Done. Reset our state. |
| 931 | finishPowerKeyPress(); |
| 932 | } |
| 933 | |
| 934 | private void finishPowerKeyPress() { |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 935 | mBeganFromNonInteractive = false; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 936 | mPowerKeyPressCounter = 0; |
| 937 | if (mPowerKeyWakeLock.isHeld()) { |
| 938 | mPowerKeyWakeLock.release(); |
| 939 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 940 | } |
| 941 | |
| 942 | private void cancelPendingPowerKeyAction() { |
| 943 | if (!mPowerKeyHandled) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 944 | mPowerKeyHandled = true; |
| 945 | mHandler.removeMessages(MSG_POWER_LONG_PRESS); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 946 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | private void powerPress(long eventTime, boolean interactive, int count) { |
| 950 | if (mScreenOnEarly && !mScreenOnFully) { |
| 951 | Slog.i(TAG, "Suppressed redundant power key press while " |
| 952 | + "already in the process of turning the screen on."); |
| 953 | return; |
Jeff Brown | ff20471 | 2011-10-25 21:27:54 -0700 | [diff] [blame] | 954 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 955 | |
| 956 | if (count == 2) { |
| 957 | powerMultiPressAction(eventTime, interactive, mDoublePressOnPowerBehavior); |
| 958 | } else if (count == 3) { |
| 959 | powerMultiPressAction(eventTime, interactive, mTriplePressOnPowerBehavior); |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 960 | } else if (interactive && !mBeganFromNonInteractive) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 961 | switch (mShortPressOnPowerBehavior) { |
| 962 | case SHORT_PRESS_POWER_NOTHING: |
| 963 | break; |
| 964 | case SHORT_PRESS_POWER_GO_TO_SLEEP: |
| 965 | mPowerManager.goToSleep(eventTime, |
| 966 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); |
| 967 | break; |
| 968 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP: |
| 969 | mPowerManager.goToSleep(eventTime, |
| 970 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, |
| 971 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 972 | break; |
| 973 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME: |
| 974 | mPowerManager.goToSleep(eventTime, |
| 975 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, |
| 976 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 977 | launchHomeFromHotKey(); |
| 978 | break; |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 979 | case SHORT_PRESS_POWER_GO_HOME: |
| 980 | launchHomeFromHotKey(); |
| 981 | break; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 982 | } |
| 983 | } |
| 984 | } |
| 985 | |
| 986 | private void powerMultiPressAction(long eventTime, boolean interactive, int behavior) { |
| 987 | switch (behavior) { |
| 988 | case MULTI_PRESS_POWER_NOTHING: |
| 989 | break; |
| 990 | case MULTI_PRESS_POWER_THEATER_MODE: |
| 991 | if (isTheaterModeEnabled()) { |
| 992 | Slog.i(TAG, "Toggling theater mode off."); |
| 993 | Settings.Global.putInt(mContext.getContentResolver(), |
| 994 | Settings.Global.THEATER_MODE_ON, 0); |
| 995 | if (!interactive) { |
| 996 | wakeUpFromPowerKey(eventTime); |
| 997 | } |
| 998 | } else { |
| 999 | Slog.i(TAG, "Toggling theater mode on."); |
| 1000 | Settings.Global.putInt(mContext.getContentResolver(), |
| 1001 | Settings.Global.THEATER_MODE_ON, 1); |
Bryce Lee | 55e846d | 2014-11-04 12:43:44 -0800 | [diff] [blame] | 1002 | |
| 1003 | if (mGoToSleepOnButtonPressTheaterMode && interactive) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1004 | mPowerManager.goToSleep(eventTime, |
| 1005 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); |
| 1006 | } |
| 1007 | } |
| 1008 | break; |
| 1009 | case MULTI_PRESS_POWER_BRIGHTNESS_BOOST: |
Jeff Brown | 7b5be5e | 2014-11-12 18:45:31 -0800 | [diff] [blame] | 1010 | Slog.i(TAG, "Starting brightness boost."); |
| 1011 | if (!interactive) { |
| 1012 | wakeUpFromPowerKey(eventTime); |
| 1013 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1014 | mPowerManager.boostScreenBrightness(eventTime); |
| 1015 | break; |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | private int getMaxMultiPressPowerCount() { |
| 1020 | if (mTriplePressOnPowerBehavior != MULTI_PRESS_POWER_NOTHING) { |
| 1021 | return 3; |
| 1022 | } |
| 1023 | if (mDoublePressOnPowerBehavior != MULTI_PRESS_POWER_NOTHING) { |
| 1024 | return 2; |
| 1025 | } |
| 1026 | return 1; |
| 1027 | } |
| 1028 | |
| 1029 | private void powerLongPress() { |
| 1030 | final int behavior = getResolvedLongPressOnPowerBehavior(); |
| 1031 | switch (behavior) { |
| 1032 | case LONG_PRESS_POWER_NOTHING: |
| 1033 | break; |
| 1034 | case LONG_PRESS_POWER_GLOBAL_ACTIONS: |
| 1035 | mPowerKeyHandled = true; |
| 1036 | if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) { |
| 1037 | performAuditoryFeedbackForAccessibilityIfNeed(); |
| 1038 | } |
| 1039 | showGlobalActionsInternal(); |
| 1040 | break; |
| 1041 | case LONG_PRESS_POWER_SHUT_OFF: |
| 1042 | case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM: |
| 1043 | mPowerKeyHandled = true; |
| 1044 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 1045 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
| 1046 | mWindowManagerFuncs.shutdown(behavior == LONG_PRESS_POWER_SHUT_OFF); |
| 1047 | break; |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | private int getResolvedLongPressOnPowerBehavior() { |
| 1052 | if (FactoryTest.isLongPressOnPowerOffEnabled()) { |
| 1053 | return LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM; |
| 1054 | } |
| 1055 | return mLongPressOnPowerBehavior; |
| 1056 | } |
| 1057 | |
| 1058 | private boolean hasLongPressOnPowerBehavior() { |
| 1059 | return getResolvedLongPressOnPowerBehavior() != LONG_PRESS_POWER_NOTHING; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | private void interceptScreenshotChord() { |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1063 | if (mScreenshotChordEnabled |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1064 | && mScreenshotChordVolumeDownKeyTriggered && mScreenshotChordPowerKeyTriggered |
| 1065 | && !mScreenshotChordVolumeUpKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1066 | final long now = SystemClock.uptimeMillis(); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1067 | if (now <= mScreenshotChordVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS |
| 1068 | && now <= mScreenshotChordPowerKeyTime |
| 1069 | + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) { |
| 1070 | mScreenshotChordVolumeDownKeyConsumed = true; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1071 | cancelPendingPowerKeyAction(); |
| 1072 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 1073 | mHandler.postDelayed(mScreenshotRunnable, getScreenshotChordLongPressDelay()); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1074 | } |
| 1075 | } |
| 1076 | } |
| 1077 | |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 1078 | private long getScreenshotChordLongPressDelay() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1079 | if (mKeyguardDelegate.isShowing()) { |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 1080 | // Double the time it takes to take a screenshot from the keyguard |
| 1081 | return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER * |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 1082 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 1083 | } |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 1084 | return ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout(); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 1085 | } |
| 1086 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1087 | private void cancelPendingScreenshotChordAction() { |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 1088 | mHandler.removeCallbacks(mScreenshotRunnable); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1089 | } |
| 1090 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1091 | private final Runnable mEndCallLongPress = new Runnable() { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 1092 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1093 | public void run() { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1094 | mEndCallKeyHandled = true; |
| 1095 | if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) { |
| 1096 | performAuditoryFeedbackForAccessibilityIfNeed(); |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 1097 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1098 | showGlobalActionsInternal(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1099 | } |
| 1100 | }; |
| 1101 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 1102 | private final Runnable mScreenshotRunnable = new Runnable() { |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1103 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1104 | public void run() { |
| 1105 | takeScreenshot(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1106 | } |
| 1107 | }; |
| 1108 | |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 1109 | @Override |
| 1110 | public void showGlobalActions() { |
| 1111 | mHandler.removeMessages(MSG_DISPATCH_SHOW_GLOBAL_ACTIONS); |
| 1112 | mHandler.sendEmptyMessage(MSG_DISPATCH_SHOW_GLOBAL_ACTIONS); |
| 1113 | } |
| 1114 | |
| 1115 | void showGlobalActionsInternal() { |
| 1116 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1117 | if (mGlobalActions == null) { |
Jeff Brown | 7304c34 | 2012-05-11 18:42:42 -0700 | [diff] [blame] | 1118 | mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1119 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 1120 | final boolean keyguardShowing = isKeyguardShowingAndNotOccluded(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1121 | mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); |
| 1122 | if (keyguardShowing) { |
| 1123 | // since it took two seconds of long press to bring this up, |
| 1124 | // 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] | 1125 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1126 | } |
| 1127 | } |
| 1128 | |
| 1129 | boolean isDeviceProvisioned() { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 1130 | return Settings.Global.getInt( |
| 1131 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1132 | } |
| 1133 | |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 1134 | boolean isUserSetupComplete() { |
| 1135 | return Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 1136 | Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; |
| 1137 | } |
| 1138 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1139 | private void handleShortPressOnHome() { |
| 1140 | // If there's a dream running then use home to escape the dream |
| 1141 | // but don't actually go home. |
| 1142 | if (mDreamManagerInternal != null && mDreamManagerInternal.isDreaming()) { |
| 1143 | mDreamManagerInternal.stopDream(false /*immediate*/); |
| 1144 | return; |
| 1145 | } |
| 1146 | |
| 1147 | // Go home! |
| 1148 | launchHomeFromHotKey(); |
| 1149 | } |
| 1150 | |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 1151 | private void handleLongPressOnHome() { |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 1152 | if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1153 | mHomeConsumed = true; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 1154 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 1155 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1156 | if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) { |
| 1157 | toggleRecentApps(); |
| 1158 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_ASSIST) { |
| 1159 | launchAssistAction(); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 1160 | } |
| 1161 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1162 | } |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 1163 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1164 | private void handleDoubleTapOnHome() { |
| 1165 | if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 1166 | mHomeConsumed = true; |
| 1167 | toggleRecentApps(); |
| 1168 | } |
| 1169 | } |
| 1170 | |
| 1171 | private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable() { |
| 1172 | @Override |
| 1173 | public void run() { |
| 1174 | if (mHomeDoubleTapPending) { |
| 1175 | mHomeDoubleTapPending = false; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1176 | handleShortPressOnHome(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1177 | } |
| 1178 | } |
| 1179 | }; |
| 1180 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1181 | /** {@inheritDoc} */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1182 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1183 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 1184 | WindowManagerFuncs windowManagerFuncs) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1185 | mContext = context; |
| 1186 | mWindowManager = windowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1187 | mWindowManagerFuncs = windowManagerFuncs; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 1188 | mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1189 | mDreamManagerInternal = LocalServices.getService(DreamManagerInternal.class); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 1190 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1191 | mHandler = new PolicyHandler(); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1192 | mWakeGestureListener = new MyWakeGestureListener(mContext, mHandler); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 1193 | mOrientationListener = new MyOrientationListener(mContext, mHandler); |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 1194 | try { |
| 1195 | mOrientationListener.setCurrentRotation(windowManager.getRotation()); |
| 1196 | } catch (RemoteException ex) { } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1197 | mSettingsObserver = new SettingsObserver(mHandler); |
| 1198 | mSettingsObserver.observe(); |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1199 | mShortcutManager = new ShortcutManager(context); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 1200 | mUiMode = context.getResources().getInteger( |
| 1201 | com.android.internal.R.integer.config_defaultUiModeType); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1202 | mHomeIntent = new Intent(Intent.ACTION_MAIN, null); |
| 1203 | mHomeIntent.addCategory(Intent.CATEGORY_HOME); |
| 1204 | mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 1205 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 1206 | mCarDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 1207 | mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK); |
| 1208 | mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 1209 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 1210 | mDeskDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 1211 | mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK); |
| 1212 | mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 1213 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 1214 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 1215 | mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 1216 | mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1217 | "PhoneWindowManager.mBroadcastWakeLock"); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1218 | mPowerKeyWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
| 1219 | "PhoneWindowManager.mPowerKeyWakeLock"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1220 | mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 1221 | mSupportAutoRotation = mContext.getResources().getBoolean( |
| 1222 | com.android.internal.R.bool.config_supportAutoRotation); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1223 | mLidOpenRotation = readRotation( |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1224 | com.android.internal.R.integer.config_lidOpenRotation); |
| 1225 | mCarDockRotation = readRotation( |
| 1226 | com.android.internal.R.integer.config_carDockRotation); |
| 1227 | mDeskDockRotation = readRotation( |
| 1228 | com.android.internal.R.integer.config_deskDockRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1229 | mUndockedHdmiRotation = readRotation( |
| 1230 | com.android.internal.R.integer.config_undockedHdmiRotation); |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 1231 | mCarDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 1232 | com.android.internal.R.bool.config_carDockEnablesAccelerometer); |
| 1233 | mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 1234 | com.android.internal.R.bool.config_deskDockEnablesAccelerometer); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1235 | mLidKeyboardAccessibility = mContext.getResources().getInteger( |
| 1236 | com.android.internal.R.integer.config_lidKeyboardAccessibility); |
| 1237 | mLidNavigationAccessibility = mContext.getResources().getInteger( |
| 1238 | com.android.internal.R.integer.config_lidNavigationAccessibility); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1239 | mLidControlsSleep = mContext.getResources().getBoolean( |
| 1240 | com.android.internal.R.bool.config_lidControlsSleep); |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 1241 | mTranslucentDecorEnabled = mContext.getResources().getBoolean( |
| 1242 | com.android.internal.R.bool.config_enableTranslucentDecor); |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 1243 | |
| 1244 | mAllowTheaterModeWakeFromKey = mContext.getResources().getBoolean( |
| 1245 | com.android.internal.R.bool.config_allowTheaterModeWakeFromKey); |
| 1246 | mAllowTheaterModeWakeFromPowerKey = mAllowTheaterModeWakeFromKey |
| 1247 | || mContext.getResources().getBoolean( |
| 1248 | com.android.internal.R.bool.config_allowTheaterModeWakeFromPowerKey); |
| 1249 | mAllowTheaterModeWakeFromMotion = mContext.getResources().getBoolean( |
| 1250 | com.android.internal.R.bool.config_allowTheaterModeWakeFromMotion); |
Bryce Lee | 812d702 | 2014-11-10 13:33:28 -0800 | [diff] [blame] | 1251 | mAllowTheaterModeWakeFromMotionWhenNotDreaming = mContext.getResources().getBoolean( |
| 1252 | com.android.internal.R.bool.config_allowTheaterModeWakeFromMotionWhenNotDreaming); |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 1253 | mAllowTheaterModeWakeFromCameraLens = mContext.getResources().getBoolean( |
| 1254 | com.android.internal.R.bool.config_allowTheaterModeWakeFromCameraLens); |
| 1255 | mAllowTheaterModeWakeFromLidSwitch = mContext.getResources().getBoolean( |
| 1256 | com.android.internal.R.bool.config_allowTheaterModeWakeFromLidSwitch); |
| 1257 | mAllowTheaterModeWakeFromWakeGesture = mContext.getResources().getBoolean( |
| 1258 | com.android.internal.R.bool.config_allowTheaterModeWakeFromGesture); |
| 1259 | |
Bryce Lee | 55e846d | 2014-11-04 12:43:44 -0800 | [diff] [blame] | 1260 | mGoToSleepOnButtonPressTheaterMode = mContext.getResources().getBoolean( |
| 1261 | com.android.internal.R.bool.config_goToSleepOnButtonPressTheaterMode); |
| 1262 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1263 | mShortPressOnPowerBehavior = mContext.getResources().getInteger( |
| 1264 | com.android.internal.R.integer.config_shortPressOnPowerBehavior); |
| 1265 | mLongPressOnPowerBehavior = mContext.getResources().getInteger( |
| 1266 | com.android.internal.R.integer.config_longPressOnPowerBehavior); |
| 1267 | mDoublePressOnPowerBehavior = mContext.getResources().getInteger( |
| 1268 | com.android.internal.R.integer.config_doublePressOnPowerBehavior); |
| 1269 | mTriplePressOnPowerBehavior = mContext.getResources().getInteger( |
| 1270 | com.android.internal.R.integer.config_triplePressOnPowerBehavior); |
| 1271 | |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 1272 | mUseTvRouting = AudioSystem.getPlatformType(mContext) == AudioSystem.PLATFORM_TELEVISION; |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 1273 | mUseMasterVolume = mContext.getResources().getBoolean( |
| 1274 | com.android.internal.R.bool.config_useMasterVolume); |
| 1275 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1276 | readConfigurationDependentBehaviors(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1277 | |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 1278 | mAccessibilityManager = (AccessibilityManager) context.getSystemService( |
| 1279 | Context.ACCESSIBILITY_SERVICE); |
| 1280 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1281 | // register for dock events |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 1282 | IntentFilter filter = new IntentFilter(); |
| 1283 | filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); |
| 1284 | filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE); |
| 1285 | filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); |
| 1286 | filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1287 | filter.addAction(Intent.ACTION_DOCK_EVENT); |
| 1288 | Intent intent = context.registerReceiver(mDockReceiver, filter); |
| 1289 | if (intent != null) { |
| 1290 | // Retrieve current sticky dock event broadcast. |
| 1291 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 1292 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 1293 | } |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 1294 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 1295 | // register for dream-related broadcasts |
| 1296 | filter = new IntentFilter(); |
| 1297 | filter.addAction(Intent.ACTION_DREAMING_STARTED); |
| 1298 | filter.addAction(Intent.ACTION_DREAMING_STOPPED); |
| 1299 | context.registerReceiver(mDreamReceiver, filter); |
| 1300 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1301 | // register for multiuser-relevant broadcasts |
| 1302 | filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); |
| 1303 | context.registerReceiver(mMultiuserReceiver, filter); |
| 1304 | |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 1305 | // monitor for system gestures |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1306 | mSystemGestures = new SystemGesturesPointerEventListener(context, |
| 1307 | new SystemGesturesPointerEventListener.Callbacks() { |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 1308 | @Override |
| 1309 | public void onSwipeFromTop() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1310 | if (mStatusBar != null) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1311 | requestTransientBars(mStatusBar); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1312 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1313 | } |
| 1314 | @Override |
| 1315 | public void onSwipeFromBottom() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1316 | if (mNavigationBar != null && mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1317 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1318 | } |
| 1319 | } |
| 1320 | @Override |
| 1321 | public void onSwipeFromRight() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1322 | if (mNavigationBar != null && !mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1323 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1324 | } |
| 1325 | } |
| 1326 | @Override |
| 1327 | public void onDebug() { |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1328 | // no-op |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1329 | } |
| 1330 | }); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1331 | mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1332 | mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 1333 | |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 1334 | mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 1335 | mLongPressVibePattern = getLongIntArray(mContext.getResources(), |
| 1336 | com.android.internal.R.array.config_longPressVibePattern); |
| 1337 | mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(), |
| 1338 | com.android.internal.R.array.config_virtualKeyVibePattern); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 1339 | mKeyboardTapVibePattern = getLongIntArray(mContext.getResources(), |
| 1340 | com.android.internal.R.array.config_keyboardTapVibePattern); |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 1341 | mClockTickVibePattern = getLongIntArray(mContext.getResources(), |
| 1342 | com.android.internal.R.array.config_clockTickVibePattern); |
Fabrice Di Meglio | bd9152f | 2013-10-01 11:21:31 -0700 | [diff] [blame] | 1343 | mCalendarDateVibePattern = getLongIntArray(mContext.getResources(), |
| 1344 | com.android.internal.R.array.config_calendarDateVibePattern); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 1345 | mSafeModeDisabledVibePattern = getLongIntArray(mContext.getResources(), |
| 1346 | com.android.internal.R.array.config_safeModeDisabledVibePattern); |
| 1347 | mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), |
| 1348 | com.android.internal.R.array.config_safeModeEnabledVibePattern); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 1349 | |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1350 | mScreenshotChordEnabled = mContext.getResources().getBoolean( |
| 1351 | com.android.internal.R.bool.config_enableScreenshotChord); |
| 1352 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 1353 | mGlobalKeyManager = new GlobalKeyManager(mContext); |
| 1354 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 1355 | // Controls rotation and the like. |
| 1356 | initializeHdmiState(); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1357 | |
| 1358 | // Match current screen state. |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 1359 | if (!mPowerManager.isInteractive()) { |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 1360 | goingToSleep(WindowManagerPolicy.OFF_BECAUSE_OF_USER); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1361 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1362 | } |
| 1363 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1364 | /** |
| 1365 | * Read values from config.xml that may be overridden depending on |
| 1366 | * the configuration of the device. |
| 1367 | * eg. Disable long press on home goes to recents on sw600dp. |
| 1368 | */ |
| 1369 | private void readConfigurationDependentBehaviors() { |
| 1370 | mLongPressOnHomeBehavior = mContext.getResources().getInteger( |
| 1371 | com.android.internal.R.integer.config_longPressOnHomeBehavior); |
| 1372 | if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING || |
| 1373 | mLongPressOnHomeBehavior > LONG_PRESS_HOME_ASSIST) { |
| 1374 | mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1375 | } |
| 1376 | |
| 1377 | mDoubleTapOnHomeBehavior = mContext.getResources().getInteger( |
| 1378 | com.android.internal.R.integer.config_doubleTapOnHomeBehavior); |
| 1379 | if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING || |
| 1380 | mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 1381 | mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1382 | } |
| 1383 | } |
| 1384 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1385 | @Override |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1386 | public void setInitialDisplaySize(Display display, int width, int height, int density) { |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 1387 | // This method might be called before the policy has been fully initialized |
| 1388 | // or for other displays we don't care about. |
| 1389 | if (mContext == null || display.getDisplayId() != Display.DEFAULT_DISPLAY) { |
| 1390 | return; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1391 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1392 | mDisplay = display; |
| 1393 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1394 | final Resources res = mContext.getResources(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1395 | int shortSize, longSize; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1396 | if (width > height) { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1397 | shortSize = height; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1398 | longSize = width; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1399 | mLandscapeRotation = Surface.ROTATION_0; |
| 1400 | mSeascapeRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1401 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1402 | mPortraitRotation = Surface.ROTATION_90; |
| 1403 | mUpsideDownRotation = Surface.ROTATION_270; |
| 1404 | } else { |
| 1405 | mPortraitRotation = Surface.ROTATION_270; |
| 1406 | mUpsideDownRotation = Surface.ROTATION_90; |
| 1407 | } |
| 1408 | } else { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1409 | shortSize = width; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1410 | longSize = height; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1411 | mPortraitRotation = Surface.ROTATION_0; |
| 1412 | mUpsideDownRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1413 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1414 | mLandscapeRotation = Surface.ROTATION_270; |
| 1415 | mSeascapeRotation = Surface.ROTATION_90; |
| 1416 | } else { |
| 1417 | mLandscapeRotation = Surface.ROTATION_90; |
| 1418 | mSeascapeRotation = Surface.ROTATION_270; |
| 1419 | } |
| 1420 | } |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1421 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1422 | mStatusBarHeight = |
| 1423 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1424 | |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1425 | // Height of the navigation bar when presented horizontally at bottom |
| 1426 | mNavigationBarHeightForRotation[mPortraitRotation] = |
| 1427 | mNavigationBarHeightForRotation[mUpsideDownRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1428 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1429 | mNavigationBarHeightForRotation[mLandscapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1430 | mNavigationBarHeightForRotation[mSeascapeRotation] = res.getDimensionPixelSize( |
| 1431 | com.android.internal.R.dimen.navigation_bar_height_landscape); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1432 | |
| 1433 | // Width of the navigation bar when presented vertically along one side |
| 1434 | mNavigationBarWidthForRotation[mPortraitRotation] = |
| 1435 | mNavigationBarWidthForRotation[mUpsideDownRotation] = |
| 1436 | mNavigationBarWidthForRotation[mLandscapeRotation] = |
| 1437 | mNavigationBarWidthForRotation[mSeascapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1438 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1439 | |
| 1440 | // SystemUI (status bar) layout policy |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1441 | int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1442 | int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1443 | |
Devin Kim | d7b12b4 | 2014-05-05 14:34:58 -0700 | [diff] [blame] | 1444 | // Allow the navigation bar to move on non-square small devices (phones). |
| 1445 | mNavigationBarCanMove = width != height && shortSizeDp < 600; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1446 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1447 | mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1448 | // Allow a system property to override this. Used by the emulator. |
| 1449 | // See also hasNavigationBar(). |
| 1450 | String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); |
| 1451 | if ("1".equals(navBarOverride)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1452 | mHasNavigationBar = false; |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1453 | } else if ("0".equals(navBarOverride)) { |
| 1454 | mHasNavigationBar = true; |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1455 | } |
| 1456 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 1457 | // For demo purposes, allow the rotation of the HDMI display to be controlled. |
| 1458 | // By default, HDMI locks rotation to landscape. |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1459 | if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1460 | mDemoHdmiRotation = mPortraitRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1461 | } else { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1462 | mDemoHdmiRotation = mLandscapeRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1463 | } |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1464 | mDemoHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1465 | |
Chong Zhang | ae6119ff | 2014-11-11 18:54:39 -0800 | [diff] [blame] | 1466 | // For demo purposes, allow the rotation of the remote display to be controlled. |
| 1467 | // By default, remote display locks rotation to landscape. |
| 1468 | if ("portrait".equals(SystemProperties.get("persist.demo.remoterotation"))) { |
| 1469 | mDemoRotation = mPortraitRotation; |
| 1470 | } else { |
| 1471 | mDemoRotation = mLandscapeRotation; |
| 1472 | } |
| 1473 | mDemoRotationLock = SystemProperties.getBoolean( |
| 1474 | "persist.demo.rotationlock", false); |
| 1475 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1476 | // Only force the default orientation if the screen is xlarge, at least 960dp x 720dp, per |
| 1477 | // http://developer.android.com/guide/practices/screens_support.html#range |
| 1478 | mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 && |
| 1479 | res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) && |
| 1480 | // For debug purposes the next line turns this feature off with: |
| 1481 | // $ adb shell setprop config.override_forced_orient true |
| 1482 | // $ adb shell wm size reset |
| 1483 | !"true".equals(SystemProperties.get("config.override_forced_orient")); |
| 1484 | } |
| 1485 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1486 | /** |
| 1487 | * @return whether the navigation bar can be hidden, e.g. the device has a |
| 1488 | * navigation bar and touch exploration is not enabled |
| 1489 | */ |
| 1490 | private boolean canHideNavigationBar() { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 1491 | return mHasNavigationBar |
| 1492 | && !mAccessibilityManager.isTouchExplorationEnabled(); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1493 | } |
| 1494 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1495 | @Override |
| 1496 | public boolean isDefaultOrientationForced() { |
| 1497 | return mForceDefaultOrientation; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1498 | } |
| 1499 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1500 | @Override |
| 1501 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom) { |
| 1502 | if (display.getDisplayId() == Display.DEFAULT_DISPLAY) { |
| 1503 | mOverscanLeft = left; |
| 1504 | mOverscanTop = top; |
| 1505 | mOverscanRight = right; |
| 1506 | mOverscanBottom = bottom; |
| 1507 | } |
| 1508 | } |
| 1509 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1510 | public void updateSettings() { |
| 1511 | ContentResolver resolver = mContext.getContentResolver(); |
| 1512 | boolean updateRotation = false; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1513 | synchronized (mLock) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1514 | mEndcallBehavior = Settings.System.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1515 | Settings.System.END_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1516 | Settings.System.END_BUTTON_BEHAVIOR_DEFAULT, |
| 1517 | UserHandle.USER_CURRENT); |
| 1518 | mIncallPowerBehavior = Settings.Secure.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1519 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1520 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT, |
| 1521 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1522 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1523 | // Configure wake gesture. |
| 1524 | boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver, |
| 1525 | Settings.Secure.WAKE_GESTURE_ENABLED, 0, |
| 1526 | UserHandle.USER_CURRENT) != 0; |
| 1527 | if (mWakeGestureEnabledSetting != wakeGestureEnabledSetting) { |
| 1528 | mWakeGestureEnabledSetting = wakeGestureEnabledSetting; |
| 1529 | updateWakeGestureListenerLp(); |
| 1530 | } |
| 1531 | |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1532 | // Configure rotation lock. |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1533 | int userRotation = Settings.System.getIntForUser(resolver, |
| 1534 | Settings.System.USER_ROTATION, Surface.ROTATION_0, |
| 1535 | UserHandle.USER_CURRENT); |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1536 | if (mUserRotation != userRotation) { |
| 1537 | mUserRotation = userRotation; |
| 1538 | updateRotation = true; |
| 1539 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1540 | int userRotationMode = Settings.System.getIntForUser(resolver, |
| 1541 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1542 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 1543 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
| 1544 | if (mUserRotationMode != userRotationMode) { |
| 1545 | mUserRotationMode = userRotationMode; |
| 1546 | updateRotation = true; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1547 | updateOrientationListenerLp(); |
| 1548 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1549 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1550 | if (mSystemReady) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1551 | int pointerLocation = Settings.System.getIntForUser(resolver, |
| 1552 | Settings.System.POINTER_LOCATION, 0, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1553 | if (mPointerLocationMode != pointerLocation) { |
| 1554 | mPointerLocationMode = pointerLocation; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1555 | mHandler.sendEmptyMessage(pointerLocation != 0 ? |
| 1556 | MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1557 | } |
| 1558 | } |
| 1559 | // use screen off timeout setting as the timeout for the lockscreen |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1560 | mLockScreenTimeout = Settings.System.getIntForUser(resolver, |
| 1561 | Settings.System.SCREEN_OFF_TIMEOUT, 0, UserHandle.USER_CURRENT); |
| 1562 | String imId = Settings.Secure.getStringForUser(resolver, |
| 1563 | Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1564 | boolean hasSoftInput = imId != null && imId.length() > 0; |
| 1565 | if (mHasSoftInput != hasSoftInput) { |
| 1566 | mHasSoftInput = hasSoftInput; |
| 1567 | updateRotation = true; |
| 1568 | } |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1569 | if (mImmersiveModeConfirmation != null) { |
John Spurlock | 4355a53 | 2014-02-19 09:49:25 -0500 | [diff] [blame] | 1570 | mImmersiveModeConfirmation.loadSetting(mCurrentUserId); |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1571 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 1572 | PolicyControl.reloadFromSetting(mContext); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1573 | } |
| 1574 | if (updateRotation) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1575 | updateRotation(true); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1576 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1577 | } |
| 1578 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1579 | private void updateWakeGestureListenerLp() { |
| 1580 | if (shouldEnableWakeGestureLp()) { |
| 1581 | mWakeGestureListener.requestWakeUpTrigger(); |
| 1582 | } else { |
| 1583 | mWakeGestureListener.cancelWakeUpTrigger(); |
| 1584 | } |
| 1585 | } |
| 1586 | |
| 1587 | private boolean shouldEnableWakeGestureLp() { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 1588 | return mWakeGestureEnabledSetting && !mAwake |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1589 | && (!mLidControlsSleep || mLidState != LID_CLOSED) |
| 1590 | && mWakeGestureListener.isSupported(); |
| 1591 | } |
| 1592 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1593 | private void enablePointerLocation() { |
| 1594 | if (mPointerLocationView == null) { |
| 1595 | mPointerLocationView = new PointerLocationView(mContext); |
| 1596 | mPointerLocationView.setPrintCoords(false); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1597 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 1598 | WindowManager.LayoutParams.MATCH_PARENT, |
| 1599 | WindowManager.LayoutParams.MATCH_PARENT); |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1600 | lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1601 | lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
| 1602 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
| 1603 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1604 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
Jeff Brown | 90fc905 | 2012-10-01 14:44:24 -0700 | [diff] [blame] | 1605 | if (ActivityManager.isHighEndGfx()) { |
| 1606 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1607 | lp.privateFlags |= |
| 1608 | WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; |
| 1609 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1610 | lp.format = PixelFormat.TRANSLUCENT; |
| 1611 | lp.setTitle("PointerLocation"); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1612 | WindowManager wm = (WindowManager) |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1613 | mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1614 | lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1615 | wm.addView(mPointerLocationView, lp); |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1616 | mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1617 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1618 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1619 | |
| 1620 | private void disablePointerLocation() { |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1621 | if (mPointerLocationView != null) { |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1622 | mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView); |
| 1623 | WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1624 | wm.removeView(mPointerLocationView); |
| 1625 | mPointerLocationView = null; |
| 1626 | } |
| 1627 | } |
| 1628 | |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1629 | private int readRotation(int resID) { |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1630 | try { |
| 1631 | int rotation = mContext.getResources().getInteger(resID); |
| 1632 | switch (rotation) { |
| 1633 | case 0: |
| 1634 | return Surface.ROTATION_0; |
| 1635 | case 90: |
| 1636 | return Surface.ROTATION_90; |
| 1637 | case 180: |
| 1638 | return Surface.ROTATION_180; |
| 1639 | case 270: |
| 1640 | return Surface.ROTATION_270; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1641 | } |
| 1642 | } catch (Resources.NotFoundException e) { |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1643 | // fall through |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1644 | } |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1645 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1646 | } |
| 1647 | |
| 1648 | /** {@inheritDoc} */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1649 | @Override |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1650 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1651 | int type = attrs.type; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1652 | |
| 1653 | outAppOp[0] = AppOpsManager.OP_NONE; |
| 1654 | |
Wale Ogunwale | 74bf065 | 2015-01-12 10:24:36 -0800 | [diff] [blame] | 1655 | if (!((type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) |
| 1656 | || (type >= FIRST_SUB_WINDOW && type <= LAST_SUB_WINDOW) |
| 1657 | || (type >= FIRST_SYSTEM_WINDOW && type <= LAST_SYSTEM_WINDOW))) { |
| 1658 | return WindowManagerGlobal.ADD_INVALID_TYPE; |
| 1659 | } |
| 1660 | |
| 1661 | if (type < FIRST_SYSTEM_WINDOW || type > LAST_SYSTEM_WINDOW) { |
| 1662 | // Window manager will make sure these are okay. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1663 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1664 | } |
| 1665 | String permission = null; |
| 1666 | switch (type) { |
| 1667 | case TYPE_TOAST: |
| 1668 | // XXX right now the app process has complete control over |
| 1669 | // this... should introduce a token to let the system |
| 1670 | // monitor/control what they are doing. |
Jason Monk | 1c7c319 | 2014-06-26 12:52:18 -0400 | [diff] [blame] | 1671 | outAppOp[0] = AppOpsManager.OP_TOAST_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1672 | break; |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 1673 | case TYPE_DREAM: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1674 | case TYPE_INPUT_METHOD: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1675 | case TYPE_WALLPAPER: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1676 | case TYPE_PRIVATE_PRESENTATION: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1677 | case TYPE_VOICE_INTERACTION: |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 1678 | case TYPE_ACCESSIBILITY_OVERLAY: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1679 | // The window manager will check these. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1680 | break; |
| 1681 | case TYPE_PHONE: |
| 1682 | case TYPE_PRIORITY_PHONE: |
| 1683 | case TYPE_SYSTEM_ALERT: |
| 1684 | case TYPE_SYSTEM_ERROR: |
| 1685 | case TYPE_SYSTEM_OVERLAY: |
| 1686 | permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1687 | outAppOp[0] = AppOpsManager.OP_SYSTEM_ALERT_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1688 | break; |
| 1689 | default: |
| 1690 | permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; |
| 1691 | } |
| 1692 | if (permission != null) { |
| 1693 | if (mContext.checkCallingOrSelfPermission(permission) |
| 1694 | != PackageManager.PERMISSION_GRANTED) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1695 | return WindowManagerGlobal.ADD_PERMISSION_DENIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1696 | } |
| 1697 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1698 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1699 | } |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1700 | |
| 1701 | @Override |
| 1702 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs) { |
| 1703 | |
| 1704 | // If this switch statement is modified, modify the comment in the declarations of |
| 1705 | // the type in {@link WindowManager.LayoutParams} as well. |
| 1706 | switch (attrs.type) { |
| 1707 | default: |
| 1708 | // These are the windows that by default are shown only to the user that created |
| 1709 | // them. If this needs to be overridden, set |
| 1710 | // {@link WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS} in |
| 1711 | // {@link WindowManager.LayoutParams}. Note that permission |
| 1712 | // {@link android.Manifest.permission.INTERNAL_SYSTEM_WINDOW} is required as well. |
| 1713 | if ((attrs.privateFlags & PRIVATE_FLAG_SHOW_FOR_ALL_USERS) == 0) { |
| 1714 | return true; |
| 1715 | } |
| 1716 | break; |
| 1717 | |
| 1718 | // These are the windows that by default are shown to all users. However, to |
| 1719 | // protect against spoofing, check permissions below. |
| 1720 | case TYPE_APPLICATION_STARTING: |
| 1721 | case TYPE_BOOT_PROGRESS: |
| 1722 | case TYPE_DISPLAY_OVERLAY: |
| 1723 | case TYPE_HIDDEN_NAV_CONSUMER: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1724 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1725 | case TYPE_KEYGUARD_DIALOG: |
| 1726 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1727 | case TYPE_NAVIGATION_BAR: |
| 1728 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1729 | case TYPE_PHONE: |
| 1730 | case TYPE_POINTER: |
| 1731 | case TYPE_PRIORITY_PHONE: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1732 | case TYPE_SEARCH_BAR: |
| 1733 | case TYPE_STATUS_BAR: |
| 1734 | case TYPE_STATUS_BAR_PANEL: |
| 1735 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1736 | case TYPE_SYSTEM_DIALOG: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1737 | case TYPE_VOLUME_OVERLAY: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1738 | case TYPE_PRIVATE_PRESENTATION: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1739 | break; |
| 1740 | } |
| 1741 | |
| 1742 | // Check if third party app has set window to system window type. |
| 1743 | return mContext.checkCallingOrSelfPermission( |
| 1744 | android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) |
| 1745 | != PackageManager.PERMISSION_GRANTED; |
| 1746 | } |
| 1747 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1748 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1749 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) { |
| 1750 | switch (attrs.type) { |
| 1751 | case TYPE_SYSTEM_OVERLAY: |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1752 | case TYPE_SECURE_SYSTEM_OVERLAY: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1753 | // These types of windows can't receive input events. |
| 1754 | attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1755 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1756 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1757 | break; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1758 | case TYPE_STATUS_BAR: |
| 1759 | |
| 1760 | // If the Keyguard is in a hidden state (occluded by another window), we force to |
| 1761 | // remove the wallpaper and keyguard flag so that any change in-flight after setting |
| 1762 | // the keyguard as occluded wouldn't set these flags again. |
| 1763 | // See {@link #processKeyguardSetHiddenResultLw}. |
| 1764 | if (mKeyguardHidden) { |
| 1765 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 1766 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 1767 | } |
| 1768 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1769 | } |
Adrian Roos | 3850211 | 2014-04-09 21:04:11 +0200 | [diff] [blame] | 1770 | |
| 1771 | if (attrs.type != TYPE_STATUS_BAR) { |
| 1772 | // The status bar is the only window allowed to exhibit keyguard behavior. |
| 1773 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 1774 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1775 | |
| 1776 | if (ActivityManager.isHighEndGfx() |
| 1777 | && (attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) { |
Adrian Roos | f5e9b5c | 2014-09-10 15:27:41 +0200 | [diff] [blame] | 1778 | attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 1779 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; |
| 1780 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1781 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1782 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1783 | void readLidState() { |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 1784 | mLidState = mWindowManagerFuncs.getLidState(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1785 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 1786 | |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 1787 | private void readCameraLensCoverState() { |
| 1788 | mCameraLensCoverState = mWindowManagerFuncs.getCameraLensCoverState(); |
| 1789 | } |
| 1790 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1791 | private boolean isHidden(int accessibilityMode) { |
| 1792 | switch (accessibilityMode) { |
| 1793 | case 1: |
| 1794 | return mLidState == LID_CLOSED; |
| 1795 | case 2: |
| 1796 | return mLidState == LID_OPEN; |
| 1797 | default: |
| 1798 | return false; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1799 | } |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1800 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1801 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1802 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1803 | @Override |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1804 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 1805 | int navigationPresence) { |
| 1806 | mHaveBuiltInKeyboard = (keyboardPresence & PRESENCE_INTERNAL) != 0; |
| 1807 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1808 | readConfigurationDependentBehaviors(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1809 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1810 | applyLidSwitchState(); |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1811 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1812 | if (config.keyboard == Configuration.KEYBOARD_NOKEYS |
| 1813 | || (keyboardPresence == PRESENCE_INTERNAL |
| 1814 | && isHidden(mLidKeyboardAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1815 | config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1816 | if (!mHasSoftInput) { |
| 1817 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; |
| 1818 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1819 | } |
| 1820 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 1821 | if (config.navigation == Configuration.NAVIGATION_NONAV |
| 1822 | || (navigationPresence == PRESENCE_INTERNAL |
| 1823 | && isHidden(mLidNavigationAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1824 | config.navigationHidden = Configuration.NAVIGATIONHIDDEN_YES; |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1825 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1826 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1827 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1828 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1829 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1830 | public int windowTypeToLayerLw(int type) { |
| 1831 | if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1832 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1833 | } |
| 1834 | switch (type) { |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 1835 | case TYPE_PRIVATE_PRESENTATION: |
| 1836 | return 2; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1837 | case TYPE_WALLPAPER: |
| 1838 | // wallpaper is at the bottom, though the window manager may move it. |
| 1839 | return 2; |
| 1840 | case TYPE_PHONE: |
| 1841 | return 3; |
| 1842 | case TYPE_SEARCH_BAR: |
| 1843 | return 4; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1844 | case TYPE_VOICE_INTERACTION: |
| 1845 | // voice interaction layer is almost immediately above apps. |
| 1846 | return 5; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1847 | case TYPE_SYSTEM_DIALOG: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1848 | return 6; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1849 | case TYPE_TOAST: |
| 1850 | // toasts and the plugged-in battery thing |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1851 | return 7; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1852 | case TYPE_PRIORITY_PHONE: |
| 1853 | // 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] | 1854 | return 8; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1855 | case TYPE_DREAM: |
| 1856 | // used for Dreams (screensavers with TYPE_DREAM windows) |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1857 | return 9; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1858 | case TYPE_SYSTEM_ALERT: |
| 1859 | // like the ANR / app crashed dialogs |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1860 | return 10; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1861 | case TYPE_INPUT_METHOD: |
| 1862 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1863 | return 11; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1864 | case TYPE_INPUT_METHOD_DIALOG: |
| 1865 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1866 | return 12; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1867 | case TYPE_KEYGUARD_SCRIM: |
| 1868 | // the safety window that shows behind keyguard while keyguard is starting |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1869 | return 13; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1870 | case TYPE_STATUS_BAR_SUB_PANEL: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1871 | return 14; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1872 | case TYPE_STATUS_BAR: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1873 | return 15; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1874 | case TYPE_STATUS_BAR_PANEL: |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1875 | return 16; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1876 | case TYPE_KEYGUARD_DIALOG: |
| 1877 | return 17; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1878 | case TYPE_VOLUME_OVERLAY: |
| 1879 | // the on-screen volume indicator and controller shown when the user |
| 1880 | // changes the device volume |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1881 | return 18; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1882 | case TYPE_SYSTEM_OVERLAY: |
| 1883 | // the on-screen volume indicator and controller shown when the user |
| 1884 | // changes the device volume |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1885 | return 19; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1886 | case TYPE_NAVIGATION_BAR: |
| 1887 | // the navigation bar, if available, shows atop most things |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1888 | return 20; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1889 | case TYPE_NAVIGATION_BAR_PANEL: |
| 1890 | // 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] | 1891 | return 21; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1892 | case TYPE_SYSTEM_ERROR: |
| 1893 | // system-level error dialogs |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1894 | return 22; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1895 | case TYPE_MAGNIFICATION_OVERLAY: |
| 1896 | // used to highlight the magnified portion of a display |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1897 | return 23; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1898 | case TYPE_DISPLAY_OVERLAY: |
| 1899 | // used to simulate secondary display devices |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1900 | return 24; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1901 | case TYPE_DRAG: |
| 1902 | // the drag layer: input for drag-and-drop is associated with this window, |
| 1903 | // which sits above all other focusable windows |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1904 | return 25; |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 1905 | case TYPE_ACCESSIBILITY_OVERLAY: |
| 1906 | // overlay put by accessibility services to intercept user interaction |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 1907 | return 26; |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 1908 | case TYPE_SECURE_SYSTEM_OVERLAY: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1909 | return 27; |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 1910 | case TYPE_BOOT_PROGRESS: |
| 1911 | return 28; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1912 | case TYPE_POINTER: |
| 1913 | // the (mouse) pointer layer |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 1914 | return 29; |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 1915 | case TYPE_HIDDEN_NAV_CONSUMER: |
| 1916 | return 30; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1917 | } |
| 1918 | Log.e(TAG, "Unknown window type: " + type); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1919 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1920 | } |
| 1921 | |
| 1922 | /** {@inheritDoc} */ |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1923 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1924 | public int subWindowTypeToLayerLw(int type) { |
| 1925 | switch (type) { |
| 1926 | case TYPE_APPLICATION_PANEL: |
| 1927 | case TYPE_APPLICATION_ATTACHED_DIALOG: |
| 1928 | return APPLICATION_PANEL_SUBLAYER; |
| 1929 | case TYPE_APPLICATION_MEDIA: |
| 1930 | return APPLICATION_MEDIA_SUBLAYER; |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 1931 | case TYPE_APPLICATION_MEDIA_OVERLAY: |
| 1932 | return APPLICATION_MEDIA_OVERLAY_SUBLAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1933 | case TYPE_APPLICATION_SUB_PANEL: |
| 1934 | return APPLICATION_SUB_PANEL_SUBLAYER; |
| 1935 | } |
| 1936 | Log.e(TAG, "Unknown sub-window type: " + type); |
| 1937 | return 0; |
| 1938 | } |
| 1939 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1940 | @Override |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1941 | public int getMaxWallpaperLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1942 | return windowTypeToLayerLw(TYPE_STATUS_BAR); |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1943 | } |
| 1944 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1945 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1946 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1947 | if (mHasNavigationBar) { |
| 1948 | // For a basic navigation bar, when we are in landscape mode we place |
| 1949 | // the navigation bar to the side. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1950 | if (mNavigationBarCanMove && fullWidth > fullHeight) { |
| 1951 | return fullWidth - mNavigationBarWidthForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1952 | } |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1953 | } |
| 1954 | return fullWidth; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1955 | } |
| 1956 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1957 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1958 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1959 | if (mHasNavigationBar) { |
| 1960 | // For a basic navigation bar, when we are in portrait mode we place |
| 1961 | // the navigation bar to the bottom. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1962 | if (!mNavigationBarCanMove || fullWidth < fullHeight) { |
| 1963 | return fullHeight - mNavigationBarHeightForRotation[rotation]; |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 1964 | } |
| 1965 | } |
| 1966 | return fullHeight; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1967 | } |
| 1968 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1969 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1970 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
| 1971 | return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1972 | } |
| 1973 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1974 | @Override |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1975 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1976 | // There is a separate status bar at the top of the display. We don't count that as part |
| 1977 | // 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] | 1978 | // we do want to exclude it since applications can't generally use that part |
| 1979 | // of the screen. |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1980 | return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation) - mStatusBarHeight; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1981 | } |
| 1982 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1983 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 1984 | public boolean isForceHiding(WindowManager.LayoutParams attrs) { |
| 1985 | return (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 || |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 1986 | (isKeyguardHostWindow(attrs) && |
| 1987 | (mKeyguardDelegate != null && mKeyguardDelegate.isShowing())) || |
Adrian Roos | 69e510d | 2014-07-13 14:57:59 +0200 | [diff] [blame] | 1988 | (attrs.type == TYPE_KEYGUARD_SCRIM); |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1989 | } |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 1990 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1991 | @Override |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1992 | public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs) { |
| 1993 | return attrs.type == TYPE_STATUS_BAR; |
| 1994 | } |
| 1995 | |
| 1996 | @Override |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1997 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs) { |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 1998 | switch (attrs.type) { |
| 1999 | case TYPE_STATUS_BAR: |
| 2000 | case TYPE_NAVIGATION_BAR: |
| 2001 | case TYPE_WALLPAPER: |
| 2002 | case TYPE_DREAM: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2003 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 2004 | return false; |
| 2005 | default: |
| 2006 | return true; |
| 2007 | } |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 2008 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2009 | |
Craig Mautner | 7d7808f | 2014-09-11 18:02:38 -0700 | [diff] [blame] | 2010 | @Override |
| 2011 | public WindowState getWinShowWhenLockedLw() { |
| 2012 | return mWinShowWhenLocked; |
| 2013 | } |
| 2014 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2015 | /** {@inheritDoc} */ |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2016 | @Override |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 2017 | public View addStartingWindow(IBinder appToken, String packageName, int theme, |
| 2018 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 2019 | int icon, int logo, int windowFlags) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2020 | if (!SHOW_STARTING_ANIMATIONS) { |
| 2021 | return null; |
| 2022 | } |
| 2023 | if (packageName == null) { |
| 2024 | return null; |
| 2025 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2026 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 2027 | WindowManager wm = null; |
| 2028 | View view = null; |
| 2029 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2030 | try { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2031 | Context context = mContext; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 2032 | if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow " + packageName |
| 2033 | + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" |
| 2034 | + Integer.toHexString(theme)); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 2035 | if (theme != context.getThemeResId() || labelRes != 0) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2036 | try { |
| 2037 | context = context.createPackageContext(packageName, 0); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 2038 | context.setTheme(theme); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2039 | } catch (PackageManager.NameNotFoundException e) { |
| 2040 | // Ignore |
| 2041 | } |
| 2042 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2043 | |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 2044 | Window win = new PhoneWindow(context); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2045 | final TypedArray ta = win.getWindowStyle(); |
| 2046 | if (ta.getBoolean( |
| 2047 | com.android.internal.R.styleable.Window_windowDisablePreview, false) |
| 2048 | || ta.getBoolean( |
| 2049 | com.android.internal.R.styleable.Window_windowShowWallpaper,false)) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2050 | return null; |
| 2051 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2052 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2053 | Resources r = context.getResources(); |
| 2054 | win.setTitle(r.getText(labelRes, nonLocalizedLabel)); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2055 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2056 | win.setType( |
| 2057 | WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); |
| 2058 | // Force the window flags: this is a fake window, so it is not really |
| 2059 | // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM |
| 2060 | // flag because we do know that the next window will take input |
| 2061 | // focus, so we want to get the IME window up on top of us right away. |
| 2062 | win.setFlags( |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 2063 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2064 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 2065 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 2066 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 2067 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2068 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 2069 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 2070 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2071 | |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 2072 | win.setDefaultIcon(icon); |
| 2073 | win.setDefaultLogo(logo); |
| 2074 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2075 | win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 2076 | WindowManager.LayoutParams.MATCH_PARENT); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2077 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2078 | final WindowManager.LayoutParams params = win.getAttributes(); |
| 2079 | params.token = appToken; |
| 2080 | params.packageName = packageName; |
| 2081 | params.windowAnimations = win.getWindowStyle().getResourceId( |
| 2082 | com.android.internal.R.styleable.Window_windowAnimationStyle, 0); |
John Reck | 61375a8 | 2014-09-18 19:27:48 +0000 | [diff] [blame] | 2083 | params.privateFlags |= |
| 2084 | WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 2085 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 2086 | |
| 2087 | if (!compatInfo.supportsScreen()) { |
| 2088 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; |
| 2089 | } |
| 2090 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2091 | params.setTitle("Starting " + packageName); |
| 2092 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 2093 | wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
| 2094 | view = win.getDecorView(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2095 | |
| 2096 | if (win.isFloating()) { |
| 2097 | // Whoops, there is no way to display an animation/preview |
| 2098 | // of such a thing! After all that work... let's skip it. |
| 2099 | // (Note that we must do this here because it is in |
| 2100 | // getDecorView() where the theme is evaluated... maybe |
| 2101 | // we should peek the floating attribute from the theme |
| 2102 | // earlier.) |
| 2103 | return null; |
| 2104 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2105 | |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 2106 | if (DEBUG_STARTING_WINDOW) Slog.d( |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2107 | TAG, "Adding starting window for " + packageName |
| 2108 | + " / " + appToken + ": " |
| 2109 | + (view.getParent() != null ? view : null)); |
| 2110 | |
| 2111 | wm.addView(view, params); |
| 2112 | |
| 2113 | // Only return the view if it was successfully added to the |
| 2114 | // window manager... which we can tell by it having a parent. |
| 2115 | return view.getParent() != null ? view : null; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2116 | } catch (WindowManager.BadTokenException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2117 | // ignore |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 2118 | Log.w(TAG, appToken + " already running, starting window not displayed. " + |
| 2119 | e.getMessage()); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2120 | } catch (RuntimeException e) { |
| 2121 | // don't crash if something else bad happens, for example a |
| 2122 | // failure loading resources because we are loading from an app |
| 2123 | // on external storage that has been unmounted. |
| 2124 | Log.w(TAG, appToken + " failed creating starting window", e); |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 2125 | } finally { |
| 2126 | if (view != null && view.getParent() == null) { |
| 2127 | Log.w(TAG, "view not successfully added to wm, removing view"); |
| 2128 | wm.removeViewImmediate(view); |
| 2129 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2130 | } |
| 2131 | |
| 2132 | return null; |
| 2133 | } |
| 2134 | |
| 2135 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2136 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2137 | public void removeStartingWindow(IBinder appToken, View window) { |
Craig Mautner | 276a6eb | 2014-11-04 15:32:57 -0800 | [diff] [blame] | 2138 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Removing starting window for " + appToken + ": " |
| 2139 | + window + " Callers=" + Debug.getCallers(4)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2140 | |
| 2141 | if (window != null) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 2142 | WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2143 | wm.removeView(window); |
| 2144 | } |
| 2145 | } |
| 2146 | |
| 2147 | /** |
| 2148 | * Preflight adding a window to the system. |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2149 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2150 | * Currently enforces that three window types are singletons: |
| 2151 | * <ul> |
| 2152 | * <li>STATUS_BAR_TYPE</li> |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2153 | * <li>KEYGUARD_TYPE</li> |
| 2154 | * </ul> |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2155 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2156 | * @param win The window to be added |
| 2157 | * @param attrs Information about the window to be added |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2158 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2159 | * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, |
| 2160 | * WindowManagerImpl.ADD_MULTIPLE_SINGLETON |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2161 | */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2162 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2163 | public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) { |
| 2164 | switch (attrs.type) { |
| 2165 | case TYPE_STATUS_BAR: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 2166 | mContext.enforceCallingOrSelfPermission( |
| 2167 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 2168 | "PhoneWindowManager"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2169 | if (mStatusBar != null) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2170 | if (mStatusBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2171 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2172 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2173 | } |
| 2174 | mStatusBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2175 | mStatusBarController.setWindow(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2176 | break; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2177 | case TYPE_NAVIGATION_BAR: |
| 2178 | mContext.enforceCallingOrSelfPermission( |
| 2179 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 2180 | "PhoneWindowManager"); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2181 | if (mNavigationBar != null) { |
| 2182 | if (mNavigationBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2183 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2184 | } |
| 2185 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2186 | mNavigationBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2187 | mNavigationBarController.setWindow(win); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2188 | if (DEBUG_LAYOUT) Slog.i(TAG, "NAVIGATION BAR: " + mNavigationBar); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2189 | break; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 2190 | case TYPE_NAVIGATION_BAR_PANEL: |
| 2191 | mContext.enforceCallingOrSelfPermission( |
| 2192 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 2193 | "PhoneWindowManager"); |
| 2194 | break; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 2195 | case TYPE_STATUS_BAR_PANEL: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 2196 | mContext.enforceCallingOrSelfPermission( |
| 2197 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 2198 | "PhoneWindowManager"); |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 2199 | break; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2200 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 2201 | mContext.enforceCallingOrSelfPermission( |
| 2202 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 2203 | "PhoneWindowManager"); |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2204 | break; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2205 | case TYPE_KEYGUARD_SCRIM: |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 2206 | if (mKeyguardScrim != null) { |
| 2207 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
| 2208 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2209 | mKeyguardScrim = win; |
| 2210 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2211 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2212 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2213 | } |
| 2214 | |
| 2215 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2216 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2217 | public void removeWindowLw(WindowState win) { |
| 2218 | if (mStatusBar == win) { |
| 2219 | mStatusBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2220 | mStatusBarController.setWindow(null); |
Jim Miller | c0b676d | 2013-03-22 16:11:08 -0700 | [diff] [blame] | 2221 | mKeyguardDelegate.showScrim(); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2222 | } else if (mKeyguardScrim == win) { |
| 2223 | Log.v(TAG, "Removing keyguard scrim"); |
| 2224 | mKeyguardScrim = null; |
| 2225 | } if (mNavigationBar == win) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2226 | mNavigationBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2227 | mNavigationBarController.setWindow(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2228 | } |
| 2229 | } |
| 2230 | |
| 2231 | static final boolean PRINT_ANIM = false; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2232 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2233 | /** {@inheritDoc} */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2234 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2235 | public int selectAnimationLw(WindowState win, int transit) { |
| 2236 | if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win |
| 2237 | + ": transit=" + transit); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2238 | if (win == mStatusBar) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2239 | boolean isKeyguard = (win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2240 | if (transit == TRANSIT_EXIT |
| 2241 | || transit == TRANSIT_HIDE) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2242 | return isKeyguard ? -1 : R.anim.dock_top_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2243 | } else if (transit == TRANSIT_ENTER |
| 2244 | || transit == TRANSIT_SHOW) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2245 | return isKeyguard ? -1 : R.anim.dock_top_enter; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2246 | } |
| 2247 | } else if (win == mNavigationBar) { |
| 2248 | // This can be on either the bottom or the right. |
| 2249 | if (mNavigationBarOnBottom) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2250 | if (transit == TRANSIT_EXIT |
| 2251 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2252 | return R.anim.dock_bottom_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2253 | } else if (transit == TRANSIT_ENTER |
| 2254 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2255 | return R.anim.dock_bottom_enter; |
| 2256 | } |
| 2257 | } else { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2258 | if (transit == TRANSIT_EXIT |
| 2259 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2260 | return R.anim.dock_right_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2261 | } else if (transit == TRANSIT_ENTER |
| 2262 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2263 | return R.anim.dock_right_enter; |
| 2264 | } |
| 2265 | } |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2266 | } |
| 2267 | |
| 2268 | if (transit == TRANSIT_PREVIEW_DONE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2269 | if (win.hasAppShownWindows()) { |
| 2270 | if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT"); |
| 2271 | return com.android.internal.R.anim.app_starting_exit; |
| 2272 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 2273 | } else if (win.getAttrs().type == TYPE_DREAM && mDreamingLockscreen |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2274 | && transit == TRANSIT_ENTER) { |
| 2275 | // Special case: we are animating in a dream, while the keyguard |
| 2276 | // is shown. We don't want an animation on the dream, because |
| 2277 | // we need it shown immediately with the keyguard animating away |
| 2278 | // to reveal it. |
| 2279 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2280 | } |
| 2281 | |
| 2282 | return 0; |
| 2283 | } |
| 2284 | |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 2285 | @Override |
| 2286 | public void selectRotationAnimationLw(int anim[]) { |
| 2287 | if (PRINT_ANIM) Slog.i(TAG, "selectRotationAnimation mTopFullscreen=" |
| 2288 | + mTopFullscreenOpaqueWindowState + " rotationAnimation=" |
| 2289 | + (mTopFullscreenOpaqueWindowState == null ? |
| 2290 | "0" : mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation)); |
| 2291 | if (mTopFullscreenOpaqueWindowState != null && mTopIsFullscreen) { |
| 2292 | switch (mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation) { |
| 2293 | case ROTATION_ANIMATION_CROSSFADE: |
| 2294 | anim[0] = R.anim.rotation_animation_xfade_exit; |
| 2295 | anim[1] = R.anim.rotation_animation_enter; |
| 2296 | break; |
| 2297 | case ROTATION_ANIMATION_JUMPCUT: |
| 2298 | anim[0] = R.anim.rotation_animation_jump_exit; |
| 2299 | anim[1] = R.anim.rotation_animation_enter; |
| 2300 | break; |
| 2301 | case ROTATION_ANIMATION_ROTATE: |
| 2302 | default: |
| 2303 | anim[0] = anim[1] = 0; |
| 2304 | break; |
| 2305 | } |
| 2306 | } else { |
| 2307 | anim[0] = anim[1] = 0; |
| 2308 | } |
| 2309 | } |
| 2310 | |
| 2311 | @Override |
| 2312 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 2313 | boolean forceDefault) { |
| 2314 | switch (exitAnimId) { |
| 2315 | case R.anim.rotation_animation_xfade_exit: |
| 2316 | case R.anim.rotation_animation_jump_exit: |
| 2317 | // These are the only cases that matter. |
| 2318 | if (forceDefault) { |
| 2319 | return false; |
| 2320 | } |
| 2321 | int anim[] = new int[2]; |
| 2322 | selectRotationAnimationLw(anim); |
| 2323 | return (exitAnimId == anim[0] && enterAnimId == anim[1]); |
| 2324 | default: |
| 2325 | return true; |
| 2326 | } |
| 2327 | } |
| 2328 | |
| 2329 | @Override |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 2330 | public Animation createForceHideEnterAnimation(boolean onWallpaper, |
| 2331 | boolean goingToNotificationShade) { |
| 2332 | if (goingToNotificationShade) { |
| 2333 | return AnimationUtils.loadAnimation(mContext, R.anim.lock_screen_behind_enter_fade_in); |
Craig Mautner | b834080 | 2014-11-04 15:32:57 -0800 | [diff] [blame] | 2334 | } |
Craig Mautner | 276a6eb | 2014-11-04 15:32:57 -0800 | [diff] [blame] | 2335 | |
| 2336 | AnimationSet set = (AnimationSet) AnimationUtils.loadAnimation(mContext, onWallpaper ? |
| 2337 | R.anim.lock_screen_behind_enter_wallpaper : |
| 2338 | R.anim.lock_screen_behind_enter); |
| 2339 | |
| 2340 | // TODO: Use XML interpolators when we have log interpolators available in XML. |
| 2341 | final List<Animation> animations = set.getAnimations(); |
| 2342 | for (int i = animations.size() - 1; i >= 0; --i) { |
| 2343 | animations.get(i).setInterpolator(mLogDecelerateInterpolator); |
| 2344 | } |
| 2345 | |
| 2346 | return set; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 2347 | } |
| 2348 | |
| 2349 | |
| 2350 | @Override |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 2351 | public Animation createForceHideWallpaperExitAnimation(boolean goingToNotificationShade) { |
| 2352 | if (goingToNotificationShade) { |
| 2353 | return null; |
| 2354 | } else { |
| 2355 | return AnimationUtils.loadAnimation(mContext, R.anim.lock_screen_wallpaper_exit); |
| 2356 | } |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 2357 | } |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 2358 | |
| 2359 | private static void awakenDreams() { |
| 2360 | IDreamManager dreamManager = getDreamManager(); |
| 2361 | if (dreamManager != null) { |
| 2362 | try { |
| 2363 | dreamManager.awaken(); |
| 2364 | } catch (RemoteException e) { |
| 2365 | // fine, stay asleep then |
| 2366 | } |
| 2367 | } |
| 2368 | } |
| 2369 | |
| 2370 | static IDreamManager getDreamManager() { |
| 2371 | return IDreamManager.Stub.asInterface( |
| 2372 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
| 2373 | } |
| 2374 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2375 | TelecomManager getTelecommService() { |
| 2376 | return (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2377 | } |
| 2378 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 2379 | static IAudioService getAudioService() { |
| 2380 | IAudioService audioService = IAudioService.Stub.asInterface( |
| 2381 | ServiceManager.checkService(Context.AUDIO_SERVICE)); |
| 2382 | if (audioService == null) { |
| 2383 | Log.w(TAG, "Unable to find IAudioService interface."); |
| 2384 | } |
| 2385 | return audioService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2386 | } |
| 2387 | |
| 2388 | boolean keyguardOn() { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2389 | return isKeyguardShowingAndNotOccluded() || inKeyguardRestrictedKeyInputMode(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2390 | } |
| 2391 | |
| 2392 | private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { |
| 2393 | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, |
| 2394 | WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, |
| 2395 | }; |
| 2396 | |
| 2397 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2398 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2399 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2400 | final boolean keyguardOn = keyguardOn(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2401 | final int keyCode = event.getKeyCode(); |
| 2402 | final int repeatCount = event.getRepeatCount(); |
| 2403 | final int metaState = event.getMetaState(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2404 | final int flags = event.getFlags(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2405 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 2406 | final boolean canceled = event.isCanceled(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2407 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2408 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2409 | Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount=" |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2410 | + repeatCount + " keyguardOn=" + keyguardOn + " mHomePressed=" + mHomePressed |
| 2411 | + " canceled=" + canceled); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2412 | } |
| 2413 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2414 | // If we think we might have a volume down & power key chord on the way |
| 2415 | // but we're not sure, then tell the dispatcher to wait a little while and |
| 2416 | // try again later before dispatching. |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 2417 | if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2418 | if (mScreenshotChordVolumeDownKeyTriggered && !mScreenshotChordPowerKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2419 | final long now = SystemClock.uptimeMillis(); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2420 | final long timeoutTime = mScreenshotChordVolumeDownKeyTime |
| 2421 | + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2422 | if (now < timeoutTime) { |
| 2423 | return timeoutTime - now; |
| 2424 | } |
| 2425 | } |
| 2426 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2427 | && mScreenshotChordVolumeDownKeyConsumed) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2428 | if (!down) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2429 | mScreenshotChordVolumeDownKeyConsumed = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2430 | } |
| 2431 | return -1; |
| 2432 | } |
| 2433 | } |
| 2434 | |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2435 | // Cancel any pending meta actions if we see any other keys being pressed between the down |
| 2436 | // of the meta key and its corresponding up. |
Michael Wright | 251e35d | 2014-08-22 15:40:27 -0700 | [diff] [blame] | 2437 | if (mPendingMetaAction && !KeyEvent.isMetaKey(keyCode)) { |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2438 | mPendingMetaAction = false; |
| 2439 | } |
| 2440 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2441 | // First we always handle the home key here, so applications |
| 2442 | // can never break it, although if keyguard is on, we do let |
| 2443 | // it handle it, because that gives us the correct 5 second |
| 2444 | // timeout. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2445 | if (keyCode == KeyEvent.KEYCODE_HOME) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2446 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2447 | // If we have released the home key, and didn't do anything else |
| 2448 | // while it was pressed, then it is time to go home! |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2449 | if (!down) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2450 | cancelPreloadRecentApps(); |
| 2451 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2452 | mHomePressed = false; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2453 | if (mHomeConsumed) { |
| 2454 | mHomeConsumed = false; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2455 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2456 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2457 | |
| 2458 | if (canceled) { |
| 2459 | Log.i(TAG, "Ignoring HOME; event canceled."); |
| 2460 | return -1; |
| 2461 | } |
| 2462 | |
Yorke Lee | 4f80324 | 2014-12-15 23:22:06 +0000 | [diff] [blame] | 2463 | // If an incoming call is ringing, HOME is totally disabled. |
| 2464 | // (The user is already on the InCallUI at this point, |
| 2465 | // and his ONLY options are to answer or reject the call.) |
| 2466 | TelecomManager telecomManager = getTelecommService(); |
| 2467 | if (telecomManager != null && telecomManager.isRinging()) { |
| 2468 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); |
| 2469 | return -1; |
| 2470 | } |
| 2471 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2472 | // Delay handling home if a double-tap is possible. |
| 2473 | if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) { |
| 2474 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case |
| 2475 | mHomeDoubleTapPending = true; |
| 2476 | mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable, |
| 2477 | ViewConfiguration.getDoubleTapTimeout()); |
| 2478 | return -1; |
| 2479 | } |
| 2480 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2481 | handleShortPressOnHome(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2482 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2483 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2484 | |
| 2485 | // If a system window has focus, then it doesn't make sense |
| 2486 | // right now to interact with applications. |
| 2487 | WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null; |
| 2488 | if (attrs != null) { |
| 2489 | final int type = attrs.type; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2490 | if (type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM |
| 2491 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG |
| 2492 | || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2493 | // the "app" is keyguard, so give it the key |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2494 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2495 | } |
| 2496 | final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length; |
| 2497 | for (int i=0; i<typeCount; i++) { |
| 2498 | if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) { |
| 2499 | // 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] | 2500 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2501 | } |
| 2502 | } |
| 2503 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2504 | |
| 2505 | // Remember that home is pressed and handle special actions. |
| 2506 | if (repeatCount == 0) { |
| 2507 | mHomePressed = true; |
| 2508 | if (mHomeDoubleTapPending) { |
| 2509 | mHomeDoubleTapPending = false; |
| 2510 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); |
| 2511 | handleDoubleTapOnHome(); |
| 2512 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI |
| 2513 | || mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 2514 | preloadRecentApps(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2515 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2516 | } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { |
| 2517 | if (!keyguardOn) { |
| 2518 | handleLongPressOnHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2519 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2520 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2521 | return -1; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2522 | } else if (keyCode == KeyEvent.KEYCODE_MENU) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2523 | // Hijack modified menu keys for debugging features |
| 2524 | final int chordBug = KeyEvent.META_SHIFT_ON; |
| 2525 | |
| 2526 | if (down && repeatCount == 0) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2527 | if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2528 | Intent intent = new Intent(Intent.ACTION_BUG_REPORT); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2529 | mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, |
| 2530 | null, null, null, 0, null, null); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2531 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2532 | } else if (SHOW_PROCESSES_ON_ALT_MENU && |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2533 | (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2534 | Intent service = new Intent(); |
| 2535 | service.setClassName(mContext, "com.android.server.LoadAverageService"); |
| 2536 | ContentResolver res = mContext.getContentResolver(); |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2537 | boolean shown = Settings.Global.getInt( |
| 2538 | res, Settings.Global.SHOW_PROCESSES, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2539 | if (!shown) { |
| 2540 | mContext.startService(service); |
| 2541 | } else { |
| 2542 | mContext.stopService(service); |
| 2543 | } |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2544 | Settings.Global.putInt( |
| 2545 | res, Settings.Global.SHOW_PROCESSES, shown ? 0 : 1); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2546 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2547 | } |
| 2548 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2549 | } else if (keyCode == KeyEvent.KEYCODE_SEARCH) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2550 | if (down) { |
| 2551 | if (repeatCount == 0) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2552 | mSearchKeyShortcutPending = true; |
| 2553 | mConsumeSearchKeyUp = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2554 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2555 | } else { |
| 2556 | mSearchKeyShortcutPending = false; |
| 2557 | if (mConsumeSearchKeyUp) { |
| 2558 | mConsumeSearchKeyUp = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2559 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2560 | } |
| 2561 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2562 | return 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2563 | } else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) { |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2564 | if (!keyguardOn) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2565 | if (down && repeatCount == 0) { |
| 2566 | preloadRecentApps(); |
| 2567 | } else if (!down) { |
| 2568 | toggleRecentApps(); |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2569 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2570 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2571 | return -1; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2572 | } else if (keyCode == KeyEvent.KEYCODE_ASSIST) { |
| 2573 | if (down) { |
| 2574 | if (repeatCount == 0) { |
| 2575 | mAssistKeyLongPressed = false; |
| 2576 | } else if (repeatCount == 1) { |
| 2577 | mAssistKeyLongPressed = true; |
| 2578 | if (!keyguardOn) { |
| 2579 | launchAssistLongPressAction(); |
| 2580 | } |
| 2581 | } |
| 2582 | } else { |
| 2583 | if (mAssistKeyLongPressed) { |
| 2584 | mAssistKeyLongPressed = false; |
| 2585 | } else { |
| 2586 | if (!keyguardOn) { |
| 2587 | launchAssistAction(); |
| 2588 | } |
| 2589 | } |
| 2590 | } |
| 2591 | return -1; |
Michael Wright | dc63f7b | 2014-08-21 19:05:21 -0700 | [diff] [blame] | 2592 | } else if (keyCode == KeyEvent.KEYCODE_VOICE_ASSIST) { |
| 2593 | if (!down) { |
| 2594 | Intent voiceIntent; |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 2595 | if (!keyguardOn) { |
Michael Wright | dc63f7b | 2014-08-21 19:05:21 -0700 | [diff] [blame] | 2596 | voiceIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); |
| 2597 | } else { |
| 2598 | voiceIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE); |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 2599 | voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, true); |
Michael Wright | dc63f7b | 2014-08-21 19:05:21 -0700 | [diff] [blame] | 2600 | } |
| 2601 | mContext.startActivityAsUser(voiceIntent, UserHandle.CURRENT_OR_SELF); |
| 2602 | } |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 2603 | } else if (keyCode == KeyEvent.KEYCODE_SYSRQ) { |
| 2604 | if (down && repeatCount == 0) { |
| 2605 | mHandler.post(mScreenshotRunnable); |
| 2606 | } |
| 2607 | return -1; |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 2608 | } else if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP |
| 2609 | || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) { |
| 2610 | if (down) { |
| 2611 | int direction = keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP ? 1 : -1; |
| 2612 | |
| 2613 | // Disable autobrightness if it's on |
| 2614 | int auto = Settings.System.getIntForUser( |
| 2615 | mContext.getContentResolver(), |
| 2616 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2617 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2618 | UserHandle.USER_CURRENT_OR_SELF); |
| 2619 | if (auto != 0) { |
| 2620 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2621 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 2622 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 2623 | UserHandle.USER_CURRENT_OR_SELF); |
| 2624 | } |
| 2625 | |
| 2626 | int min = mPowerManager.getMinimumScreenBrightnessSetting(); |
| 2627 | int max = mPowerManager.getMaximumScreenBrightnessSetting(); |
| 2628 | int step = (max - min + BRIGHTNESS_STEPS - 1) / BRIGHTNESS_STEPS * direction; |
| 2629 | int brightness = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 2630 | Settings.System.SCREEN_BRIGHTNESS, |
| 2631 | mPowerManager.getDefaultScreenBrightnessSetting(), |
| 2632 | UserHandle.USER_CURRENT_OR_SELF); |
| 2633 | brightness += step; |
| 2634 | // Make sure we don't go beyond the limits. |
| 2635 | brightness = Math.min(max, brightness); |
| 2636 | brightness = Math.max(min, brightness); |
| 2637 | |
| 2638 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 2639 | Settings.System.SCREEN_BRIGHTNESS, brightness, |
| 2640 | UserHandle.USER_CURRENT_OR_SELF); |
Alan Viverette | 5a39949 | 2014-07-14 16:19:38 -0700 | [diff] [blame] | 2641 | mContext.startActivityAsUser(new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG), |
| 2642 | UserHandle.CURRENT_OR_SELF); |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 2643 | } |
| 2644 | return -1; |
Michael Wright | ce0c13a | 2014-07-30 10:49:21 -0700 | [diff] [blame] | 2645 | } else if (KeyEvent.isMetaKey(keyCode)) { |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2646 | if (down) { |
| 2647 | mPendingMetaAction = true; |
| 2648 | } else if (mPendingMetaAction) { |
Michael Wright | 8ab940a | 2014-09-01 11:01:27 -0700 | [diff] [blame] | 2649 | launchAssistAction(Intent.EXTRA_ASSIST_INPUT_HINT_KEYBOARD); |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2650 | } |
| 2651 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2652 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2653 | |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2654 | // Shortcuts are invoked through Search+key, so intercept those here |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2655 | // Any printing key that is chorded with Search should be consumed |
| 2656 | // even if no shortcut was invoked. This prevents text from being |
| 2657 | // inadvertently inserted when using a keyboard that has built-in macro |
| 2658 | // 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] | 2659 | if (mSearchKeyShortcutPending) { |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2660 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
| 2661 | if (kcm.isPrintingKey(keyCode)) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2662 | mConsumeSearchKeyUp = true; |
| 2663 | mSearchKeyShortcutPending = false; |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2664 | if (down && repeatCount == 0 && !keyguardOn) { |
| 2665 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState); |
| 2666 | if (shortcutIntent != null) { |
| 2667 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2668 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2669 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2670 | } catch (ActivityNotFoundException ex) { |
| 2671 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2672 | + "the activity to which it is registered was not found: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2673 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode), ex); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 2674 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 2675 | } else { |
| 2676 | Slog.i(TAG, "Dropping unregistered shortcut key combination: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2677 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2678 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2679 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2680 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2681 | } |
| 2682 | } |
| 2683 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2684 | // Invoke shortcuts using Meta. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2685 | if (down && repeatCount == 0 && !keyguardOn |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2686 | && (metaState & KeyEvent.META_META_ON) != 0) { |
| 2687 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2688 | if (kcm.isPrintingKey(keyCode)) { |
| 2689 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, |
| 2690 | metaState & ~(KeyEvent.META_META_ON |
| 2691 | | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON)); |
| 2692 | if (shortcutIntent != null) { |
| 2693 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2694 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2695 | mContext.startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2696 | } catch (ActivityNotFoundException ex) { |
| 2697 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 2698 | + "the activity to which it is registered was not found: " |
| 2699 | + "META+" + KeyEvent.keyCodeToString(keyCode), ex); |
| 2700 | } |
| 2701 | return -1; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2702 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2703 | } |
| 2704 | } |
| 2705 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2706 | // Handle application launch keys. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 2707 | if (down && repeatCount == 0 && !keyguardOn) { |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2708 | String category = sApplicationLaunchKeyCategories.get(keyCode); |
| 2709 | if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 2710 | Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2711 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2712 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2713 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2714 | } catch (ActivityNotFoundException ex) { |
| 2715 | Slog.w(TAG, "Dropping application launch key because " |
| 2716 | + "the activity to which it is registered was not found: " |
| 2717 | + "keyCode=" + keyCode + ", category=" + category, ex); |
| 2718 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2719 | return -1; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 2720 | } |
| 2721 | } |
| 2722 | |
Michael Wright | 61c4675 | 2014-08-21 16:57:33 -0700 | [diff] [blame] | 2723 | // Display task switcher for ALT-TAB. |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2724 | if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2725 | if (mRecentAppsHeldModifiers == 0 && !keyguardOn) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2726 | final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK; |
Michael Wright | 61c4675 | 2014-08-21 16:57:33 -0700 | [diff] [blame] | 2727 | if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON)) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2728 | mRecentAppsHeldModifiers = shiftlessModifiers; |
| 2729 | showRecentApps(true); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2730 | return -1; |
| 2731 | } |
| 2732 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2733 | } else if (!down && mRecentAppsHeldModifiers != 0 |
| 2734 | && (metaState & mRecentAppsHeldModifiers) == 0) { |
| 2735 | mRecentAppsHeldModifiers = 0; |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 2736 | hideRecentApps(true, false); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2737 | } |
| 2738 | |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 2739 | // Handle keyboard language switching. |
| 2740 | if (down && repeatCount == 0 |
| 2741 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2742 | || (keyCode == KeyEvent.KEYCODE_SPACE |
| 2743 | && (metaState & KeyEvent.META_CTRL_MASK) != 0))) { |
| 2744 | int direction = (metaState & KeyEvent.META_SHIFT_MASK) != 0 ? -1 : 1; |
| 2745 | mWindowManagerFuncs.switchKeyboardLayout(event.getDeviceId(), direction); |
| 2746 | return -1; |
| 2747 | } |
| 2748 | if (mLanguageSwitchKeyPressed && !down |
| 2749 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 2750 | || keyCode == KeyEvent.KEYCODE_SPACE)) { |
| 2751 | mLanguageSwitchKeyPressed = false; |
| 2752 | return -1; |
| 2753 | } |
| 2754 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2755 | if (isValidGlobalKey(keyCode) |
| 2756 | && mGlobalKeyManager.handleGlobalKey(mContext, keyCode, event)) { |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 2757 | return -1; |
| 2758 | } |
| 2759 | |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2760 | // Reserve all the META modifier combos for system behavior |
Michael Wright | ce0c13a | 2014-07-30 10:49:21 -0700 | [diff] [blame] | 2761 | if ((metaState & KeyEvent.META_META_ON) != 0) { |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2762 | return -1; |
| 2763 | } |
| 2764 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 2765 | // Let the application handle the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2766 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2767 | } |
| 2768 | |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2769 | /** {@inheritDoc} */ |
| 2770 | @Override |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2771 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2772 | // Note: This method is only called if the initial down was unhandled. |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2773 | if (DEBUG_INPUT) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2774 | Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction() |
| 2775 | + ", flags=" + event.getFlags() |
| 2776 | + ", keyCode=" + event.getKeyCode() |
| 2777 | + ", scanCode=" + event.getScanCode() |
| 2778 | + ", metaState=" + event.getMetaState() |
| 2779 | + ", repeatCount=" + event.getRepeatCount() |
| 2780 | + ", policyFlags=" + policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2781 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2782 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2783 | KeyEvent fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2784 | if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 2785 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 2786 | final int keyCode = event.getKeyCode(); |
| 2787 | final int metaState = event.getMetaState(); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2788 | final boolean initialDown = event.getAction() == KeyEvent.ACTION_DOWN |
| 2789 | && event.getRepeatCount() == 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2790 | |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 2791 | // Check for fallback actions specified by the key character map. |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2792 | final FallbackAction fallbackAction; |
| 2793 | if (initialDown) { |
| 2794 | fallbackAction = kcm.getFallbackAction(keyCode, metaState); |
| 2795 | } else { |
| 2796 | fallbackAction = mFallbackActions.get(keyCode); |
| 2797 | } |
| 2798 | |
| 2799 | if (fallbackAction != null) { |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2800 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2801 | Slog.d(TAG, "Fallback: keyCode=" + fallbackAction.keyCode |
| 2802 | + " metaState=" + Integer.toHexString(fallbackAction.metaState)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2803 | } |
| 2804 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2805 | final int flags = event.getFlags() | KeyEvent.FLAG_FALLBACK; |
| 2806 | fallbackEvent = KeyEvent.obtain( |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2807 | event.getDownTime(), event.getEventTime(), |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2808 | event.getAction(), fallbackAction.keyCode, |
| 2809 | event.getRepeatCount(), fallbackAction.metaState, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2810 | event.getDeviceId(), event.getScanCode(), |
| 2811 | flags, event.getSource(), null); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2812 | |
| 2813 | if (!interceptFallback(win, fallbackEvent, policyFlags)) { |
| 2814 | fallbackEvent.recycle(); |
| 2815 | fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2816 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2817 | |
| 2818 | if (initialDown) { |
| 2819 | mFallbackActions.put(keyCode, fallbackAction); |
| 2820 | } else if (event.getAction() == KeyEvent.ACTION_UP) { |
| 2821 | mFallbackActions.remove(keyCode); |
| 2822 | fallbackAction.recycle(); |
| 2823 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2824 | } |
| 2825 | } |
| 2826 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2827 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2828 | if (fallbackEvent == null) { |
| 2829 | Slog.d(TAG, "No fallback."); |
| 2830 | } else { |
| 2831 | Slog.d(TAG, "Performing fallback: " + fallbackEvent); |
| 2832 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2833 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2834 | return fallbackEvent; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 2835 | } |
| 2836 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2837 | private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 2838 | int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2839 | if ((actions & ACTION_PASS_TO_USER) != 0) { |
| 2840 | long delayMillis = interceptKeyBeforeDispatching( |
| 2841 | win, fallbackEvent, policyFlags); |
| 2842 | if (delayMillis == 0) { |
| 2843 | return true; |
| 2844 | } |
| 2845 | } |
| 2846 | return false; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 2847 | } |
| 2848 | |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2849 | private void launchAssistLongPressAction() { |
| 2850 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 2851 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
| 2852 | |
| 2853 | // launch the search activity |
| 2854 | Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); |
| 2855 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 2856 | try { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2857 | // TODO: This only stops the factory-installed search manager. |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2858 | // Need to formalize an API to handle others |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2859 | SearchManager searchManager = getSearchManager(); |
| 2860 | if (searchManager != null) { |
| 2861 | searchManager.stopSearch(); |
| 2862 | } |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2863 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2864 | } catch (ActivityNotFoundException e) { |
| 2865 | Slog.w(TAG, "No activity to handle assist long press action.", e); |
| 2866 | } |
| 2867 | } |
| 2868 | |
| 2869 | private void launchAssistAction() { |
Michael Wright | 8ab940a | 2014-09-01 11:01:27 -0700 | [diff] [blame] | 2870 | launchAssistAction(null); |
| 2871 | } |
| 2872 | |
| 2873 | private void launchAssistAction(String hint) { |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2874 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
Amith Yamasani | c1d07a4 | 2012-08-14 09:32:02 -0700 | [diff] [blame] | 2875 | Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 2876 | .getAssistIntent(mContext, true, UserHandle.USER_CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2877 | if (intent != null) { |
Michael Wright | 8ab940a | 2014-09-01 11:01:27 -0700 | [diff] [blame] | 2878 | if (hint != null) { |
| 2879 | intent.putExtra(hint, true); |
| 2880 | } |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2881 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 2882 | | Intent.FLAG_ACTIVITY_SINGLE_TOP |
| 2883 | | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 2884 | try { |
Michael Wright | 43e27f7 | 2013-04-10 14:06:48 -0700 | [diff] [blame] | 2885 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 2886 | } catch (ActivityNotFoundException e) { |
| 2887 | Slog.w(TAG, "No activity to handle assist action.", e); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 2888 | } |
| 2889 | } |
| 2890 | } |
| 2891 | |
| 2892 | private SearchManager getSearchManager() { |
| 2893 | if (mSearchManager == null) { |
| 2894 | mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); |
| 2895 | } |
| 2896 | return mSearchManager; |
| 2897 | } |
| 2898 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2899 | private void preloadRecentApps() { |
| 2900 | mPreloadedRecentApps = true; |
| 2901 | try { |
| 2902 | IStatusBarService statusbar = getStatusBarService(); |
| 2903 | if (statusbar != null) { |
| 2904 | statusbar.preloadRecentApps(); |
| 2905 | } |
| 2906 | } catch (RemoteException e) { |
| 2907 | Slog.e(TAG, "RemoteException when preloading recent apps", e); |
| 2908 | // re-acquire status bar service next time it is needed. |
| 2909 | mStatusBarService = null; |
| 2910 | } |
| 2911 | } |
| 2912 | |
| 2913 | private void cancelPreloadRecentApps() { |
| 2914 | if (mPreloadedRecentApps) { |
| 2915 | mPreloadedRecentApps = false; |
| 2916 | try { |
| 2917 | IStatusBarService statusbar = getStatusBarService(); |
| 2918 | if (statusbar != null) { |
| 2919 | statusbar.cancelPreloadRecentApps(); |
| 2920 | } |
| 2921 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2922 | Slog.e(TAG, "RemoteException when cancelling recent apps preload", e); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2923 | // re-acquire status bar service next time it is needed. |
| 2924 | mStatusBarService = null; |
| 2925 | } |
| 2926 | } |
| 2927 | } |
| 2928 | |
| 2929 | private void toggleRecentApps() { |
| 2930 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2931 | try { |
| 2932 | IStatusBarService statusbar = getStatusBarService(); |
| 2933 | if (statusbar != null) { |
| 2934 | statusbar.toggleRecentApps(); |
| 2935 | } |
| 2936 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2937 | Slog.e(TAG, "RemoteException when toggling recent apps", e); |
| 2938 | // re-acquire status bar service next time it is needed. |
| 2939 | mStatusBarService = null; |
| 2940 | } |
| 2941 | } |
| 2942 | |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 2943 | @Override |
| 2944 | public void showRecentApps() { |
| 2945 | mHandler.removeMessages(MSG_DISPATCH_SHOW_RECENTS); |
| 2946 | mHandler.sendEmptyMessage(MSG_DISPATCH_SHOW_RECENTS); |
| 2947 | } |
| 2948 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2949 | private void showRecentApps(boolean triggeredFromAltTab) { |
| 2950 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2951 | try { |
| 2952 | IStatusBarService statusbar = getStatusBarService(); |
| 2953 | if (statusbar != null) { |
| 2954 | statusbar.showRecentApps(triggeredFromAltTab); |
| 2955 | } |
| 2956 | } catch (RemoteException e) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2957 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
| 2958 | // re-acquire status bar service next time it is needed. |
| 2959 | mStatusBarService = null; |
| 2960 | } |
| 2961 | } |
| 2962 | |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 2963 | private void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHome) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2964 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 2965 | try { |
| 2966 | IStatusBarService statusbar = getStatusBarService(); |
| 2967 | if (statusbar != null) { |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 2968 | statusbar.hideRecentApps(triggeredFromAltTab, triggeredFromHome); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 2969 | } |
| 2970 | } catch (RemoteException e) { |
| 2971 | Slog.e(TAG, "RemoteException when closing recent apps", e); |
| 2972 | // re-acquire status bar service next time it is needed. |
| 2973 | mStatusBarService = null; |
| 2974 | } |
| 2975 | } |
| 2976 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2977 | /** |
| 2978 | * A home key -> launch home action was detected. Take the appropriate action |
| 2979 | * given the situation with the keyguard. |
| 2980 | */ |
| 2981 | void launchHomeFromHotKey() { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2982 | if (isKeyguardShowingAndNotOccluded()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2983 | // don't launch home if keyguard showing |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2984 | } else if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2985 | // when in keyguard restricted mode, must first verify unlock |
| 2986 | // before launching home |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2987 | mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() { |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2988 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2989 | public void onKeyguardExitResult(boolean success) { |
| 2990 | if (success) { |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 2991 | try { |
| 2992 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 2993 | } catch (RemoteException e) { |
| 2994 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 2995 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 2996 | startDockOrHome(true /*fromHomeKey*/); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2997 | } |
| 2998 | } |
| 2999 | }); |
| 3000 | } else { |
| 3001 | // no keyguard stuff to worry about, just launch home! |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 3002 | try { |
| 3003 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 3004 | } catch (RemoteException e) { |
| 3005 | } |
Winson Chung | d543c1b | 2014-06-23 15:06:45 -0700 | [diff] [blame] | 3006 | if (mRecentsVisible) { |
| 3007 | // Hide Recents and notify it to launch Home |
| 3008 | awakenDreams(); |
| 3009 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 3010 | hideRecentApps(false, true); |
Winson Chung | d543c1b | 2014-06-23 15:06:45 -0700 | [diff] [blame] | 3011 | } else { |
| 3012 | // Otherwise, just launch Home |
| 3013 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 3014 | startDockOrHome(true /*fromHomeKey*/); |
Winson Chung | d543c1b | 2014-06-23 15:06:45 -0700 | [diff] [blame] | 3015 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3016 | } |
| 3017 | } |
| 3018 | |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 3019 | private final Runnable mClearHideNavigationFlag = new Runnable() { |
| 3020 | @Override |
| 3021 | public void run() { |
| 3022 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
| 3023 | // Clear flags. |
| 3024 | mForceClearedSystemUiFlags &= |
| 3025 | ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 3026 | } |
| 3027 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3028 | } |
| 3029 | }; |
| 3030 | |
| 3031 | /** |
| 3032 | * Input handler used while nav bar is hidden. Captures any touch on the screen, |
| 3033 | * to determine when the nav bar should be shown and prevent applications from |
| 3034 | * receiving those touches. |
| 3035 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 3036 | final class HideNavInputEventReceiver extends InputEventReceiver { |
| 3037 | public HideNavInputEventReceiver(InputChannel inputChannel, Looper looper) { |
| 3038 | super(inputChannel, looper); |
| 3039 | } |
| 3040 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3041 | @Override |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 3042 | public void onInputEvent(InputEvent event) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3043 | boolean handled = false; |
| 3044 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 3045 | if (event instanceof MotionEvent |
| 3046 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 3047 | final MotionEvent motionEvent = (MotionEvent)event; |
| 3048 | if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3049 | // When the user taps down, we re-show the nav bar. |
| 3050 | boolean changed = false; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 3051 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3052 | // Any user activity always causes us to show the |
| 3053 | // navigation controls, if they had been hidden. |
| 3054 | // We also clear the low profile and only content |
| 3055 | // flags so that tapping on the screen will atomically |
| 3056 | // restore all currently hidden screen decorations. |
| 3057 | int newVal = mResettingSystemUiFlags | |
| 3058 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| 3059 | View.SYSTEM_UI_FLAG_LOW_PROFILE | |
| 3060 | View.SYSTEM_UI_FLAG_FULLSCREEN; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3061 | if (mResettingSystemUiFlags != newVal) { |
| 3062 | mResettingSystemUiFlags = newVal; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3063 | changed = true; |
| 3064 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3065 | // We don't allow the system's nav bar to be hidden |
| 3066 | // again for 1 second, to prevent applications from |
| 3067 | // spamming us and keeping it from being shown. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3068 | newVal = mForceClearedSystemUiFlags | |
| 3069 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3070 | if (mForceClearedSystemUiFlags != newVal) { |
| 3071 | mForceClearedSystemUiFlags = newVal; |
| 3072 | changed = true; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 3073 | mHandler.postDelayed(mClearHideNavigationFlag, 1000); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3074 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3075 | } |
| 3076 | if (changed) { |
| 3077 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 3078 | } |
| 3079 | } |
| 3080 | } |
| 3081 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 3082 | finishInputEvent(event, handled); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3083 | } |
| 3084 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 3085 | } |
| 3086 | final InputEventReceiver.Factory mHideNavInputEventReceiverFactory = |
| 3087 | new InputEventReceiver.Factory() { |
| 3088 | @Override |
| 3089 | public InputEventReceiver createInputEventReceiver( |
| 3090 | InputChannel inputChannel, Looper looper) { |
| 3091 | return new HideNavInputEventReceiver(inputChannel, looper); |
| 3092 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3093 | }; |
| 3094 | |
| 3095 | @Override |
| 3096 | public int adjustSystemUiVisibilityLw(int visibility) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3097 | mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
| 3098 | mNavigationBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 3099 | mRecentsVisible = (visibility & View.RECENT_APPS_VISIBLE) > 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3100 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3101 | // Reset any bits in mForceClearingStatusBarVisibility that |
| 3102 | // are now clear. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3103 | mResettingSystemUiFlags &= visibility; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3104 | // Clear any bits in the new visibility that are currently being |
| 3105 | // force cleared, before reporting it. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3106 | return visibility & ~mResettingSystemUiFlags |
| 3107 | & ~mForceClearedSystemUiFlags; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3108 | } |
| 3109 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3110 | @Override |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3111 | public void getInsetHintLw(WindowManager.LayoutParams attrs, Rect outContentInsets, |
| 3112 | Rect outStableInsets) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3113 | final int fl = PolicyControl.getWindowFlags(null, attrs); |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 3114 | final int sysuiVis = PolicyControl.getSystemUiVisibility(null, attrs); |
| 3115 | final int systemUiVisibility = (sysuiVis | attrs.subtreeSystemUiVisibility); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3116 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3117 | 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] | 3118 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3119 | int availRight, availBottom; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3120 | if (canHideNavigationBar() && |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3121 | (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3122 | availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3123 | availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
| 3124 | } else { |
| 3125 | availRight = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 3126 | availBottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
| 3127 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3128 | if ((systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 3129 | if ((fl & FLAG_FULLSCREEN) != 0) { |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3130 | outContentInsets.set(mStableFullscreenLeft, mStableFullscreenTop, |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3131 | availRight - mStableFullscreenRight, |
| 3132 | availBottom - mStableFullscreenBottom); |
| 3133 | } else { |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3134 | outContentInsets.set(mStableLeft, mStableTop, |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3135 | availRight - mStableRight, availBottom - mStableBottom); |
| 3136 | } |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3137 | } else if ((fl & FLAG_FULLSCREEN) != 0 || (fl & FLAG_LAYOUT_IN_OVERSCAN) != 0) { |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3138 | outContentInsets.setEmpty(); |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3139 | } else if ((systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3140 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) { |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3141 | outContentInsets.set(mCurLeft, mCurTop, |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3142 | availRight - mCurRight, availBottom - mCurBottom); |
| 3143 | } else { |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3144 | outContentInsets.set(mCurLeft, mCurTop, |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3145 | availRight - mCurRight, availBottom - mCurBottom); |
| 3146 | } |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3147 | |
| 3148 | outStableInsets.set(mStableLeft, mStableTop, |
| 3149 | availRight - mStableRight, availBottom - mStableBottom); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3150 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3151 | } |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3152 | outContentInsets.setEmpty(); |
| 3153 | outStableInsets.setEmpty(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3154 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3155 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3156 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3157 | @Override |
| 3158 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
| 3159 | int displayRotation) { |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3160 | final int overscanLeft, overscanTop, overscanRight, overscanBottom; |
| 3161 | if (isDefaultDisplay) { |
| 3162 | switch (displayRotation) { |
| 3163 | case Surface.ROTATION_90: |
| 3164 | overscanLeft = mOverscanTop; |
| 3165 | overscanTop = mOverscanRight; |
| 3166 | overscanRight = mOverscanBottom; |
| 3167 | overscanBottom = mOverscanLeft; |
| 3168 | break; |
| 3169 | case Surface.ROTATION_180: |
| 3170 | overscanLeft = mOverscanRight; |
| 3171 | overscanTop = mOverscanBottom; |
| 3172 | overscanRight = mOverscanLeft; |
| 3173 | overscanBottom = mOverscanTop; |
| 3174 | break; |
| 3175 | case Surface.ROTATION_270: |
| 3176 | overscanLeft = mOverscanBottom; |
| 3177 | overscanTop = mOverscanLeft; |
| 3178 | overscanRight = mOverscanTop; |
| 3179 | overscanBottom = mOverscanRight; |
| 3180 | break; |
| 3181 | default: |
| 3182 | overscanLeft = mOverscanLeft; |
| 3183 | overscanTop = mOverscanTop; |
| 3184 | overscanRight = mOverscanRight; |
| 3185 | overscanBottom = mOverscanBottom; |
| 3186 | break; |
| 3187 | } |
| 3188 | } else { |
| 3189 | overscanLeft = 0; |
| 3190 | overscanTop = 0; |
| 3191 | overscanRight = 0; |
| 3192 | overscanBottom = 0; |
| 3193 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3194 | mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0; |
| 3195 | mOverscanScreenTop = mRestrictedOverscanScreenTop = 0; |
| 3196 | mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth; |
| 3197 | mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3198 | mSystemLeft = 0; |
| 3199 | mSystemTop = 0; |
| 3200 | mSystemRight = displayWidth; |
| 3201 | mSystemBottom = displayHeight; |
| 3202 | mUnrestrictedScreenLeft = overscanLeft; |
| 3203 | mUnrestrictedScreenTop = overscanTop; |
| 3204 | mUnrestrictedScreenWidth = displayWidth - overscanLeft - overscanRight; |
| 3205 | mUnrestrictedScreenHeight = displayHeight - overscanTop - overscanBottom; |
| 3206 | mRestrictedScreenLeft = mUnrestrictedScreenLeft; |
| 3207 | mRestrictedScreenTop = mUnrestrictedScreenTop; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3208 | mRestrictedScreenWidth = mSystemGestures.screenWidth = mUnrestrictedScreenWidth; |
| 3209 | mRestrictedScreenHeight = mSystemGestures.screenHeight = mUnrestrictedScreenHeight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3210 | mDockLeft = mContentLeft = mVoiceContentLeft = mStableLeft = mStableFullscreenLeft |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3211 | = mCurLeft = mUnrestrictedScreenLeft; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3212 | mDockTop = mContentTop = mVoiceContentTop = mStableTop = mStableFullscreenTop |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3213 | = mCurTop = mUnrestrictedScreenTop; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3214 | mDockRight = mContentRight = mVoiceContentRight = mStableRight = mStableFullscreenRight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3215 | = mCurRight = displayWidth - overscanRight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3216 | mDockBottom = mContentBottom = mVoiceContentBottom = mStableBottom = mStableFullscreenBottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3217 | = mCurBottom = displayHeight - overscanBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3218 | mDockLayer = 0x10000000; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 3219 | mStatusBarLayer = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3220 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3221 | // start with the current dock rect, which will be (0,0,displayWidth,displayHeight) |
| 3222 | final Rect pf = mTmpParentFrame; |
| 3223 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3224 | final Rect of = mTmpOverscanFrame; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3225 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3226 | final Rect dcf = mTmpDecorFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3227 | pf.left = df.left = of.left = vf.left = mDockLeft; |
| 3228 | pf.top = df.top = of.top = vf.top = mDockTop; |
| 3229 | pf.right = df.right = of.right = vf.right = mDockRight; |
| 3230 | pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3231 | dcf.setEmpty(); // Decor frame N/A for system bars. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3232 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3233 | if (isDefaultDisplay) { |
| 3234 | // For purposes of putting out fake window up to steal focus, we will |
| 3235 | // drive nav being hidden only by whether it is requested. |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3236 | final int sysui = mLastSystemUiFlags; |
| 3237 | boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3238 | boolean navTranslucent = (sysui |
| 3239 | & (View.NAVIGATION_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 3240 | boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0; |
| 3241 | boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
| 3242 | boolean navAllowedHidden = immersive || immersiveSticky; |
| 3243 | navTranslucent &= !immersiveSticky; // transient trumps translucent |
Adrian Roos | 4fb3ee3 | 2014-08-22 19:29:09 +0200 | [diff] [blame] | 3244 | boolean isKeyguardShowing = isStatusBarKeyguard() && !mHideLockScreen; |
| 3245 | if (!isKeyguardShowing) { |
| 3246 | navTranslucent &= areTranslucentBarsAllowed(); |
| 3247 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3248 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3249 | // When the navigation bar isn't visible, we put up a fake |
| 3250 | // input window to catch all touch events. This way we can |
| 3251 | // detect when the user presses anywhere to bring back the nav |
| 3252 | // bar and ensure the application doesn't see the event. |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 3253 | if (navVisible || navAllowedHidden) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3254 | if (mHideNavFakeWindow != null) { |
| 3255 | mHideNavFakeWindow.dismiss(); |
| 3256 | mHideNavFakeWindow = null; |
| 3257 | } |
| 3258 | } else if (mHideNavFakeWindow == null) { |
| 3259 | mHideNavFakeWindow = mWindowManagerFuncs.addFakeWindow( |
| 3260 | mHandler.getLooper(), mHideNavInputEventReceiverFactory, |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 3261 | "hidden nav", WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER, 0, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3262 | 0, false, false, true); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3263 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3264 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3265 | // For purposes of positioning and showing the nav bar, if we have |
| 3266 | // decided that it can't be hidden (because of the screen aspect ratio), |
| 3267 | // then take that into account. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3268 | navVisible |= !canHideNavigationBar(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3269 | |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3270 | boolean updateSysUiVisibility = false; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3271 | if (mNavigationBar != null) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3272 | boolean transientNavBarShowing = mNavigationBarController.isTransientShowing(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3273 | // Force the navigation bar to its appropriate place and |
| 3274 | // size. We need to do this directly, instead of relying on |
| 3275 | // it to bubble up from the nav bar, because this needs to |
| 3276 | // change atomically with screen rotations. |
| 3277 | mNavigationBarOnBottom = (!mNavigationBarCanMove || displayWidth < displayHeight); |
| 3278 | if (mNavigationBarOnBottom) { |
| 3279 | // 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] | 3280 | int top = displayHeight - overscanBottom |
| 3281 | - mNavigationBarHeightForRotation[displayRotation]; |
| 3282 | mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3283 | mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 3284 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3285 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3286 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3287 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3288 | mDockBottom = mTmpNavigationFrame.top; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3289 | mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop; |
| 3290 | mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3291 | } else { |
| 3292 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3293 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3294 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3295 | if (navVisible && !navTranslucent && !navAllowedHidden |
| 3296 | && !mNavigationBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3297 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3298 | // If the opaque nav bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3299 | // and not in the process of animating on or off, then |
| 3300 | // we can tell the app that it is covered by it. |
| 3301 | mSystemBottom = mTmpNavigationFrame.top; |
| 3302 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3303 | } else { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3304 | // Landscape screen; nav bar goes to the right. |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3305 | int left = displayWidth - overscanRight |
| 3306 | - mNavigationBarWidthForRotation[displayRotation]; |
| 3307 | mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3308 | mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left; |
John Spurlock | f95b89a | 2013-10-10 22:10:42 -0400 | [diff] [blame] | 3309 | if (transientNavBarShowing) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3310 | mNavigationBarController.setBarShowingLw(true); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3311 | } else if (navVisible) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3312 | mNavigationBarController.setBarShowingLw(true); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3313 | mDockRight = mTmpNavigationFrame.left; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3314 | mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft; |
| 3315 | mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3316 | } else { |
| 3317 | // We currently want to hide the navigation UI. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3318 | mNavigationBarController.setBarShowingLw(false); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3319 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3320 | if (navVisible && !navTranslucent && !mNavigationBar.isAnimatingLw() |
| 3321 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3322 | // If the nav bar is currently requested to be visible, |
| 3323 | // and not in the process of animating on or off, then |
| 3324 | // we can tell the app that it is covered by it. |
| 3325 | mSystemRight = mTmpNavigationFrame.left; |
| 3326 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3327 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3328 | // Make sure the content and current rectangles are updated to |
| 3329 | // account for the restrictions from the navigation bar. |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3330 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 3331 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 3332 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 3333 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3334 | mStatusBarLayer = mNavigationBar.getSurfaceLayer(); |
| 3335 | // And compute the final frame. |
| 3336 | mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3337 | mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf, |
| 3338 | mTmpNavigationFrame); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3339 | if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3340 | if (mNavigationBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3341 | updateSysUiVisibility = true; |
| 3342 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3343 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3344 | 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] | 3345 | mDockLeft, mDockTop, mDockRight, mDockBottom)); |
| 3346 | |
| 3347 | // decide where the status bar goes ahead of time |
| 3348 | if (mStatusBar != null) { |
| 3349 | // apply any navigation bar insets |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3350 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3351 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3352 | pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft; |
| 3353 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight |
| 3354 | + mUnrestrictedScreenTop; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3355 | vf.left = mStableLeft; |
| 3356 | vf.top = mStableTop; |
| 3357 | vf.right = mStableRight; |
| 3358 | vf.bottom = mStableBottom; |
| 3359 | |
| 3360 | mStatusBarLayer = mStatusBar.getSurfaceLayer(); |
| 3361 | |
| 3362 | // Let the status bar determine its size. |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3363 | mStatusBar.computeFrameLw(pf, df, vf, vf, vf, dcf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3364 | |
| 3365 | // For layout, the status bar is always at the top with our fixed height. |
| 3366 | mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3367 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3368 | boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3369 | boolean statusBarTranslucent = (sysui |
| 3370 | & (View.STATUS_BAR_TRANSLUCENT | View.SYSTEM_UI_TRANSPARENT)) != 0; |
Adrian Roos | 4fb3ee3 | 2014-08-22 19:29:09 +0200 | [diff] [blame] | 3371 | if (!isKeyguardShowing) { |
| 3372 | statusBarTranslucent &= areTranslucentBarsAllowed(); |
| 3373 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3374 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3375 | // If the status bar is hidden, we don't want to cause |
| 3376 | // windows behind it to scroll. |
John Spurlock | eda1f69 | 2013-09-16 11:38:44 -0400 | [diff] [blame] | 3377 | if (mStatusBar.isVisibleLw() && !statusBarTransient) { |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3378 | // Status bar may go away, so the screen area it occupies |
| 3379 | // is available to apps but just covering them when the |
| 3380 | // status bar is visible. |
| 3381 | mDockTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3382 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3383 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 3384 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 3385 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 3386 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3387 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3388 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar: " + |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3389 | String.format( |
| 3390 | "dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]", |
| 3391 | mDockLeft, mDockTop, mDockRight, mDockBottom, |
| 3392 | mContentLeft, mContentTop, mContentRight, mContentBottom, |
| 3393 | mCurLeft, mCurTop, mCurRight, mCurBottom)); |
| 3394 | } |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3395 | if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw() |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3396 | && !statusBarTransient && !statusBarTranslucent |
| 3397 | && !mStatusBarController.wasRecentlyTranslucent()) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3398 | // If the opaque status bar is currently requested to be visible, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3399 | // and not in the process of animating on or off, then |
| 3400 | // we can tell the app that it is covered by it. |
| 3401 | mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3402 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3403 | if (mStatusBarController.checkHiddenLw()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3404 | updateSysUiVisibility = true; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 3405 | } |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 3406 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3407 | if (updateSysUiVisibility) { |
| 3408 | updateSystemUiVisibilityLw(); |
| 3409 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3410 | } |
| 3411 | } |
| 3412 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 3413 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 3414 | @Override |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3415 | public int getSystemDecorLayerLw() { |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 3416 | if (mStatusBar != null) return mStatusBar.getSurfaceLayer(); |
| 3417 | if (mNavigationBar != null) return mNavigationBar.getSurfaceLayer(); |
| 3418 | return 0; |
| 3419 | } |
| 3420 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 3421 | @Override |
| 3422 | public void getContentRectLw(Rect r) { |
| 3423 | r.set(mContentLeft, mContentTop, mContentRight, mContentBottom); |
| 3424 | } |
| 3425 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3426 | void setAttachedWindowFrames(WindowState win, int fl, int adjust, WindowState attached, |
| 3427 | 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] | 3428 | if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) { |
| 3429 | // Here's a special case: if this attached window is a panel that is |
| 3430 | // above the dock window, and the window it is attached to is below |
| 3431 | // the dock window, then the frames we computed for the window it is |
| 3432 | // attached to can not be used because the dock is effectively part |
| 3433 | // of the underlying window and the attached window is floating on top |
| 3434 | // of the whole thing. So, we ignore the attached window and explicitly |
| 3435 | // compute the frames that would be appropriate without the dock. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3436 | df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3437 | df.top = of.top = cf.top = vf.top = mDockTop; |
| 3438 | df.right = of.right = cf.right = vf.right = mDockRight; |
| 3439 | df.bottom = of.bottom = cf.bottom = vf.bottom = mDockBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3440 | } else { |
| 3441 | // The effective display frame of the attached window depends on |
| 3442 | // whether it is taking care of insetting its content. If not, |
| 3443 | // we need to use the parent's content frame so that the entire |
| 3444 | // window is positioned within that content. Otherwise we can use |
Wale Ogunwale | 393b1c1 | 2014-10-18 16:22:01 -0700 | [diff] [blame] | 3445 | // the overscan frame and let the attached window take care of |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3446 | // positioning its content appropriately. |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3447 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Wale Ogunwale | 393b1c1 | 2014-10-18 16:22:01 -0700 | [diff] [blame] | 3448 | // Set the content frame of the attached window to the parent's decor frame |
| 3449 | // (same as content frame when IME isn't present) if specifically requested by |
| 3450 | // setting {@link WindowManager.LayoutParams#FLAG_LAYOUT_ATTACHED_IN_DECOR} flag. |
| 3451 | // Otherwise, use the overscan frame. |
| 3452 | cf.set((fl & FLAG_LAYOUT_ATTACHED_IN_DECOR) != 0 |
| 3453 | ? attached.getContentFrameLw() : attached.getOverscanFrameLw()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3454 | } else { |
| 3455 | // If the window is resizing, then we want to base the content |
| 3456 | // frame on our attached content frame to resize... however, |
| 3457 | // things can be tricky if the attached window is NOT in resize |
| 3458 | // mode, in which case its content frame will be larger. |
| 3459 | // Ungh. So to deal with that, make sure the content frame |
| 3460 | // we end up using is not covering the IM dock. |
| 3461 | cf.set(attached.getContentFrameLw()); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3462 | if (attached.isVoiceInteraction()) { |
| 3463 | if (cf.left < mVoiceContentLeft) cf.left = mVoiceContentLeft; |
| 3464 | if (cf.top < mVoiceContentTop) cf.top = mVoiceContentTop; |
| 3465 | if (cf.right > mVoiceContentRight) cf.right = mVoiceContentRight; |
| 3466 | if (cf.bottom > mVoiceContentBottom) cf.bottom = mVoiceContentBottom; |
| 3467 | } else if (attached.getSurfaceLayer() < mDockLayer) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3468 | if (cf.left < mContentLeft) cf.left = mContentLeft; |
| 3469 | if (cf.top < mContentTop) cf.top = mContentTop; |
| 3470 | if (cf.right > mContentRight) cf.right = mContentRight; |
| 3471 | if (cf.bottom > mContentBottom) cf.bottom = mContentBottom; |
| 3472 | } |
| 3473 | } |
| 3474 | df.set(insetDecors ? attached.getDisplayFrameLw() : cf); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3475 | of.set(insetDecors ? attached.getOverscanFrameLw() : cf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3476 | vf.set(attached.getVisibleFrameLw()); |
| 3477 | } |
| 3478 | // The LAYOUT_IN_SCREEN flag is used to determine whether the attached |
| 3479 | // window should be positioned relative to its parent or the entire |
| 3480 | // screen. |
| 3481 | pf.set((fl & FLAG_LAYOUT_IN_SCREEN) == 0 |
| 3482 | ? attached.getFrameLw() : df); |
| 3483 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3484 | |
| 3485 | private void applyStableConstraints(int sysui, int fl, Rect r) { |
| 3486 | if ((sysui & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 3487 | // If app is requesting a stable layout, don't let the |
| 3488 | // content insets go below the stable values. |
| 3489 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 3490 | if (r.left < mStableFullscreenLeft) r.left = mStableFullscreenLeft; |
| 3491 | if (r.top < mStableFullscreenTop) r.top = mStableFullscreenTop; |
| 3492 | if (r.right > mStableFullscreenRight) r.right = mStableFullscreenRight; |
| 3493 | if (r.bottom > mStableFullscreenBottom) r.bottom = mStableFullscreenBottom; |
| 3494 | } else { |
| 3495 | if (r.left < mStableLeft) r.left = mStableLeft; |
| 3496 | if (r.top < mStableTop) r.top = mStableTop; |
| 3497 | if (r.right > mStableRight) r.right = mStableRight; |
| 3498 | if (r.bottom > mStableBottom) r.bottom = mStableBottom; |
| 3499 | } |
| 3500 | } |
| 3501 | } |
| 3502 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3503 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3504 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3505 | public void layoutWindowLw(WindowState win, WindowState attached) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3506 | // we've already done the status bar |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3507 | final WindowManager.LayoutParams attrs = win.getAttrs(); |
| 3508 | if ((win == mStatusBar && (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) == 0) || |
| 3509 | win == mNavigationBar) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3510 | return; |
| 3511 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3512 | final boolean isDefaultDisplay = win.isDefaultDisplay(); |
| 3513 | final boolean needsToOffsetInputMethodTarget = isDefaultDisplay && |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3514 | (win == mLastInputMethodTargetWindow && mLastInputMethodWindow != null); |
| 3515 | if (needsToOffsetInputMethodTarget) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3516 | 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] | 3517 | offsetInputMethodWindowLw(mLastInputMethodWindow); |
| 3518 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3519 | |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3520 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3521 | final int sim = attrs.softInputMode; |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 3522 | final int sysUiFl = PolicyControl.getSystemUiVisibility(win, null); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3523 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3524 | final Rect pf = mTmpParentFrame; |
| 3525 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3526 | final Rect of = mTmpOverscanFrame; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3527 | final Rect cf = mTmpContentFrame; |
| 3528 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3529 | final Rect dcf = mTmpDecorFrame; |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3530 | final Rect sf = mTmpStableFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3531 | dcf.setEmpty(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3532 | |
| 3533 | final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3534 | && mNavigationBar != null && mNavigationBar.isVisibleLw()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3535 | |
Craig Mautner | f683b56 | 2012-10-02 11:10:57 -0700 | [diff] [blame] | 3536 | final int adjust = sim & SOFT_INPUT_MASK_ADJUST; |
| 3537 | |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3538 | if (isDefaultDisplay) { |
| 3539 | sf.set(mStableLeft, mStableTop, mStableRight, mStableBottom); |
| 3540 | } else { |
| 3541 | sf.set(mOverscanLeft, mOverscanTop, mOverscanRight, mOverscanBottom); |
| 3542 | } |
| 3543 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3544 | if (!isDefaultDisplay) { |
| 3545 | if (attached != null) { |
| 3546 | // If this window is attached to another, our display |
| 3547 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3548 | setAttachedWindowFrames(win, fl, adjust, attached, true, pf, df, of, cf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3549 | } else { |
| 3550 | // Give the window full screen. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3551 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3552 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3553 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3554 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3555 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3556 | = mOverscanScreenTop + mOverscanScreenHeight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3557 | } |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 3558 | } else if (attrs.type == TYPE_INPUT_METHOD || attrs.type == TYPE_VOICE_INTERACTION) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3559 | pf.left = df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3560 | pf.top = df.top = of.top = cf.top = vf.top = mDockTop; |
| 3561 | pf.right = df.right = of.right = cf.right = vf.right = mDockRight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3562 | // IM dock windows layout below the nav bar... |
John Spurlock | 57beb3b | 2013-10-10 10:27:44 -0400 | [diff] [blame] | 3563 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 3564 | // ...with content insets above the nav bar |
| 3565 | cf.bottom = vf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3566 | // IM dock windows always go to the bottom of the screen. |
| 3567 | attrs.gravity = Gravity.BOTTOM; |
| 3568 | mDockLayer = win.getSurfaceLayer(); |
Jorim Jaggi | e070018 | 2014-08-21 01:12:37 +0200 | [diff] [blame] | 3569 | } else if (win == mStatusBar && (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
| 3570 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3571 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3572 | pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft; |
| 3573 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight + mUnrestrictedScreenTop; |
| 3574 | cf.left = vf.left = mStableLeft; |
| 3575 | cf.top = vf.top = mStableTop; |
| 3576 | cf.right = vf.right = mStableRight; |
| 3577 | vf.bottom = mStableBottom; |
| 3578 | cf.bottom = mContentBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3579 | } else { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3580 | |
| 3581 | // Default policy decor for the default display |
| 3582 | dcf.left = mSystemLeft; |
| 3583 | dcf.top = mSystemTop; |
| 3584 | dcf.right = mSystemRight; |
| 3585 | dcf.bottom = mSystemBottom; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3586 | final boolean inheritTranslucentDecor = (attrs.privateFlags |
| 3587 | & WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR) != 0; |
John Spurlock | 65567d4 | 2013-10-08 10:08:32 -0400 | [diff] [blame] | 3588 | final boolean isAppWindow = |
| 3589 | attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW && |
| 3590 | attrs.type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 3591 | final boolean topAtRest = |
| 3592 | win == mTopFullscreenOpaqueWindowState && !win.isAnimatingLw(); |
| 3593 | if (isAppWindow && !inheritTranslucentDecor && !topAtRest) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3594 | if ((sysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 |
| 3595 | && (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3596 | && (fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == 0 |
| 3597 | && (fl & WindowManager.LayoutParams. |
| 3598 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3599 | // Ensure policy decor includes status bar |
| 3600 | dcf.top = mStableTop; |
| 3601 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3602 | if ((fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3603 | && (sysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0 |
| 3604 | && (fl & WindowManager.LayoutParams. |
| 3605 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3606 | // Ensure policy decor includes navigation bar |
| 3607 | dcf.bottom = mStableBottom; |
| 3608 | dcf.right = mStableRight; |
| 3609 | } |
| 3610 | } |
| 3611 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3612 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) |
| 3613 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3614 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3615 | + "): IN_SCREEN, INSET_DECOR"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3616 | // This is the case for a normal activity window: we want it |
| 3617 | // to cover all of the screen space, and it can take care of |
| 3618 | // moving its contents to account for screen decorations that |
| 3619 | // intrude into that space. |
| 3620 | if (attached != null) { |
| 3621 | // If this window is attached to another, our display |
| 3622 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3623 | 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] | 3624 | } else { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3625 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3626 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3627 | // Status bar panels are the only windows who can go on top of |
| 3628 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3629 | // permission, so they have the same privileges as the status |
| 3630 | // bar itself. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3631 | // |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3632 | // However, they should still dodge the navigation bar if it exists. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3633 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3634 | pf.left = df.left = of.left = hasNavBar |
| 3635 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3636 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3637 | pf.right = df.right = of.right = hasNavBar |
| 3638 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
| 3639 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3640 | pf.bottom = df.bottom = of.bottom = hasNavBar |
| 3641 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
| 3642 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3643 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3644 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3645 | "Laying out status bar window: (%d,%d - %d,%d)", |
| 3646 | pf.left, pf.top, pf.right, pf.bottom)); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3647 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3648 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3649 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3650 | // Asking to layout into the overscan region, so give it that pure |
| 3651 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3652 | pf.left = df.left = of.left = mOverscanScreenLeft; |
| 3653 | pf.top = df.top = of.top = mOverscanScreenTop; |
| 3654 | pf.right = df.right = of.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3655 | pf.bottom = df.bottom = of.bottom = mOverscanScreenTop |
| 3656 | + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3657 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3658 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 3659 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3660 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3661 | // Asking for layout as if the nav bar is hidden, lets the |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3662 | // application extend into the unrestricted overscan screen area. We |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3663 | // only do this for application windows to ensure no window that |
| 3664 | // can be above the nav bar can do this. |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3665 | pf.left = df.left = mOverscanScreenLeft; |
| 3666 | pf.top = df.top = mOverscanScreenTop; |
| 3667 | pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3668 | pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3669 | // We need to tell the app about where the frame inside the overscan |
| 3670 | // is, so it can inset its content by that amount -- it didn't ask |
| 3671 | // to actually extend itself into the overscan region. |
| 3672 | of.left = mUnrestrictedScreenLeft; |
| 3673 | of.top = mUnrestrictedScreenTop; |
| 3674 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3675 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3676 | } else { |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3677 | pf.left = df.left = mRestrictedOverscanScreenLeft; |
| 3678 | pf.top = df.top = mRestrictedOverscanScreenTop; |
| 3679 | pf.right = df.right = mRestrictedOverscanScreenLeft |
| 3680 | + mRestrictedOverscanScreenWidth; |
| 3681 | pf.bottom = df.bottom = mRestrictedOverscanScreenTop |
| 3682 | + mRestrictedOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3683 | // We need to tell the app about where the frame inside the overscan |
| 3684 | // is, so it can inset its content by that amount -- it didn't ask |
| 3685 | // to actually extend itself into the overscan region. |
| 3686 | of.left = mUnrestrictedScreenLeft; |
| 3687 | of.top = mUnrestrictedScreenTop; |
| 3688 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3689 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3690 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3691 | |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3692 | if ((fl & FLAG_FULLSCREEN) == 0) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3693 | if (win.isVoiceInteraction()) { |
| 3694 | cf.left = mVoiceContentLeft; |
| 3695 | cf.top = mVoiceContentTop; |
| 3696 | cf.right = mVoiceContentRight; |
| 3697 | cf.bottom = mVoiceContentBottom; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3698 | } else { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3699 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
| 3700 | cf.left = mDockLeft; |
| 3701 | cf.top = mDockTop; |
| 3702 | cf.right = mDockRight; |
| 3703 | cf.bottom = mDockBottom; |
| 3704 | } else { |
| 3705 | cf.left = mContentLeft; |
| 3706 | cf.top = mContentTop; |
| 3707 | cf.right = mContentRight; |
| 3708 | cf.bottom = mContentBottom; |
| 3709 | } |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3710 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3711 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3712 | // Full screen windows are always given a layout that is as if the |
| 3713 | // status bar and other transient decors are gone. This is to avoid |
| 3714 | // bad states when moving from a window that is not hding the |
| 3715 | // status bar to one that is. |
| 3716 | cf.left = mRestrictedScreenLeft; |
| 3717 | cf.top = mRestrictedScreenTop; |
| 3718 | cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 3719 | cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3720 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3721 | applyStableConstraints(sysUiFl, fl, cf); |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3722 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3723 | vf.left = mCurLeft; |
| 3724 | vf.top = mCurTop; |
| 3725 | vf.right = mCurRight; |
| 3726 | vf.bottom = mCurBottom; |
| 3727 | } else { |
| 3728 | vf.set(cf); |
| 3729 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3730 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3731 | } else if ((fl & FLAG_LAYOUT_IN_SCREEN) != 0 || (sysUiFl |
| 3732 | & (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 3733 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3734 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3735 | "): IN_SCREEN"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3736 | // A window that has requested to fill the entire screen just |
| 3737 | // gets everything, period. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3738 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 3739 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3740 | pf.left = df.left = of.left = cf.left = hasNavBar |
| 3741 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 3742 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3743 | pf.right = df.right = of.right = cf.right = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3744 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3745 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3746 | pf.bottom = df.bottom = of.bottom = cf.bottom = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3747 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3748 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3749 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 3750 | "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)", |
| 3751 | pf.left, pf.top, pf.right, pf.bottom)); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 3752 | } else if (attrs.type == TYPE_NAVIGATION_BAR |
| 3753 | || attrs.type == TYPE_NAVIGATION_BAR_PANEL) { |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3754 | // The navigation bar has Real Ultimate Power. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3755 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3756 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3757 | pf.right = df.right = of.right = mUnrestrictedScreenLeft |
| 3758 | + mUnrestrictedScreenWidth; |
| 3759 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop |
| 3760 | + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3761 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 3762 | "Laying out navigation bar window: (%d,%d - %d,%d)", |
| 3763 | pf.left, pf.top, pf.right, pf.bottom)); |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3764 | } else if ((attrs.type == TYPE_SECURE_SYSTEM_OVERLAY |
| 3765 | || attrs.type == TYPE_BOOT_PROGRESS) |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 3766 | && ((fl & FLAG_FULLSCREEN) != 0)) { |
| 3767 | // Fullscreen secure system overlays get what they ask for. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3768 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3769 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3770 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3771 | + mOverscanScreenWidth; |
| 3772 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3773 | + mOverscanScreenHeight; |
Craig Mautner | 165be0c | 2015-01-27 15:16:58 -0800 | [diff] [blame] | 3774 | } else if (attrs.type == TYPE_BOOT_PROGRESS) { |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 3775 | // Boot progress screen always covers entire display. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3776 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3777 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3778 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 3779 | + mOverscanScreenWidth; |
| 3780 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 3781 | + mOverscanScreenHeight; |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 3782 | } else if (attrs.type == TYPE_WALLPAPER) { |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 3783 | // The wallpaper also has Real Ultimate Power, but we want to tell |
| 3784 | // it about the overscan area. |
| 3785 | pf.left = df.left = mOverscanScreenLeft; |
| 3786 | pf.top = df.top = mOverscanScreenTop; |
| 3787 | pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 3788 | pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight; |
| 3789 | of.left = cf.left = mUnrestrictedScreenLeft; |
| 3790 | of.top = cf.top = mUnrestrictedScreenTop; |
| 3791 | of.right = cf.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3792 | of.bottom = cf.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3793 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3794 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3795 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 3796 | // Asking to layout into the overscan region, so give it that pure |
| 3797 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3798 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 3799 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 3800 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3801 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3802 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3803 | = mOverscanScreenTop + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3804 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3805 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Craig Mautner | beac106 | 2014-06-03 14:38:57 -0700 | [diff] [blame] | 3806 | && (attrs.type == TYPE_STATUS_BAR |
| 3807 | || attrs.type == TYPE_TOAST |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3808 | || (attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 3809 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW))) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3810 | // Asking for layout as if the nav bar is hidden, lets the |
| 3811 | // application extend into the unrestricted screen area. We |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 3812 | // 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] | 3813 | // can be above the nav bar can do this. |
| 3814 | // XXX This assumes that an app asking for this will also |
| 3815 | // ask for layout in only content. We can't currently figure out |
| 3816 | // 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] | 3817 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 3818 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 3819 | pf.right = df.right = of.right = cf.right = mUnrestrictedScreenLeft |
| 3820 | + mUnrestrictedScreenWidth; |
| 3821 | pf.bottom = df.bottom = of.bottom = cf.bottom = mUnrestrictedScreenTop |
| 3822 | + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3823 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3824 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3825 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3826 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3827 | + mRestrictedScreenWidth; |
| 3828 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3829 | + mRestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 3830 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3831 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3832 | applyStableConstraints(sysUiFl, fl, cf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3833 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3834 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3835 | vf.left = mCurLeft; |
| 3836 | vf.top = mCurTop; |
| 3837 | vf.right = mCurRight; |
| 3838 | vf.bottom = mCurBottom; |
| 3839 | } else { |
| 3840 | vf.set(cf); |
| 3841 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3842 | } else if (attached != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3843 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3844 | "): attached to " + attached); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3845 | // A child window should be placed inside of the same visible |
| 3846 | // frame that its parent had. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3847 | 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] | 3848 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3849 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 3850 | "): normal window"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3851 | // Otherwise, a normal window must be placed inside the content |
| 3852 | // of all screen decorations. |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3853 | if (attrs.type == TYPE_STATUS_BAR_PANEL) { |
| 3854 | // Status bar panels are the only windows who can go on top of |
| 3855 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 3856 | // permission, so they have the same privileges as the status |
| 3857 | // bar itself. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3858 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 3859 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 3860 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 3861 | + mRestrictedScreenWidth; |
| 3862 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 3863 | + mRestrictedScreenHeight; |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 3864 | } else if (attrs.type == TYPE_TOAST || attrs.type == TYPE_SYSTEM_ALERT |
| 3865 | || attrs.type == TYPE_VOLUME_OVERLAY) { |
| 3866 | // These dialogs are stable to interim decor changes. |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 3867 | pf.left = df.left = of.left = cf.left = mStableLeft; |
| 3868 | pf.top = df.top = of.top = cf.top = mStableTop; |
| 3869 | pf.right = df.right = of.right = cf.right = mStableRight; |
| 3870 | pf.bottom = df.bottom = of.bottom = cf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3871 | } else { |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3872 | pf.left = mContentLeft; |
| 3873 | pf.top = mContentTop; |
| 3874 | pf.right = mContentRight; |
| 3875 | pf.bottom = mContentBottom; |
Dianne Hackborn | 20d9474 | 2014-05-29 18:35:45 -0700 | [diff] [blame] | 3876 | if (win.isVoiceInteraction()) { |
| 3877 | df.left = of.left = cf.left = mVoiceContentLeft; |
| 3878 | df.top = of.top = cf.top = mVoiceContentTop; |
| 3879 | df.right = of.right = cf.right = mVoiceContentRight; |
| 3880 | df.bottom = of.bottom = cf.bottom = mVoiceContentBottom; |
| 3881 | } else if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3882 | df.left = of.left = cf.left = mDockLeft; |
| 3883 | df.top = of.top = cf.top = mDockTop; |
| 3884 | df.right = of.right = cf.right = mDockRight; |
| 3885 | df.bottom = of.bottom = cf.bottom = mDockBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3886 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3887 | df.left = of.left = cf.left = mContentLeft; |
| 3888 | df.top = of.top = cf.top = mContentTop; |
| 3889 | df.right = of.right = cf.right = mContentRight; |
| 3890 | df.bottom = of.bottom = cf.bottom = mContentBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 3891 | } |
| 3892 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 3893 | vf.left = mCurLeft; |
| 3894 | vf.top = mCurTop; |
| 3895 | vf.right = mCurRight; |
| 3896 | vf.bottom = mCurBottom; |
| 3897 | } else { |
| 3898 | vf.set(cf); |
| 3899 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3900 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3901 | } |
| 3902 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3903 | |
Craig Mautner | b816bed | 2013-07-23 10:26:17 -0700 | [diff] [blame] | 3904 | // TYPE_SYSTEM_ERROR is above the NavigationBar so it can't be allowed to extend over it. |
| 3905 | if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0 && attrs.type != TYPE_SYSTEM_ERROR) { |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 3906 | df.left = df.top = -10000; |
| 3907 | df.right = df.bottom = 10000; |
| 3908 | if (attrs.type != TYPE_WALLPAPER) { |
| 3909 | of.left = of.top = cf.left = cf.top = vf.left = vf.top = -10000; |
| 3910 | of.right = of.bottom = cf.right = cf.bottom = vf.right = vf.bottom = 10000; |
| 3911 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3912 | } |
| 3913 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3914 | 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] | 3915 | + ": sim=#" + Integer.toHexString(sim) |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3916 | + " attach=" + attached + " type=" + attrs.type |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3917 | + String.format(" flags=0x%08x", fl) |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 3918 | + " pf=" + pf.toShortString() + " df=" + df.toShortString() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3919 | + " of=" + of.toShortString() |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3920 | + " cf=" + cf.toShortString() + " vf=" + vf.toShortString() |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3921 | + " dcf=" + dcf.toShortString() |
| 3922 | + " sf=" + sf.toShortString()); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3923 | |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 3924 | win.computeFrameLw(pf, df, of, cf, vf, dcf, sf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3925 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3926 | // Dock windows carve out the bottom of the screen, so normal windows |
| 3927 | // can't appear underneath them. |
Craig Mautner | 8bd206b | 2012-10-03 10:32:02 -0700 | [diff] [blame] | 3928 | if (attrs.type == TYPE_INPUT_METHOD && win.isVisibleOrBehindKeyguardLw() |
| 3929 | && !win.getGivenInsetsPendingLw()) { |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3930 | setLastInputMethodWindowLw(null, null); |
| 3931 | offsetInputMethodWindowLw(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3932 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3933 | if (attrs.type == TYPE_VOICE_INTERACTION && win.isVisibleOrBehindKeyguardLw() |
| 3934 | && !win.getGivenInsetsPendingLw()) { |
| 3935 | offsetVoiceInputWindowLw(win); |
| 3936 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3937 | } |
| 3938 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3939 | private void offsetInputMethodWindowLw(WindowState win) { |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 3940 | int top = win.getDisplayFrameLw().top; |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3941 | top += win.getGivenContentInsetsLw().top; |
| 3942 | if (mContentBottom > top) { |
| 3943 | mContentBottom = top; |
| 3944 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3945 | if (mVoiceContentBottom > top) { |
| 3946 | mVoiceContentBottom = top; |
| 3947 | } |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3948 | top = win.getVisibleFrameLw().top; |
| 3949 | top += win.getGivenVisibleInsetsLw().top; |
| 3950 | if (mCurBottom > top) { |
| 3951 | mCurBottom = top; |
| 3952 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3953 | if (DEBUG_LAYOUT) Slog.v(TAG, "Input method: mDockBottom=" |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 3954 | + mDockBottom + " mContentBottom=" |
| 3955 | + mContentBottom + " mCurBottom=" + mCurBottom); |
| 3956 | } |
| 3957 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3958 | private void offsetVoiceInputWindowLw(WindowState win) { |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 3959 | int top = win.getDisplayFrameLw().top; |
| 3960 | top += win.getGivenContentInsetsLw().top; |
| 3961 | if (mVoiceContentBottom > top) { |
| 3962 | mVoiceContentBottom = top; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3963 | } |
| 3964 | } |
| 3965 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3966 | /** {@inheritDoc} */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 3967 | @Override |
| 3968 | public void finishLayoutLw() { |
| 3969 | return; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3970 | } |
| 3971 | |
| 3972 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3973 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 3974 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3975 | mTopFullscreenOpaqueWindowState = null; |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame^] | 3976 | mTopFullscreenOpaqueOrDimmingWindowState = null; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 3977 | mAppsToBeHidden.clear(); |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 3978 | mAppsThatDismissKeyguard.clear(); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3979 | mForceStatusBar = false; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 3980 | mForceStatusBarFromKeyguard = false; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 3981 | mForcingShowNavBar = false; |
| 3982 | mForcingShowNavBarLayer = -1; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3983 | |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3984 | mHideLockScreen = false; |
| 3985 | mAllowLockscreenWhenOn = false; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3986 | mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 3987 | mShowingLockscreen = false; |
| 3988 | mShowingDream = false; |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3989 | mWinShowWhenLocked = null; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 3990 | mKeyguardSecure = isKeyguardSecure(); |
| 3991 | mKeyguardSecureIncludingHidden = mKeyguardSecure |
| 3992 | && (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 3993 | } |
| 3994 | |
| 3995 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 3996 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 3997 | public void applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams attrs) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3998 | if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw=" |
| 3999 | + win.isVisibleOrBehindKeyguardLw()); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4000 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 4001 | if (mTopFullscreenOpaqueWindowState == null |
| 4002 | && win.isVisibleLw() && attrs.type == TYPE_INPUT_METHOD) { |
| 4003 | mForcingShowNavBar = true; |
| 4004 | mForcingShowNavBarLayer = win.getSurfaceLayer(); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 4005 | } |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 4006 | if (attrs.type == TYPE_STATUS_BAR && (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 4007 | mForceStatusBarFromKeyguard = true; |
| 4008 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4009 | if (mTopFullscreenOpaqueWindowState == null && |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 4010 | win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4011 | if ((fl & FLAG_FORCE_NOT_FULLSCREEN) != 0) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4012 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 4013 | mForceStatusBarFromKeyguard = true; |
| 4014 | } else { |
| 4015 | mForceStatusBar = true; |
| 4016 | } |
| 4017 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4018 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 4019 | mShowingLockscreen = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4020 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4021 | boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW |
Craig Mautner | 7d7808f | 2014-09-11 18:02:38 -0700 | [diff] [blame] | 4022 | && attrs.type < FIRST_SYSTEM_WINDOW; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 4023 | if (attrs.type == TYPE_DREAM) { |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 4024 | // If the lockscreen was showing when the dream started then wait |
| 4025 | // for the dream to draw before hiding the lockscreen. |
| 4026 | if (!mDreamingLockscreen |
| 4027 | || (win.isVisibleLw() && win.hasDrawnLw())) { |
| 4028 | mShowingDream = true; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4029 | appWindow = true; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 4030 | } |
| 4031 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4032 | |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 4033 | final boolean showWhenLocked = (fl & FLAG_SHOW_WHEN_LOCKED) != 0; |
Craig Mautner | 74ee938 | 2014-04-01 15:20:16 -0700 | [diff] [blame] | 4034 | final boolean dismissKeyguard = (fl & FLAG_DISMISS_KEYGUARD) != 0; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4035 | if (appWindow) { |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4036 | final IApplicationToken appToken = win.getAppToken(); |
| 4037 | if (showWhenLocked) { |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4038 | // Remove any previous windows with the same appToken. |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4039 | mAppsToBeHidden.remove(appToken); |
| 4040 | mAppsThatDismissKeyguard.remove(appToken); |
Craig Mautner | ca0a124 | 2014-12-02 12:25:14 -0800 | [diff] [blame] | 4041 | if (mAppsToBeHidden.isEmpty()) { |
Craig Mautner | 192d604 | 2014-12-02 23:24:48 -0800 | [diff] [blame] | 4042 | if (dismissKeyguard && !mKeyguardSecure) { |
| 4043 | mAppsThatDismissKeyguard.add(appToken); |
| 4044 | } else { |
Craig Mautner | ca0a124 | 2014-12-02 12:25:14 -0800 | [diff] [blame] | 4045 | mWinShowWhenLocked = win; |
| 4046 | mHideLockScreen = true; |
| 4047 | mForceStatusBarFromKeyguard = false; |
Craig Mautner | ca0a124 | 2014-12-02 12:25:14 -0800 | [diff] [blame] | 4048 | } |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4049 | } |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4050 | } else if (dismissKeyguard) { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4051 | if (mKeyguardSecure) { |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4052 | mAppsToBeHidden.add(appToken); |
| 4053 | } else { |
| 4054 | mAppsToBeHidden.remove(appToken); |
| 4055 | } |
| 4056 | mAppsThatDismissKeyguard.add(appToken); |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 4057 | } else { |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4058 | mAppsToBeHidden.add(appToken); |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 4059 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4060 | if (attrs.x == 0 && attrs.y == 0 |
| 4061 | && attrs.width == WindowManager.LayoutParams.MATCH_PARENT |
| 4062 | && attrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
| 4063 | if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win); |
| 4064 | mTopFullscreenOpaqueWindowState = win; |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame^] | 4065 | if (mTopFullscreenOpaqueOrDimmingWindowState == null) { |
| 4066 | mTopFullscreenOpaqueOrDimmingWindowState = win; |
| 4067 | } |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4068 | if (!mAppsThatDismissKeyguard.isEmpty() && |
| 4069 | mDismissKeyguard == DISMISS_KEYGUARD_NONE) { |
| 4070 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 4071 | "Setting mDismissKeyguard true by win " + win); |
| 4072 | mDismissKeyguard = mWinDismissingKeyguard == win ? |
| 4073 | DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START; |
| 4074 | mWinDismissingKeyguard = win; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4075 | mForceStatusBarFromKeyguard = mShowingLockscreen && mKeyguardSecure; |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4076 | } else if (mAppsToBeHidden.isEmpty() && showWhenLocked) { |
| 4077 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 4078 | "Setting mHideLockScreen to true by win " + win); |
| 4079 | mHideLockScreen = true; |
| 4080 | mForceStatusBarFromKeyguard = false; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4081 | } |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 4082 | if ((fl & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) { |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4083 | mAllowLockscreenWhenOn = true; |
| 4084 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4085 | } |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4086 | |
| 4087 | if (mWinShowWhenLocked != null && |
| 4088 | mWinShowWhenLocked.getAppToken() != win.getAppToken()) { |
| 4089 | win.hideLw(false); |
| 4090 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4091 | } |
| 4092 | } |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame^] | 4093 | if (mTopFullscreenOpaqueOrDimmingWindowState == null |
| 4094 | && win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw() |
| 4095 | && win.isDimming()) { |
| 4096 | mTopFullscreenOpaqueOrDimmingWindowState = win; |
| 4097 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4098 | } |
| 4099 | |
| 4100 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 4101 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 4102 | public int finishPostLayoutPolicyLw() { |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4103 | if (mWinShowWhenLocked != null && |
| 4104 | mWinShowWhenLocked != mTopFullscreenOpaqueWindowState) { |
| 4105 | // A dialog is dismissing the keyguard. Put the wallpaper behind it and hide the |
| 4106 | // fullscreen window. |
| 4107 | // TODO: Make sure FLAG_SHOW_WALLPAPER is restored when dialog is dismissed. Or not. |
| 4108 | mWinShowWhenLocked.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 4109 | mTopFullscreenOpaqueWindowState.hideLw(false); |
| 4110 | mTopFullscreenOpaqueWindowState = mWinShowWhenLocked; |
| 4111 | } |
| 4112 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4113 | int changes = 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4114 | boolean topIsFullscreen = false; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 4115 | |
| 4116 | final WindowManager.LayoutParams lp = (mTopFullscreenOpaqueWindowState != null) |
| 4117 | ? mTopFullscreenOpaqueWindowState.getAttrs() |
| 4118 | : null; |
| 4119 | |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 4120 | // If we are not currently showing a dream then remember the current |
| 4121 | // lockscreen state. We will use this to determine whether the dream |
| 4122 | // started while the lockscreen was showing and remember this state |
| 4123 | // while the dream is showing. |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 4124 | if (!mShowingDream) { |
| 4125 | mDreamingLockscreen = mShowingLockscreen; |
| 4126 | } |
| 4127 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4128 | if (mStatusBar != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4129 | if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 4130 | + " forcefkg=" + mForceStatusBarFromKeyguard |
Dianne Hackborn | d70bc2f | 2009-10-06 23:25:51 -0700 | [diff] [blame] | 4131 | + " top=" + mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 4132 | if (mForceStatusBar || mForceStatusBarFromKeyguard) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4133 | if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4134 | if (mStatusBarController.setBarShowingLw(true)) { |
| 4135 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 4136 | } |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 4137 | // Maintain fullscreen layout until incoming animation is complete. |
| 4138 | topIsFullscreen = mTopIsFullscreen && mStatusBar.isAnimatingLw(); |
John Spurlock | f92b616 | 2013-11-11 15:01:16 -0500 | [diff] [blame] | 4139 | // Transient status bar on the lockscreen is not allowed |
| 4140 | if (mForceStatusBarFromKeyguard && mStatusBarController.isTransientShowing()) { |
| 4141 | mStatusBarController.updateVisibilityLw(false /*transientAllowed*/, |
| 4142 | mLastSystemUiFlags, mLastSystemUiFlags); |
| 4143 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4144 | } else if (mTopFullscreenOpaqueWindowState != null) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4145 | final int fl = PolicyControl.getWindowFlags(null, lp); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4146 | if (localLOGV) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4147 | Slog.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw() |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4148 | + " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw()); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4149 | Slog.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs() |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4150 | + " lp.flags=0x" + Integer.toHexString(fl)); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4151 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4152 | topIsFullscreen = (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0 |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4153 | || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4154 | // The subtle difference between the window for mTopFullscreenOpaqueWindowState |
Mark Doliner | d0646dc | 2014-08-27 16:04:02 -0700 | [diff] [blame] | 4155 | // and mTopIsFullscreen is that mTopIsFullscreen is set only if the window |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4156 | // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the |
| 4157 | // case though. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4158 | if (mStatusBarController.isTransientShowing()) { |
| 4159 | if (mStatusBarController.setBarShowingLw(true)) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 4160 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 4161 | } |
| 4162 | } else if (topIsFullscreen) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4163 | if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4164 | if (mStatusBarController.setBarShowingLw(false)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 4165 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4166 | } else { |
Craig Mautner | c5a6e44 | 2013-06-05 17:22:35 -0700 | [diff] [blame] | 4167 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar already hiding"); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 4168 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4169 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4170 | 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] | 4171 | if (mStatusBarController.setBarShowingLw(true)) { |
| 4172 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 4173 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4174 | } |
| 4175 | } |
| 4176 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 4177 | |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 4178 | if (mTopIsFullscreen != topIsFullscreen) { |
| 4179 | if (!topIsFullscreen) { |
| 4180 | // Force another layout when status bar becomes fully shown. |
| 4181 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 4182 | } |
| 4183 | mTopIsFullscreen = topIsFullscreen; |
| 4184 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 4185 | |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 4186 | // Hide the key guard if a visible window explicitly specifies that it wants to be |
| 4187 | // displayed when the screen is locked. |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4188 | if (mKeyguardDelegate != null && mStatusBar != null) { |
| 4189 | if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard=" |
| 4190 | + mHideLockScreen); |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4191 | if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !mKeyguardSecure) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4192 | mKeyguardHidden = true; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4193 | if (setKeyguardOccludedLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4194 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 4195 | | FINISH_LAYOUT_REDO_CONFIG |
| 4196 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 4197 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4198 | if (mKeyguardDelegate.isShowing()) { |
| 4199 | mHandler.post(new Runnable() { |
| 4200 | @Override |
| 4201 | public void run() { |
| 4202 | mKeyguardDelegate.keyguardDone(false, false); |
| 4203 | } |
| 4204 | }); |
| 4205 | } |
| 4206 | } else if (mHideLockScreen) { |
| 4207 | mKeyguardHidden = true; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4208 | if (setKeyguardOccludedLw(true)) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4209 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 4210 | | FINISH_LAYOUT_REDO_CONFIG |
| 4211 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 4212 | } |
| 4213 | } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) { |
| 4214 | // This is the case of keyguard isSecure() and not mHideLockScreen. |
| 4215 | if (mDismissKeyguard == DISMISS_KEYGUARD_START) { |
| 4216 | // Only launch the next keyguard unlock window once per window. |
| 4217 | mKeyguardHidden = false; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4218 | if (setKeyguardOccludedLw(false)) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4219 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 4220 | | FINISH_LAYOUT_REDO_CONFIG |
| 4221 | | FINISH_LAYOUT_REDO_WALLPAPER; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4222 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4223 | mHandler.post(new Runnable() { |
| 4224 | @Override |
| 4225 | public void run() { |
| 4226 | mKeyguardDelegate.dismiss(); |
| 4227 | } |
| 4228 | }); |
| 4229 | } |
| 4230 | } else { |
| 4231 | mWinDismissingKeyguard = null; |
| 4232 | mKeyguardHidden = false; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4233 | if (setKeyguardOccludedLw(false)) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4234 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 4235 | | FINISH_LAYOUT_REDO_CONFIG |
| 4236 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 4237 | } |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 4238 | } |
| 4239 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4240 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4241 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4242 | // If the navigation bar has been hidden or shown, we need to do another |
| 4243 | // layout pass to update that window. |
| 4244 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 4245 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4246 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4247 | // update since mAllowLockscreenWhenOn might have changed |
| 4248 | updateLockScreenTimeout(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4249 | return changes; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4250 | } |
| 4251 | |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4252 | /** |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4253 | * Updates the occluded state of the Keyguard. |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4254 | * |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4255 | * @return Whether the flags have changed and we have to redo the layout. |
| 4256 | */ |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4257 | private boolean setKeyguardOccludedLw(boolean isOccluded) { |
| 4258 | boolean wasOccluded = mKeyguardOccluded; |
| 4259 | boolean showing = mKeyguardDelegate.isShowing(); |
| 4260 | if (wasOccluded && !isOccluded && showing) { |
| 4261 | mKeyguardOccluded = false; |
| 4262 | mKeyguardDelegate.setOccluded(false); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4263 | mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD; |
| 4264 | mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 4265 | return true; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4266 | } else if (!wasOccluded && isOccluded && showing) { |
| 4267 | mKeyguardOccluded = true; |
| 4268 | mKeyguardDelegate.setOccluded(true); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4269 | mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD; |
| 4270 | mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER; |
| 4271 | return true; |
| 4272 | } else { |
| 4273 | return false; |
| 4274 | } |
| 4275 | } |
| 4276 | |
| 4277 | private boolean isStatusBarKeyguard() { |
| 4278 | return mStatusBar != null |
| 4279 | && (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
| 4280 | } |
| 4281 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4282 | @Override |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4283 | public boolean allowAppAnimationsLw() { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4284 | if (isStatusBarKeyguard() || mShowingDream) { |
Craig Mautner | 2881630 | 2013-10-10 20:31:00 -0700 | [diff] [blame] | 4285 | // 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] | 4286 | return false; |
| 4287 | } |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4288 | return true; |
| 4289 | } |
| 4290 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4291 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4292 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus) { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4293 | mFocusedWindow = newFocus; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4294 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4295 | // If the navigation bar has been hidden or shown, we need to do another |
| 4296 | // layout pass to update that window. |
| 4297 | return FINISH_LAYOUT_REDO_LAYOUT; |
| 4298 | } |
| 4299 | return 0; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4300 | } |
| 4301 | |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 4302 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4303 | @Override |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 4304 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
| 4305 | // lid changed state |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4306 | final int newLidState = lidOpen ? LID_OPEN : LID_CLOSED; |
| 4307 | if (newLidState == mLidState) { |
| 4308 | return; |
| 4309 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4310 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4311 | mLidState = newLidState; |
| 4312 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4313 | updateRotation(true); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4314 | |
| 4315 | if (lidOpen) { |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 4316 | wakeUp(SystemClock.uptimeMillis(), mAllowTheaterModeWakeFromLidSwitch); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4317 | } else if (!mLidControlsSleep) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 4318 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 4319 | } |
| 4320 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4321 | |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 4322 | @Override |
| 4323 | public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) { |
| 4324 | int lensCoverState = lensCovered ? CAMERA_LENS_COVERED : CAMERA_LENS_UNCOVERED; |
| 4325 | if (mCameraLensCoverState == lensCoverState) { |
| 4326 | return; |
| 4327 | } |
| 4328 | if (mCameraLensCoverState == CAMERA_LENS_COVERED && |
| 4329 | lensCoverState == CAMERA_LENS_UNCOVERED) { |
| 4330 | Intent intent; |
| 4331 | final boolean keyguardActive = mKeyguardDelegate == null ? false : |
| 4332 | mKeyguardDelegate.isShowing(); |
| 4333 | if (keyguardActive) { |
| 4334 | intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE); |
| 4335 | } else { |
| 4336 | intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); |
| 4337 | } |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 4338 | wakeUp(whenNanos / 1000000, mAllowTheaterModeWakeFromCameraLens); |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 4339 | mContext.startActivityAsUser(intent, UserHandle.CURRENT_OR_SELF); |
| 4340 | } |
| 4341 | mCameraLensCoverState = lensCoverState; |
| 4342 | } |
| 4343 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 4344 | void setHdmiPlugged(boolean plugged) { |
| 4345 | if (mHdmiPlugged != plugged) { |
| 4346 | mHdmiPlugged = plugged; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 4347 | updateRotation(true, true); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 4348 | Intent intent = new Intent(ACTION_HDMI_PLUGGED); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 4349 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 4350 | intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 4351 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 4352 | } |
| 4353 | } |
| 4354 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 4355 | void initializeHdmiState() { |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 4356 | boolean plugged = false; |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 4357 | // watch for HDMI plug messages if the hdmi switch exists |
| 4358 | if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) { |
| 4359 | mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi"); |
| 4360 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 4361 | final String filename = "/sys/class/switch/hdmi/state"; |
| 4362 | FileReader reader = null; |
| 4363 | try { |
| 4364 | reader = new FileReader(filename); |
| 4365 | char[] buf = new char[15]; |
| 4366 | int n = reader.read(buf); |
| 4367 | if (n > 1) { |
| 4368 | plugged = 0 != Integer.parseInt(new String(buf, 0, n-1)); |
| 4369 | } |
| 4370 | } catch (IOException ex) { |
| 4371 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 4372 | } catch (NumberFormatException ex) { |
| 4373 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 4374 | } finally { |
| 4375 | if (reader != null) { |
| 4376 | try { |
| 4377 | reader.close(); |
| 4378 | } catch (IOException ex) { |
| 4379 | } |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 4380 | } |
| 4381 | } |
| 4382 | } |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 4383 | // This dance forces the code in setHdmiPlugged to run. |
| 4384 | // Always do this so the sticky intent is stuck (to false) if there is no hdmi. |
| 4385 | mHdmiPlugged = !plugged; |
| 4386 | setHdmiPlugged(!mHdmiPlugged); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 4387 | } |
| 4388 | |
Dianne Hackborn | c0e3f24 | 2011-08-19 14:19:10 -0700 | [diff] [blame] | 4389 | final Object mScreenshotLock = new Object(); |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 4390 | ServiceConnection mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 4391 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4392 | final Runnable mScreenshotTimeout = new Runnable() { |
| 4393 | @Override public void run() { |
| 4394 | synchronized (mScreenshotLock) { |
| 4395 | if (mScreenshotConnection != null) { |
| 4396 | mContext.unbindService(mScreenshotConnection); |
| 4397 | mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 4398 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4399 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4400 | } |
| 4401 | }; |
| 4402 | |
| 4403 | // Assume this is called from the Handler thread. |
| 4404 | private void takeScreenshot() { |
| 4405 | synchronized (mScreenshotLock) { |
| 4406 | if (mScreenshotConnection != null) { |
| 4407 | return; |
| 4408 | } |
| 4409 | ComponentName cn = new ComponentName("com.android.systemui", |
| 4410 | "com.android.systemui.screenshot.TakeScreenshotService"); |
| 4411 | Intent intent = new Intent(); |
| 4412 | intent.setComponent(cn); |
| 4413 | ServiceConnection conn = new ServiceConnection() { |
| 4414 | @Override |
| 4415 | public void onServiceConnected(ComponentName name, IBinder service) { |
| 4416 | synchronized (mScreenshotLock) { |
| 4417 | if (mScreenshotConnection != this) { |
| 4418 | return; |
| 4419 | } |
| 4420 | Messenger messenger = new Messenger(service); |
| 4421 | Message msg = Message.obtain(null, 1); |
| 4422 | final ServiceConnection myConn = this; |
| 4423 | Handler h = new Handler(mHandler.getLooper()) { |
| 4424 | @Override |
| 4425 | public void handleMessage(Message msg) { |
| 4426 | synchronized (mScreenshotLock) { |
| 4427 | if (mScreenshotConnection == myConn) { |
| 4428 | mContext.unbindService(mScreenshotConnection); |
| 4429 | mScreenshotConnection = null; |
| 4430 | mHandler.removeCallbacks(mScreenshotTimeout); |
| 4431 | } |
| 4432 | } |
| 4433 | } |
| 4434 | }; |
| 4435 | msg.replyTo = new Messenger(h); |
Winson Chung | a63bb84 | 2011-10-17 10:26:28 -0700 | [diff] [blame] | 4436 | msg.arg1 = msg.arg2 = 0; |
| 4437 | if (mStatusBar != null && mStatusBar.isVisibleLw()) |
| 4438 | msg.arg1 = 1; |
| 4439 | if (mNavigationBar != null && mNavigationBar.isVisibleLw()) |
| 4440 | msg.arg2 = 1; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4441 | try { |
| 4442 | messenger.send(msg); |
| 4443 | } catch (RemoteException e) { |
| 4444 | } |
| 4445 | } |
| 4446 | } |
| 4447 | @Override |
| 4448 | public void onServiceDisconnected(ComponentName name) {} |
| 4449 | }; |
Amith Yamasani | 27b89e6 | 2013-01-16 12:30:11 -0800 | [diff] [blame] | 4450 | if (mContext.bindServiceAsUser( |
| 4451 | intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4452 | mScreenshotConnection = conn; |
| 4453 | mHandler.postDelayed(mScreenshotTimeout, 10000); |
| 4454 | } |
| 4455 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 4456 | } |
| 4457 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4458 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4459 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4460 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 4461 | if (!mSystemBooted) { |
| 4462 | // If we have not yet booted, don't let key events do anything. |
| 4463 | return 0; |
| 4464 | } |
| 4465 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4466 | final boolean interactive = (policyFlags & FLAG_INTERACTIVE) != 0; |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 4467 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 4468 | final boolean canceled = event.isCanceled(); |
| 4469 | final int keyCode = event.getKeyCode(); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 4470 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4471 | final boolean isInjected = (policyFlags & WindowManagerPolicy.FLAG_INJECTED) != 0; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 4472 | |
Mike Lockwood | c72b15f | 2009-11-28 20:58:22 -0500 | [diff] [blame] | 4473 | // If screen is off then we treat the case where the keyguard is open but hidden |
| 4474 | // the same as if it were open and in front. |
| 4475 | // This will prevent any keys other than the power button from waking the screen |
| 4476 | // when the keyguard is hidden by another activity. |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4477 | final boolean keyguardActive = (mKeyguardDelegate == null ? false : |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4478 | (interactive ? |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4479 | isKeyguardShowingAndNotOccluded() : |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4480 | mKeyguardDelegate.isShowing())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4481 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4482 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4483 | Log.d(TAG, "interceptKeyTq keycode=" + keyCode |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4484 | + " interactive=" + interactive + " keyguardActive=" + keyguardActive |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4485 | + " policyFlags=" + Integer.toHexString(policyFlags)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4486 | } |
| 4487 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4488 | // Basic policy based on interactive state. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4489 | int result; |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 4490 | boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0 |
| 4491 | || event.isWakeKey(); |
Michael Wright | fc01f04 | 2014-09-08 14:12:24 -0700 | [diff] [blame] | 4492 | if (interactive || (isInjected && !isWakeKey)) { |
RoboErik | de9ba39 | 2014-09-26 12:51:01 -0700 | [diff] [blame] | 4493 | // When the device is interactive or the key is injected pass the |
| 4494 | // key to the application. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4495 | result = ACTION_PASS_TO_USER; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4496 | isWakeKey = false; |
Michael Wright | fc01f04 | 2014-09-08 14:12:24 -0700 | [diff] [blame] | 4497 | } else if (!interactive && shouldDispatchInputWhenNonInteractive()) { |
| 4498 | // If we're currently dozing with the screen on and the keyguard showing, pass the key |
| 4499 | // to the application but preserve its wake key status to make sure we still move |
| 4500 | // from dozing to fully interactive if we would normally go from off to fully |
| 4501 | // interactive. |
| 4502 | result = ACTION_PASS_TO_USER; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4503 | } else { |
| 4504 | // When the screen is off and the key is not injected, determine whether |
| 4505 | // to wake the device but don't pass the key to the application. |
| 4506 | result = 0; |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4507 | if (isWakeKey && (!down || !isWakeKeyWhenScreenOff(keyCode))) { |
| 4508 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4509 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4510 | } |
| 4511 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 4512 | // If the key would be handled globally, just return the result, don't worry about special |
| 4513 | // key processing. |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4514 | if (isValidGlobalKey(keyCode) |
| 4515 | && mGlobalKeyManager.shouldHandleGlobalKey(keyCode, event)) { |
Michael Wright | 85b1af6 | 2014-06-04 14:51:58 -0700 | [diff] [blame] | 4516 | if (isWakeKey) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4517 | wakeUp(event.getEventTime(), mAllowTheaterModeWakeFromKey); |
Michael Wright | 85b1af6 | 2014-06-04 14:51:58 -0700 | [diff] [blame] | 4518 | } |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 4519 | return result; |
| 4520 | } |
| 4521 | |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 4522 | boolean useHapticFeedback = down |
| 4523 | && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 |
| 4524 | && event.getRepeatCount() == 0; |
| 4525 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4526 | // Handle special keys. |
| 4527 | switch (keyCode) { |
| 4528 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 4529 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4530 | case KeyEvent.KEYCODE_VOLUME_MUTE: { |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 4531 | if (mUseTvRouting) { |
| 4532 | // On TVs volume keys never go to the foreground app |
| 4533 | result &= ~ACTION_PASS_TO_USER; |
| 4534 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4535 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { |
| 4536 | if (down) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4537 | if (interactive && !mScreenshotChordVolumeDownKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4538 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4539 | mScreenshotChordVolumeDownKeyTriggered = true; |
| 4540 | mScreenshotChordVolumeDownKeyTime = event.getDownTime(); |
| 4541 | mScreenshotChordVolumeDownKeyConsumed = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4542 | cancelPendingPowerKeyAction(); |
| 4543 | interceptScreenshotChord(); |
| 4544 | } |
| 4545 | } else { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4546 | mScreenshotChordVolumeDownKeyTriggered = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4547 | cancelPendingScreenshotChordAction(); |
| 4548 | } |
| 4549 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { |
| 4550 | if (down) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4551 | if (interactive && !mScreenshotChordVolumeUpKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4552 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4553 | mScreenshotChordVolumeUpKeyTriggered = true; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4554 | cancelPendingPowerKeyAction(); |
| 4555 | cancelPendingScreenshotChordAction(); |
| 4556 | } |
| 4557 | } else { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4558 | mScreenshotChordVolumeUpKeyTriggered = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 4559 | cancelPendingScreenshotChordAction(); |
| 4560 | } |
| 4561 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4562 | if (down) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4563 | TelecomManager telecomManager = getTelecommService(); |
| 4564 | if (telecomManager != null) { |
| 4565 | if (telecomManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4566 | // If an incoming call is ringing, either VOLUME key means |
| 4567 | // "silence ringer". We handle these keys here, rather than |
| 4568 | // in the InCallScreen, to make sure we'll respond to them |
| 4569 | // even if the InCallScreen hasn't come to the foreground yet. |
| 4570 | // Look for the DOWN event here, to agree with the "fallback" |
| 4571 | // behavior in the InCallScreen. |
| 4572 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4573 | + " VOLUME key-down while ringing: Silence ringer!"); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4574 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4575 | // Silence the ringer. (It's safe to call this |
| 4576 | // even if the ringer has already been silenced.) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4577 | telecomManager.silenceRinger(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4578 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4579 | // And *don't* pass this key thru to the current activity |
| 4580 | // (which is probably the InCallScreen.) |
| 4581 | result &= ~ACTION_PASS_TO_USER; |
| 4582 | break; |
| 4583 | } |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4584 | if (telecomManager.isInCall() |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4585 | && (result & ACTION_PASS_TO_USER) == 0) { |
| 4586 | // 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] | 4587 | // the application, just pass it to the session service. |
| 4588 | |
| 4589 | MediaSessionLegacyHelper.getHelper(mContext) |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 4590 | .sendVolumeKeyEvent(event, false); |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4591 | break; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4592 | } |
| 4593 | } |
| 4594 | |
RoboErik | 430fc48 | 2014-06-12 15:49:20 -0700 | [diff] [blame] | 4595 | if ((result & ACTION_PASS_TO_USER) == 0) { |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 4596 | if (mUseTvRouting) { |
| 4597 | dispatchDirectAudioEvent(event); |
| 4598 | } else { |
| 4599 | // If we aren't passing to the user and no one else |
| 4600 | // handled it send it to the session manager to |
| 4601 | // figure out. |
| 4602 | MediaSessionLegacyHelper.getHelper(mContext) |
| 4603 | .sendVolumeKeyEvent(event, true); |
| 4604 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4605 | break; |
| 4606 | } |
| 4607 | } |
| 4608 | break; |
| 4609 | } |
| 4610 | |
| 4611 | case KeyEvent.KEYCODE_ENDCALL: { |
| 4612 | result &= ~ACTION_PASS_TO_USER; |
| 4613 | if (down) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4614 | TelecomManager telecomManager = getTelecommService(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4615 | boolean hungUp = false; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4616 | if (telecomManager != null) { |
| 4617 | hungUp = telecomManager.endCall(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4618 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4619 | if (interactive && !hungUp) { |
| 4620 | mEndCallKeyHandled = false; |
| 4621 | mHandler.postDelayed(mEndCallLongPress, |
| 4622 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
| 4623 | } else { |
| 4624 | mEndCallKeyHandled = true; |
| 4625 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4626 | } else { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4627 | if (!mEndCallKeyHandled) { |
| 4628 | mHandler.removeCallbacks(mEndCallLongPress); |
| 4629 | if (!canceled) { |
| 4630 | if ((mEndcallBehavior |
| 4631 | & Settings.System.END_BUTTON_BEHAVIOR_HOME) != 0) { |
| 4632 | if (goHome()) { |
| 4633 | break; |
| 4634 | } |
Dianne Hackborn | 0041e97 | 2009-07-24 17:14:43 -0700 | [diff] [blame] | 4635 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4636 | if ((mEndcallBehavior |
| 4637 | & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { |
| 4638 | mPowerManager.goToSleep(event.getEventTime(), |
| 4639 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); |
| 4640 | isWakeKey = false; |
| 4641 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4642 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4643 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4644 | } |
| 4645 | break; |
| 4646 | } |
| 4647 | |
| 4648 | case KeyEvent.KEYCODE_POWER: { |
| 4649 | result &= ~ACTION_PASS_TO_USER; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4650 | isWakeKey = false; // wake-up will be handled separately |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4651 | if (down) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4652 | interceptPowerKeyDown(event, interactive); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4653 | } else { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4654 | interceptPowerKeyUp(event, interactive, canceled); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4655 | } |
| 4656 | break; |
| 4657 | } |
| 4658 | |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4659 | case KeyEvent.KEYCODE_SLEEP: { |
| 4660 | result &= ~ACTION_PASS_TO_USER; |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 4661 | if (!mPowerManager.isInteractive()) { |
| 4662 | useHapticFeedback = false; // suppress feedback if already non-interactive |
| 4663 | } |
Jeff Brown | c12035c | 2014-08-13 18:52:25 -0700 | [diff] [blame] | 4664 | mPowerManager.goToSleep(event.getEventTime(), |
| 4665 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4666 | isWakeKey = false; |
| 4667 | break; |
| 4668 | } |
| 4669 | |
| 4670 | case KeyEvent.KEYCODE_WAKEUP: { |
| 4671 | result &= ~ACTION_PASS_TO_USER; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4672 | isWakeKey = true; |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 4673 | break; |
| 4674 | } |
| 4675 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4676 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4677 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4678 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4679 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4680 | case KeyEvent.KEYCODE_MUTE: |
| 4681 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4682 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4683 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4684 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4685 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4686 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
| 4687 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: { |
RoboErik | de9ba39 | 2014-09-26 12:51:01 -0700 | [diff] [blame] | 4688 | if (MediaSessionLegacyHelper.getHelper(mContext).isGlobalPriorityActive()) { |
| 4689 | // If the global session is active pass all media keys to it |
| 4690 | // instead of the active window. |
| 4691 | result &= ~ACTION_PASS_TO_USER; |
| 4692 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4693 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 4694 | // Only do this if we would otherwise not pass it to the user. In that |
| 4695 | // case, the PhoneWindow class will do the same thing, except it will |
| 4696 | // 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] | 4697 | // Note that we need to make a copy of the key event here because the |
| 4698 | // original key event will be recycled when we return. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4699 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4700 | Message msg = mHandler.obtainMessage(MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK, |
| 4701 | new KeyEvent(event)); |
| 4702 | msg.setAsynchronous(true); |
| 4703 | msg.sendToTarget(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4704 | } |
| 4705 | break; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4706 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4707 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4708 | case KeyEvent.KEYCODE_CALL: { |
| 4709 | if (down) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4710 | TelecomManager telecomManager = getTelecommService(); |
| 4711 | if (telecomManager != null) { |
| 4712 | if (telecomManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4713 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 4714 | + " CALL key-down while ringing: Answer the call!"); |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 4715 | telecomManager.acceptRingingCall(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4716 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 4717 | // And *don't* pass this key thru to the current activity |
| 4718 | // (which is presumably the InCallScreen.) |
| 4719 | result &= ~ACTION_PASS_TO_USER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4720 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4721 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 4722 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 4723 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4724 | } |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 4725 | case KeyEvent.KEYCODE_VOICE_ASSIST: { |
| 4726 | // Only do this if we would otherwise not pass it to the user. In that case, |
| 4727 | // interceptKeyBeforeDispatching would apply a similar but different policy in |
| 4728 | // order to invoke voice assist actions. Note that we need to make a copy of the |
| 4729 | // key event here because the original key event will be recycled when we return. |
| 4730 | if ((result & ACTION_PASS_TO_USER) == 0 && !down) { |
| 4731 | mBroadcastWakeLock.acquire(); |
| 4732 | Message msg = mHandler.obtainMessage(MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK, |
| 4733 | keyguardActive ? 1 : 0, 0); |
| 4734 | msg.setAsynchronous(true); |
| 4735 | msg.sendToTarget(); |
| 4736 | } |
| 4737 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4738 | } |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4739 | |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 4740 | if (useHapticFeedback) { |
| 4741 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
| 4742 | } |
| 4743 | |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4744 | if (isWakeKey) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4745 | wakeUp(event.getEventTime(), mAllowTheaterModeWakeFromKey); |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 4746 | } |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 4747 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4748 | return result; |
| 4749 | } |
| 4750 | |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4751 | /** |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 4752 | * Returns true if the key can have global actions attached to it. |
| 4753 | * We reserve all power management keys for the system since they require |
| 4754 | * very careful handling. |
| 4755 | */ |
| 4756 | private static boolean isValidGlobalKey(int keyCode) { |
| 4757 | switch (keyCode) { |
| 4758 | case KeyEvent.KEYCODE_POWER: |
| 4759 | case KeyEvent.KEYCODE_WAKEUP: |
| 4760 | case KeyEvent.KEYCODE_SLEEP: |
| 4761 | return false; |
| 4762 | default: |
| 4763 | return true; |
| 4764 | } |
| 4765 | } |
| 4766 | |
| 4767 | /** |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4768 | * When the screen is off we ignore some keys that might otherwise typically |
| 4769 | * be considered wake keys. We filter them out here. |
| 4770 | * |
| 4771 | * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it |
| 4772 | * is always considered a wake key. |
| 4773 | */ |
| 4774 | private boolean isWakeKeyWhenScreenOff(int keyCode) { |
| 4775 | switch (keyCode) { |
| 4776 | // ignore volume keys unless docked |
| 4777 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4778 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 4779 | case KeyEvent.KEYCODE_VOLUME_MUTE: |
| 4780 | return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 4781 | |
| 4782 | // ignore media and camera keys |
| 4783 | case KeyEvent.KEYCODE_MUTE: |
| 4784 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 4785 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 4786 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 4787 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 4788 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 4789 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 4790 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 4791 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 4792 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
| 4793 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 4794 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 4795 | case KeyEvent.KEYCODE_CAMERA: |
| 4796 | return false; |
| 4797 | } |
| 4798 | return true; |
| 4799 | } |
| 4800 | |
| 4801 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4802 | /** {@inheritDoc} */ |
| 4803 | @Override |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 4804 | public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags) { |
| 4805 | if ((policyFlags & FLAG_WAKE) != 0) { |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 4806 | if (wakeUp(whenNanos / 1000000, mAllowTheaterModeWakeFromMotion)) { |
| 4807 | return 0; |
| 4808 | } |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 4809 | } |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 4810 | |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 4811 | if (shouldDispatchInputWhenNonInteractive()) { |
| 4812 | return ACTION_PASS_TO_USER; |
| 4813 | } |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 4814 | |
Bryce Lee | 812d702 | 2014-11-10 13:33:28 -0800 | [diff] [blame] | 4815 | // If we have not passed the action up and we are in theater mode without dreaming, |
| 4816 | // there will be no dream to intercept the touch and wake into ambient. The device should |
| 4817 | // wake up in this case. |
| 4818 | if (isTheaterModeEnabled() && (policyFlags & FLAG_WAKE) != 0) { |
| 4819 | wakeUp(whenNanos / 1000000, mAllowTheaterModeWakeFromMotionWhenNotDreaming); |
| 4820 | } |
| 4821 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 4822 | return 0; |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 4823 | } |
| 4824 | |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 4825 | private boolean shouldDispatchInputWhenNonInteractive() { |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 4826 | // Send events to keyguard while the screen is on. |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4827 | if (isKeyguardShowingAndNotOccluded() && mDisplay != null |
| 4828 | && mDisplay.getState() != Display.STATE_OFF) { |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 4829 | return true; |
| 4830 | } |
| 4831 | |
| 4832 | // Send events to a dozing dream even if the screen is off since the dream |
| 4833 | // is in control of the state of the screen. |
| 4834 | IDreamManager dreamManager = getDreamManager(); |
| 4835 | |
| 4836 | try { |
| 4837 | if (dreamManager != null && dreamManager.isDreaming()) { |
| 4838 | return true; |
| 4839 | } |
| 4840 | } catch (RemoteException e) { |
| 4841 | Slog.e(TAG, "RemoteException when checking if dreaming", e); |
| 4842 | } |
| 4843 | |
| 4844 | // Otherwise, consume events since the user can't see what is being |
| 4845 | // interacted with. |
| 4846 | return false; |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 4847 | } |
| 4848 | |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 4849 | private void dispatchDirectAudioEvent(KeyEvent event) { |
| 4850 | if (event.getAction() != KeyEvent.ACTION_DOWN) { |
| 4851 | return; |
| 4852 | } |
| 4853 | int keyCode = event.getKeyCode(); |
| 4854 | int flags = AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND; |
| 4855 | String pkgName = mContext.getOpPackageName(); |
| 4856 | switch (keyCode) { |
| 4857 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 4858 | try { |
| 4859 | if (mUseMasterVolume) { |
| 4860 | getAudioService().adjustMasterVolume(AudioManager.ADJUST_RAISE, flags, |
| 4861 | pkgName); |
| 4862 | } else { |
| 4863 | getAudioService().adjustSuggestedStreamVolume(AudioManager.ADJUST_RAISE, |
| 4864 | AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName); |
| 4865 | } |
| 4866 | } catch (RemoteException e) { |
| 4867 | Log.e(TAG, "Error dispatching volume up in dispatchTvAudioEvent.", e); |
| 4868 | } |
| 4869 | break; |
| 4870 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 4871 | try { |
| 4872 | if (mUseMasterVolume) { |
| 4873 | getAudioService().adjustMasterVolume(AudioManager.ADJUST_LOWER, flags, |
| 4874 | pkgName); |
| 4875 | } else { |
| 4876 | getAudioService().adjustSuggestedStreamVolume(AudioManager.ADJUST_LOWER, |
| 4877 | AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName); |
| 4878 | } |
| 4879 | } catch (RemoteException e) { |
| 4880 | Log.e(TAG, "Error dispatching volume down in dispatchTvAudioEvent.", e); |
| 4881 | } |
| 4882 | break; |
| 4883 | case KeyEvent.KEYCODE_VOLUME_MUTE: |
| 4884 | try { |
| 4885 | if (event.getRepeatCount() == 0) { |
| 4886 | if (mUseMasterVolume) { |
| 4887 | getAudioService().adjustMasterVolume(AudioManager.ADJUST_TOGGLE_MUTE, |
| 4888 | flags, pkgName); |
| 4889 | } else { |
| 4890 | getAudioService().adjustSuggestedStreamVolume( |
| 4891 | AudioManager.ADJUST_TOGGLE_MUTE, |
| 4892 | AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName); |
| 4893 | } |
| 4894 | } |
| 4895 | } catch (RemoteException e) { |
| 4896 | Log.e(TAG, "Error dispatching mute in dispatchTvAudioEvent.", e); |
| 4897 | } |
| 4898 | break; |
| 4899 | } |
| 4900 | } |
| 4901 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4902 | void dispatchMediaKeyWithWakeLock(KeyEvent event) { |
| 4903 | if (DEBUG_INPUT) { |
| 4904 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: " + event); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4905 | } |
| 4906 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 4907 | if (mHavePendingMediaKeyRepeatWithWakeLock) { |
| 4908 | if (DEBUG_INPUT) { |
| 4909 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: canceled repeat"); |
| 4910 | } |
| 4911 | |
| 4912 | mHandler.removeMessages(MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK); |
| 4913 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4914 | mBroadcastWakeLock.release(); // pending repeat was holding onto the wake lock |
| 4915 | } |
| 4916 | |
| 4917 | dispatchMediaKeyWithWakeLockToAudioService(event); |
| 4918 | |
| 4919 | if (event.getAction() == KeyEvent.ACTION_DOWN |
| 4920 | && event.getRepeatCount() == 0) { |
| 4921 | mHavePendingMediaKeyRepeatWithWakeLock = true; |
| 4922 | |
| 4923 | Message msg = mHandler.obtainMessage( |
| 4924 | MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK, event); |
| 4925 | msg.setAsynchronous(true); |
| 4926 | mHandler.sendMessageDelayed(msg, ViewConfiguration.getKeyRepeatTimeout()); |
| 4927 | } else { |
| 4928 | mBroadcastWakeLock.release(); |
| 4929 | } |
| 4930 | } |
| 4931 | |
| 4932 | void dispatchMediaKeyRepeatWithWakeLock(KeyEvent event) { |
| 4933 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 4934 | |
| 4935 | KeyEvent repeatEvent = KeyEvent.changeTimeRepeat(event, |
| 4936 | SystemClock.uptimeMillis(), 1, event.getFlags() | KeyEvent.FLAG_LONG_PRESS); |
| 4937 | if (DEBUG_INPUT) { |
| 4938 | Slog.d(TAG, "dispatchMediaKeyRepeatWithWakeLock: " + repeatEvent); |
| 4939 | } |
| 4940 | |
| 4941 | dispatchMediaKeyWithWakeLockToAudioService(repeatEvent); |
| 4942 | mBroadcastWakeLock.release(); |
| 4943 | } |
| 4944 | |
| 4945 | void dispatchMediaKeyWithWakeLockToAudioService(KeyEvent event) { |
| 4946 | if (ActivityManagerNative.isSystemReady()) { |
RoboErik | 430fc48 | 2014-06-12 15:49:20 -0700 | [diff] [blame] | 4947 | MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(event, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4948 | } |
| 4949 | } |
| 4950 | |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 4951 | void launchVoiceAssistWithWakeLock(boolean keyguardActive) { |
| 4952 | Intent voiceIntent = |
| 4953 | new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE); |
| 4954 | voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, keyguardActive); |
| 4955 | mContext.startActivityAsUser(voiceIntent, UserHandle.CURRENT_OR_SELF); |
| 4956 | mBroadcastWakeLock.release(); |
| 4957 | } |
| 4958 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4959 | BroadcastReceiver mDockReceiver = new BroadcastReceiver() { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4960 | @Override |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4961 | public void onReceive(Context context, Intent intent) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 4962 | if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { |
| 4963 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 4964 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 4965 | } else { |
| 4966 | try { |
| 4967 | IUiModeManager uiModeService = IUiModeManager.Stub.asInterface( |
| 4968 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 4969 | mUiMode = uiModeService.getCurrentModeType(); |
| 4970 | } catch (RemoteException e) { |
| 4971 | } |
Dianne Hackborn | 80fa166 | 2009-10-07 14:02:10 -0700 | [diff] [blame] | 4972 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 4973 | updateRotation(true); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 4974 | synchronized (mLock) { |
| 4975 | updateOrientationListenerLp(); |
| 4976 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 4977 | } |
| 4978 | }; |
| 4979 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4980 | BroadcastReceiver mDreamReceiver = new BroadcastReceiver() { |
| 4981 | @Override |
| 4982 | public void onReceive(Context context, Intent intent) { |
| 4983 | if (Intent.ACTION_DREAMING_STARTED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4984 | if (mKeyguardDelegate != null) { |
| 4985 | mKeyguardDelegate.onDreamingStarted(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4986 | } |
| 4987 | } else if (Intent.ACTION_DREAMING_STOPPED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 4988 | if (mKeyguardDelegate != null) { |
| 4989 | mKeyguardDelegate.onDreamingStopped(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 4990 | } |
| 4991 | } |
| 4992 | } |
| 4993 | }; |
| 4994 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 4995 | BroadcastReceiver mMultiuserReceiver = new BroadcastReceiver() { |
| 4996 | @Override |
| 4997 | public void onReceive(Context context, Intent intent) { |
| 4998 | if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { |
| 4999 | // tickle the settings observer: this first ensures that we're |
| 5000 | // observing the relevant settings for the newly-active user, |
| 5001 | // and then updates our own bookkeeping based on the now- |
| 5002 | // current user. |
| 5003 | mSettingsObserver.onChange(false); |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 5004 | |
| 5005 | // force a re-application of focused window sysui visibility. |
| 5006 | // the window may never have been shown for this user |
| 5007 | // e.g. the keyguard when going through the new-user setup flow |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 5008 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 5009 | mLastSystemUiFlags = 0; |
| 5010 | updateSystemUiVisibilityLw(); |
| 5011 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5012 | } |
| 5013 | } |
| 5014 | }; |
| 5015 | |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 5016 | private final Runnable mRequestTransientNav = new Runnable() { |
| 5017 | @Override |
| 5018 | public void run() { |
| 5019 | requestTransientBars(mNavigationBar); |
| 5020 | } |
| 5021 | }; |
| 5022 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 5023 | private void requestTransientBars(WindowState swipeTarget) { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 5024 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 5025 | if (!isUserSetupComplete()) { |
| 5026 | // Swipe-up for navigation bar is disabled during setup |
| 5027 | return; |
| 5028 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5029 | boolean sb = mStatusBarController.checkShowTransientBarLw(); |
| 5030 | boolean nb = mNavigationBarController.checkShowTransientBarLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5031 | if (sb || nb) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 5032 | WindowState barTarget = sb ? mStatusBar : mNavigationBar; |
| 5033 | if (sb ^ nb && barTarget != swipeTarget) { |
| 5034 | if (DEBUG) Slog.d(TAG, "Not showing transient bar, wrong swipe target"); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5035 | return; |
| 5036 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5037 | if (sb) mStatusBarController.showTransient(); |
| 5038 | if (nb) mNavigationBarController.showTransient(); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5039 | mImmersiveModeConfirmation.confirmCurrentPrompt(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5040 | updateSystemUiVisibilityLw(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 5041 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5042 | } |
| 5043 | } |
| 5044 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5045 | // Called on the PowerManager's Notifier thread. |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5046 | @Override |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 5047 | public void goingToSleep(int why) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 5048 | EventLog.writeEvent(70000, 0); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5049 | if (DEBUG_WAKEUP) Slog.i(TAG, "Going to sleep..."); |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5050 | |
| 5051 | // We must get this work done here because the power manager will drop |
| 5052 | // the wake lock and let the system suspend once this function returns. |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5053 | synchronized (mLock) { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5054 | mAwake = false; |
| 5055 | mKeyguardDrawComplete = false; |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5056 | updateWakeGestureListenerLp(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5057 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5058 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5059 | } |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5060 | |
| 5061 | if (mKeyguardDelegate != null) { |
| 5062 | mKeyguardDelegate.onScreenTurnedOff(why); |
| 5063 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5064 | } |
| 5065 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5066 | private void wakeUpFromPowerKey(long eventTime) { |
| 5067 | wakeUp(eventTime, mAllowTheaterModeWakeFromPowerKey); |
| 5068 | } |
| 5069 | |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 5070 | private boolean wakeUp(long wakeTime, boolean wakeInTheaterMode) { |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 5071 | if (!wakeInTheaterMode && isTheaterModeEnabled()) { |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 5072 | return false; |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 5073 | } |
| 5074 | |
| 5075 | mPowerManager.wakeUp(wakeTime); |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 5076 | return true; |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 5077 | } |
| 5078 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5079 | // Called on the PowerManager's Notifier thread. |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5080 | @Override |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5081 | public void wakingUp() { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 5082 | EventLog.writeEvent(70000, 1); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5083 | if (DEBUG_WAKEUP) Slog.i(TAG, "Waking up..."); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 5084 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5085 | // Since goToSleep performs these functions synchronously, we must |
| 5086 | // do the same here. We cannot post this work to a handler because |
| 5087 | // that might cause it to become reordered with respect to what |
| 5088 | // may happen in a future call to goToSleep. |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5089 | synchronized (mLock) { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5090 | mAwake = true; |
| 5091 | mKeyguardDrawComplete = false; |
| 5092 | if (mKeyguardDelegate != null) { |
| 5093 | mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT); |
| 5094 | mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT, 1000); |
| 5095 | } |
| 5096 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5097 | updateWakeGestureListenerLp(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5098 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5099 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5100 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5101 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5102 | if (mKeyguardDelegate != null) { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 5103 | mKeyguardDelegate.onScreenTurnedOn(mKeyguardDelegateCallback); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5104 | // ... eventually calls finishKeyguardDrawn |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5105 | } else { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 5106 | if (DEBUG_WAKEUP) Slog.d(TAG, "null mKeyguardDelegate: setting mKeyguardDrawComplete."); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5107 | finishKeyguardDrawn(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5108 | } |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5109 | } |
| 5110 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5111 | private void finishKeyguardDrawn() { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5112 | synchronized (mLock) { |
| 5113 | if (!mAwake || mKeyguardDrawComplete) { |
| 5114 | return; // spurious |
| 5115 | } |
| 5116 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5117 | mKeyguardDrawComplete = true; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5118 | if (mKeyguardDelegate != null) { |
| 5119 | mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT); |
| 5120 | } |
| 5121 | } |
| 5122 | |
| 5123 | finishScreenTurningOn(); |
| 5124 | } |
| 5125 | |
| 5126 | // Called on the DisplayManager's DisplayPowerController thread. |
| 5127 | @Override |
| 5128 | public void screenTurnedOff() { |
| 5129 | if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turned off..."); |
| 5130 | |
| 5131 | synchronized (mLock) { |
| 5132 | mScreenOnEarly = false; |
| 5133 | mScreenOnFully = false; |
| 5134 | mWindowManagerDrawComplete = false; |
| 5135 | mScreenOnListener = null; |
| 5136 | updateOrientationListenerLp(); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5137 | } |
| 5138 | } |
| 5139 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5140 | // Called on the DisplayManager's DisplayPowerController thread. |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5141 | @Override |
| 5142 | public void screenTurningOn(final ScreenOnListener screenOnListener) { |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5143 | if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on..."); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5144 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5145 | synchronized (mLock) { |
| 5146 | mScreenOnEarly = true; |
| 5147 | mScreenOnFully = false; |
| 5148 | mWindowManagerDrawComplete = false; |
| 5149 | mScreenOnListener = screenOnListener; |
| 5150 | updateOrientationListenerLp(); |
| 5151 | } |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5152 | |
Craig Mautner | c3daedd | 2014-09-13 11:17:23 -0700 | [diff] [blame] | 5153 | mWindowManagerInternal.waitForAllWindowsDrawn(mWindowManagerDrawCallback, |
| 5154 | WAITING_FOR_DRAWN_TIMEOUT); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5155 | // ... eventually calls finishWindowsDrawn |
| 5156 | } |
| 5157 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5158 | private void finishWindowsDrawn() { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5159 | synchronized (mLock) { |
| 5160 | if (!mScreenOnEarly || mWindowManagerDrawComplete) { |
| 5161 | return; // spurious |
| 5162 | } |
| 5163 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5164 | mWindowManagerDrawComplete = true; |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5165 | } |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5166 | |
| 5167 | finishScreenTurningOn(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5168 | } |
| 5169 | |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 5170 | private void finishScreenTurningOn() { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5171 | final ScreenOnListener listener; |
| 5172 | final boolean enableScreen; |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5173 | synchronized (mLock) { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5174 | if (DEBUG_WAKEUP) Slog.d(TAG, |
| 5175 | "finishScreenTurningOn: mAwake=" + mAwake |
| 5176 | + ", mScreenOnEarly=" + mScreenOnEarly |
| 5177 | + ", mScreenOnFully=" + mScreenOnFully |
| 5178 | + ", mKeyguardDrawComplete=" + mKeyguardDrawComplete |
| 5179 | + ", mWindowManagerDrawComplete=" + mWindowManagerDrawComplete); |
| 5180 | |
| 5181 | if (mScreenOnFully || !mScreenOnEarly || !mWindowManagerDrawComplete |
| 5182 | || (mAwake && !mKeyguardDrawComplete)) { |
| 5183 | return; // spurious or not ready yet |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5184 | } |
| 5185 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5186 | if (DEBUG_WAKEUP) Slog.i(TAG, "Finished screen turning on..."); |
| 5187 | listener = mScreenOnListener; |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 5188 | mScreenOnListener = null; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5189 | mScreenOnFully = true; |
| 5190 | |
| 5191 | // Remember the first time we draw the keyguard so we know when we're done with |
| 5192 | // the main part of booting and can enable the screen and hide boot messages. |
| 5193 | if (!mKeyguardDrawnOnce && mAwake) { |
| 5194 | mKeyguardDrawnOnce = true; |
| 5195 | enableScreen = true; |
| 5196 | if (mBootMessageNeedsHiding) { |
| 5197 | mBootMessageNeedsHiding = false; |
| 5198 | hideBootMessages(); |
| 5199 | } |
| 5200 | } else { |
| 5201 | enableScreen = false; |
| 5202 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5203 | } |
| 5204 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5205 | if (listener != null) { |
| 5206 | listener.onScreenOn(); |
| 5207 | } |
Jeff Brown | 4fc4527 | 2012-10-10 18:28:14 -0700 | [diff] [blame] | 5208 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5209 | if (enableScreen) { |
| 5210 | try { |
| 5211 | mWindowManager.enableScreenIfNeeded(); |
| 5212 | } catch (RemoteException unhandled) { |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5213 | } |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 5214 | } |
| 5215 | } |
| 5216 | |
| 5217 | private void handleHideBootMessage() { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5218 | synchronized (mLock) { |
| 5219 | if (!mKeyguardDrawnOnce) { |
| 5220 | mBootMessageNeedsHiding = true; |
| 5221 | return; // keyguard hasn't drawn the first time yet, not done booting |
| 5222 | } |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 5223 | } |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5224 | |
| 5225 | if (mBootMsgDialog != null) { |
| 5226 | if (DEBUG_WAKEUP) Slog.d(TAG, "handleHideBootMessage: dismissing"); |
| 5227 | mBootMsgDialog.dismiss(); |
| 5228 | mBootMsgDialog = null; |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 5229 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5230 | } |
| 5231 | |
| 5232 | @Override |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5233 | public boolean isScreenOn() { |
| 5234 | return mScreenOnFully; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 5235 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5236 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 5237 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5238 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5239 | public void enableKeyguard(boolean enabled) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5240 | if (mKeyguardDelegate != null) { |
| 5241 | mKeyguardDelegate.setKeyguardEnabled(enabled); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 5242 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5243 | } |
| 5244 | |
| 5245 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5246 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5247 | public void exitKeyguardSecurely(OnKeyguardExitResult callback) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5248 | if (mKeyguardDelegate != null) { |
| 5249 | mKeyguardDelegate.verifyUnlock(callback); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 5250 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5251 | } |
| 5252 | |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 5253 | private boolean isKeyguardShowingAndNotOccluded() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5254 | if (mKeyguardDelegate == null) return false; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 5255 | return mKeyguardDelegate.isShowing() && !mKeyguardOccluded; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5256 | } |
| 5257 | |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 5258 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5259 | @Override |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 5260 | public boolean isKeyguardLocked() { |
| 5261 | return keyguardOn(); |
| 5262 | } |
| 5263 | |
| 5264 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5265 | @Override |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 5266 | public boolean isKeyguardSecure() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5267 | if (mKeyguardDelegate == null) return false; |
| 5268 | return mKeyguardDelegate.isSecure(); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 5269 | } |
| 5270 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5271 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5272 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5273 | public boolean inKeyguardRestrictedKeyInputMode() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5274 | if (mKeyguardDelegate == null) return false; |
| 5275 | return mKeyguardDelegate.isInputRestricted(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5276 | } |
| 5277 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5278 | @Override |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 5279 | public void dismissKeyguardLw() { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 5280 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) { |
Craig Mautner | c0d2d0a | 2014-10-31 16:25:15 -0700 | [diff] [blame] | 5281 | if (DEBUG_KEYGUARD) Slog.d(TAG, "PWM.dismissKeyguardLw"); |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 5282 | mHandler.post(new Runnable() { |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5283 | @Override |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 5284 | public void run() { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 5285 | // ask the keyguard to prompt the user to authenticate if necessary |
| 5286 | mKeyguardDelegate.dismiss(); |
| 5287 | } |
| 5288 | }); |
| 5289 | } |
| 5290 | } |
| 5291 | |
| 5292 | public void notifyActivityDrawnForKeyguardLw() { |
| 5293 | if (mKeyguardDelegate != null) { |
| 5294 | mHandler.post(new Runnable() { |
| 5295 | @Override |
| 5296 | public void run() { |
| 5297 | mKeyguardDelegate.onActivityDrawn(); |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 5298 | } |
| 5299 | }); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 5300 | } |
| 5301 | } |
| 5302 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 5303 | @Override |
| 5304 | public boolean isKeyguardDrawnLw() { |
| 5305 | synchronized (mLock) { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5306 | return mKeyguardDrawnOnce; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 5307 | } |
| 5308 | } |
| 5309 | |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 5310 | @Override |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 5311 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 5312 | if (mKeyguardDelegate != null) { |
Craig Mautner | c0d2d0a | 2014-10-31 16:25:15 -0700 | [diff] [blame] | 5313 | if (DEBUG_KEYGUARD) Slog.d(TAG, "PWM.startKeyguardExitAnimation"); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 5314 | mKeyguardDelegate.startKeyguardExitAnimation(startTime, fadeoutDuration); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 5315 | } |
| 5316 | } |
| 5317 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5318 | void sendCloseSystemWindows() { |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 5319 | PhoneWindow.sendCloseSystemWindows(mContext, null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5320 | } |
| 5321 | |
| 5322 | void sendCloseSystemWindows(String reason) { |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 5323 | PhoneWindow.sendCloseSystemWindows(mContext, reason); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5324 | } |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 5325 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5326 | @Override |
| 5327 | public int rotationForOrientationLw(int orientation, int lastRotation) { |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 5328 | if (false) { |
| 5329 | Slog.v(TAG, "rotationForOrientationLw(orient=" |
| 5330 | + orientation + ", last=" + lastRotation |
| 5331 | + "); user=" + mUserRotation + " " |
| 5332 | + ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) |
| 5333 | ? "USER_ROTATION_LOCKED" : "") |
| 5334 | ); |
| 5335 | } |
| 5336 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 5337 | if (mForceDefaultOrientation) { |
| 5338 | return Surface.ROTATION_0; |
| 5339 | } |
| 5340 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5341 | synchronized (mLock) { |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 5342 | int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 |
| 5343 | if (sensorRotation < 0) { |
Jeff Brown | 0f862b4 | 2012-09-27 21:11:01 -0700 | [diff] [blame] | 5344 | sensorRotation = lastRotation; |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 5345 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5346 | |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 5347 | final int preferredRotation; |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 5348 | if (mLidState == LID_OPEN && mLidOpenRotation >= 0) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5349 | // Ignore sensor when lid switch is open and rotation is forced. |
| 5350 | preferredRotation = mLidOpenRotation; |
| 5351 | } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 5352 | && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5353 | // Ignore sensor when in car dock unless explicitly enabled. |
| 5354 | // This case can override the behavior of NOSENSOR, and can also |
| 5355 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 5356 | preferredRotation = mCarDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5357 | ? sensorRotation : mCarDockRotation; |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 5358 | } else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 5359 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 5360 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 5361 | && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5362 | // Ignore sensor when in desk dock unless explicitly enabled. |
| 5363 | // This case can override the behavior of NOSENSOR, and can also |
| 5364 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 5365 | preferredRotation = mDeskDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5366 | ? sensorRotation : mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 5367 | } else if (mHdmiPlugged && mDemoHdmiRotationLock) { |
| 5368 | // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled. |
Jeff Brown | eb3e4b9 | 2011-12-06 19:54:24 -0800 | [diff] [blame] | 5369 | // Note that the dock orientation overrides the HDMI orientation. |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 5370 | preferredRotation = mDemoHdmiRotation; |
| 5371 | } else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED |
| 5372 | && mUndockedHdmiRotation >= 0) { |
| 5373 | // Ignore sensor when plugged into HDMI and an undocked orientation has |
| 5374 | // been specified in the configuration (only for legacy devices without |
| 5375 | // full multi-display support). |
| 5376 | // Note that the dock orientation overrides the HDMI orientation. |
| 5377 | preferredRotation = mUndockedHdmiRotation; |
Chong Zhang | ae6119ff | 2014-11-11 18:54:39 -0800 | [diff] [blame] | 5378 | } else if (mDemoRotationLock) { |
| 5379 | // Ignore sensor when demo rotation lock is enabled. |
| 5380 | // Note that the dock orientation and HDMI rotation lock override this. |
| 5381 | preferredRotation = mDemoRotation; |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 5382 | } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { |
| 5383 | // Application just wants to remain locked in the last rotation. |
| 5384 | preferredRotation = lastRotation; |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 5385 | } else if (!mSupportAutoRotation) { |
| 5386 | // If we don't support auto-rotation then bail out here and ignore |
| 5387 | // the sensor and any rotation lock settings. |
| 5388 | preferredRotation = -1; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 5389 | } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5390 | && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 5391 | || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED |
| 5392 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE |
| 5393 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT |
| 5394 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER)) |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5395 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 5396 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 5397 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 5398 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { |
| 5399 | // Otherwise, use sensor only if requested by the application or enabled |
| 5400 | // by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR. |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 5401 | if (mAllowAllRotations < 0) { |
| 5402 | // Can't read this during init() because the context doesn't |
| 5403 | // have display metrics at that time so we cannot determine |
| 5404 | // tablet vs. phone then. |
| 5405 | mAllowAllRotations = mContext.getResources().getBoolean( |
| 5406 | com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; |
| 5407 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5408 | if (sensorRotation != Surface.ROTATION_180 |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 5409 | || mAllowAllRotations == 1 |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 5410 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 5411 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5412 | preferredRotation = sensorRotation; |
| 5413 | } else { |
| 5414 | preferredRotation = lastRotation; |
| 5415 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 5416 | } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED |
| 5417 | && orientation != ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { |
| 5418 | // Apply rotation lock. Does not apply to NOSENSOR. |
| 5419 | // The idea is that the user rotation expresses a weak preference for the direction |
| 5420 | // of gravity and as NOSENSOR is never affected by gravity, then neither should |
| 5421 | // 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] | 5422 | preferredRotation = mUserRotation; |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 5423 | } else { |
| 5424 | // No overriding preference. |
| 5425 | // We will do exactly what the application asked us to do. |
| 5426 | preferredRotation = -1; |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5427 | } |
| 5428 | |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 5429 | switch (orientation) { |
| 5430 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 5431 | // Return portrait unless overridden. |
| 5432 | if (isAnyPortrait(preferredRotation)) { |
| 5433 | return preferredRotation; |
| 5434 | } |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 5435 | return mPortraitRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 5436 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5437 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 5438 | // Return landscape unless overridden. |
| 5439 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 5440 | return preferredRotation; |
| 5441 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5442 | return mLandscapeRotation; |
| 5443 | |
| 5444 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 5445 | // Return reverse portrait unless overridden. |
| 5446 | if (isAnyPortrait(preferredRotation)) { |
| 5447 | return preferredRotation; |
| 5448 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5449 | return mUpsideDownRotation; |
| 5450 | |
| 5451 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 5452 | // Return seascape unless overridden. |
| 5453 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 5454 | return preferredRotation; |
| 5455 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5456 | return mSeascapeRotation; |
| 5457 | |
| 5458 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 5459 | case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5460 | // Return either landscape rotation. |
| 5461 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 5462 | return preferredRotation; |
| 5463 | } |
| 5464 | if (isLandscapeOrSeascape(lastRotation)) { |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 5465 | return lastRotation; |
| 5466 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5467 | return mLandscapeRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5468 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5469 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 5470 | case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5471 | // Return either portrait rotation. |
| 5472 | if (isAnyPortrait(preferredRotation)) { |
| 5473 | return preferredRotation; |
| 5474 | } |
| 5475 | if (isAnyPortrait(lastRotation)) { |
| 5476 | return lastRotation; |
| 5477 | } |
| 5478 | return mPortraitRotation; |
| 5479 | |
| 5480 | default: |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 5481 | // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, |
| 5482 | // just return the preferred orientation we already calculated. |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5483 | if (preferredRotation >= 0) { |
| 5484 | return preferredRotation; |
| 5485 | } |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 5486 | return Surface.ROTATION_0; |
Daniel Sandler | e7e5ac2 | 2011-02-22 16:10:21 -0500 | [diff] [blame] | 5487 | } |
| 5488 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 5489 | } |
| 5490 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5491 | @Override |
| 5492 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation) { |
| 5493 | switch (orientation) { |
| 5494 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
| 5495 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
| 5496 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
| 5497 | return isAnyPortrait(rotation); |
| 5498 | |
| 5499 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
| 5500 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
| 5501 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
| 5502 | return isLandscapeOrSeascape(rotation); |
| 5503 | |
| 5504 | default: |
| 5505 | return true; |
| 5506 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 5507 | } |
| 5508 | |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 5509 | @Override |
| 5510 | public void setRotationLw(int rotation) { |
| 5511 | mOrientationListener.setCurrentRotation(rotation); |
| 5512 | } |
| 5513 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5514 | private boolean isLandscapeOrSeascape(int rotation) { |
| 5515 | return rotation == mLandscapeRotation || rotation == mSeascapeRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 5516 | } |
| 5517 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5518 | private boolean isAnyPortrait(int rotation) { |
| 5519 | return rotation == mPortraitRotation || rotation == mUpsideDownRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 5520 | } |
| 5521 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5522 | @Override |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 5523 | public int getUserRotationMode() { |
| 5524 | return Settings.System.getIntForUser(mContext.getContentResolver(), |
Brett Chabot | 7e55c40 | 2013-05-16 19:38:08 -0700 | [diff] [blame] | 5525 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
| 5526 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 5527 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 5528 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5529 | |
| 5530 | // 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] | 5531 | @Override |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5532 | public void setUserRotationMode(int mode, int rot) { |
| 5533 | ContentResolver res = mContext.getContentResolver(); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 5534 | |
| 5535 | // mUserRotationMode and mUserRotation will be assigned by the content observer |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5536 | if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5537 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5538 | Settings.System.USER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5539 | rot, |
| 5540 | UserHandle.USER_CURRENT); |
| 5541 | Settings.System.putIntForUser(res, |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 5542 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5543 | 0, |
| 5544 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5545 | } else { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5546 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5547 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5548 | 1, |
| 5549 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 5550 | } |
| 5551 | } |
| 5552 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5553 | @Override |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 5554 | public void setSafeMode(boolean safeMode) { |
| 5555 | mSafeMode = safeMode; |
| 5556 | performHapticFeedbackLw(null, safeMode |
| 5557 | ? HapticFeedbackConstants.SAFE_MODE_ENABLED |
| 5558 | : HapticFeedbackConstants.SAFE_MODE_DISABLED, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5559 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5560 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 5561 | static long[] getLongIntArray(Resources r, int resid) { |
| 5562 | int[] ar = r.getIntArray(resid); |
| 5563 | if (ar == null) { |
| 5564 | return null; |
| 5565 | } |
| 5566 | long[] out = new long[ar.length]; |
| 5567 | for (int i=0; i<ar.length; i++) { |
| 5568 | out[i] = ar[i]; |
| 5569 | } |
| 5570 | return out; |
| 5571 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5572 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5573 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5574 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5575 | public void systemReady() { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 5576 | mKeyguardDelegate = new KeyguardServiceDelegate(mContext); |
Mike Lockwood | ed8902d | 2013-11-15 11:01:47 -0800 | [diff] [blame] | 5577 | mKeyguardDelegate.onSystemReady(); |
| 5578 | |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 5579 | readCameraLensCoverState(); |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 5580 | updateUiMode(); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5581 | synchronized (mLock) { |
| 5582 | updateOrientationListenerLp(); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 5583 | mSystemReady = true; |
| 5584 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5585 | @Override |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 5586 | public void run() { |
| 5587 | updateSettings(); |
| 5588 | } |
| 5589 | }); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5590 | } |
| 5591 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5592 | |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5593 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5594 | @Override |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5595 | public void systemBooted() { |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 5596 | if (mKeyguardDelegate != null) { |
Jason Monk | 5eeebf5 | 2014-09-26 12:36:51 -0400 | [diff] [blame] | 5597 | mKeyguardDelegate.bindService(mContext); |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 5598 | mKeyguardDelegate.onBootCompleted(); |
| 5599 | } |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5600 | synchronized (mLock) { |
| 5601 | mSystemBooted = true; |
| 5602 | } |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5603 | wakingUp(); |
| 5604 | screenTurningOn(null); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 5605 | } |
| 5606 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5607 | ProgressDialog mBootMsgDialog = null; |
| 5608 | |
| 5609 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5610 | @Override |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5611 | public void showBootMessage(final CharSequence msg, final boolean always) { |
| 5612 | mHandler.post(new Runnable() { |
| 5613 | @Override public void run() { |
| 5614 | if (mBootMsgDialog == null) { |
Craig Stout | 4c0cb8a | 2014-04-04 13:03:10 -0700 | [diff] [blame] | 5615 | int theme; |
| 5616 | if (mContext.getPackageManager().hasSystemFeature( |
| 5617 | PackageManager.FEATURE_WATCH)) { |
| 5618 | theme = com.android.internal.R.style.Theme_Micro_Dialog_Alert; |
| 5619 | } else if (mContext.getPackageManager().hasSystemFeature( |
| 5620 | PackageManager.FEATURE_TELEVISION)) { |
| 5621 | theme = com.android.internal.R.style.Theme_Leanback_Dialog_Alert; |
| 5622 | } else { |
| 5623 | theme = 0; |
| 5624 | } |
Vinod Krishnan | fa8fc41 | 2014-04-18 14:35:53 -0700 | [diff] [blame] | 5625 | |
| 5626 | mBootMsgDialog = new ProgressDialog(mContext, theme) { |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 5627 | // This dialog will consume all events coming in to |
| 5628 | // it, to avoid it trying to do things too early in boot. |
| 5629 | @Override public boolean dispatchKeyEvent(KeyEvent event) { |
| 5630 | return true; |
| 5631 | } |
| 5632 | @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 5633 | return true; |
| 5634 | } |
| 5635 | @Override public boolean dispatchTouchEvent(MotionEvent ev) { |
| 5636 | return true; |
| 5637 | } |
| 5638 | @Override public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 5639 | return true; |
| 5640 | } |
| 5641 | @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 5642 | return true; |
| 5643 | } |
| 5644 | @Override public boolean dispatchPopulateAccessibilityEvent( |
| 5645 | AccessibilityEvent event) { |
| 5646 | return true; |
| 5647 | } |
| 5648 | }; |
Jeff Hao | 9f60c08 | 2014-10-28 18:51:07 -0700 | [diff] [blame] | 5649 | if (mContext.getPackageManager().isUpgrade()) { |
| 5650 | mBootMsgDialog.setTitle(R.string.android_upgrading_title); |
| 5651 | } else { |
| 5652 | mBootMsgDialog.setTitle(R.string.android_start_title); |
| 5653 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5654 | mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); |
| 5655 | mBootMsgDialog.setIndeterminate(true); |
| 5656 | mBootMsgDialog.getWindow().setType( |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 5657 | WindowManager.LayoutParams.TYPE_BOOT_PROGRESS); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5658 | mBootMsgDialog.getWindow().addFlags( |
| 5659 | WindowManager.LayoutParams.FLAG_DIM_BEHIND |
| 5660 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); |
| 5661 | mBootMsgDialog.getWindow().setDimAmount(1); |
Dianne Hackborn | d9efb95 | 2011-12-07 14:56:51 -0800 | [diff] [blame] | 5662 | WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes(); |
| 5663 | lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 5664 | mBootMsgDialog.getWindow().setAttributes(lp); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5665 | mBootMsgDialog.setCancelable(false); |
| 5666 | mBootMsgDialog.show(); |
| 5667 | } |
| 5668 | mBootMsgDialog.setMessage(msg); |
| 5669 | } |
| 5670 | }); |
| 5671 | } |
| 5672 | |
| 5673 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5674 | @Override |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5675 | public void hideBootMessages() { |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 5676 | mHandler.sendEmptyMessage(MSG_HIDE_BOOT_MESSAGE); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 5677 | } |
| 5678 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5679 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5680 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5681 | public void userActivity() { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 5682 | // *************************************** |
| 5683 | // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE |
| 5684 | // *************************************** |
| 5685 | // THIS IS CALLED FROM DEEP IN THE POWER MANAGER |
| 5686 | // WITH ITS LOCKS HELD. |
| 5687 | // |
| 5688 | // This code must be VERY careful about the locks |
| 5689 | // it acquires. |
| 5690 | // In fact, the current code acquires way too many, |
| 5691 | // and probably has lurking deadlocks. |
| 5692 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5693 | synchronized (mScreenLockTimeout) { |
| 5694 | if (mLockScreenTimerActive) { |
| 5695 | // reset the timer |
| 5696 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 5697 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 5698 | } |
| 5699 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 5700 | } |
| 5701 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5702 | class ScreenLockTimeout implements Runnable { |
| 5703 | Bundle options; |
| 5704 | |
| 5705 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5706 | public void run() { |
| 5707 | synchronized (this) { |
| 5708 | if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5709 | if (mKeyguardDelegate != null) { |
| 5710 | mKeyguardDelegate.doKeyguardTimeout(options); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 5711 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5712 | mLockScreenTimerActive = false; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5713 | options = null; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5714 | } |
| 5715 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5716 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5717 | public void setLockOptions(Bundle options) { |
| 5718 | this.options = options; |
| 5719 | } |
| 5720 | } |
| 5721 | |
| 5722 | ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout(); |
| 5723 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5724 | @Override |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5725 | public void lockNow(Bundle options) { |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 5726 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); |
| 5727 | mHandler.removeCallbacks(mScreenLockTimeout); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 5728 | if (options != null) { |
| 5729 | // In case multiple calls are made to lockNow, we don't wipe out the options |
| 5730 | // until the runnable actually executes. |
| 5731 | mScreenLockTimeout.setLockOptions(options); |
| 5732 | } |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 5733 | mHandler.post(mScreenLockTimeout); |
| 5734 | } |
| 5735 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5736 | private void updateLockScreenTimeout() { |
| 5737 | synchronized (mScreenLockTimeout) { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5738 | boolean enable = (mAllowLockscreenWhenOn && mAwake && |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5739 | mKeyguardDelegate != null && mKeyguardDelegate.isSecure()); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5740 | if (mLockScreenTimerActive != enable) { |
| 5741 | if (enable) { |
| 5742 | if (localLOGV) Log.v(TAG, "setting lockscreen timer"); |
| 5743 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 5744 | } else { |
| 5745 | if (localLOGV) Log.v(TAG, "clearing lockscreen timer"); |
| 5746 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 5747 | } |
| 5748 | mLockScreenTimerActive = enable; |
| 5749 | } |
| 5750 | } |
| 5751 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5752 | |
| 5753 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5754 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5755 | public void enableScreenAfterBoot() { |
| 5756 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5757 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5758 | updateRotation(true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5759 | } |
Dianne Hackborn | f54c8f9 | 2009-09-19 14:03:57 -0700 | [diff] [blame] | 5760 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5761 | private void applyLidSwitchState() { |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5762 | if (mLidState == LID_CLOSED && mLidControlsSleep) { |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 5763 | mPowerManager.goToSleep(SystemClock.uptimeMillis(), |
Jeff Brown | c12035c | 2014-08-13 18:52:25 -0700 | [diff] [blame] | 5764 | PowerManager.GO_TO_SLEEP_REASON_LID_SWITCH, |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 5765 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5766 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5767 | |
| 5768 | synchronized (mLock) { |
| 5769 | updateWakeGestureListenerLp(); |
| 5770 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5771 | } |
| 5772 | |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 5773 | void updateUiMode() { |
| 5774 | if (mUiModeManager == null) { |
| 5775 | mUiModeManager = IUiModeManager.Stub.asInterface( |
| 5776 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 5777 | } |
| 5778 | try { |
| 5779 | mUiMode = mUiModeManager.getCurrentModeType(); |
| 5780 | } catch (RemoteException e) { |
| 5781 | } |
| 5782 | } |
| 5783 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5784 | void updateRotation(boolean alwaysSendConfiguration) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5785 | try { |
| 5786 | //set orientation on WindowManager |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 5787 | mWindowManager.updateRotation(alwaysSendConfiguration, false); |
| 5788 | } catch (RemoteException e) { |
| 5789 | // Ignore |
| 5790 | } |
| 5791 | } |
| 5792 | |
| 5793 | void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout) { |
| 5794 | try { |
| 5795 | //set orientation on WindowManager |
| 5796 | mWindowManager.updateRotation(alwaysSendConfiguration, forceRelayout); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5797 | } catch (RemoteException e) { |
| 5798 | // Ignore |
| 5799 | } |
| 5800 | } |
| 5801 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5802 | /** |
| 5803 | * Return an Intent to launch the currently active dock app as home. Returns |
| 5804 | * null if the standard home should be launched, which is the case if any of the following is |
| 5805 | * true: |
| 5806 | * <ul> |
| 5807 | * <li>The device is not in either car mode or desk mode |
| 5808 | * <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false |
| 5809 | * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false |
| 5810 | * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME |
| 5811 | * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME |
| 5812 | * </ul> |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5813 | * @return A dock intent. |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5814 | */ |
| 5815 | Intent createHomeDockIntent() { |
| 5816 | Intent intent = null; |
| 5817 | |
| 5818 | // What home does is based on the mode, not the dock state. That |
| 5819 | // is, when in car mode you should be taken to car home regardless |
| 5820 | // of whether we are actually in a car dock. |
| 5821 | if (mUiMode == Configuration.UI_MODE_TYPE_CAR) { |
| 5822 | if (ENABLE_CAR_DOCK_HOME_CAPTURE) { |
| 5823 | intent = mCarDockIntent; |
| 5824 | } |
| 5825 | } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { |
| 5826 | if (ENABLE_DESK_DOCK_HOME_CAPTURE) { |
| 5827 | intent = mDeskDockIntent; |
| 5828 | } |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 5829 | } else if (mUiMode == Configuration.UI_MODE_TYPE_WATCH |
| 5830 | && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 5831 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK |
| 5832 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK)) { |
| 5833 | // Always launch dock home from home when watch is docked, if it exists. |
| 5834 | intent = mDeskDockIntent; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5835 | } |
| 5836 | |
| 5837 | if (intent == null) { |
| 5838 | return null; |
| 5839 | } |
| 5840 | |
| 5841 | ActivityInfo ai = null; |
| 5842 | ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser( |
| 5843 | intent, |
John Spurlock | f56bef1 | 2013-07-09 09:51:46 -0400 | [diff] [blame] | 5844 | PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 5845 | mCurrentUserId); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5846 | if (info != null) { |
| 5847 | ai = info.activityInfo; |
| 5848 | } |
| 5849 | if (ai != null |
| 5850 | && ai.metaData != null |
| 5851 | && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { |
| 5852 | intent = new Intent(intent); |
| 5853 | intent.setClassName(ai.packageName, ai.name); |
| 5854 | return intent; |
| 5855 | } |
| 5856 | |
| 5857 | return null; |
| 5858 | } |
| 5859 | |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 5860 | void startDockOrHome(boolean fromHomeKey) { |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 5861 | awakenDreams(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5862 | |
| 5863 | Intent dock = createHomeDockIntent(); |
| 5864 | if (dock != null) { |
| 5865 | try { |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 5866 | if (fromHomeKey) { |
| 5867 | dock.putExtra(WindowManagerPolicy.EXTRA_FROM_HOME_KEY, fromHomeKey); |
| 5868 | } |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5869 | mContext.startActivityAsUser(dock, UserHandle.CURRENT); |
| 5870 | return; |
| 5871 | } catch (ActivityNotFoundException e) { |
| 5872 | } |
| 5873 | } |
| 5874 | |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 5875 | Intent intent; |
| 5876 | |
| 5877 | if (fromHomeKey) { |
| 5878 | intent = new Intent(mHomeIntent); |
| 5879 | intent.putExtra(WindowManagerPolicy.EXTRA_FROM_HOME_KEY, fromHomeKey); |
| 5880 | } else { |
| 5881 | intent = mHomeIntent; |
| 5882 | } |
| 5883 | |
| 5884 | mContext.startActivityAsUser(intent, UserHandle.CURRENT); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5885 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5886 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5887 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5888 | * goes to the home screen |
| 5889 | * @return whether it did anything |
| 5890 | */ |
| 5891 | boolean goHome() { |
| 5892 | if (false) { |
| 5893 | // This code always brings home to the front. |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 5894 | try { |
| 5895 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 5896 | } catch (RemoteException e) { |
| 5897 | } |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 5898 | sendCloseSystemWindows(); |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 5899 | startDockOrHome(false /*fromHomeKey*/); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5900 | } else { |
| 5901 | // This code brings home to the front or, if it is already |
| 5902 | // at the front, puts the device to sleep. |
| 5903 | try { |
Wink Saville | d2e6a33 | 2010-02-12 12:12:06 -0800 | [diff] [blame] | 5904 | if (SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1) { |
| 5905 | /// Roll back EndcallBehavior as the cupcake design to pass P1 lab entry. |
| 5906 | Log.d(TAG, "UTS-TEST-MODE"); |
| 5907 | } else { |
| 5908 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 5909 | sendCloseSystemWindows(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5910 | Intent dock = createHomeDockIntent(); |
| 5911 | if (dock != null) { |
| 5912 | int result = ActivityManagerNative.getDefault() |
| 5913 | .startActivityAsUser(null, null, dock, |
| 5914 | dock.resolveTypeIfNeeded(mContext.getContentResolver()), |
| 5915 | null, null, 0, |
| 5916 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
Jeff Hao | 1b012d3 | 2014-08-20 10:35:34 -0700 | [diff] [blame] | 5917 | null, null, UserHandle.USER_CURRENT); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5918 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
| 5919 | return false; |
| 5920 | } |
| 5921 | } |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 5922 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5923 | int result = ActivityManagerNative.getDefault() |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 5924 | .startActivityAsUser(null, null, mHomeIntent, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5925 | mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 5926 | null, null, 0, |
| 5927 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
Jeff Hao | 1b012d3 | 2014-08-20 10:35:34 -0700 | [diff] [blame] | 5928 | null, null, UserHandle.USER_CURRENT); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 5929 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5930 | return false; |
| 5931 | } |
| 5932 | } catch (RemoteException ex) { |
| 5933 | // bummer, the activity manager, which is in this process, is dead |
| 5934 | } |
| 5935 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5936 | return true; |
| 5937 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5938 | |
| 5939 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5940 | public void setCurrentOrientationLw(int newOrientation) { |
| 5941 | synchronized (mLock) { |
| 5942 | if (newOrientation != mCurrentAppOrientation) { |
| 5943 | mCurrentAppOrientation = newOrientation; |
| 5944 | updateOrientationListenerLp(); |
| 5945 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5946 | } |
| 5947 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5948 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5949 | private void performAuditoryFeedbackForAccessibilityIfNeed() { |
| 5950 | if (!isGlobalAccessibilityGestureEnabled()) { |
| 5951 | return; |
| 5952 | } |
| 5953 | AudioManager audioManager = (AudioManager) mContext.getSystemService( |
| 5954 | Context.AUDIO_SERVICE); |
| 5955 | if (audioManager.isSilentMode()) { |
| 5956 | return; |
| 5957 | } |
| 5958 | Ringtone ringTone = RingtoneManager.getRingtone(mContext, |
| 5959 | Settings.System.DEFAULT_NOTIFICATION_URI); |
| 5960 | ringTone.setStreamType(AudioManager.STREAM_MUSIC); |
| 5961 | ringTone.play(); |
| 5962 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5963 | |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 5964 | private boolean isTheaterModeEnabled() { |
| 5965 | return Settings.Global.getInt(mContext.getContentResolver(), |
| 5966 | Settings.Global.THEATER_MODE_ON, 0) == 1; |
| 5967 | } |
| 5968 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 5969 | private boolean isGlobalAccessibilityGestureEnabled() { |
| 5970 | return Settings.Global.getInt(mContext.getContentResolver(), |
| 5971 | Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1; |
| 5972 | } |
| 5973 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 5974 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5975 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { |
Svetoslav Ganov | 9617921 | 2012-10-10 14:17:45 -0700 | [diff] [blame] | 5976 | if (!mVibrator.hasVibrator()) { |
| 5977 | return false; |
| 5978 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5979 | final boolean hapticsDisabled = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 5980 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) == 0; |
Jeff Brown | 82379ba | 2014-07-25 19:03:28 -0700 | [diff] [blame] | 5981 | if (hapticsDisabled && !always) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5982 | return false; |
| 5983 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5984 | long[] pattern = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5985 | switch (effectId) { |
| 5986 | case HapticFeedbackConstants.LONG_PRESS: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5987 | pattern = mLongPressVibePattern; |
| 5988 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 5989 | case HapticFeedbackConstants.VIRTUAL_KEY: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 5990 | pattern = mVirtualKeyVibePattern; |
| 5991 | break; |
| 5992 | case HapticFeedbackConstants.KEYBOARD_TAP: |
| 5993 | pattern = mKeyboardTapVibePattern; |
| 5994 | break; |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 5995 | case HapticFeedbackConstants.CLOCK_TICK: |
| 5996 | pattern = mClockTickVibePattern; |
| 5997 | break; |
Fabrice Di Meglio | bd9152f | 2013-10-01 11:21:31 -0700 | [diff] [blame] | 5998 | case HapticFeedbackConstants.CALENDAR_DATE: |
| 5999 | pattern = mCalendarDateVibePattern; |
| 6000 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 6001 | case HapticFeedbackConstants.SAFE_MODE_DISABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6002 | pattern = mSafeModeDisabledVibePattern; |
| 6003 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 6004 | case HapticFeedbackConstants.SAFE_MODE_ENABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6005 | pattern = mSafeModeEnabledVibePattern; |
| 6006 | break; |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6007 | default: |
| 6008 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6009 | } |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 6010 | int owningUid; |
| 6011 | String owningPackage; |
| 6012 | if (win != null) { |
| 6013 | owningUid = win.getOwningUid(); |
| 6014 | owningPackage = win.getOwningPackage(); |
| 6015 | } else { |
| 6016 | owningUid = android.os.Process.myUid(); |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 6017 | owningPackage = mContext.getOpPackageName(); |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 6018 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6019 | if (pattern.length == 1) { |
| 6020 | // One-shot vibration |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 6021 | mVibrator.vibrate(owningUid, owningPackage, pattern[0], VIBRATION_ATTRIBUTES); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6022 | } else { |
| 6023 | // Pattern vibration |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 6024 | mVibrator.vibrate(owningUid, owningPackage, pattern, -1, VIBRATION_ATTRIBUTES); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6025 | } |
| 6026 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6027 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 6028 | |
| 6029 | @Override |
| 6030 | public void keepScreenOnStartedLw() { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 6031 | } |
| 6032 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 6033 | @Override |
| 6034 | public void keepScreenOnStoppedLw() { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 6035 | if (isKeyguardShowingAndNotOccluded()) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 6036 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6037 | } |
| 6038 | } |
Mike Lockwood | fcb3924 | 2009-10-21 23:01:07 -0400 | [diff] [blame] | 6039 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6040 | private int updateSystemUiVisibilityLw() { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 6041 | // If there is no window focused, there will be nobody to handle the events |
| 6042 | // anyway, so just hang on in whatever state we're in until things settle down. |
Adrian Roos | 53f28ec | 2014-10-29 17:26:12 +0100 | [diff] [blame] | 6043 | final WindowState win = mFocusedWindow != null ? mFocusedWindow |
| 6044 | : mTopFullscreenOpaqueWindowState; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6045 | if (win == null) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6046 | return 0; |
| 6047 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 6048 | if ((win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 && mHideLockScreen == true) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 6049 | // We are updating at a point where the keyguard has gotten |
| 6050 | // focus, but we were last in a state where the top window is |
| 6051 | // hiding it. This is probably because the keyguard as been |
| 6052 | // shown while the top window was displayed, so we want to ignore |
| 6053 | // it here because this is just a very transient change and it |
| 6054 | // will quickly lose focus once it correctly gets hidden. |
| 6055 | return 0; |
| 6056 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 6057 | |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 6058 | int tmpVisibility = PolicyControl.getSystemUiVisibility(win, null) |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 6059 | & ~mResettingSystemUiFlags |
| 6060 | & ~mForceClearedSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6061 | if (mForcingShowNavBar && win.getSurfaceLayer() < mForcingShowNavBarLayer) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 6062 | tmpVisibility &= ~PolicyControl.adjustClearableFlags(win, View.SYSTEM_UI_CLEARABLE_FLAGS); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 6063 | } |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame^] | 6064 | tmpVisibility = updateLightStatusBarLw(tmpVisibility); |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6065 | final int visibility = updateSystemBarsLw(win, mLastSystemUiFlags, tmpVisibility); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 6066 | final int diff = visibility ^ mLastSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6067 | final boolean needsMenu = win.getNeedsMenuLw(mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 6068 | if (diff == 0 && mLastFocusNeedsMenu == needsMenu |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6069 | && mFocusedApp == win.getAppToken()) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6070 | return 0; |
| 6071 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 6072 | mLastSystemUiFlags = visibility; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 6073 | mLastFocusNeedsMenu = needsMenu; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6074 | mFocusedApp = win.getAppToken(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6075 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6076 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6077 | public void run() { |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 6078 | try { |
| 6079 | IStatusBarService statusbar = getStatusBarService(); |
| 6080 | if (statusbar != null) { |
Adrian Roos | 53f28ec | 2014-10-29 17:26:12 +0100 | [diff] [blame] | 6081 | statusbar.setSystemUiVisibility(visibility, 0xffffffff, win.toString()); |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 6082 | statusbar.topAppWindowChanged(needsMenu); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 6083 | } |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 6084 | } catch (RemoteException e) { |
| 6085 | // re-acquire status bar service next time it is needed. |
| 6086 | mStatusBarService = null; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 6087 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6088 | } |
| 6089 | }); |
| 6090 | return diff; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 6091 | } |
| 6092 | |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame^] | 6093 | private int updateLightStatusBarLw(int vis) { |
| 6094 | WindowState statusColorWin = isStatusBarKeyguard() && !mHideLockScreen |
| 6095 | ? mStatusBar |
| 6096 | : mTopFullscreenOpaqueOrDimmingWindowState; |
| 6097 | |
| 6098 | if (statusColorWin != null) { |
| 6099 | if (statusColorWin == mTopFullscreenOpaqueWindowState) { |
| 6100 | // If the top fullscreen-or-dimming window is also the top fullscreen, respect |
| 6101 | // its light flag. |
| 6102 | vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
| 6103 | vis |= PolicyControl.getSystemUiVisibility(statusColorWin, null) |
| 6104 | & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
| 6105 | } else if (statusColorWin != null && statusColorWin.isDimming()) { |
| 6106 | // Otherwise if it's dimming, clear the light flag. |
| 6107 | vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
| 6108 | } |
| 6109 | } |
| 6110 | return vis; |
| 6111 | } |
| 6112 | |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6113 | private int updateSystemBarsLw(WindowState win, int oldVis, int vis) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 6114 | // apply translucent bar vis flags |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 6115 | WindowState transWin = isStatusBarKeyguard() && !mHideLockScreen |
| 6116 | ? mStatusBar |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 6117 | : mTopFullscreenOpaqueWindowState; |
| 6118 | vis = mStatusBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 6119 | vis = mNavigationBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 6120 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 6121 | // prevent status bar interaction from clearing certain flags |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6122 | boolean statusBarHasFocus = win.getAttrs().type == TYPE_STATUS_BAR; |
John Spurlock | 08ffcf5 | 2014-07-11 10:13:46 -0400 | [diff] [blame] | 6123 | if (statusBarHasFocus && !isStatusBarKeyguard()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 6124 | int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
| 6125 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 6126 | | View.SYSTEM_UI_FLAG_IMMERSIVE |
Jorim Jaggi | 73fef8d | 2015-02-16 17:32:28 +0100 | [diff] [blame] | 6127 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
| 6128 | | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
John Spurlock | 08ffcf5 | 2014-07-11 10:13:46 -0400 | [diff] [blame] | 6129 | if (mHideLockScreen) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 6130 | flags |= View.STATUS_BAR_TRANSLUCENT | View.NAVIGATION_BAR_TRANSLUCENT; |
| 6131 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 6132 | vis = (vis & ~flags) | (oldVis & flags); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 6133 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 6134 | |
Adrian Roos | 4fb3ee3 | 2014-08-22 19:29:09 +0200 | [diff] [blame] | 6135 | if (!areTranslucentBarsAllowed() && transWin != mStatusBar) { |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 6136 | vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT |
| 6137 | | View.SYSTEM_UI_TRANSPARENT); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 6138 | } |
| 6139 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 6140 | // update status bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 6141 | boolean immersiveSticky = |
| 6142 | (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 6143 | boolean hideStatusBarWM = |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 6144 | mTopFullscreenOpaqueWindowState != null && |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 6145 | (PolicyControl.getWindowFlags(mTopFullscreenOpaqueWindowState, null) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 6146 | & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; |
| 6147 | boolean hideStatusBarSysui = |
| 6148 | (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 6149 | boolean hideNavBarSysui = |
| 6150 | (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 6151 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 6152 | boolean transientStatusBarAllowed = |
| 6153 | mStatusBar != null && ( |
| 6154 | hideStatusBarWM |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 6155 | || (hideStatusBarSysui && immersiveSticky) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 6156 | || statusBarHasFocus); |
| 6157 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 6158 | boolean transientNavBarAllowed = |
| 6159 | mNavigationBar != null && |
| 6160 | hideNavBarSysui && immersiveSticky; |
| 6161 | |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 6162 | boolean denyTransientStatus = mStatusBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 6163 | && !transientStatusBarAllowed && hideStatusBarSysui; |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 6164 | boolean denyTransientNav = mNavigationBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 6165 | && !transientNavBarAllowed; |
| 6166 | if (denyTransientStatus || denyTransientNav) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 6167 | // clear the clearable flags instead |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 6168 | clearClearableFlagsLw(); |
tiger_huang | c58d756 | 2014-10-23 20:24:19 +0800 | [diff] [blame] | 6169 | vis &= ~View.SYSTEM_UI_CLEARABLE_FLAGS; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 6170 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 6171 | |
| 6172 | vis = mStatusBarController.updateVisibilityLw(transientStatusBarAllowed, oldVis, vis); |
| 6173 | |
| 6174 | // update navigation bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 6175 | boolean oldImmersiveMode = isImmersiveMode(oldVis); |
| 6176 | boolean newImmersiveMode = isImmersiveMode(vis); |
| 6177 | if (win != null && oldImmersiveMode != newImmersiveMode) { |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6178 | final String pkg = win.getOwningPackage(); |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 6179 | mImmersiveModeConfirmation.immersiveModeChanged(pkg, newImmersiveMode, |
| 6180 | isUserSetupComplete()); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 6181 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 6182 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 6183 | vis = mNavigationBarController.updateVisibilityLw(transientNavBarAllowed, oldVis, vis); |
| 6184 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 6185 | return vis; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 6186 | } |
| 6187 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 6188 | private void clearClearableFlagsLw() { |
| 6189 | int newVal = mResettingSystemUiFlags | View.SYSTEM_UI_CLEARABLE_FLAGS; |
| 6190 | if (newVal != mResettingSystemUiFlags) { |
| 6191 | mResettingSystemUiFlags = newVal; |
| 6192 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 6193 | } |
| 6194 | } |
| 6195 | |
| 6196 | private boolean isImmersiveMode(int vis) { |
| 6197 | 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] | 6198 | return mNavigationBar != null |
| 6199 | && (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0 |
Daniel Sandler | 900ece5 | 2013-10-18 15:53:27 -0400 | [diff] [blame] | 6200 | && (vis & flags) != 0 |
| 6201 | && canHideNavigationBar(); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 6202 | } |
| 6203 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 6204 | /** |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 6205 | * @return whether the navigation or status bar can be made translucent |
| 6206 | * |
| 6207 | * This should return true unless touch exploration is not enabled or |
| 6208 | * R.boolean.config_enableTranslucentDecor is false. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 6209 | */ |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 6210 | private boolean areTranslucentBarsAllowed() { |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 6211 | return mTranslucentDecorEnabled |
| 6212 | && !mAccessibilityManager.isTouchExplorationEnabled(); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 6213 | } |
| 6214 | |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 6215 | // Use this instead of checking config_showNavigationBar so that it can be consistently |
| 6216 | // overridden by qemu.hw.mainkeys in the emulator. |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6217 | @Override |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 6218 | public boolean hasNavigationBar() { |
| 6219 | return mHasNavigationBar; |
| 6220 | } |
| 6221 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 6222 | @Override |
| 6223 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target) { |
| 6224 | mLastInputMethodWindow = ime; |
| 6225 | mLastInputMethodTargetWindow = target; |
| 6226 | } |
| 6227 | |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 6228 | @Override |
Satoshi Kataoka | 658c7b8 | 2013-10-10 17:03:51 +0900 | [diff] [blame] | 6229 | public int getInputMethodWindowVisibleHeightLw() { |
| 6230 | return mDockBottom - mCurBottom; |
| 6231 | } |
| 6232 | |
| 6233 | @Override |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 6234 | public void setCurrentUserLw(int newUserId) { |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 6235 | mCurrentUserId = newUserId; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 6236 | if (mKeyguardDelegate != null) { |
| 6237 | mKeyguardDelegate.setCurrentUser(newUserId); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 6238 | } |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 6239 | if (mStatusBarService != null) { |
| 6240 | try { |
| 6241 | mStatusBarService.setCurrentUser(newUserId); |
| 6242 | } catch (RemoteException e) { |
| 6243 | // oh well |
| 6244 | } |
| 6245 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 6246 | setLastInputMethodWindowLw(null, null); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 6247 | } |
| 6248 | |
| 6249 | @Override |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 6250 | public boolean canMagnifyWindow(int windowType) { |
| 6251 | switch (windowType) { |
| 6252 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD: |
| 6253 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG: |
| 6254 | case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR: |
| 6255 | case WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY: { |
| 6256 | return false; |
| 6257 | } |
| 6258 | } |
| 6259 | return true; |
| 6260 | } |
| 6261 | |
| 6262 | @Override |
| 6263 | public boolean isTopLevelWindow(int windowType) { |
| 6264 | if (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW |
| 6265 | && windowType <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 6266 | return (windowType == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG); |
| 6267 | } |
| 6268 | return true; |
| 6269 | } |
| 6270 | |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 6271 | @Override |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 6272 | public void dump(String prefix, PrintWriter pw, String[] args) { |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6273 | pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 6274 | pw.print(" mSystemReady="); pw.print(mSystemReady); |
| 6275 | pw.print(" mSystemBooted="); pw.println(mSystemBooted); |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 6276 | pw.print(prefix); pw.print("mLidState="); pw.print(mLidState); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6277 | pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 6278 | pw.print(" mCameraLensCoverState="); pw.print(mCameraLensCoverState); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6279 | pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 6280 | if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 |
| 6281 | || mForceClearedSystemUiFlags != 0) { |
| 6282 | pw.print(prefix); pw.print("mLastSystemUiFlags=0x"); |
| 6283 | pw.print(Integer.toHexString(mLastSystemUiFlags)); |
| 6284 | pw.print(" mResettingSystemUiFlags=0x"); |
| 6285 | pw.print(Integer.toHexString(mResettingSystemUiFlags)); |
| 6286 | pw.print(" mForceClearedSystemUiFlags=0x"); |
| 6287 | pw.println(Integer.toHexString(mForceClearedSystemUiFlags)); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6288 | } |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 6289 | if (mLastFocusNeedsMenu) { |
| 6290 | pw.print(prefix); pw.print("mLastFocusNeedsMenu="); |
| 6291 | pw.println(mLastFocusNeedsMenu); |
| 6292 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 6293 | pw.print(prefix); pw.print("mWakeGestureEnabledSetting="); |
| 6294 | pw.println(mWakeGestureEnabledSetting); |
| 6295 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 6296 | pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6297 | pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); |
| 6298 | pw.print(" mDockMode="); pw.print(mDockMode); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6299 | pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); |
| 6300 | pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); |
| 6301 | pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); |
| 6302 | pw.print(" mUserRotation="); pw.print(mUserRotation); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 6303 | pw.print(" mAllowAllRotations="); pw.println(mAllowAllRotations); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 6304 | pw.print(prefix); pw.print("mCurrentAppOrientation="); pw.println(mCurrentAppOrientation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6305 | pw.print(prefix); pw.print("mCarDockEnablesAccelerometer="); |
| 6306 | pw.print(mCarDockEnablesAccelerometer); |
| 6307 | pw.print(" mDeskDockEnablesAccelerometer="); |
| 6308 | pw.println(mDeskDockEnablesAccelerometer); |
| 6309 | pw.print(prefix); pw.print("mLidKeyboardAccessibility="); |
| 6310 | pw.print(mLidKeyboardAccessibility); |
| 6311 | pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 6312 | pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep); |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 6313 | pw.print(prefix); |
| 6314 | pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior); |
| 6315 | pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 6316 | pw.print(prefix); |
| 6317 | pw.print("mDoublePressOnPowerBehavior="); pw.print(mDoublePressOnPowerBehavior); |
| 6318 | pw.print(" mTriplePressOnPowerBehavior="); pw.println(mTriplePressOnPowerBehavior); |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 6319 | pw.print(prefix); pw.print("mHasSoftInput="); pw.println(mHasSoftInput); |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 6320 | pw.print(prefix); pw.print("mAwake="); pw.println(mAwake); |
| 6321 | pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly); |
| 6322 | pw.print(" mScreenOnFully="); pw.println(mScreenOnFully); |
| 6323 | pw.print(prefix); pw.print("mKeyguardDrawComplete="); pw.print(mKeyguardDrawComplete); |
| 6324 | pw.print(" mWindowManagerDrawComplete="); pw.println(mWindowManagerDrawComplete); |
| 6325 | pw.print(prefix); pw.print("mOrientationSensorEnabled="); |
| 6326 | pw.println(mOrientationSensorEnabled); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 6327 | pw.print(prefix); pw.print("mOverscanScreen=("); pw.print(mOverscanScreenLeft); |
| 6328 | pw.print(","); pw.print(mOverscanScreenTop); |
| 6329 | pw.print(") "); pw.print(mOverscanScreenWidth); |
| 6330 | pw.print("x"); pw.println(mOverscanScreenHeight); |
| 6331 | if (mOverscanLeft != 0 || mOverscanTop != 0 |
| 6332 | || mOverscanRight != 0 || mOverscanBottom != 0) { |
| 6333 | pw.print(prefix); pw.print("mOverscan left="); pw.print(mOverscanLeft); |
| 6334 | pw.print(" top="); pw.print(mOverscanTop); |
| 6335 | pw.print(" right="); pw.print(mOverscanRight); |
| 6336 | pw.print(" bottom="); pw.println(mOverscanBottom); |
| 6337 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 6338 | pw.print(prefix); pw.print("mRestrictedOverscanScreen=("); |
| 6339 | pw.print(mRestrictedOverscanScreenLeft); |
| 6340 | pw.print(","); pw.print(mRestrictedOverscanScreenTop); |
| 6341 | pw.print(") "); pw.print(mRestrictedOverscanScreenWidth); |
| 6342 | pw.print("x"); pw.println(mRestrictedOverscanScreenHeight); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6343 | pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft); |
| 6344 | pw.print(","); pw.print(mUnrestrictedScreenTop); |
| 6345 | pw.print(") "); pw.print(mUnrestrictedScreenWidth); |
| 6346 | pw.print("x"); pw.println(mUnrestrictedScreenHeight); |
| 6347 | pw.print(prefix); pw.print("mRestrictedScreen=("); pw.print(mRestrictedScreenLeft); |
| 6348 | pw.print(","); pw.print(mRestrictedScreenTop); |
| 6349 | pw.print(") "); pw.print(mRestrictedScreenWidth); |
| 6350 | pw.print("x"); pw.println(mRestrictedScreenHeight); |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 6351 | pw.print(prefix); pw.print("mStableFullscreen=("); pw.print(mStableFullscreenLeft); |
| 6352 | pw.print(","); pw.print(mStableFullscreenTop); |
| 6353 | pw.print(")-("); pw.print(mStableFullscreenRight); |
| 6354 | pw.print(","); pw.print(mStableFullscreenBottom); pw.println(")"); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 6355 | pw.print(prefix); pw.print("mStable=("); pw.print(mStableLeft); |
| 6356 | pw.print(","); pw.print(mStableTop); |
| 6357 | pw.print(")-("); pw.print(mStableRight); |
| 6358 | pw.print(","); pw.print(mStableBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 6359 | pw.print(prefix); pw.print("mSystem=("); pw.print(mSystemLeft); |
| 6360 | pw.print(","); pw.print(mSystemTop); |
| 6361 | pw.print(")-("); pw.print(mSystemRight); |
| 6362 | pw.print(","); pw.print(mSystemBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6363 | pw.print(prefix); pw.print("mCur=("); pw.print(mCurLeft); |
| 6364 | pw.print(","); pw.print(mCurTop); |
| 6365 | pw.print(")-("); pw.print(mCurRight); |
| 6366 | pw.print(","); pw.print(mCurBottom); pw.println(")"); |
| 6367 | pw.print(prefix); pw.print("mContent=("); pw.print(mContentLeft); |
| 6368 | pw.print(","); pw.print(mContentTop); |
| 6369 | pw.print(")-("); pw.print(mContentRight); |
| 6370 | pw.print(","); pw.print(mContentBottom); pw.println(")"); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 6371 | pw.print(prefix); pw.print("mVoiceContent=("); pw.print(mVoiceContentLeft); |
| 6372 | pw.print(","); pw.print(mVoiceContentTop); |
| 6373 | pw.print(")-("); pw.print(mVoiceContentRight); |
| 6374 | pw.print(","); pw.print(mVoiceContentBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6375 | pw.print(prefix); pw.print("mDock=("); pw.print(mDockLeft); |
| 6376 | pw.print(","); pw.print(mDockTop); |
| 6377 | pw.print(")-("); pw.print(mDockRight); |
| 6378 | pw.print(","); pw.print(mDockBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 6379 | pw.print(prefix); pw.print("mDockLayer="); pw.print(mDockLayer); |
| 6380 | pw.print(" mStatusBarLayer="); pw.println(mStatusBarLayer); |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 6381 | pw.print(prefix); pw.print("mShowingLockscreen="); pw.print(mShowingLockscreen); |
| 6382 | pw.print(" mShowingDream="); pw.print(mShowingDream); |
| 6383 | pw.print(" mDreamingLockscreen="); pw.println(mDreamingLockscreen); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 6384 | if (mLastInputMethodWindow != null) { |
| 6385 | pw.print(prefix); pw.print("mLastInputMethodWindow="); |
| 6386 | pw.println(mLastInputMethodWindow); |
| 6387 | } |
| 6388 | if (mLastInputMethodTargetWindow != null) { |
| 6389 | pw.print(prefix); pw.print("mLastInputMethodTargetWindow="); |
| 6390 | pw.println(mLastInputMethodTargetWindow); |
| 6391 | } |
| 6392 | if (mStatusBar != null) { |
| 6393 | pw.print(prefix); pw.print("mStatusBar="); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 6394 | pw.print(mStatusBar); pw.print(" isStatusBarKeyguard="); |
| 6395 | pw.println(isStatusBarKeyguard()); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 6396 | } |
| 6397 | if (mNavigationBar != null) { |
| 6398 | pw.print(prefix); pw.print("mNavigationBar="); |
| 6399 | pw.println(mNavigationBar); |
| 6400 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 6401 | if (mFocusedWindow != null) { |
| 6402 | pw.print(prefix); pw.print("mFocusedWindow="); |
| 6403 | pw.println(mFocusedWindow); |
| 6404 | } |
| 6405 | if (mFocusedApp != null) { |
| 6406 | pw.print(prefix); pw.print("mFocusedApp="); |
| 6407 | pw.println(mFocusedApp); |
| 6408 | } |
| 6409 | if (mWinDismissingKeyguard != null) { |
| 6410 | pw.print(prefix); pw.print("mWinDismissingKeyguard="); |
| 6411 | pw.println(mWinDismissingKeyguard); |
| 6412 | } |
| 6413 | if (mTopFullscreenOpaqueWindowState != null) { |
| 6414 | pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); |
| 6415 | pw.println(mTopFullscreenOpaqueWindowState); |
| 6416 | } |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame^] | 6417 | if (mTopFullscreenOpaqueOrDimmingWindowState != null) { |
| 6418 | pw.print(prefix); pw.print("mTopFullscreenOpaqueOrDimmingWindowState="); |
| 6419 | pw.println(mTopFullscreenOpaqueOrDimmingWindowState); |
| 6420 | } |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 6421 | if (mForcingShowNavBar) { |
| 6422 | pw.print(prefix); pw.print("mForcingShowNavBar="); |
| 6423 | pw.println(mForcingShowNavBar); pw.print( "mForcingShowNavBarLayer="); |
| 6424 | pw.println(mForcingShowNavBarLayer); |
| 6425 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 6426 | pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6427 | pw.print(" mHideLockScreen="); pw.println(mHideLockScreen); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 6428 | pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); |
| 6429 | pw.print(" mForceStatusBarFromKeyguard="); |
| 6430 | pw.println(mForceStatusBarFromKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6431 | pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 6432 | pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6433 | pw.print(" mHomePressed="); pw.println(mHomePressed); |
| 6434 | pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); |
| 6435 | pw.print(" mLockScreenTimeout="); pw.print(mLockScreenTimeout); |
| 6436 | pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive); |
| 6437 | pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior); |
| 6438 | pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior); |
| 6439 | pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior); |
| 6440 | pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation); |
| 6441 | pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); |
| 6442 | pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); |
| 6443 | pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 6444 | pw.print(prefix); pw.print("mDemoHdmiRotation="); pw.print(mDemoHdmiRotation); |
| 6445 | pw.print(" mDemoHdmiRotationLock="); pw.println(mDemoHdmiRotationLock); |
| 6446 | pw.print(prefix); pw.print("mUndockedHdmiRotation="); pw.println(mUndockedHdmiRotation); |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 6447 | |
Tim Kilbourn | d7c0c2e | 2014-05-29 16:08:10 -0700 | [diff] [blame] | 6448 | mGlobalKeyManager.dump(prefix, pw); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 6449 | mStatusBarController.dump(pw, prefix); |
| 6450 | mNavigationBarController.dump(pw, prefix); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 6451 | PolicyControl.dump(prefix, pw); |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 6452 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 6453 | if (mWakeGestureListener != null) { |
| 6454 | mWakeGestureListener.dump(pw, prefix); |
| 6455 | } |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 6456 | if (mOrientationListener != null) { |
| 6457 | mOrientationListener.dump(pw, prefix); |
| 6458 | } |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 6459 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6460 | } |