The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1 | /* |
Jeff Brown | 37df39a9 | 2015-02-25 15:42:31 -0800 | [diff] [blame] | 2 | * Copyright (C) 2006 The Android Open Source Project |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 17 | package com.android.server.policy; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 18 | |
Wale Ogunwale | 3797c22 | 2015-10-27 14:21:58 -0700 | [diff] [blame] | 19 | import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; |
| 20 | import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 21 | import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; |
| 22 | import static android.app.ActivityManager.StackId.HOME_STACK_ID; |
Jaewan Kim | 4911787 | 2016-01-19 17:24:08 +0900 | [diff] [blame] | 23 | import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE; |
| 24 | import static android.content.pm.PackageManager.FEATURE_TELEVISION; |
| 25 | import static android.content.pm.PackageManager.FEATURE_WATCH; |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 26 | import static android.content.res.Configuration.UI_MODE_TYPE_CAR; |
| 27 | import static android.content.res.Configuration.UI_MODE_TYPE_MASK; |
Jorim Jaggi | 5060bd8 | 2016-02-19 17:12:19 -0800 | [diff] [blame] | 28 | import static android.view.WindowManager.DOCKED_TOP; |
| 29 | import static android.view.WindowManager.DOCKED_LEFT; |
| 30 | import static android.view.WindowManager.DOCKED_RIGHT; |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 31 | import static android.view.WindowManager.LayoutParams.*; |
Jaewan Kim | 4911787 | 2016-01-19 17:24:08 +0900 | [diff] [blame] | 32 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVERED; |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 33 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVER_ABSENT; |
| 34 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_UNCOVERED; |
Jaewan Kim | 4911787 | 2016-01-19 17:24:08 +0900 | [diff] [blame] | 35 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; |
| 36 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; |
| 37 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 38 | |
Svet Ganov | 9cea80cd | 2016-02-16 11:47:00 -0800 | [diff] [blame] | 39 | import android.Manifest; |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 40 | import android.app.ActivityManager; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 41 | import android.app.ActivityManager.StackId; |
Jeff Brown | 061ea99 | 2015-04-17 19:55:47 -0700 | [diff] [blame] | 42 | import android.app.ActivityManagerInternal; |
| 43 | import android.app.ActivityManagerInternal.SleepToken; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 44 | import android.app.ActivityManagerNative; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 45 | import android.app.AppOpsManager; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 46 | import android.app.IUiModeManager; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 47 | import android.app.ProgressDialog; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 48 | import android.app.SearchManager; |
John Spurlock | 9764218 | 2013-07-29 17:58:39 -0400 | [diff] [blame] | 49 | import android.app.StatusBarManager; |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 50 | import android.app.UiModeManager; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 51 | import android.content.ActivityNotFoundException; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 52 | import android.content.BroadcastReceiver; |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 53 | import android.content.ComponentName; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 54 | import android.content.ContentResolver; |
| 55 | import android.content.Context; |
| 56 | import android.content.Intent; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 57 | import android.content.IntentFilter; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 58 | import android.content.ServiceConnection; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 59 | import android.content.pm.ActivityInfo; |
| 60 | import android.content.pm.PackageManager; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 61 | import android.content.pm.ResolveInfo; |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 62 | import android.content.res.CompatibilityInfo; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 63 | import android.content.res.Configuration; |
| 64 | import android.content.res.Resources; |
| 65 | import android.database.ContentObserver; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 66 | import android.graphics.PixelFormat; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 67 | import android.graphics.Rect; |
Jinsuk Kim | e601b71 | 2015-07-07 08:01:02 +0900 | [diff] [blame] | 68 | import android.hardware.hdmi.HdmiControlManager; |
| 69 | import android.hardware.hdmi.HdmiPlaybackClient; |
| 70 | import android.hardware.hdmi.HdmiPlaybackClient.OneTouchPlayCallback; |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 71 | import android.media.AudioAttributes; |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 72 | import android.media.AudioManager; |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 73 | import android.media.AudioSystem; |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 74 | import android.media.IAudioService; |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 75 | import android.media.Ringtone; |
| 76 | import android.media.RingtoneManager; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 77 | import android.media.session.MediaSessionLegacyHelper; |
Billy Lau | cbe540f | 2015-06-25 01:51:44 +0100 | [diff] [blame] | 78 | import android.os.Binder; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 79 | import android.os.Bundle; |
Craig Mautner | 276a6eb | 2014-11-04 15:32:57 -0800 | [diff] [blame] | 80 | import android.os.Debug; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 81 | import android.os.FactoryTest; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 82 | import android.os.Handler; |
| 83 | import android.os.IBinder; |
Dianne Hackborn | b6683c4 | 2015-06-18 17:40:33 -0700 | [diff] [blame] | 84 | import android.os.IDeviceIdleController; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 85 | import android.os.Looper; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 86 | import android.os.Message; |
| 87 | import android.os.Messenger; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 88 | import android.os.PowerManager; |
Nick Armstrong-Crews | 56ecfcc | 2015-09-07 21:46:50 -0700 | [diff] [blame] | 89 | import android.os.PowerManagerInternal; |
Billy Lau | cbe540f | 2015-06-25 01:51:44 +0100 | [diff] [blame] | 90 | import android.os.Process; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 91 | import android.os.RemoteException; |
| 92 | import android.os.ServiceManager; |
| 93 | import android.os.SystemClock; |
| 94 | import android.os.SystemProperties; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 95 | import android.os.UEventObserver; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 96 | import android.os.UserHandle; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 97 | import android.os.Vibrator; |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 98 | import android.provider.MediaStore; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 99 | import android.provider.Settings; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 100 | import android.service.dreams.DreamManagerInternal; |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 101 | import android.service.dreams.DreamService; |
| 102 | import android.service.dreams.IDreamManager; |
Michael Wright | dc63f7b | 2014-08-21 19:05:21 -0700 | [diff] [blame] | 103 | import android.speech.RecognizerIntent; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 104 | import android.telecom.TelecomManager; |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 105 | import android.util.DisplayMetrics; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 106 | import android.util.EventLog; |
| 107 | import android.util.Log; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 108 | import android.util.Slog; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 109 | import android.util.SparseArray; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 110 | import android.view.Display; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 111 | import android.view.Gravity; |
| 112 | import android.view.HapticFeedbackConstants; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 113 | import android.view.IApplicationToken; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 114 | import android.view.IWindowManager; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 115 | import android.view.InputChannel; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 116 | import android.view.InputDevice; |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 117 | import android.view.InputEvent; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 118 | import android.view.InputEventReceiver; |
Jeff Brown | 6b53e8d | 2010-11-10 16:03:06 -0800 | [diff] [blame] | 119 | import android.view.KeyCharacterMap; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 120 | import android.view.KeyCharacterMap.FallbackAction; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 121 | import android.view.KeyEvent; |
| 122 | import android.view.MotionEvent; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 123 | import android.view.Surface; |
| 124 | import android.view.View; |
| 125 | import android.view.ViewConfiguration; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 126 | import android.view.WindowManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 127 | import android.view.WindowManagerGlobal; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 128 | import android.view.WindowManagerInternal; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 129 | import android.view.WindowManagerPolicy; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 130 | import android.view.accessibility.AccessibilityEvent; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 131 | import android.view.accessibility.AccessibilityManager; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 132 | import android.view.animation.Animation; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 133 | import android.view.animation.AnimationSet; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 134 | import android.view.animation.AnimationUtils; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 135 | import com.android.internal.R; |
Jason Monk | 8f7f318 | 2015-11-18 16:35:14 -0500 | [diff] [blame] | 136 | import com.android.internal.logging.MetricsLogger; |
| 137 | import com.android.internal.policy.PhoneWindow; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 138 | import com.android.internal.statusbar.IStatusBarService; |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 139 | import com.android.internal.util.ScreenShapeHelper; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 140 | import com.android.internal.widget.PointerLocationView; |
Adrian Roos | 5941c98 | 2015-09-03 15:59:49 -0700 | [diff] [blame] | 141 | import com.android.server.GestureLauncherService; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 142 | import com.android.server.LocalServices; |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 143 | import com.android.server.policy.keyguard.KeyguardServiceDelegate; |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 144 | import com.android.server.policy.keyguard.KeyguardServiceDelegate.DrawnListener; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 145 | import com.android.server.statusbar.StatusBarManagerInternal; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 146 | |
| 147 | import java.io.File; |
| 148 | import java.io.FileReader; |
| 149 | import java.io.IOException; |
| 150 | import java.io.PrintWriter; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 151 | import java.util.HashSet; |
Craig Mautner | 276a6eb | 2014-11-04 15:32:57 -0800 | [diff] [blame] | 152 | import java.util.List; |
Craig Mautner | ae44659 | 2012-12-06 19:05:05 -0800 | [diff] [blame] | 153 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 154 | /** |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 155 | * WindowManagerPolicy implementation for the Android phone UI. This |
| 156 | * introduces a new method suffix, Lp, for an internal lock of the |
| 157 | * PhoneWindowManager. This is used to protect some internal state, and |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 158 | * 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] | 159 | * of both of those when held. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 160 | */ |
| 161 | public class PhoneWindowManager implements WindowManagerPolicy { |
| 162 | static final String TAG = "WindowManager"; |
| 163 | static final boolean DEBUG = false; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 164 | static final boolean localLOGV = false; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 165 | static final boolean DEBUG_INPUT = false; |
Craig Mautner | c0d2d0a | 2014-10-31 16:25:15 -0700 | [diff] [blame] | 166 | static final boolean DEBUG_KEYGUARD = false; |
| 167 | static final boolean DEBUG_LAYOUT = false; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 168 | static final boolean DEBUG_STARTING_WINDOW = false; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 169 | static final boolean DEBUG_WAKEUP = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 170 | static final boolean SHOW_STARTING_ANIMATIONS = true; |
| 171 | static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 172 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 173 | // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. |
keunyoung | a771049 | 2015-09-23 11:33:58 -0700 | [diff] [blame] | 174 | // No longer recommended for desk docks; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 175 | static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; |
| 176 | |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 177 | static final int SHORT_PRESS_POWER_NOTHING = 0; |
| 178 | static final int SHORT_PRESS_POWER_GO_TO_SLEEP = 1; |
| 179 | static final int SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP = 2; |
| 180 | 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] | 181 | static final int SHORT_PRESS_POWER_GO_HOME = 4; |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 182 | |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 183 | static final int LONG_PRESS_POWER_NOTHING = 0; |
| 184 | static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; |
| 185 | static final int LONG_PRESS_POWER_SHUT_OFF = 2; |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 186 | static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 187 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 188 | static final int MULTI_PRESS_POWER_NOTHING = 0; |
| 189 | static final int MULTI_PRESS_POWER_THEATER_MODE = 1; |
| 190 | static final int MULTI_PRESS_POWER_BRIGHTNESS_BOOST = 2; |
| 191 | |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 192 | // These need to match the documentation/constant in |
| 193 | // core/res/res/values/config.xml |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 194 | static final int LONG_PRESS_HOME_NOTHING = 0; |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 195 | static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 196 | static final int LONG_PRESS_HOME_ASSIST = 2; |
Jaewan Kim | 76b7d0d | 2016-02-12 19:01:02 +0900 | [diff] [blame] | 197 | static final int LAST_LONG_PRESS_HOME_BEHAVIOR = LONG_PRESS_HOME_ASSIST; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 198 | |
| 199 | static final int DOUBLE_TAP_HOME_NOTHING = 0; |
| 200 | static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 201 | |
Jaewan Kim | 4911787 | 2016-01-19 17:24:08 +0900 | [diff] [blame] | 202 | static final int SHORT_PRESS_WINDOW_NOTHING = 0; |
| 203 | static final int SHORT_PRESS_WINDOW_PICTURE_IN_PICTURE = 1; |
| 204 | |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 205 | static final int SHORT_PRESS_SLEEP_GO_TO_SLEEP = 0; |
| 206 | static final int SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME = 1; |
| 207 | |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 208 | static final int APPLICATION_MEDIA_SUBLAYER = -2; |
| 209 | static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 210 | static final int APPLICATION_PANEL_SUBLAYER = 1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 211 | static final int APPLICATION_SUB_PANEL_SUBLAYER = 2; |
Wale Ogunwale | 0a4dc22 | 2015-04-14 12:58:42 -0700 | [diff] [blame] | 212 | static final int APPLICATION_ABOVE_SUB_PANEL_SUBLAYER = 3; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 213 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 214 | static public final String SYSTEM_DIALOG_REASON_KEY = "reason"; |
| 215 | static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions"; |
| 216 | static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 217 | static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 218 | static public final String SYSTEM_DIALOG_REASON_ASSIST = "assist"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 219 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 220 | /** |
| 221 | * These are the system UI flags that, when changing, can cause the layout |
| 222 | * of the screen to change. |
| 223 | */ |
| 224 | static final int SYSTEM_UI_CHANGING_LAYOUT = |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 225 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | 7f4820a | 2013-10-08 12:54:35 -0400 | [diff] [blame] | 226 | | View.SYSTEM_UI_FLAG_FULLSCREEN |
| 227 | | View.STATUS_BAR_TRANSLUCENT |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 228 | | View.NAVIGATION_BAR_TRANSLUCENT |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 229 | | View.STATUS_BAR_TRANSPARENT |
| 230 | | View.NAVIGATION_BAR_TRANSPARENT; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 231 | |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 232 | private static final AudioAttributes VIBRATION_ATTRIBUTES = new AudioAttributes.Builder() |
| 233 | .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
| 234 | .setUsage(AudioAttributes.USAGE_ASSISTANCE_SONIFICATION) |
| 235 | .build(); |
| 236 | |
Adrian Roos | ddc8b27 | 2015-05-21 16:28:27 -0700 | [diff] [blame] | 237 | // The panic gesture may become active only after the keyguard is dismissed and the immersive |
| 238 | // app shows again. If that doesn't happen for 30s we drop the gesture. |
| 239 | private static final long PANIC_GESTURE_EXPIRATION = 30000; |
| 240 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 241 | /** |
| 242 | * Keyguard stuff |
| 243 | */ |
| 244 | private WindowState mKeyguardScrim; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 245 | private boolean mKeyguardHidden; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 246 | private boolean mKeyguardDrawnOnce; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 247 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 248 | /* Table of Application Launch keys. Maps from key codes to intent categories. |
| 249 | * |
| 250 | * These are special keys that are used to launch particular kinds of applications, |
| 251 | * such as a web browser. HID defines nearly a hundred of them in the Consumer (0x0C) |
| 252 | * usage page. We don't support quite that many yet... |
| 253 | */ |
| 254 | static SparseArray<String> sApplicationLaunchKeyCategories; |
| 255 | static { |
| 256 | sApplicationLaunchKeyCategories = new SparseArray<String>(); |
| 257 | sApplicationLaunchKeyCategories.append( |
| 258 | KeyEvent.KEYCODE_EXPLORER, Intent.CATEGORY_APP_BROWSER); |
| 259 | sApplicationLaunchKeyCategories.append( |
| 260 | KeyEvent.KEYCODE_ENVELOPE, Intent.CATEGORY_APP_EMAIL); |
| 261 | sApplicationLaunchKeyCategories.append( |
| 262 | KeyEvent.KEYCODE_CONTACTS, Intent.CATEGORY_APP_CONTACTS); |
| 263 | sApplicationLaunchKeyCategories.append( |
| 264 | KeyEvent.KEYCODE_CALENDAR, Intent.CATEGORY_APP_CALENDAR); |
| 265 | sApplicationLaunchKeyCategories.append( |
| 266 | KeyEvent.KEYCODE_MUSIC, Intent.CATEGORY_APP_MUSIC); |
| 267 | sApplicationLaunchKeyCategories.append( |
| 268 | KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); |
| 269 | } |
| 270 | |
Craig Mautner | c3daedd | 2014-09-13 11:17:23 -0700 | [diff] [blame] | 271 | /** Amount of time (in milliseconds) to wait for windows drawn before powering on. */ |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 272 | static final int WAITING_FOR_DRAWN_TIMEOUT = 1000; |
Craig Mautner | c3daedd | 2014-09-13 11:17:23 -0700 | [diff] [blame] | 273 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 274 | /** |
| 275 | * Lock protecting internal state. Must not call out into window |
| 276 | * manager with lock held. (This lock will be acquired in places |
| 277 | * where the window manager is calling in with its own lock held.) |
| 278 | */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 279 | private final Object mLock = new Object(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 280 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 281 | Context mContext; |
| 282 | IWindowManager mWindowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 283 | WindowManagerFuncs mWindowManagerFuncs; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 284 | WindowManagerInternal mWindowManagerInternal; |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 285 | PowerManager mPowerManager; |
Jeff Brown | 061ea99 | 2015-04-17 19:55:47 -0700 | [diff] [blame] | 286 | ActivityManagerInternal mActivityManagerInternal; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 287 | DreamManagerInternal mDreamManagerInternal; |
Michael Wright | a4d22d7 | 2015-09-16 23:19:26 +0100 | [diff] [blame] | 288 | PowerManagerInternal mPowerManagerInternal; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 289 | IStatusBarService mStatusBarService; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 290 | StatusBarManagerInternal mStatusBarManagerInternal; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 291 | boolean mPreloadedRecentApps; |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 292 | final Object mServiceAquireLock = new Object(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 293 | Vibrator mVibrator; // Vibrator for giving feedback of orientation changes |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 294 | SearchManager mSearchManager; |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 295 | AccessibilityManager mAccessibilityManager; |
Filip Gruszczynski | cfb3185 | 2015-02-25 21:47:12 +0000 | [diff] [blame] | 296 | BurnInProtectionHelper mBurnInProtectionHelper; |
Billy Lau | cbe540f | 2015-06-25 01:51:44 +0100 | [diff] [blame] | 297 | AppOpsManager mAppOpsManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 298 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 299 | // Vibrator pattern for haptic feedback of a long press. |
| 300 | long[] mLongPressVibePattern; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 301 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 302 | // Vibrator pattern for haptic feedback of virtual key press. |
| 303 | long[] mVirtualKeyVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 304 | |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 305 | // Vibrator pattern for a short vibration. |
| 306 | long[] mKeyboardTapVibePattern; |
| 307 | |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 308 | // Vibrator pattern for a short vibration when tapping on an hour/minute tick of a Clock. |
| 309 | long[] mClockTickVibePattern; |
| 310 | |
Fabrice Di Meglio | bd9152f | 2013-10-01 11:21:31 -0700 | [diff] [blame] | 311 | // Vibrator pattern for a short vibration when tapping on a day/month/year date of a Calendar. |
| 312 | long[] mCalendarDateVibePattern; |
| 313 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 314 | // Vibrator pattern for haptic feedback during boot when safe mode is disabled. |
| 315 | long[] mSafeModeDisabledVibePattern; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 316 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 317 | // Vibrator pattern for haptic feedback during boot when safe mode is enabled. |
| 318 | long[] mSafeModeEnabledVibePattern; |
Romain Guy | 8154cd3 | 2010-03-29 14:41:15 -0700 | [diff] [blame] | 319 | |
Mady Mellor | e860891 | 2015-06-05 09:02:55 -0700 | [diff] [blame] | 320 | // Vibrator pattern for haptic feedback of a context click. |
| 321 | long[] mContextClickVibePattern; |
Mady Mellor | e82067b | 2015-04-30 09:58:35 -0700 | [diff] [blame] | 322 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 323 | /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */ |
| 324 | boolean mEnableShiftMenuBugReports = false; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 325 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 326 | boolean mSafeMode; |
| 327 | WindowState mStatusBar = null; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 328 | int mStatusBarHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 329 | WindowState mNavigationBar = null; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 330 | boolean mHasNavigationBar = false; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 331 | boolean mCanHideNavigationBar = false; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 332 | boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side? |
| 333 | boolean mNavigationBarOnBottom = true; // is the navigation bar on the bottom *right now*? |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 334 | int[] mNavigationBarHeightForRotationDefault = new int[4]; |
| 335 | int[] mNavigationBarWidthForRotationDefault = new int[4]; |
| 336 | int[] mNavigationBarHeightForRotationInCarMode = new int[4]; |
| 337 | int[] mNavigationBarWidthForRotationInCarMode = new int[4]; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 338 | |
keunyoung | a771049 | 2015-09-23 11:33:58 -0700 | [diff] [blame] | 339 | // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. |
| 340 | // This is for car dock and this is updated from resource. |
| 341 | private boolean mEnableCarDockHomeCapture = true; |
| 342 | |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 343 | boolean mBootMessageNeedsHiding; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 344 | KeyguardServiceDelegate mKeyguardDelegate; |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 345 | final Runnable mWindowManagerDrawCallback = new Runnable() { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 346 | @Override |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 347 | public void run() { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 348 | if (DEBUG_WAKEUP) Slog.i(TAG, "All windows ready for display!"); |
| 349 | mHandler.sendEmptyMessage(MSG_WINDOW_MANAGER_DRAWN_COMPLETE); |
| 350 | } |
| 351 | }; |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 352 | final DrawnListener mKeyguardDrawnCallback = new DrawnListener() { |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 353 | @Override |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 354 | public void onDrawn() { |
| 355 | if (DEBUG_WAKEUP) Slog.d(TAG, "mKeyguardDelegate.ShowListener.onDrawn."); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 356 | mHandler.sendEmptyMessage(MSG_KEYGUARD_DRAWN_COMPLETE); |
| 357 | } |
| 358 | }; |
| 359 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 360 | GlobalActions mGlobalActions; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 361 | Handler mHandler; |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 362 | WindowState mLastInputMethodWindow = null; |
| 363 | WindowState mLastInputMethodTargetWindow = null; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 364 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 365 | // FIXME This state is shared between the input reader and handler thread. |
| 366 | // Technically it's broken and buggy but it has been like this for many years |
| 367 | // and we have not yet seen any problems. Someday we'll rewrite this logic |
| 368 | // so that only one thread is involved in handling input policy. Unfortunately |
| 369 | // it's on a critical path for power management so we can't just post the work to the |
| 370 | // handler thread. We'll need to resolve this someday by teaching the input dispatcher |
| 371 | // to hold wakelocks during dispatch and eliminating the critical path. |
| 372 | volatile boolean mPowerKeyHandled; |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 373 | volatile boolean mBeganFromNonInteractive; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 374 | volatile int mPowerKeyPressCounter; |
| 375 | volatile boolean mEndCallKeyHandled; |
| 376 | |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 377 | boolean mRecentsVisible; |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 378 | int mRecentAppsHeldModifiers; |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 379 | boolean mLanguageSwitchKeyPressed; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 380 | |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 381 | int mLidState = LID_ABSENT; |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 382 | int mCameraLensCoverState = CAMERA_LENS_COVER_ABSENT; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 383 | boolean mHaveBuiltInKeyboard; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 384 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 385 | boolean mSystemReady; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 386 | boolean mSystemBooted; |
Adrian Roos | 3542f7d | 2015-07-13 15:57:53 -0700 | [diff] [blame] | 387 | private boolean mDeferBindKeyguard; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 388 | boolean mHdmiPlugged; |
Jinsuk Kim | e601b71 | 2015-07-07 08:01:02 +0900 | [diff] [blame] | 389 | HdmiControl mHdmiControl; |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 390 | IUiModeManager mUiModeManager; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 391 | int mUiMode; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 392 | int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 393 | int mLidOpenRotation; |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 394 | int mCarDockRotation; |
| 395 | int mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 396 | int mUndockedHdmiRotation; |
| 397 | int mDemoHdmiRotation; |
| 398 | boolean mDemoHdmiRotationLock; |
Chong Zhang | ae6119ff | 2014-11-11 18:54:39 -0800 | [diff] [blame] | 399 | int mDemoRotation; |
| 400 | boolean mDemoRotationLock; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 401 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 402 | boolean mWakeGestureEnabledSetting; |
| 403 | MyWakeGestureListener mWakeGestureListener; |
| 404 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 405 | // Default display does not rotate, apps that require non-default orientation will have to |
| 406 | // have the orientation emulated. |
| 407 | private boolean mForceDefaultOrientation = false; |
| 408 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 409 | int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; |
| 410 | int mUserRotation = Surface.ROTATION_0; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 411 | boolean mAccelerometerDefault; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 412 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 413 | boolean mSupportAutoRotation; |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 414 | int mAllowAllRotations = -1; |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 415 | boolean mCarDockEnablesAccelerometer; |
| 416 | boolean mDeskDockEnablesAccelerometer; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 417 | int mLidKeyboardAccessibility; |
| 418 | int mLidNavigationAccessibility; |
Edward Savage-Jones | 7def60d | 2015-11-13 13:27:03 +0100 | [diff] [blame] | 419 | boolean mLidControlsScreenLock; |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 420 | boolean mLidControlsSleep; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 421 | int mShortPressOnPowerBehavior; |
| 422 | int mLongPressOnPowerBehavior; |
| 423 | int mDoublePressOnPowerBehavior; |
| 424 | int mTriplePressOnPowerBehavior; |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 425 | int mShortPressOnSleepBehavior; |
Jaewan Kim | 4911787 | 2016-01-19 17:24:08 +0900 | [diff] [blame] | 426 | int mShortPressWindowBehavior; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 427 | boolean mAwake; |
| 428 | boolean mScreenOnEarly; |
| 429 | boolean mScreenOnFully; |
| 430 | ScreenOnListener mScreenOnListener; |
| 431 | boolean mKeyguardDrawComplete; |
| 432 | boolean mWindowManagerDrawComplete; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 433 | boolean mOrientationSensorEnabled = false; |
| 434 | int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 435 | boolean mHasSoftInput = false; |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 436 | boolean mTranslucentDecorEnabled = true; |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 437 | boolean mUseTvRouting; |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 438 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 439 | int mPointerLocationMode = 0; // guarded by mLock |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 440 | |
| 441 | // The last window we were told about in focusChanged. |
| 442 | WindowState mFocusedWindow; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 443 | IApplicationToken mFocusedApp; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 444 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 445 | PointerLocationView mPointerLocationView; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 446 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 447 | // The current size of the screen; really; extends into the overscan area of |
| 448 | // the screen and doesn't account for any system elements like the status bar. |
| 449 | int mOverscanScreenLeft, mOverscanScreenTop; |
| 450 | int mOverscanScreenWidth, mOverscanScreenHeight; |
| 451 | // The current visible size of the screen; really; (ir)regardless of whether the status |
| 452 | // bar can be hidden but not extending into the overscan area. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 453 | int mUnrestrictedScreenLeft, mUnrestrictedScreenTop; |
| 454 | int mUnrestrictedScreenWidth, mUnrestrictedScreenHeight; |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 455 | // Like mOverscanScreen*, but allowed to move into the overscan region where appropriate. |
| 456 | int mRestrictedOverscanScreenLeft, mRestrictedOverscanScreenTop; |
| 457 | int mRestrictedOverscanScreenWidth, mRestrictedOverscanScreenHeight; |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 458 | // The current size of the screen; these may be different than (0,0)-(dw,dh) |
| 459 | // if the status bar can't be hidden; in that case it effectively carves out |
| 460 | // that area of the display from all other windows. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 461 | int mRestrictedScreenLeft, mRestrictedScreenTop; |
| 462 | int mRestrictedScreenWidth, mRestrictedScreenHeight; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 463 | // During layout, the current screen borders accounting for any currently |
| 464 | // visible system UI elements. |
| 465 | int mSystemLeft, mSystemTop, mSystemRight, mSystemBottom; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 466 | // For applications requesting stable content insets, these are them. |
| 467 | int mStableLeft, mStableTop, mStableRight, mStableBottom; |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 468 | // For applications requesting stable content insets but have also set the |
| 469 | // fullscreen window flag, these are the stable dimensions without the status bar. |
| 470 | int mStableFullscreenLeft, mStableFullscreenTop; |
| 471 | int mStableFullscreenRight, mStableFullscreenBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 472 | // During layout, the current screen borders with all outer decoration |
| 473 | // (status bar, input method dock) accounted for. |
| 474 | int mCurLeft, mCurTop, mCurRight, mCurBottom; |
| 475 | // During layout, the frame in which content should be displayed |
| 476 | // to the user, accounting for all screen decoration except for any |
| 477 | // space they deem as available for other content. This is usually |
| 478 | // the same as mCur*, but may be larger if the screen decor has supplied |
| 479 | // content insets. |
| 480 | int mContentLeft, mContentTop, mContentRight, mContentBottom; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 481 | // During layout, the frame in which voice content should be displayed |
| 482 | // to the user, accounting for all screen decoration except for any |
| 483 | // space they deem as available for other content. |
| 484 | int mVoiceContentLeft, mVoiceContentTop, mVoiceContentRight, mVoiceContentBottom; |
Dianne Hackborn | 8e11ef0 | 2010-11-18 19:47:42 -0800 | [diff] [blame] | 485 | // 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] | 486 | // windows are placed. |
| 487 | int mDockLeft, mDockTop, mDockRight, mDockBottom; |
| 488 | // During layout, the layer at which the doc window is placed. |
| 489 | int mDockLayer; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 490 | // During layout, this is the layer of the status bar. |
| 491 | int mStatusBarLayer; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 492 | int mLastSystemUiFlags; |
| 493 | // Bits that we are in the process of clearing, so we want to prevent |
| 494 | // them from being set by applications until everything has been updated |
| 495 | // to have them clear. |
| 496 | int mResettingSystemUiFlags = 0; |
| 497 | // Bits that we are currently always keeping cleared. |
| 498 | int mForceClearedSystemUiFlags = 0; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 499 | int mLastFullscreenStackSysUiFlags; |
| 500 | int mLastDockedStackSysUiFlags; |
| 501 | final Rect mNonDockedStackBounds = new Rect(); |
| 502 | final Rect mDockedStackBounds = new Rect(); |
| 503 | final Rect mLastNonDockedStackBounds = new Rect(); |
| 504 | final Rect mLastDockedStackBounds = new Rect(); |
| 505 | |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 506 | // What we last reported to system UI about whether the compatibility |
| 507 | // menu needs to be displayed. |
| 508 | boolean mLastFocusNeedsMenu = false; |
Adrian Roos | ddc8b27 | 2015-05-21 16:28:27 -0700 | [diff] [blame] | 509 | // If nonzero, a panic gesture was performed at that time in uptime millis and is still pending. |
| 510 | private long mPendingPanicGestureUptime; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 511 | |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 512 | InputConsumer mInputConsumer = null; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 513 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 514 | static final Rect mTmpParentFrame = new Rect(); |
| 515 | static final Rect mTmpDisplayFrame = new Rect(); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 516 | static final Rect mTmpOverscanFrame = new Rect(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 517 | static final Rect mTmpContentFrame = new Rect(); |
| 518 | static final Rect mTmpVisibleFrame = new Rect(); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 519 | static final Rect mTmpDecorFrame = new Rect(); |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 520 | static final Rect mTmpStableFrame = new Rect(); |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 521 | static final Rect mTmpNavigationFrame = new Rect(); |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 522 | static final Rect mTmpOutsetFrame = new Rect(); |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 523 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 524 | WindowState mTopFullscreenOpaqueWindowState; |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 525 | WindowState mTopFullscreenOpaqueOrDimmingWindowState; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 526 | WindowState mTopDockedOpaqueWindowState; |
| 527 | WindowState mTopDockedOpaqueOrDimmingWindowState; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 528 | HashSet<IApplicationToken> mAppsToBeHidden = new HashSet<IApplicationToken>(); |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 529 | HashSet<IApplicationToken> mAppsThatDismissKeyguard = new HashSet<IApplicationToken>(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 530 | boolean mTopIsFullscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 531 | boolean mForceStatusBar; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 532 | boolean mForceStatusBarFromKeyguard; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 533 | private boolean mForceStatusBarTransparent; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 534 | boolean mHideLockScreen; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 535 | boolean mForcingShowNavBar; |
| 536 | int mForcingShowNavBarLayer; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 537 | |
| 538 | // States of keyguard dismiss. |
| 539 | private static final int DISMISS_KEYGUARD_NONE = 0; // Keyguard not being dismissed. |
| 540 | private static final int DISMISS_KEYGUARD_START = 1; // Keyguard needs to be dismissed. |
| 541 | private static final int DISMISS_KEYGUARD_CONTINUE = 2; // Keyguard has been dismissed. |
| 542 | int mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
| 543 | |
| 544 | /** The window that is currently dismissing the keyguard. Dismissing the keyguard must only |
| 545 | * be done once per window. */ |
| 546 | private WindowState mWinDismissingKeyguard; |
| 547 | |
tingna_sung | e785ffa | 2015-05-12 13:23:15 +0800 | [diff] [blame] | 548 | /** When window is currently dismissing the keyguard, dismissing the keyguard must handle |
| 549 | * the keygaurd secure state change instantly case, e.g. the use case of inserting a PIN |
| 550 | * lock SIM card. This variable is used to record the previous keyguard secure state for |
| 551 | * monitoring secure state change on window dismissing keyguard. */ |
| 552 | private boolean mSecureDismissingKeyguard; |
| 553 | |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 554 | /** The window that is currently showing "over" the keyguard. If there is an app window |
| 555 | * belonging to another app on top of this the keyguard shows. If there is a fullscreen |
| 556 | * app window under this, still dismiss the keyguard but don't show the app underneath. Show |
| 557 | * the wallpaper. */ |
| 558 | private WindowState mWinShowWhenLocked; |
| 559 | |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 560 | boolean mShowingLockscreen; |
| 561 | boolean mShowingDream; |
| 562 | boolean mDreamingLockscreen; |
Jeff Brown | 061ea99 | 2015-04-17 19:55:47 -0700 | [diff] [blame] | 563 | boolean mDreamingSleepTokenNeeded; |
| 564 | SleepToken mDreamingSleepToken; |
Jeff Brown | 48d1b14 | 2015-06-10 16:36:03 -0700 | [diff] [blame] | 565 | SleepToken mScreenOffSleepToken; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 566 | boolean mKeyguardSecure; |
| 567 | boolean mKeyguardSecureIncludingHidden; |
| 568 | volatile boolean mKeyguardOccluded; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 569 | boolean mHomePressed; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 570 | boolean mHomeConsumed; |
| 571 | boolean mHomeDoubleTapPending; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 572 | Intent mHomeIntent; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 573 | Intent mCarDockIntent; |
| 574 | Intent mDeskDockIntent; |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 575 | boolean mSearchKeyShortcutPending; |
| 576 | boolean mConsumeSearchKeyUp; |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 577 | boolean mAssistKeyLongPressed; |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 578 | boolean mPendingMetaAction; |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 579 | boolean mForceShowSystemBars; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 580 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 581 | // support for activating the lock screen while the screen is on |
| 582 | boolean mAllowLockscreenWhenOn; |
| 583 | int mLockScreenTimeout; |
| 584 | boolean mLockScreenTimerActive; |
| 585 | |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 586 | // 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] | 587 | int mEndcallBehavior; |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 588 | |
| 589 | // Behavior of POWER button while in-call and screen on. |
| 590 | // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) |
| 591 | int mIncallPowerBehavior; |
| 592 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 593 | Display mDisplay; |
| 594 | |
Filip Gruszczynski | 2987f61 | 2015-06-30 15:03:30 -0700 | [diff] [blame] | 595 | private int mDisplayRotation; |
| 596 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 597 | int mLandscapeRotation = 0; // default landscape rotation |
| 598 | int mSeascapeRotation = 0; // "other" landscape rotation, 180 degrees from mLandscapeRotation |
| 599 | int mPortraitRotation = 0; // default portrait rotation |
| 600 | int mUpsideDownRotation = 0; // "other" portrait rotation |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 601 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 602 | int mOverscanLeft = 0; |
| 603 | int mOverscanTop = 0; |
| 604 | int mOverscanRight = 0; |
| 605 | int mOverscanBottom = 0; |
| 606 | |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 607 | // What we do when the user long presses on home |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 608 | private int mLongPressOnHomeBehavior; |
| 609 | |
| 610 | // What we do when the user double-taps on home |
| 611 | private int mDoubleTapOnHomeBehavior; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 612 | |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 613 | // Allowed theater mode wake actions |
| 614 | private boolean mAllowTheaterModeWakeFromKey; |
| 615 | private boolean mAllowTheaterModeWakeFromPowerKey; |
| 616 | private boolean mAllowTheaterModeWakeFromMotion; |
Bryce Lee | 812d702 | 2014-11-10 13:33:28 -0800 | [diff] [blame] | 617 | private boolean mAllowTheaterModeWakeFromMotionWhenNotDreaming; |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 618 | private boolean mAllowTheaterModeWakeFromCameraLens; |
| 619 | private boolean mAllowTheaterModeWakeFromLidSwitch; |
| 620 | private boolean mAllowTheaterModeWakeFromWakeGesture; |
| 621 | |
Bryce Lee | d3b2840 | 2015-03-09 15:49:13 +0000 | [diff] [blame] | 622 | // Whether to support long press from power button in non-interactive mode |
| 623 | private boolean mSupportLongPressPowerWhenNonInteractive; |
| 624 | |
Bryce Lee | 55e846d | 2014-11-04 12:43:44 -0800 | [diff] [blame] | 625 | // Whether to go to sleep entering theater mode from power button |
| 626 | private boolean mGoToSleepOnButtonPressTheaterMode; |
| 627 | |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 628 | // Screenshot trigger states |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 629 | // Time to volume and power must be pressed within this interval of each other. |
| 630 | private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150; |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 631 | // Increase the chord delay when taking a screenshot from the keyguard |
| 632 | private static final float KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER = 2.5f; |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 633 | private boolean mScreenshotChordEnabled; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 634 | private boolean mScreenshotChordVolumeDownKeyTriggered; |
| 635 | private long mScreenshotChordVolumeDownKeyTime; |
| 636 | private boolean mScreenshotChordVolumeDownKeyConsumed; |
| 637 | private boolean mScreenshotChordVolumeUpKeyTriggered; |
| 638 | private boolean mScreenshotChordPowerKeyTriggered; |
| 639 | private long mScreenshotChordPowerKeyTime; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 640 | |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 641 | /* The number of steps between min and max brightness */ |
| 642 | private static final int BRIGHTNESS_STEPS = 10; |
| 643 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 644 | SettingsObserver mSettingsObserver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 645 | ShortcutManager mShortcutManager; |
| 646 | PowerManager.WakeLock mBroadcastWakeLock; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 647 | PowerManager.WakeLock mPowerKeyWakeLock; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 648 | boolean mHavePendingMediaKeyRepeatWithWakeLock; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 649 | |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 650 | private int mCurrentUserId; |
| 651 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 652 | // Maps global key codes to the components that will handle them. |
| 653 | private GlobalKeyManager mGlobalKeyManager; |
| 654 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 655 | // Fallback actions by key code. |
| 656 | private final SparseArray<KeyCharacterMap.FallbackAction> mFallbackActions = |
| 657 | new SparseArray<KeyCharacterMap.FallbackAction>(); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 658 | |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 659 | private final LogDecelerateInterpolator mLogDecelerateInterpolator |
| 660 | = new LogDecelerateInterpolator(100, 0); |
| 661 | |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 662 | private boolean mForceWindowDrawsStatusBarBackground; |
| 663 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 664 | private static final int MSG_ENABLE_POINTER_LOCATION = 1; |
| 665 | private static final int MSG_DISABLE_POINTER_LOCATION = 2; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 666 | private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; |
| 667 | 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] | 668 | private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5; |
| 669 | private static final int MSG_KEYGUARD_DRAWN_TIMEOUT = 6; |
| 670 | private static final int MSG_WINDOW_MANAGER_DRAWN_COMPLETE = 7; |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 671 | private static final int MSG_DISPATCH_SHOW_RECENTS = 9; |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 672 | private static final int MSG_DISPATCH_SHOW_GLOBAL_ACTIONS = 10; |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 673 | private static final int MSG_HIDE_BOOT_MESSAGE = 11; |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 674 | private static final int MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK = 12; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 675 | private static final int MSG_POWER_DELAYED_PRESS = 13; |
| 676 | private static final int MSG_POWER_LONG_PRESS = 14; |
Jeff Brown | 061ea99 | 2015-04-17 19:55:47 -0700 | [diff] [blame] | 677 | private static final int MSG_UPDATE_DREAMING_SLEEP_TOKEN = 15; |
Jun Mukai | d2e7e35 | 2015-07-22 17:14:02 -0700 | [diff] [blame] | 678 | private static final int MSG_REQUEST_TRANSIENT_BARS = 16; |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 679 | private static final int MSG_REQUEST_TV_PICTURE_IN_PICTURE = 17; |
Jun Mukai | d2e7e35 | 2015-07-22 17:14:02 -0700 | [diff] [blame] | 680 | |
| 681 | private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS = 0; |
| 682 | private static final int MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION = 1; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 683 | |
| 684 | private class PolicyHandler extends Handler { |
| 685 | @Override |
| 686 | public void handleMessage(Message msg) { |
| 687 | switch (msg.what) { |
| 688 | case MSG_ENABLE_POINTER_LOCATION: |
| 689 | enablePointerLocation(); |
| 690 | break; |
| 691 | case MSG_DISABLE_POINTER_LOCATION: |
| 692 | disablePointerLocation(); |
| 693 | break; |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 694 | case MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK: |
| 695 | dispatchMediaKeyWithWakeLock((KeyEvent)msg.obj); |
| 696 | break; |
| 697 | case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK: |
| 698 | dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj); |
| 699 | break; |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 700 | case MSG_DISPATCH_SHOW_RECENTS: |
| 701 | showRecentApps(false); |
| 702 | break; |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 703 | case MSG_DISPATCH_SHOW_GLOBAL_ACTIONS: |
| 704 | showGlobalActionsInternal(); |
| 705 | break; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 706 | case MSG_KEYGUARD_DRAWN_COMPLETE: |
| 707 | if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mKeyguardDrawComplete"); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 708 | finishKeyguardDrawn(); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 709 | break; |
| 710 | case MSG_KEYGUARD_DRAWN_TIMEOUT: |
| 711 | Slog.w(TAG, "Keyguard drawn timeout. Setting mKeyguardDrawComplete"); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 712 | finishKeyguardDrawn(); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 713 | break; |
| 714 | case MSG_WINDOW_MANAGER_DRAWN_COMPLETE: |
| 715 | if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mWindowManagerDrawComplete"); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 716 | finishWindowsDrawn(); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 717 | break; |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 718 | case MSG_HIDE_BOOT_MESSAGE: |
| 719 | handleHideBootMessage(); |
| 720 | break; |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 721 | case MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK: |
| 722 | launchVoiceAssistWithWakeLock(msg.arg1 != 0); |
| 723 | break; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 724 | case MSG_POWER_DELAYED_PRESS: |
| 725 | powerPress((Long)msg.obj, msg.arg1 != 0, msg.arg2); |
| 726 | finishPowerKeyPress(); |
| 727 | break; |
| 728 | case MSG_POWER_LONG_PRESS: |
| 729 | powerLongPress(); |
| 730 | break; |
Jeff Brown | 061ea99 | 2015-04-17 19:55:47 -0700 | [diff] [blame] | 731 | case MSG_UPDATE_DREAMING_SLEEP_TOKEN: |
| 732 | updateDreamingSleepToken(msg.arg1 != 0); |
| 733 | break; |
Jun Mukai | d2e7e35 | 2015-07-22 17:14:02 -0700 | [diff] [blame] | 734 | case MSG_REQUEST_TRANSIENT_BARS: |
| 735 | WindowState targetBar = (msg.arg1 == MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS) ? |
| 736 | mStatusBar : mNavigationBar; |
| 737 | if (targetBar != null) { |
| 738 | requestTransientBars(targetBar); |
| 739 | } |
| 740 | break; |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 741 | case MSG_REQUEST_TV_PICTURE_IN_PICTURE: |
| 742 | requestTvPictureInPictureInternal(); |
| 743 | break; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 744 | } |
| 745 | } |
| 746 | } |
| 747 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 748 | private UEventObserver mHDMIObserver = new UEventObserver() { |
| 749 | @Override |
| 750 | public void onUEvent(UEventObserver.UEvent event) { |
| 751 | setHdmiPlugged("1".equals(event.get("SWITCH_STATE"))); |
| 752 | } |
| 753 | }; |
| 754 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 755 | class SettingsObserver extends ContentObserver { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 756 | SettingsObserver(Handler handler) { |
| 757 | super(handler); |
| 758 | } |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 759 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 760 | void observe() { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 761 | // Observe all users' changes |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 762 | ContentResolver resolver = mContext.getContentResolver(); |
| 763 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 764 | Settings.System.END_BUTTON_BEHAVIOR), false, this, |
| 765 | UserHandle.USER_ALL); |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 766 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 767 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this, |
| 768 | UserHandle.USER_ALL); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 769 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
| 770 | Settings.Secure.WAKE_GESTURE_ENABLED), false, this, |
| 771 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 772 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 773 | Settings.System.ACCELEROMETER_ROTATION), false, this, |
| 774 | UserHandle.USER_ALL); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 775 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 776 | Settings.System.USER_ROTATION), false, this, |
| 777 | UserHandle.USER_ALL); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 778 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 779 | Settings.System.SCREEN_OFF_TIMEOUT), false, this, |
| 780 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 781 | resolver.registerContentObserver(Settings.System.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 782 | Settings.System.POINTER_LOCATION), false, this, |
| 783 | UserHandle.USER_ALL); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 784 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 785 | Settings.Secure.DEFAULT_INPUT_METHOD), false, this, |
| 786 | UserHandle.USER_ALL); |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 787 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 788 | Settings.Secure.IMMERSIVE_MODE_CONFIRMATIONS), false, this, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 789 | UserHandle.USER_ALL); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 790 | resolver.registerContentObserver(Settings.Global.getUriFor( |
| 791 | Settings.Global.POLICY_CONTROL), false, this, |
| 792 | UserHandle.USER_ALL); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 793 | updateSettings(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | @Override public void onChange(boolean selfChange) { |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 797 | updateSettings(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 798 | updateRotation(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 799 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 800 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 801 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 802 | class MyWakeGestureListener extends WakeGestureListener { |
| 803 | MyWakeGestureListener(Context context, Handler handler) { |
| 804 | super(context, handler); |
| 805 | } |
| 806 | |
| 807 | @Override |
| 808 | public void onWakeUp() { |
| 809 | synchronized (mLock) { |
| 810 | if (shouldEnableWakeGestureLp()) { |
Jeff Brown | e07b94b | 2014-06-18 15:56:27 -0700 | [diff] [blame] | 811 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 812 | wakeUp(SystemClock.uptimeMillis(), mAllowTheaterModeWakeFromWakeGesture, |
| 813 | "android.policy:GESTURE"); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 814 | } |
| 815 | } |
| 816 | } |
| 817 | } |
| 818 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 819 | class MyOrientationListener extends WindowOrientationListener { |
Chong Zhang | 5aaa0b3 | 2015-08-28 10:22:36 -0700 | [diff] [blame] | 820 | private final Runnable mUpdateRotationRunnable = new Runnable() { |
| 821 | @Override |
| 822 | public void run() { |
Tim Murray | 1f40764 | 2015-10-01 17:07:12 -0700 | [diff] [blame] | 823 | // send interaction hint to improve redraw performance |
| 824 | mPowerManagerInternal.powerHint(PowerManagerInternal.POWER_HINT_INTERACTION, 0); |
Chong Zhang | 5aaa0b3 | 2015-08-28 10:22:36 -0700 | [diff] [blame] | 825 | updateRotation(false); |
| 826 | } |
| 827 | }; |
| 828 | |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 829 | MyOrientationListener(Context context, Handler handler) { |
| 830 | super(context, handler); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 831 | } |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 832 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 833 | @Override |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 834 | public void onProposedRotationChanged(int rotation) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 835 | if (localLOGV) Slog.v(TAG, "onProposedRotationChanged, rotation=" + rotation); |
Chong Zhang | 5aaa0b3 | 2015-08-28 10:22:36 -0700 | [diff] [blame] | 836 | mHandler.post(mUpdateRotationRunnable); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 837 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 838 | } |
| 839 | MyOrientationListener mOrientationListener; |
| 840 | |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 841 | private final StatusBarController mStatusBarController = new StatusBarController(); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 842 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 843 | private final BarController mNavigationBarController = new BarController("NavigationBar", |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 844 | View.NAVIGATION_BAR_TRANSIENT, |
| 845 | View.NAVIGATION_BAR_UNHIDE, |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 846 | View.NAVIGATION_BAR_TRANSLUCENT, |
| 847 | StatusBarManager.WINDOW_NAVIGATION_BAR, |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 848 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, |
| 849 | View.NAVIGATION_BAR_TRANSPARENT); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 850 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 851 | private ImmersiveModeConfirmation mImmersiveModeConfirmation; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 852 | |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 853 | private SystemGesturesPointerEventListener mSystemGestures; |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 854 | |
Dianne Hackborn | 42e620c | 2012-06-24 13:20:51 -0700 | [diff] [blame] | 855 | IStatusBarService getStatusBarService() { |
| 856 | synchronized (mServiceAquireLock) { |
| 857 | if (mStatusBarService == null) { |
| 858 | mStatusBarService = IStatusBarService.Stub.asInterface( |
| 859 | ServiceManager.getService("statusbar")); |
| 860 | } |
| 861 | return mStatusBarService; |
| 862 | } |
| 863 | } |
| 864 | |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 865 | StatusBarManagerInternal getStatusBarManagerInternal() { |
| 866 | synchronized (mServiceAquireLock) { |
| 867 | if (mStatusBarManagerInternal == null) { |
| 868 | mStatusBarManagerInternal = |
| 869 | LocalServices.getService(StatusBarManagerInternal.class); |
| 870 | } |
| 871 | return mStatusBarManagerInternal; |
| 872 | } |
| 873 | } |
| 874 | |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 875 | /* |
| 876 | * We always let the sensor be switched on by default except when |
| 877 | * the user has explicitly disabled sensor based rotation or when the |
| 878 | * screen is switched off. |
| 879 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 880 | boolean needSensorRunningLp() { |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 881 | if (mSupportAutoRotation) { |
| 882 | if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 883 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 884 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT |
| 885 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { |
| 886 | // If the application has explicitly requested to follow the |
| 887 | // orientation, then we need to turn the sensor on. |
| 888 | return true; |
| 889 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 890 | } |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 891 | if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 892 | (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 893 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 894 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK))) { |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 895 | // enable accelerometer if we are docked in a dock that enables accelerometer |
| 896 | // orientation management, |
| 897 | return true; |
| 898 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 899 | if (mUserRotationMode == USER_ROTATION_LOCKED) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 900 | // If the setting for using the sensor by default is enabled, then |
| 901 | // we will always leave it on. Note that the user could go to |
| 902 | // a window that forces an orientation that does not use the |
| 903 | // sensor and in theory we could turn it off... however, when next |
| 904 | // turning it on we won't have a good value for the current |
| 905 | // orientation for a little bit, which can cause orientation |
| 906 | // changes to lag, so we'd like to keep it always on. (It will |
| 907 | // still be turned off when the screen is off.) |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 908 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 909 | } |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 910 | return mSupportAutoRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 911 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 912 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 913 | /* |
| 914 | * Various use cases for invoking this function |
| 915 | * screen turning off, should always disable listeners if already enabled |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 916 | * 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] | 917 | * if not already enabled |
| 918 | * screen turned on and current app does not have sensor orientation, disable listeners if |
| 919 | * already enabled |
| 920 | * screen turning on and current app has sensor based orientation, enable listeners if needed |
| 921 | * screen turning on and current app has nosensor based orientation, do nothing |
| 922 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 923 | void updateOrientationListenerLp() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 924 | if (!mOrientationListener.canDetectOrientation()) { |
| 925 | // If sensor is turned off or nonexistent for some reason |
| 926 | return; |
| 927 | } |
Stefan Kuhne | 9326dc1 | 2015-06-12 09:25:32 -1000 | [diff] [blame] | 928 | // Could have been invoked due to screen turning on or off or |
| 929 | // change of the currently visible window's orientation. |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 930 | if (localLOGV) Slog.v(TAG, "mScreenOnEarly=" + mScreenOnEarly |
| 931 | + ", mAwake=" + mAwake + ", mCurrentAppOrientation=" + mCurrentAppOrientation |
Stefan Kuhne | 9326dc1 | 2015-06-12 09:25:32 -1000 | [diff] [blame] | 932 | + ", mOrientationSensorEnabled=" + mOrientationSensorEnabled |
| 933 | + ", mKeyguardDrawComplete=" + mKeyguardDrawComplete |
| 934 | + ", mWindowManagerDrawComplete=" + mWindowManagerDrawComplete); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 935 | boolean disable = true; |
Stefan Kuhne | 9326dc1 | 2015-06-12 09:25:32 -1000 | [diff] [blame] | 936 | // Note: We postpone the rotating of the screen until the keyguard as well as the |
| 937 | // window manager have reported a draw complete. |
| 938 | if (mScreenOnEarly && mAwake && |
| 939 | mKeyguardDrawComplete && mWindowManagerDrawComplete) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 940 | if (needSensorRunningLp()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 941 | disable = false; |
| 942 | //enable listener if not already enabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 943 | if (!mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 944 | mOrientationListener.enable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 945 | if(localLOGV) Slog.v(TAG, "Enabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 946 | mOrientationSensorEnabled = true; |
| 947 | } |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 948 | } |
| 949 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 950 | //check if sensors need to be disabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 951 | if (disable && mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 952 | mOrientationListener.disable(); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 953 | if(localLOGV) Slog.v(TAG, "Disabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 954 | mOrientationSensorEnabled = false; |
| 955 | } |
| 956 | } |
| 957 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 958 | private void interceptPowerKeyDown(KeyEvent event, boolean interactive) { |
| 959 | // Hold a wake lock until the power key is released. |
| 960 | if (!mPowerKeyWakeLock.isHeld()) { |
| 961 | mPowerKeyWakeLock.acquire(); |
| 962 | } |
| 963 | |
| 964 | // Cancel multi-press detection timeout. |
| 965 | if (mPowerKeyPressCounter != 0) { |
| 966 | mHandler.removeMessages(MSG_POWER_DELAYED_PRESS); |
| 967 | } |
| 968 | |
| 969 | // Detect user pressing the power button in panic when an application has |
| 970 | // taken over the whole screen. |
| 971 | boolean panic = mImmersiveModeConfirmation.onPowerKeyDown(interactive, |
Craig Mautner | 0124980e9 | 2014-11-30 21:15:34 -0800 | [diff] [blame] | 972 | SystemClock.elapsedRealtime(), isImmersiveMode(mLastSystemUiFlags)); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 973 | if (panic) { |
Adrian Roos | ddc8b27 | 2015-05-21 16:28:27 -0700 | [diff] [blame] | 974 | mHandler.post(mHiddenNavPanic); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 975 | } |
| 976 | |
| 977 | // Latch power key state to detect screenshot chord. |
| 978 | if (interactive && !mScreenshotChordPowerKeyTriggered |
| 979 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 980 | mScreenshotChordPowerKeyTriggered = true; |
| 981 | mScreenshotChordPowerKeyTime = event.getDownTime(); |
| 982 | interceptScreenshotChord(); |
| 983 | } |
| 984 | |
| 985 | // Stop ringing or end call if configured to do so when power is pressed. |
| 986 | TelecomManager telecomManager = getTelecommService(); |
| 987 | boolean hungUp = false; |
| 988 | if (telecomManager != null) { |
| 989 | if (telecomManager.isRinging()) { |
| 990 | // Pressing Power while there's a ringing incoming |
| 991 | // call should silence the ringer. |
| 992 | telecomManager.silenceRinger(); |
| 993 | } else if ((mIncallPowerBehavior |
| 994 | & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 |
| 995 | && telecomManager.isInCall() && interactive) { |
| 996 | // Otherwise, if "Power button ends call" is enabled, |
| 997 | // the Power button will hang up any current active call. |
| 998 | hungUp = telecomManager.endCall(); |
| 999 | } |
| 1000 | } |
| 1001 | |
Adrian Roos | 5941c98 | 2015-09-03 15:59:49 -0700 | [diff] [blame] | 1002 | GestureLauncherService gestureService = LocalServices.getService( |
| 1003 | GestureLauncherService.class); |
| 1004 | boolean gesturedServiceIntercepted = false; |
| 1005 | if (gestureService != null) { |
| 1006 | gesturedServiceIntercepted = gestureService.interceptPowerKeyDown(event, interactive); |
| 1007 | } |
| 1008 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1009 | // If the power key has still not yet been handled, then detect short |
| 1010 | // press, long press, or multi press and decide what to do. |
| 1011 | mPowerKeyHandled = hungUp || mScreenshotChordVolumeDownKeyTriggered |
Adrian Roos | 5941c98 | 2015-09-03 15:59:49 -0700 | [diff] [blame] | 1012 | || mScreenshotChordVolumeUpKeyTriggered || gesturedServiceIntercepted; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1013 | if (!mPowerKeyHandled) { |
| 1014 | if (interactive) { |
| 1015 | // When interactive, we're already awake. |
| 1016 | // Wait for a long press or for the button to be released to decide what to do. |
| 1017 | if (hasLongPressOnPowerBehavior()) { |
| 1018 | Message msg = mHandler.obtainMessage(MSG_POWER_LONG_PRESS); |
| 1019 | msg.setAsynchronous(true); |
| 1020 | mHandler.sendMessageDelayed(msg, |
| 1021 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
| 1022 | } |
| 1023 | } else { |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 1024 | wakeUpFromPowerKey(event.getDownTime()); |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 1025 | |
Bryce Lee | d3b2840 | 2015-03-09 15:49:13 +0000 | [diff] [blame] | 1026 | if (mSupportLongPressPowerWhenNonInteractive && hasLongPressOnPowerBehavior()) { |
| 1027 | Message msg = mHandler.obtainMessage(MSG_POWER_LONG_PRESS); |
| 1028 | msg.setAsynchronous(true); |
| 1029 | mHandler.sendMessageDelayed(msg, |
| 1030 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 1031 | mBeganFromNonInteractive = true; |
Bryce Lee | d3b2840 | 2015-03-09 15:49:13 +0000 | [diff] [blame] | 1032 | } else { |
| 1033 | final int maxCount = getMaxMultiPressPowerCount(); |
| 1034 | |
| 1035 | if (maxCount <= 1) { |
| 1036 | mPowerKeyHandled = true; |
| 1037 | } else { |
| 1038 | mBeganFromNonInteractive = true; |
| 1039 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1040 | } |
| 1041 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1042 | } |
| 1043 | } |
| 1044 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1045 | private void interceptPowerKeyUp(KeyEvent event, boolean interactive, boolean canceled) { |
| 1046 | final boolean handled = canceled || mPowerKeyHandled; |
| 1047 | mScreenshotChordPowerKeyTriggered = false; |
| 1048 | cancelPendingScreenshotChordAction(); |
| 1049 | cancelPendingPowerKeyAction(); |
| 1050 | |
| 1051 | if (!handled) { |
| 1052 | // Figure out how to handle the key now that it has been released. |
| 1053 | mPowerKeyPressCounter += 1; |
| 1054 | |
| 1055 | final int maxCount = getMaxMultiPressPowerCount(); |
| 1056 | final long eventTime = event.getDownTime(); |
| 1057 | if (mPowerKeyPressCounter < maxCount) { |
| 1058 | // This could be a multi-press. Wait a little bit longer to confirm. |
| 1059 | // Continue holding the wake lock. |
| 1060 | Message msg = mHandler.obtainMessage(MSG_POWER_DELAYED_PRESS, |
| 1061 | interactive ? 1 : 0, mPowerKeyPressCounter, eventTime); |
| 1062 | msg.setAsynchronous(true); |
| 1063 | mHandler.sendMessageDelayed(msg, ViewConfiguration.getDoubleTapTimeout()); |
| 1064 | return; |
| 1065 | } |
| 1066 | |
| 1067 | // No other actions. Handle it immediately. |
| 1068 | powerPress(eventTime, interactive, mPowerKeyPressCounter); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1069 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1070 | |
| 1071 | // Done. Reset our state. |
| 1072 | finishPowerKeyPress(); |
| 1073 | } |
| 1074 | |
| 1075 | private void finishPowerKeyPress() { |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 1076 | mBeganFromNonInteractive = false; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1077 | mPowerKeyPressCounter = 0; |
| 1078 | if (mPowerKeyWakeLock.isHeld()) { |
| 1079 | mPowerKeyWakeLock.release(); |
| 1080 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1081 | } |
| 1082 | |
| 1083 | private void cancelPendingPowerKeyAction() { |
| 1084 | if (!mPowerKeyHandled) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1085 | mPowerKeyHandled = true; |
| 1086 | mHandler.removeMessages(MSG_POWER_LONG_PRESS); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1087 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | private void powerPress(long eventTime, boolean interactive, int count) { |
| 1091 | if (mScreenOnEarly && !mScreenOnFully) { |
| 1092 | Slog.i(TAG, "Suppressed redundant power key press while " |
| 1093 | + "already in the process of turning the screen on."); |
| 1094 | return; |
Jeff Brown | ff20471 | 2011-10-25 21:27:54 -0700 | [diff] [blame] | 1095 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1096 | |
| 1097 | if (count == 2) { |
| 1098 | powerMultiPressAction(eventTime, interactive, mDoublePressOnPowerBehavior); |
| 1099 | } else if (count == 3) { |
| 1100 | powerMultiPressAction(eventTime, interactive, mTriplePressOnPowerBehavior); |
Bryce Lee | d9268e3 | 2014-11-17 17:40:59 -0800 | [diff] [blame] | 1101 | } else if (interactive && !mBeganFromNonInteractive) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1102 | switch (mShortPressOnPowerBehavior) { |
| 1103 | case SHORT_PRESS_POWER_NOTHING: |
| 1104 | break; |
| 1105 | case SHORT_PRESS_POWER_GO_TO_SLEEP: |
| 1106 | mPowerManager.goToSleep(eventTime, |
| 1107 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); |
| 1108 | break; |
| 1109 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP: |
| 1110 | mPowerManager.goToSleep(eventTime, |
| 1111 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, |
| 1112 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 1113 | break; |
| 1114 | case SHORT_PRESS_POWER_REALLY_GO_TO_SLEEP_AND_GO_HOME: |
| 1115 | mPowerManager.goToSleep(eventTime, |
| 1116 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, |
| 1117 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
| 1118 | launchHomeFromHotKey(); |
| 1119 | break; |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 1120 | case SHORT_PRESS_POWER_GO_HOME: |
Bryce Lee | 662ed80 | 2015-04-10 20:11:39 +0000 | [diff] [blame] | 1121 | launchHomeFromHotKey(true /* awakenFromDreams */, false /*respectKeyguard*/); |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 1122 | break; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1123 | } |
| 1124 | } |
| 1125 | } |
| 1126 | |
| 1127 | private void powerMultiPressAction(long eventTime, boolean interactive, int behavior) { |
| 1128 | switch (behavior) { |
| 1129 | case MULTI_PRESS_POWER_NOTHING: |
| 1130 | break; |
| 1131 | case MULTI_PRESS_POWER_THEATER_MODE: |
Bryce Lee | 3ae447e | 2015-06-30 12:31:41 -0700 | [diff] [blame] | 1132 | if (!isUserSetupComplete()) { |
| 1133 | Slog.i(TAG, "Ignoring toggling theater mode - device not setup."); |
| 1134 | break; |
| 1135 | } |
| 1136 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1137 | if (isTheaterModeEnabled()) { |
| 1138 | Slog.i(TAG, "Toggling theater mode off."); |
| 1139 | Settings.Global.putInt(mContext.getContentResolver(), |
| 1140 | Settings.Global.THEATER_MODE_ON, 0); |
| 1141 | if (!interactive) { |
| 1142 | wakeUpFromPowerKey(eventTime); |
| 1143 | } |
| 1144 | } else { |
| 1145 | Slog.i(TAG, "Toggling theater mode on."); |
| 1146 | Settings.Global.putInt(mContext.getContentResolver(), |
| 1147 | Settings.Global.THEATER_MODE_ON, 1); |
Bryce Lee | 55e846d | 2014-11-04 12:43:44 -0800 | [diff] [blame] | 1148 | |
| 1149 | if (mGoToSleepOnButtonPressTheaterMode && interactive) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1150 | mPowerManager.goToSleep(eventTime, |
| 1151 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); |
| 1152 | } |
| 1153 | } |
| 1154 | break; |
| 1155 | case MULTI_PRESS_POWER_BRIGHTNESS_BOOST: |
Jeff Brown | 7b5be5e | 2014-11-12 18:45:31 -0800 | [diff] [blame] | 1156 | Slog.i(TAG, "Starting brightness boost."); |
| 1157 | if (!interactive) { |
| 1158 | wakeUpFromPowerKey(eventTime); |
| 1159 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1160 | mPowerManager.boostScreenBrightness(eventTime); |
| 1161 | break; |
| 1162 | } |
| 1163 | } |
| 1164 | |
| 1165 | private int getMaxMultiPressPowerCount() { |
| 1166 | if (mTriplePressOnPowerBehavior != MULTI_PRESS_POWER_NOTHING) { |
| 1167 | return 3; |
| 1168 | } |
| 1169 | if (mDoublePressOnPowerBehavior != MULTI_PRESS_POWER_NOTHING) { |
| 1170 | return 2; |
| 1171 | } |
| 1172 | return 1; |
| 1173 | } |
| 1174 | |
| 1175 | private void powerLongPress() { |
| 1176 | final int behavior = getResolvedLongPressOnPowerBehavior(); |
| 1177 | switch (behavior) { |
| 1178 | case LONG_PRESS_POWER_NOTHING: |
| 1179 | break; |
| 1180 | case LONG_PRESS_POWER_GLOBAL_ACTIONS: |
| 1181 | mPowerKeyHandled = true; |
| 1182 | if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) { |
| 1183 | performAuditoryFeedbackForAccessibilityIfNeed(); |
| 1184 | } |
| 1185 | showGlobalActionsInternal(); |
| 1186 | break; |
| 1187 | case LONG_PRESS_POWER_SHUT_OFF: |
| 1188 | case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM: |
| 1189 | mPowerKeyHandled = true; |
| 1190 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 1191 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
| 1192 | mWindowManagerFuncs.shutdown(behavior == LONG_PRESS_POWER_SHUT_OFF); |
| 1193 | break; |
| 1194 | } |
| 1195 | } |
| 1196 | |
Nick Vaccaro | b593a81 | 2015-05-15 11:23:05 -0700 | [diff] [blame] | 1197 | private void sleepPress(long eventTime) { |
| 1198 | if (mShortPressOnSleepBehavior == SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME) { |
| 1199 | launchHomeFromHotKey(false /* awakenDreams */, true /*respectKeyguard*/); |
| 1200 | } |
| 1201 | } |
| 1202 | |
| 1203 | private void sleepRelease(long eventTime) { |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 1204 | switch (mShortPressOnSleepBehavior) { |
| 1205 | case SHORT_PRESS_SLEEP_GO_TO_SLEEP: |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 1206 | case SHORT_PRESS_SLEEP_GO_TO_SLEEP_AND_GO_HOME: |
Nick Vaccaro | b593a81 | 2015-05-15 11:23:05 -0700 | [diff] [blame] | 1207 | Slog.i(TAG, "sleepRelease() calling goToSleep(GO_TO_SLEEP_REASON_SLEEP_BUTTON)"); |
| 1208 | mPowerManager.goToSleep(eventTime, |
| 1209 | PowerManager.GO_TO_SLEEP_REASON_SLEEP_BUTTON, 0); |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 1210 | break; |
| 1211 | } |
| 1212 | } |
| 1213 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1214 | private int getResolvedLongPressOnPowerBehavior() { |
| 1215 | if (FactoryTest.isLongPressOnPowerOffEnabled()) { |
| 1216 | return LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM; |
| 1217 | } |
| 1218 | return mLongPressOnPowerBehavior; |
| 1219 | } |
| 1220 | |
| 1221 | private boolean hasLongPressOnPowerBehavior() { |
| 1222 | return getResolvedLongPressOnPowerBehavior() != LONG_PRESS_POWER_NOTHING; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1223 | } |
| 1224 | |
| 1225 | private void interceptScreenshotChord() { |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1226 | if (mScreenshotChordEnabled |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1227 | && mScreenshotChordVolumeDownKeyTriggered && mScreenshotChordPowerKeyTriggered |
| 1228 | && !mScreenshotChordVolumeUpKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1229 | final long now = SystemClock.uptimeMillis(); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1230 | if (now <= mScreenshotChordVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS |
| 1231 | && now <= mScreenshotChordPowerKeyTime |
| 1232 | + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) { |
| 1233 | mScreenshotChordVolumeDownKeyConsumed = true; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1234 | cancelPendingPowerKeyAction(); |
| 1235 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 1236 | mHandler.postDelayed(mScreenshotRunnable, getScreenshotChordLongPressDelay()); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1237 | } |
| 1238 | } |
| 1239 | } |
| 1240 | |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 1241 | private long getScreenshotChordLongPressDelay() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1242 | if (mKeyguardDelegate.isShowing()) { |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 1243 | // Double the time it takes to take a screenshot from the keyguard |
| 1244 | return (long) (KEYGUARD_SCREENSHOT_CHORD_DELAY_MULTIPLIER * |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 1245 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 1246 | } |
Justin Koh | feabd2c | 2014-05-02 10:02:44 -0700 | [diff] [blame] | 1247 | return ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout(); |
Winson Chung | 1cea2f3 | 2012-10-08 20:42:01 -0700 | [diff] [blame] | 1248 | } |
| 1249 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1250 | private void cancelPendingScreenshotChordAction() { |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 1251 | mHandler.removeCallbacks(mScreenshotRunnable); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1252 | } |
| 1253 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1254 | private final Runnable mEndCallLongPress = new Runnable() { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 1255 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1256 | public void run() { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1257 | mEndCallKeyHandled = true; |
| 1258 | if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) { |
| 1259 | performAuditoryFeedbackForAccessibilityIfNeed(); |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 1260 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1261 | showGlobalActionsInternal(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1262 | } |
| 1263 | }; |
| 1264 | |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 1265 | private final Runnable mScreenshotRunnable = new Runnable() { |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1266 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1267 | public void run() { |
| 1268 | takeScreenshot(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1269 | } |
| 1270 | }; |
| 1271 | |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 1272 | @Override |
| 1273 | public void showGlobalActions() { |
| 1274 | mHandler.removeMessages(MSG_DISPATCH_SHOW_GLOBAL_ACTIONS); |
| 1275 | mHandler.sendEmptyMessage(MSG_DISPATCH_SHOW_GLOBAL_ACTIONS); |
| 1276 | } |
| 1277 | |
| 1278 | void showGlobalActionsInternal() { |
| 1279 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1280 | if (mGlobalActions == null) { |
Jeff Brown | 7304c34 | 2012-05-11 18:42:42 -0700 | [diff] [blame] | 1281 | mGlobalActions = new GlobalActions(mContext, mWindowManagerFuncs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1282 | } |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 1283 | final boolean keyguardShowing = isKeyguardShowingAndNotOccluded(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1284 | mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); |
| 1285 | if (keyguardShowing) { |
| 1286 | // since it took two seconds of long press to bring this up, |
| 1287 | // 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] | 1288 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1289 | } |
| 1290 | } |
| 1291 | |
| 1292 | boolean isDeviceProvisioned() { |
Jeff Brown | bf6f6f9 | 2012-09-25 15:03:20 -0700 | [diff] [blame] | 1293 | return Settings.Global.getInt( |
| 1294 | mContext.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1295 | } |
| 1296 | |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 1297 | boolean isUserSetupComplete() { |
| 1298 | return Settings.Secure.getIntForUser(mContext.getContentResolver(), |
| 1299 | Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0; |
| 1300 | } |
| 1301 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1302 | private void handleShortPressOnHome() { |
Jinsuk Kim | e601b71 | 2015-07-07 08:01:02 +0900 | [diff] [blame] | 1303 | // Turn on the connected TV and switch HDMI input if we're a HDMI playback device. |
| 1304 | getHdmiControl().turnOnTv(); |
| 1305 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1306 | // If there's a dream running then use home to escape the dream |
| 1307 | // but don't actually go home. |
| 1308 | if (mDreamManagerInternal != null && mDreamManagerInternal.isDreaming()) { |
| 1309 | mDreamManagerInternal.stopDream(false /*immediate*/); |
| 1310 | return; |
| 1311 | } |
| 1312 | |
| 1313 | // Go home! |
| 1314 | launchHomeFromHotKey(); |
| 1315 | } |
| 1316 | |
Jinsuk Kim | e601b71 | 2015-07-07 08:01:02 +0900 | [diff] [blame] | 1317 | /** |
| 1318 | * Creates an accessor to HDMI control service that performs the operation of |
| 1319 | * turning on TV (optional) and switching input to us. If HDMI control service |
| 1320 | * is not available or we're not a HDMI playback device, the operation is no-op. |
| 1321 | */ |
| 1322 | private HdmiControl getHdmiControl() { |
| 1323 | if (null == mHdmiControl) { |
| 1324 | HdmiControlManager manager = (HdmiControlManager) mContext.getSystemService( |
| 1325 | Context.HDMI_CONTROL_SERVICE); |
| 1326 | HdmiPlaybackClient client = null; |
| 1327 | if (manager != null) { |
| 1328 | client = manager.getPlaybackClient(); |
| 1329 | } |
| 1330 | mHdmiControl = new HdmiControl(client); |
| 1331 | } |
| 1332 | return mHdmiControl; |
| 1333 | } |
| 1334 | |
| 1335 | private static class HdmiControl { |
| 1336 | private final HdmiPlaybackClient mClient; |
| 1337 | |
| 1338 | private HdmiControl(HdmiPlaybackClient client) { |
| 1339 | mClient = client; |
| 1340 | } |
| 1341 | |
| 1342 | public void turnOnTv() { |
| 1343 | if (mClient == null) { |
| 1344 | return; |
| 1345 | } |
| 1346 | mClient.oneTouchPlay(new OneTouchPlayCallback() { |
| 1347 | @Override |
| 1348 | public void onComplete(int result) { |
| 1349 | if (result != HdmiControlManager.RESULT_SUCCESS) { |
| 1350 | Log.w(TAG, "One touch play failed: " + result); |
| 1351 | } |
| 1352 | } |
| 1353 | }); |
| 1354 | } |
| 1355 | } |
| 1356 | |
Jaewan Kim | 76b7d0d | 2016-02-12 19:01:02 +0900 | [diff] [blame] | 1357 | private void handleLongPressOnHome(int deviceId) { |
Jaewan Kim | 52632e2 | 2016-01-14 18:01:52 +0900 | [diff] [blame] | 1358 | if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_NOTHING) { |
| 1359 | return; |
| 1360 | } |
| 1361 | mHomeConsumed = true; |
| 1362 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 1363 | |
Jaewan Kim | 52632e2 | 2016-01-14 18:01:52 +0900 | [diff] [blame] | 1364 | switch (mLongPressOnHomeBehavior) { |
| 1365 | case LONG_PRESS_HOME_RECENT_SYSTEM_UI: |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1366 | toggleRecentApps(); |
Jaewan Kim | 52632e2 | 2016-01-14 18:01:52 +0900 | [diff] [blame] | 1367 | break; |
| 1368 | case LONG_PRESS_HOME_ASSIST: |
Tim Kilbourn | 0e5f110 | 2015-06-05 16:18:09 -0700 | [diff] [blame] | 1369 | launchAssistAction(null, deviceId); |
Jaewan Kim | 52632e2 | 2016-01-14 18:01:52 +0900 | [diff] [blame] | 1370 | break; |
Jaewan Kim | 52632e2 | 2016-01-14 18:01:52 +0900 | [diff] [blame] | 1371 | default: |
Jaewan Kim | 76b7d0d | 2016-02-12 19:01:02 +0900 | [diff] [blame] | 1372 | Log.w(TAG, "Undefined home long press behavior: " + mLongPressOnHomeBehavior); |
Jaewan Kim | 52632e2 | 2016-01-14 18:01:52 +0900 | [diff] [blame] | 1373 | break; |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 1374 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1375 | } |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 1376 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1377 | private void handleDoubleTapOnHome() { |
| 1378 | if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 1379 | mHomeConsumed = true; |
| 1380 | toggleRecentApps(); |
| 1381 | } |
| 1382 | } |
| 1383 | |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 1384 | private void requestTvPictureInPicture(KeyEvent event) { |
| 1385 | if (DEBUG_INPUT) Log.d(TAG, "requestTvPictureInPicture event=" + event); |
| 1386 | mHandler.removeMessages(MSG_REQUEST_TV_PICTURE_IN_PICTURE); |
| 1387 | Message msg = mHandler.obtainMessage(MSG_REQUEST_TV_PICTURE_IN_PICTURE); |
| 1388 | msg.setAsynchronous(true); |
| 1389 | msg.sendToTarget(); |
| 1390 | } |
| 1391 | |
| 1392 | private void requestTvPictureInPictureInternal() { |
| 1393 | try { |
| 1394 | IStatusBarService statusbar = getStatusBarService(); |
| 1395 | if (statusbar != null) { |
| 1396 | statusbar.requestTvPictureInPicture(); |
| 1397 | } |
| 1398 | } catch (RemoteException|IllegalArgumentException e) { |
| 1399 | Slog.e(TAG, "Cannot handle picture-in-picture key", e); |
| 1400 | // re-acquire status bar service next time it is needed. |
| 1401 | mStatusBarService = null; |
| 1402 | } |
Jaewan Kim | 52632e2 | 2016-01-14 18:01:52 +0900 | [diff] [blame] | 1403 | } |
| 1404 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1405 | private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable() { |
| 1406 | @Override |
| 1407 | public void run() { |
| 1408 | if (mHomeDoubleTapPending) { |
| 1409 | mHomeDoubleTapPending = false; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1410 | handleShortPressOnHome(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1411 | } |
| 1412 | } |
| 1413 | }; |
| 1414 | |
Mark Renouf | c125691 | 2015-03-11 14:38:23 -0400 | [diff] [blame] | 1415 | private boolean isRoundWindow() { |
Adam Powell | 01f280d | 2015-05-18 16:07:42 -0700 | [diff] [blame] | 1416 | return mContext.getResources().getConfiguration().isScreenRound(); |
Mark Renouf | c125691 | 2015-03-11 14:38:23 -0400 | [diff] [blame] | 1417 | } |
| 1418 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1419 | /** {@inheritDoc} */ |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1420 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1421 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 1422 | WindowManagerFuncs windowManagerFuncs) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1423 | mContext = context; |
| 1424 | mWindowManager = windowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1425 | mWindowManagerFuncs = windowManagerFuncs; |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 1426 | mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class); |
Jeff Brown | 061ea99 | 2015-04-17 19:55:47 -0700 | [diff] [blame] | 1427 | mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class); |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 1428 | mDreamManagerInternal = LocalServices.getService(DreamManagerInternal.class); |
Michael Wright | a4d22d7 | 2015-09-16 23:19:26 +0100 | [diff] [blame] | 1429 | mPowerManagerInternal = LocalServices.getService(PowerManagerInternal.class); |
Billy Lau | cbe540f | 2015-06-25 01:51:44 +0100 | [diff] [blame] | 1430 | mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); |
Mark Renouf | c125691 | 2015-03-11 14:38:23 -0400 | [diff] [blame] | 1431 | |
| 1432 | // Init display burn-in protection |
| 1433 | boolean burnInProtectionEnabled = context.getResources().getBoolean( |
| 1434 | com.android.internal.R.bool.config_enableBurnInProtection); |
| 1435 | // Allow a system property to override this. Used by developer settings. |
| 1436 | boolean burnInProtectionDevMode = |
| 1437 | SystemProperties.getBoolean("persist.debug.force_burn_in", false); |
| 1438 | if (burnInProtectionEnabled || burnInProtectionDevMode) { |
| 1439 | final int minHorizontal; |
| 1440 | final int maxHorizontal; |
| 1441 | final int minVertical; |
| 1442 | final int maxVertical; |
| 1443 | final int maxRadius; |
| 1444 | if (burnInProtectionDevMode) { |
| 1445 | minHorizontal = -8; |
| 1446 | maxHorizontal = 8; |
| 1447 | minVertical = -8; |
| 1448 | maxVertical = -4; |
| 1449 | maxRadius = (isRoundWindow()) ? 6 : -1; |
| 1450 | } else { |
| 1451 | Resources resources = context.getResources(); |
| 1452 | minHorizontal = resources.getInteger( |
| 1453 | com.android.internal.R.integer.config_burnInProtectionMinHorizontalOffset); |
| 1454 | maxHorizontal = resources.getInteger( |
| 1455 | com.android.internal.R.integer.config_burnInProtectionMaxHorizontalOffset); |
| 1456 | minVertical = resources.getInteger( |
| 1457 | com.android.internal.R.integer.config_burnInProtectionMinVerticalOffset); |
| 1458 | maxVertical = resources.getInteger( |
| 1459 | com.android.internal.R.integer.config_burnInProtectionMaxVerticalOffset); |
| 1460 | maxRadius = resources.getInteger( |
| 1461 | com.android.internal.R.integer.config_burnInProtectionMaxRadius); |
| 1462 | } |
| 1463 | mBurnInProtectionHelper = new BurnInProtectionHelper( |
| 1464 | context, minHorizontal, maxHorizontal, minVertical, maxVertical, maxRadius); |
Filip Gruszczynski | cfb3185 | 2015-02-25 21:47:12 +0000 | [diff] [blame] | 1465 | } |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 1466 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1467 | mHandler = new PolicyHandler(); |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1468 | mWakeGestureListener = new MyWakeGestureListener(mContext, mHandler); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 1469 | mOrientationListener = new MyOrientationListener(mContext, mHandler); |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 1470 | try { |
| 1471 | mOrientationListener.setCurrentRotation(windowManager.getRotation()); |
| 1472 | } catch (RemoteException ex) { } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1473 | mSettingsObserver = new SettingsObserver(mHandler); |
| 1474 | mSettingsObserver.observe(); |
Svetoslav | 683914b | 2015-01-15 14:22:26 -0800 | [diff] [blame] | 1475 | mShortcutManager = new ShortcutManager(context); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 1476 | mUiMode = context.getResources().getInteger( |
| 1477 | com.android.internal.R.integer.config_defaultUiModeType); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1478 | mHomeIntent = new Intent(Intent.ACTION_MAIN, null); |
| 1479 | mHomeIntent.addCategory(Intent.CATEGORY_HOME); |
| 1480 | mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 1481 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
keunyoung | a771049 | 2015-09-23 11:33:58 -0700 | [diff] [blame] | 1482 | mEnableCarDockHomeCapture = context.getResources().getBoolean( |
| 1483 | com.android.internal.R.bool.config_enableCarDockHomeLaunch); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 1484 | mCarDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 1485 | mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK); |
| 1486 | mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 1487 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 1488 | mDeskDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 1489 | mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK); |
| 1490 | mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 1491 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 1492 | |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 1493 | mPowerManager = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 1494 | mBroadcastWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1495 | "PhoneWindowManager.mBroadcastWakeLock"); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1496 | mPowerKeyWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
| 1497 | "PhoneWindowManager.mPowerKeyWakeLock"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1498 | mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 1499 | mSupportAutoRotation = mContext.getResources().getBoolean( |
| 1500 | com.android.internal.R.bool.config_supportAutoRotation); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1501 | mLidOpenRotation = readRotation( |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1502 | com.android.internal.R.integer.config_lidOpenRotation); |
| 1503 | mCarDockRotation = readRotation( |
| 1504 | com.android.internal.R.integer.config_carDockRotation); |
| 1505 | mDeskDockRotation = readRotation( |
| 1506 | com.android.internal.R.integer.config_deskDockRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1507 | mUndockedHdmiRotation = readRotation( |
| 1508 | com.android.internal.R.integer.config_undockedHdmiRotation); |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 1509 | mCarDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 1510 | com.android.internal.R.bool.config_carDockEnablesAccelerometer); |
| 1511 | mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 1512 | com.android.internal.R.bool.config_deskDockEnablesAccelerometer); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1513 | mLidKeyboardAccessibility = mContext.getResources().getInteger( |
| 1514 | com.android.internal.R.integer.config_lidKeyboardAccessibility); |
| 1515 | mLidNavigationAccessibility = mContext.getResources().getInteger( |
| 1516 | com.android.internal.R.integer.config_lidNavigationAccessibility); |
Edward Savage-Jones | 7def60d | 2015-11-13 13:27:03 +0100 | [diff] [blame] | 1517 | mLidControlsScreenLock = mContext.getResources().getBoolean( |
| 1518 | com.android.internal.R.bool.config_lidControlsScreenLock); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 1519 | mLidControlsSleep = mContext.getResources().getBoolean( |
| 1520 | com.android.internal.R.bool.config_lidControlsSleep); |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 1521 | mTranslucentDecorEnabled = mContext.getResources().getBoolean( |
| 1522 | com.android.internal.R.bool.config_enableTranslucentDecor); |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 1523 | |
| 1524 | mAllowTheaterModeWakeFromKey = mContext.getResources().getBoolean( |
| 1525 | com.android.internal.R.bool.config_allowTheaterModeWakeFromKey); |
| 1526 | mAllowTheaterModeWakeFromPowerKey = mAllowTheaterModeWakeFromKey |
| 1527 | || mContext.getResources().getBoolean( |
| 1528 | com.android.internal.R.bool.config_allowTheaterModeWakeFromPowerKey); |
| 1529 | mAllowTheaterModeWakeFromMotion = mContext.getResources().getBoolean( |
| 1530 | com.android.internal.R.bool.config_allowTheaterModeWakeFromMotion); |
Bryce Lee | 812d702 | 2014-11-10 13:33:28 -0800 | [diff] [blame] | 1531 | mAllowTheaterModeWakeFromMotionWhenNotDreaming = mContext.getResources().getBoolean( |
| 1532 | com.android.internal.R.bool.config_allowTheaterModeWakeFromMotionWhenNotDreaming); |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 1533 | mAllowTheaterModeWakeFromCameraLens = mContext.getResources().getBoolean( |
| 1534 | com.android.internal.R.bool.config_allowTheaterModeWakeFromCameraLens); |
| 1535 | mAllowTheaterModeWakeFromLidSwitch = mContext.getResources().getBoolean( |
| 1536 | com.android.internal.R.bool.config_allowTheaterModeWakeFromLidSwitch); |
| 1537 | mAllowTheaterModeWakeFromWakeGesture = mContext.getResources().getBoolean( |
| 1538 | com.android.internal.R.bool.config_allowTheaterModeWakeFromGesture); |
| 1539 | |
Bryce Lee | 55e846d | 2014-11-04 12:43:44 -0800 | [diff] [blame] | 1540 | mGoToSleepOnButtonPressTheaterMode = mContext.getResources().getBoolean( |
| 1541 | com.android.internal.R.bool.config_goToSleepOnButtonPressTheaterMode); |
| 1542 | |
Bryce Lee | d3b2840 | 2015-03-09 15:49:13 +0000 | [diff] [blame] | 1543 | mSupportLongPressPowerWhenNonInteractive = mContext.getResources().getBoolean( |
| 1544 | com.android.internal.R.bool.config_supportLongPressPowerWhenNonInteractive); |
| 1545 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1546 | mShortPressOnPowerBehavior = mContext.getResources().getInteger( |
| 1547 | com.android.internal.R.integer.config_shortPressOnPowerBehavior); |
| 1548 | mLongPressOnPowerBehavior = mContext.getResources().getInteger( |
| 1549 | com.android.internal.R.integer.config_longPressOnPowerBehavior); |
| 1550 | mDoublePressOnPowerBehavior = mContext.getResources().getInteger( |
| 1551 | com.android.internal.R.integer.config_doublePressOnPowerBehavior); |
| 1552 | mTriplePressOnPowerBehavior = mContext.getResources().getInteger( |
| 1553 | com.android.internal.R.integer.config_triplePressOnPowerBehavior); |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 1554 | mShortPressOnSleepBehavior = mContext.getResources().getInteger( |
| 1555 | com.android.internal.R.integer.config_shortPressOnSleepBehavior); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 1556 | |
John Spurlock | 6156017 | 2015-02-06 19:46:04 -0500 | [diff] [blame] | 1557 | mUseTvRouting = AudioSystem.getPlatformType(mContext) == AudioSystem.PLATFORM_TELEVISION; |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 1558 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1559 | readConfigurationDependentBehaviors(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 1560 | |
Svetoslav | 8e3feb1 | 2014-02-24 13:46:47 -0800 | [diff] [blame] | 1561 | mAccessibilityManager = (AccessibilityManager) context.getSystemService( |
| 1562 | Context.ACCESSIBILITY_SERVICE); |
| 1563 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1564 | // register for dock events |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 1565 | IntentFilter filter = new IntentFilter(); |
| 1566 | filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); |
| 1567 | filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE); |
| 1568 | filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); |
| 1569 | filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1570 | filter.addAction(Intent.ACTION_DOCK_EVENT); |
| 1571 | Intent intent = context.registerReceiver(mDockReceiver, filter); |
| 1572 | if (intent != null) { |
| 1573 | // Retrieve current sticky dock event broadcast. |
| 1574 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 1575 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 1576 | } |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 1577 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 1578 | // register for dream-related broadcasts |
| 1579 | filter = new IntentFilter(); |
| 1580 | filter.addAction(Intent.ACTION_DREAMING_STARTED); |
| 1581 | filter.addAction(Intent.ACTION_DREAMING_STOPPED); |
| 1582 | context.registerReceiver(mDreamReceiver, filter); |
| 1583 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1584 | // register for multiuser-relevant broadcasts |
| 1585 | filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); |
| 1586 | context.registerReceiver(mMultiuserReceiver, filter); |
| 1587 | |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 1588 | // monitor for system gestures |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1589 | mSystemGestures = new SystemGesturesPointerEventListener(context, |
| 1590 | new SystemGesturesPointerEventListener.Callbacks() { |
John Spurlock | 57306e6 | 2013-04-22 09:48:49 -0400 | [diff] [blame] | 1591 | @Override |
| 1592 | public void onSwipeFromTop() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1593 | if (mStatusBar != null) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1594 | requestTransientBars(mStatusBar); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1595 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1596 | } |
| 1597 | @Override |
| 1598 | public void onSwipeFromBottom() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1599 | if (mNavigationBar != null && mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1600 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1601 | } |
| 1602 | } |
| 1603 | @Override |
| 1604 | public void onSwipeFromRight() { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 1605 | if (mNavigationBar != null && !mNavigationBarOnBottom) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 1606 | requestTransientBars(mNavigationBar); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1607 | } |
| 1608 | } |
| 1609 | @Override |
Michael Wright | a4d22d7 | 2015-09-16 23:19:26 +0100 | [diff] [blame] | 1610 | public void onFling(int duration) { |
| 1611 | if (mPowerManagerInternal != null) { |
| 1612 | mPowerManagerInternal.powerHint( |
| 1613 | PowerManagerInternal.POWER_HINT_INTERACTION, duration); |
| 1614 | } |
| 1615 | } |
| 1616 | @Override |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1617 | public void onDebug() { |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1618 | // no-op |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1619 | } |
Adrian Roos | 3595be4 | 2015-03-05 16:31:15 +0100 | [diff] [blame] | 1620 | @Override |
| 1621 | public void onDown() { |
| 1622 | mOrientationListener.onTouchStart(); |
| 1623 | } |
| 1624 | @Override |
| 1625 | public void onUpOrCancel() { |
| 1626 | mOrientationListener.onTouchEnd(); |
| 1627 | } |
Jun Mukai | d2e7e35 | 2015-07-22 17:14:02 -0700 | [diff] [blame] | 1628 | @Override |
| 1629 | public void onMouseHoverAtTop() { |
| 1630 | mHandler.removeMessages(MSG_REQUEST_TRANSIENT_BARS); |
| 1631 | Message msg = mHandler.obtainMessage(MSG_REQUEST_TRANSIENT_BARS); |
| 1632 | msg.arg1 = MSG_REQUEST_TRANSIENT_BARS_ARG_STATUS; |
| 1633 | mHandler.sendMessageDelayed(msg, 500); |
| 1634 | } |
| 1635 | @Override |
| 1636 | public void onMouseHoverAtBottom() { |
| 1637 | mHandler.removeMessages(MSG_REQUEST_TRANSIENT_BARS); |
| 1638 | Message msg = mHandler.obtainMessage(MSG_REQUEST_TRANSIENT_BARS); |
| 1639 | msg.arg1 = MSG_REQUEST_TRANSIENT_BARS_ARG_NAVIGATION; |
| 1640 | mHandler.sendMessageDelayed(msg, 500); |
| 1641 | } |
| 1642 | @Override |
| 1643 | public void onMouseLeaveFromEdge() { |
| 1644 | mHandler.removeMessages(MSG_REQUEST_TRANSIENT_BARS); |
| 1645 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 1646 | }); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1647 | mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 1648 | mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 1649 | |
Jeff Brown | c234613 | 2012-04-13 01:55:38 -0700 | [diff] [blame] | 1650 | mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 1651 | mLongPressVibePattern = getLongIntArray(mContext.getResources(), |
| 1652 | com.android.internal.R.array.config_longPressVibePattern); |
| 1653 | mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(), |
| 1654 | com.android.internal.R.array.config_virtualKeyVibePattern); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 1655 | mKeyboardTapVibePattern = getLongIntArray(mContext.getResources(), |
| 1656 | com.android.internal.R.array.config_keyboardTapVibePattern); |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 1657 | mClockTickVibePattern = getLongIntArray(mContext.getResources(), |
| 1658 | com.android.internal.R.array.config_clockTickVibePattern); |
Fabrice Di Meglio | bd9152f | 2013-10-01 11:21:31 -0700 | [diff] [blame] | 1659 | mCalendarDateVibePattern = getLongIntArray(mContext.getResources(), |
| 1660 | com.android.internal.R.array.config_calendarDateVibePattern); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 1661 | mSafeModeDisabledVibePattern = getLongIntArray(mContext.getResources(), |
| 1662 | com.android.internal.R.array.config_safeModeDisabledVibePattern); |
| 1663 | mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), |
| 1664 | com.android.internal.R.array.config_safeModeEnabledVibePattern); |
Mady Mellor | e860891 | 2015-06-05 09:02:55 -0700 | [diff] [blame] | 1665 | mContextClickVibePattern = getLongIntArray(mContext.getResources(), |
| 1666 | com.android.internal.R.array.config_contextClickVibePattern); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 1667 | |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1668 | mScreenshotChordEnabled = mContext.getResources().getBoolean( |
| 1669 | com.android.internal.R.bool.config_enableScreenshotChord); |
Jorim Jaggi | 406585a | 2015-12-21 10:58:56 +0100 | [diff] [blame] | 1670 | mForceWindowDrawsStatusBarBackground = mContext.getResources().getBoolean( |
| 1671 | R.bool.config_forceWindowDrawsStatusBarBackground); |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1672 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 1673 | mGlobalKeyManager = new GlobalKeyManager(mContext); |
| 1674 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 1675 | // Controls rotation and the like. |
| 1676 | initializeHdmiState(); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1677 | |
| 1678 | // Match current screen state. |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 1679 | if (!mPowerManager.isInteractive()) { |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 1680 | startedGoingToSleep(WindowManagerPolicy.OFF_BECAUSE_OF_USER); |
| 1681 | finishedGoingToSleep(WindowManagerPolicy.OFF_BECAUSE_OF_USER); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 1682 | } |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 1683 | |
| 1684 | mWindowManagerInternal.registerAppTransitionListener( |
| 1685 | mStatusBarController.getAppTransitionListener()); |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1686 | } |
| 1687 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1688 | /** |
| 1689 | * Read values from config.xml that may be overridden depending on |
| 1690 | * the configuration of the device. |
| 1691 | * eg. Disable long press on home goes to recents on sw600dp. |
| 1692 | */ |
| 1693 | private void readConfigurationDependentBehaviors() { |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 1694 | final Resources res = mContext.getResources(); |
| 1695 | |
| 1696 | mLongPressOnHomeBehavior = res.getInteger( |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1697 | com.android.internal.R.integer.config_longPressOnHomeBehavior); |
| 1698 | if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING || |
Jaewan Kim | 52632e2 | 2016-01-14 18:01:52 +0900 | [diff] [blame] | 1699 | mLongPressOnHomeBehavior > LAST_LONG_PRESS_HOME_BEHAVIOR) { |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1700 | mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1701 | } |
| 1702 | |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 1703 | mDoubleTapOnHomeBehavior = res.getInteger( |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1704 | com.android.internal.R.integer.config_doubleTapOnHomeBehavior); |
| 1705 | if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING || |
| 1706 | mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 1707 | mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 1708 | } |
Jaewan Kim | 4911787 | 2016-01-19 17:24:08 +0900 | [diff] [blame] | 1709 | |
| 1710 | mShortPressWindowBehavior = SHORT_PRESS_WINDOW_NOTHING; |
| 1711 | if (mContext.getPackageManager().hasSystemFeature(FEATURE_PICTURE_IN_PICTURE)) { |
| 1712 | mShortPressWindowBehavior = SHORT_PRESS_WINDOW_PICTURE_IN_PICTURE; |
| 1713 | } |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 1714 | } |
| 1715 | |
Craig Mautner | 0bf6ec9 | 2012-12-18 08:33:27 -0800 | [diff] [blame] | 1716 | @Override |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1717 | public void setInitialDisplaySize(Display display, int width, int height, int density) { |
Jeff Brown | ef981a4 | 2013-08-07 14:13:37 -0700 | [diff] [blame] | 1718 | // This method might be called before the policy has been fully initialized |
| 1719 | // or for other displays we don't care about. |
| 1720 | if (mContext == null || display.getDisplayId() != Display.DEFAULT_DISPLAY) { |
| 1721 | return; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1722 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1723 | mDisplay = display; |
| 1724 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1725 | final Resources res = mContext.getResources(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1726 | int shortSize, longSize; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1727 | if (width > height) { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1728 | shortSize = height; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1729 | longSize = width; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1730 | mLandscapeRotation = Surface.ROTATION_0; |
| 1731 | mSeascapeRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1732 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1733 | mPortraitRotation = Surface.ROTATION_90; |
| 1734 | mUpsideDownRotation = Surface.ROTATION_270; |
| 1735 | } else { |
| 1736 | mPortraitRotation = Surface.ROTATION_270; |
| 1737 | mUpsideDownRotation = Surface.ROTATION_90; |
| 1738 | } |
| 1739 | } else { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1740 | shortSize = width; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1741 | longSize = height; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1742 | mPortraitRotation = Surface.ROTATION_0; |
| 1743 | mUpsideDownRotation = Surface.ROTATION_180; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1744 | if (res.getBoolean(com.android.internal.R.bool.config_reverseDefaultRotation)) { |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1745 | mLandscapeRotation = Surface.ROTATION_270; |
| 1746 | mSeascapeRotation = Surface.ROTATION_90; |
| 1747 | } else { |
| 1748 | mLandscapeRotation = Surface.ROTATION_90; |
| 1749 | mSeascapeRotation = Surface.ROTATION_270; |
| 1750 | } |
| 1751 | } |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1752 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1753 | mStatusBarHeight = |
| 1754 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1755 | |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1756 | // Height of the navigation bar when presented horizontally at bottom |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 1757 | mNavigationBarHeightForRotationDefault[mPortraitRotation] = |
| 1758 | mNavigationBarHeightForRotationDefault[mUpsideDownRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1759 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height); |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 1760 | mNavigationBarHeightForRotationDefault[mLandscapeRotation] = |
| 1761 | mNavigationBarHeightForRotationDefault[mSeascapeRotation] = res.getDimensionPixelSize( |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1762 | com.android.internal.R.dimen.navigation_bar_height_landscape); |
Daniel Sandler | 9f65c4c | 2012-04-26 01:35:35 -0400 | [diff] [blame] | 1763 | |
| 1764 | // Width of the navigation bar when presented vertically along one side |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 1765 | mNavigationBarWidthForRotationDefault[mPortraitRotation] = |
| 1766 | mNavigationBarWidthForRotationDefault[mUpsideDownRotation] = |
| 1767 | mNavigationBarWidthForRotationDefault[mLandscapeRotation] = |
| 1768 | mNavigationBarWidthForRotationDefault[mSeascapeRotation] = |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1769 | res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width); |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1770 | |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 1771 | // Height of the navigation bar when presented horizontally at bottom |
| 1772 | mNavigationBarHeightForRotationInCarMode[mPortraitRotation] = |
| 1773 | mNavigationBarHeightForRotationInCarMode[mUpsideDownRotation] = |
| 1774 | res.getDimensionPixelSize( |
| 1775 | com.android.internal.R.dimen.navigation_bar_height_car_mode); |
| 1776 | mNavigationBarHeightForRotationInCarMode[mLandscapeRotation] = |
| 1777 | mNavigationBarHeightForRotationInCarMode[mSeascapeRotation] = res.getDimensionPixelSize( |
| 1778 | com.android.internal.R.dimen.navigation_bar_height_landscape_car_mode); |
| 1779 | |
| 1780 | // Width of the navigation bar when presented vertically along one side |
| 1781 | mNavigationBarWidthForRotationInCarMode[mPortraitRotation] = |
| 1782 | mNavigationBarWidthForRotationInCarMode[mUpsideDownRotation] = |
| 1783 | mNavigationBarWidthForRotationInCarMode[mLandscapeRotation] = |
| 1784 | mNavigationBarWidthForRotationInCarMode[mSeascapeRotation] = |
| 1785 | res.getDimensionPixelSize( |
| 1786 | com.android.internal.R.dimen.navigation_bar_width_car_mode); |
| 1787 | |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1788 | // SystemUI (status bar) layout policy |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 1789 | int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1790 | int longSizeDp = longSize * DisplayMetrics.DENSITY_DEFAULT / density; |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 1791 | |
Devin Kim | d7b12b4 | 2014-05-05 14:34:58 -0700 | [diff] [blame] | 1792 | // Allow the navigation bar to move on non-square small devices (phones). |
| 1793 | mNavigationBarCanMove = width != height && shortSizeDp < 600; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1794 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1795 | mHasNavigationBar = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1796 | // Allow a system property to override this. Used by the emulator. |
| 1797 | // See also hasNavigationBar(). |
| 1798 | String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); |
| 1799 | if ("1".equals(navBarOverride)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1800 | mHasNavigationBar = false; |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 1801 | } else if ("0".equals(navBarOverride)) { |
| 1802 | mHasNavigationBar = true; |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1803 | } |
| 1804 | |
Jeff Brown | 27f1d67 | 2012-10-17 18:32:34 -0700 | [diff] [blame] | 1805 | // For demo purposes, allow the rotation of the HDMI display to be controlled. |
| 1806 | // By default, HDMI locks rotation to landscape. |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1807 | if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1808 | mDemoHdmiRotation = mPortraitRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1809 | } else { |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1810 | mDemoHdmiRotation = mLandscapeRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1811 | } |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 1812 | mDemoHdmiRotationLock = SystemProperties.getBoolean("persist.demo.hdmirotationlock", false); |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1813 | |
Chong Zhang | ae6119ff | 2014-11-11 18:54:39 -0800 | [diff] [blame] | 1814 | // For demo purposes, allow the rotation of the remote display to be controlled. |
| 1815 | // By default, remote display locks rotation to landscape. |
| 1816 | if ("portrait".equals(SystemProperties.get("persist.demo.remoterotation"))) { |
| 1817 | mDemoRotation = mPortraitRotation; |
| 1818 | } else { |
| 1819 | mDemoRotation = mLandscapeRotation; |
| 1820 | } |
| 1821 | mDemoRotationLock = SystemProperties.getBoolean( |
| 1822 | "persist.demo.rotationlock", false); |
| 1823 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1824 | // Only force the default orientation if the screen is xlarge, at least 960dp x 720dp, per |
| 1825 | // http://developer.android.com/guide/practices/screens_support.html#range |
| 1826 | mForceDefaultOrientation = longSizeDp >= 960 && shortSizeDp >= 720 && |
| 1827 | res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation) && |
| 1828 | // For debug purposes the next line turns this feature off with: |
| 1829 | // $ adb shell setprop config.override_forced_orient true |
| 1830 | // $ adb shell wm size reset |
| 1831 | !"true".equals(SystemProperties.get("config.override_forced_orient")); |
| 1832 | } |
| 1833 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1834 | /** |
| 1835 | * @return whether the navigation bar can be hidden, e.g. the device has a |
| 1836 | * navigation bar and touch exploration is not enabled |
| 1837 | */ |
| 1838 | private boolean canHideNavigationBar() { |
Alan Viverette | 817f3cd | 2015-08-13 11:40:14 -0400 | [diff] [blame] | 1839 | return mHasNavigationBar; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1840 | } |
| 1841 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 1842 | @Override |
| 1843 | public boolean isDefaultOrientationForced() { |
| 1844 | return mForceDefaultOrientation; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1845 | } |
| 1846 | |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 1847 | @Override |
| 1848 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom) { |
| 1849 | if (display.getDisplayId() == Display.DEFAULT_DISPLAY) { |
| 1850 | mOverscanLeft = left; |
| 1851 | mOverscanTop = top; |
| 1852 | mOverscanRight = right; |
| 1853 | mOverscanBottom = bottom; |
| 1854 | } |
| 1855 | } |
| 1856 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1857 | public void updateSettings() { |
| 1858 | ContentResolver resolver = mContext.getContentResolver(); |
| 1859 | boolean updateRotation = false; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1860 | synchronized (mLock) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1861 | mEndcallBehavior = Settings.System.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1862 | Settings.System.END_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1863 | Settings.System.END_BUTTON_BEHAVIOR_DEFAULT, |
| 1864 | UserHandle.USER_CURRENT); |
| 1865 | mIncallPowerBehavior = Settings.Secure.getIntForUser(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1866 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1867 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT, |
| 1868 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1869 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1870 | // Configure wake gesture. |
| 1871 | boolean wakeGestureEnabledSetting = Settings.Secure.getIntForUser(resolver, |
| 1872 | Settings.Secure.WAKE_GESTURE_ENABLED, 0, |
| 1873 | UserHandle.USER_CURRENT) != 0; |
| 1874 | if (mWakeGestureEnabledSetting != wakeGestureEnabledSetting) { |
| 1875 | mWakeGestureEnabledSetting = wakeGestureEnabledSetting; |
| 1876 | updateWakeGestureListenerLp(); |
| 1877 | } |
| 1878 | |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1879 | // Configure rotation lock. |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1880 | int userRotation = Settings.System.getIntForUser(resolver, |
| 1881 | Settings.System.USER_ROTATION, Surface.ROTATION_0, |
| 1882 | UserHandle.USER_CURRENT); |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1883 | if (mUserRotation != userRotation) { |
| 1884 | mUserRotation = userRotation; |
| 1885 | updateRotation = true; |
| 1886 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1887 | int userRotationMode = Settings.System.getIntForUser(resolver, |
| 1888 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 1889 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 1890 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
| 1891 | if (mUserRotationMode != userRotationMode) { |
| 1892 | mUserRotationMode = userRotationMode; |
| 1893 | updateRotation = true; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1894 | updateOrientationListenerLp(); |
| 1895 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1896 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1897 | if (mSystemReady) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1898 | int pointerLocation = Settings.System.getIntForUser(resolver, |
| 1899 | Settings.System.POINTER_LOCATION, 0, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1900 | if (mPointerLocationMode != pointerLocation) { |
| 1901 | mPointerLocationMode = pointerLocation; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1902 | mHandler.sendEmptyMessage(pointerLocation != 0 ? |
| 1903 | MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1904 | } |
| 1905 | } |
| 1906 | // use screen off timeout setting as the timeout for the lockscreen |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 1907 | mLockScreenTimeout = Settings.System.getIntForUser(resolver, |
| 1908 | Settings.System.SCREEN_OFF_TIMEOUT, 0, UserHandle.USER_CURRENT); |
| 1909 | String imId = Settings.Secure.getStringForUser(resolver, |
| 1910 | Settings.Secure.DEFAULT_INPUT_METHOD, UserHandle.USER_CURRENT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1911 | boolean hasSoftInput = imId != null && imId.length() > 0; |
| 1912 | if (mHasSoftInput != hasSoftInput) { |
| 1913 | mHasSoftInput = hasSoftInput; |
| 1914 | updateRotation = true; |
| 1915 | } |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 1916 | if (mImmersiveModeConfirmation != null) { |
John Spurlock | 4355a53 | 2014-02-19 09:49:25 -0500 | [diff] [blame] | 1917 | mImmersiveModeConfirmation.loadSetting(mCurrentUserId); |
John Spurlock | d67ec25 | 2013-09-05 11:31:54 -0400 | [diff] [blame] | 1918 | } |
tiger_huang | cc6366d | 2015-06-29 17:17:30 +0800 | [diff] [blame] | 1919 | } |
| 1920 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 1921 | PolicyControl.reloadFromSetting(mContext); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1922 | } |
| 1923 | if (updateRotation) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1924 | updateRotation(true); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1925 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1926 | } |
| 1927 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1928 | private void updateWakeGestureListenerLp() { |
| 1929 | if (shouldEnableWakeGestureLp()) { |
| 1930 | mWakeGestureListener.requestWakeUpTrigger(); |
| 1931 | } else { |
| 1932 | mWakeGestureListener.cancelWakeUpTrigger(); |
| 1933 | } |
| 1934 | } |
| 1935 | |
| 1936 | private boolean shouldEnableWakeGestureLp() { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 1937 | return mWakeGestureEnabledSetting && !mAwake |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 1938 | && (!mLidControlsSleep || mLidState != LID_CLOSED) |
| 1939 | && mWakeGestureListener.isSupported(); |
| 1940 | } |
| 1941 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1942 | private void enablePointerLocation() { |
| 1943 | if (mPointerLocationView == null) { |
| 1944 | mPointerLocationView = new PointerLocationView(mContext); |
| 1945 | mPointerLocationView.setPrintCoords(false); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1946 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 1947 | WindowManager.LayoutParams.MATCH_PARENT, |
| 1948 | WindowManager.LayoutParams.MATCH_PARENT); |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1949 | lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1950 | lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
| 1951 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
| 1952 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1953 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
Jeff Brown | 90fc905 | 2012-10-01 14:44:24 -0700 | [diff] [blame] | 1954 | if (ActivityManager.isHighEndGfx()) { |
| 1955 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1956 | lp.privateFlags |= |
| 1957 | WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED; |
| 1958 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1959 | lp.format = PixelFormat.TRANSLUCENT; |
| 1960 | lp.setTitle("PointerLocation"); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1961 | WindowManager wm = (WindowManager) |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1962 | mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1963 | lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1964 | wm.addView(mPointerLocationView, lp); |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1965 | mWindowManagerFuncs.registerPointerEventListener(mPointerLocationView); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1966 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1967 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1968 | |
| 1969 | private void disablePointerLocation() { |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1970 | if (mPointerLocationView != null) { |
Michael Wright | c9c487e | 2013-11-07 18:55:09 -0800 | [diff] [blame] | 1971 | mWindowManagerFuncs.unregisterPointerEventListener(mPointerLocationView); |
| 1972 | WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1973 | wm.removeView(mPointerLocationView); |
| 1974 | mPointerLocationView = null; |
| 1975 | } |
| 1976 | } |
| 1977 | |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1978 | private int readRotation(int resID) { |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1979 | try { |
| 1980 | int rotation = mContext.getResources().getInteger(resID); |
| 1981 | switch (rotation) { |
| 1982 | case 0: |
| 1983 | return Surface.ROTATION_0; |
| 1984 | case 90: |
| 1985 | return Surface.ROTATION_90; |
| 1986 | case 180: |
| 1987 | return Surface.ROTATION_180; |
| 1988 | case 270: |
| 1989 | return Surface.ROTATION_270; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1990 | } |
| 1991 | } catch (Resources.NotFoundException e) { |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1992 | // fall through |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1993 | } |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1994 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1995 | } |
| 1996 | |
| 1997 | /** {@inheritDoc} */ |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 1998 | @Override |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 1999 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2000 | int type = attrs.type; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 2001 | |
| 2002 | outAppOp[0] = AppOpsManager.OP_NONE; |
| 2003 | |
Wale Ogunwale | 74bf065 | 2015-01-12 10:24:36 -0800 | [diff] [blame] | 2004 | if (!((type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) |
| 2005 | || (type >= FIRST_SUB_WINDOW && type <= LAST_SUB_WINDOW) |
| 2006 | || (type >= FIRST_SYSTEM_WINDOW && type <= LAST_SYSTEM_WINDOW))) { |
| 2007 | return WindowManagerGlobal.ADD_INVALID_TYPE; |
| 2008 | } |
| 2009 | |
| 2010 | if (type < FIRST_SYSTEM_WINDOW || type > LAST_SYSTEM_WINDOW) { |
| 2011 | // Window manager will make sure these are okay. |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2012 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2013 | } |
| 2014 | String permission = null; |
| 2015 | switch (type) { |
| 2016 | case TYPE_TOAST: |
| 2017 | // XXX right now the app process has complete control over |
| 2018 | // this... should introduce a token to let the system |
| 2019 | // monitor/control what they are doing. |
Jason Monk | 1c7c319 | 2014-06-26 12:52:18 -0400 | [diff] [blame] | 2020 | outAppOp[0] = AppOpsManager.OP_TOAST_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2021 | break; |
Daniel Sandler | 7d276c3 | 2012-01-30 14:33:52 -0500 | [diff] [blame] | 2022 | case TYPE_DREAM: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2023 | case TYPE_INPUT_METHOD: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 2024 | case TYPE_WALLPAPER: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 2025 | case TYPE_PRIVATE_PRESENTATION: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2026 | case TYPE_VOICE_INTERACTION: |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 2027 | case TYPE_ACCESSIBILITY_OVERLAY: |
Jason Monk | 8f7f318 | 2015-11-18 16:35:14 -0500 | [diff] [blame] | 2028 | case TYPE_QS_DIALOG: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 2029 | // The window manager will check these. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2030 | break; |
| 2031 | case TYPE_PHONE: |
| 2032 | case TYPE_PRIORITY_PHONE: |
| 2033 | case TYPE_SYSTEM_ALERT: |
| 2034 | case TYPE_SYSTEM_ERROR: |
| 2035 | case TYPE_SYSTEM_OVERLAY: |
| 2036 | permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW; |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 2037 | outAppOp[0] = AppOpsManager.OP_SYSTEM_ALERT_WINDOW; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2038 | break; |
| 2039 | default: |
| 2040 | permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; |
| 2041 | } |
| 2042 | if (permission != null) { |
Svet Ganov | 9cea80cd | 2016-02-16 11:47:00 -0800 | [diff] [blame] | 2043 | if (android.Manifest.permission.SYSTEM_ALERT_WINDOW.equals(permission)) { |
Billy Lau | cbe540f | 2015-06-25 01:51:44 +0100 | [diff] [blame] | 2044 | final int callingUid = Binder.getCallingUid(); |
Billy Lau | 060275f | 2015-07-15 22:29:19 +0100 | [diff] [blame] | 2045 | // system processes will be automatically allowed privilege to draw |
Billy Lau | cbe540f | 2015-06-25 01:51:44 +0100 | [diff] [blame] | 2046 | if (callingUid == Process.SYSTEM_UID) { |
| 2047 | return WindowManagerGlobal.ADD_OKAY; |
| 2048 | } |
| 2049 | |
Billy Lau | 060275f | 2015-07-15 22:29:19 +0100 | [diff] [blame] | 2050 | // check if user has enabled this operation. SecurityException will be thrown if |
| 2051 | // this app has not been allowed by the user |
Billy Lau | cbe540f | 2015-06-25 01:51:44 +0100 | [diff] [blame] | 2052 | final int mode = mAppOpsManager.checkOp(outAppOp[0], callingUid, |
| 2053 | attrs.packageName); |
Billy Lau | 060275f | 2015-07-15 22:29:19 +0100 | [diff] [blame] | 2054 | switch (mode) { |
| 2055 | case AppOpsManager.MODE_ALLOWED: |
| 2056 | case AppOpsManager.MODE_IGNORED: |
| 2057 | // although we return ADD_OKAY for MODE_IGNORED, the added window will |
| 2058 | // actually be hidden in WindowManagerService |
| 2059 | return WindowManagerGlobal.ADD_OKAY; |
| 2060 | case AppOpsManager.MODE_ERRORED: |
Billy Lau | cbe540f | 2015-06-25 01:51:44 +0100 | [diff] [blame] | 2061 | return WindowManagerGlobal.ADD_PERMISSION_DENIED; |
Billy Lau | 060275f | 2015-07-15 22:29:19 +0100 | [diff] [blame] | 2062 | default: |
| 2063 | // in the default mode, we will make a decision here based on |
| 2064 | // checkCallingPermission() |
| 2065 | if (mContext.checkCallingPermission(permission) != |
| 2066 | PackageManager.PERMISSION_GRANTED) { |
| 2067 | return WindowManagerGlobal.ADD_PERMISSION_DENIED; |
| 2068 | } else { |
| 2069 | return WindowManagerGlobal.ADD_OKAY; |
| 2070 | } |
Billy Lau | cbe540f | 2015-06-25 01:51:44 +0100 | [diff] [blame] | 2071 | } |
Billy Lau | cbe540f | 2015-06-25 01:51:44 +0100 | [diff] [blame] | 2072 | } |
| 2073 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2074 | if (mContext.checkCallingOrSelfPermission(permission) |
| 2075 | != PackageManager.PERMISSION_GRANTED) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2076 | return WindowManagerGlobal.ADD_PERMISSION_DENIED; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2077 | } |
| 2078 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2079 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2080 | } |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 2081 | |
| 2082 | @Override |
| 2083 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs) { |
| 2084 | |
| 2085 | // If this switch statement is modified, modify the comment in the declarations of |
| 2086 | // the type in {@link WindowManager.LayoutParams} as well. |
| 2087 | switch (attrs.type) { |
| 2088 | default: |
| 2089 | // These are the windows that by default are shown only to the user that created |
| 2090 | // them. If this needs to be overridden, set |
| 2091 | // {@link WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS} in |
| 2092 | // {@link WindowManager.LayoutParams}. Note that permission |
| 2093 | // {@link android.Manifest.permission.INTERNAL_SYSTEM_WINDOW} is required as well. |
| 2094 | if ((attrs.privateFlags & PRIVATE_FLAG_SHOW_FOR_ALL_USERS) == 0) { |
| 2095 | return true; |
| 2096 | } |
| 2097 | break; |
| 2098 | |
| 2099 | // These are the windows that by default are shown to all users. However, to |
| 2100 | // protect against spoofing, check permissions below. |
| 2101 | case TYPE_APPLICATION_STARTING: |
| 2102 | case TYPE_BOOT_PROGRESS: |
| 2103 | case TYPE_DISPLAY_OVERLAY: |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 2104 | case TYPE_INPUT_CONSUMER: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2105 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 2106 | case TYPE_KEYGUARD_DIALOG: |
| 2107 | case TYPE_MAGNIFICATION_OVERLAY: |
| 2108 | case TYPE_NAVIGATION_BAR: |
| 2109 | case TYPE_NAVIGATION_BAR_PANEL: |
| 2110 | case TYPE_PHONE: |
| 2111 | case TYPE_POINTER: |
| 2112 | case TYPE_PRIORITY_PHONE: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 2113 | case TYPE_SEARCH_BAR: |
| 2114 | case TYPE_STATUS_BAR: |
| 2115 | case TYPE_STATUS_BAR_PANEL: |
| 2116 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 2117 | case TYPE_SYSTEM_DIALOG: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 2118 | case TYPE_VOLUME_OVERLAY: |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 2119 | case TYPE_PRIVATE_PRESENTATION: |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 2120 | case TYPE_DOCK_DIVIDER: |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 2121 | break; |
| 2122 | } |
| 2123 | |
| 2124 | // Check if third party app has set window to system window type. |
| 2125 | return mContext.checkCallingOrSelfPermission( |
| 2126 | android.Manifest.permission.INTERNAL_SYSTEM_WINDOW) |
| 2127 | != PackageManager.PERMISSION_GRANTED; |
| 2128 | } |
| 2129 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 2130 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2131 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) { |
| 2132 | switch (attrs.type) { |
| 2133 | case TYPE_SYSTEM_OVERLAY: |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 2134 | case TYPE_SECURE_SYSTEM_OVERLAY: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2135 | // These types of windows can't receive input events. |
| 2136 | attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 2137 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 2138 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2139 | break; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2140 | case TYPE_STATUS_BAR: |
| 2141 | |
| 2142 | // If the Keyguard is in a hidden state (occluded by another window), we force to |
| 2143 | // remove the wallpaper and keyguard flag so that any change in-flight after setting |
| 2144 | // the keyguard as occluded wouldn't set these flags again. |
| 2145 | // See {@link #processKeyguardSetHiddenResultLw}. |
| 2146 | if (mKeyguardHidden) { |
| 2147 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; |
| 2148 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 2149 | } |
| 2150 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2151 | } |
Adrian Roos | 3850211 | 2014-04-09 21:04:11 +0200 | [diff] [blame] | 2152 | |
| 2153 | if (attrs.type != TYPE_STATUS_BAR) { |
| 2154 | // The status bar is the only window allowed to exhibit keyguard behavior. |
| 2155 | attrs.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD; |
| 2156 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 2157 | |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2158 | if (ActivityManager.isHighEndGfx()) { |
| 2159 | if ((attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) { |
| 2160 | attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; |
| 2161 | } |
| 2162 | if ((attrs.flags & FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0 |
Jorim Jaggi | 406585a | 2015-12-21 10:58:56 +0100 | [diff] [blame] | 2163 | || (mForceWindowDrawsStatusBarBackground |
| 2164 | && attrs.height == MATCH_PARENT && attrs.width == MATCH_PARENT)) { |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 2165 | attrs.subtreeSystemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; |
| 2166 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 2167 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2168 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2169 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2170 | void readLidState() { |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 2171 | mLidState = mWindowManagerFuncs.getLidState(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2172 | } |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2173 | |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 2174 | private void readCameraLensCoverState() { |
| 2175 | mCameraLensCoverState = mWindowManagerFuncs.getCameraLensCoverState(); |
| 2176 | } |
| 2177 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 2178 | private boolean isHidden(int accessibilityMode) { |
| 2179 | switch (accessibilityMode) { |
| 2180 | case 1: |
| 2181 | return mLidState == LID_CLOSED; |
| 2182 | case 2: |
| 2183 | return mLidState == LID_OPEN; |
| 2184 | default: |
| 2185 | return false; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 2186 | } |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 2187 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 2188 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2189 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 2190 | @Override |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 2191 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 2192 | int navigationPresence) { |
| 2193 | mHaveBuiltInKeyboard = (keyboardPresence & PRESENCE_INTERNAL) != 0; |
| 2194 | |
Jeff Brown | f71343d | 2013-05-31 17:59:11 -0700 | [diff] [blame] | 2195 | readConfigurationDependentBehaviors(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2196 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 2197 | applyLidSwitchState(); |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 2198 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 2199 | if (config.keyboard == Configuration.KEYBOARD_NOKEYS |
| 2200 | || (keyboardPresence == PRESENCE_INTERNAL |
| 2201 | && isHidden(mLidKeyboardAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 2202 | config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES; |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 2203 | if (!mHasSoftInput) { |
| 2204 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; |
| 2205 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 2206 | } |
| 2207 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 2208 | if (config.navigation == Configuration.NAVIGATION_NONAV |
| 2209 | || (navigationPresence == PRESENCE_INTERNAL |
| 2210 | && isHidden(mLidNavigationAccessibility))) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 2211 | config.navigationHidden = Configuration.NAVIGATIONHIDDEN_YES; |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 2212 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2213 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 2214 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2215 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 2216 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2217 | public int windowTypeToLayerLw(int type) { |
| 2218 | if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2219 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2220 | } |
| 2221 | switch (type) { |
keunyoung | a446bf0 | 2013-06-21 19:07:57 -0700 | [diff] [blame] | 2222 | case TYPE_PRIVATE_PRESENTATION: |
| 2223 | return 2; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2224 | case TYPE_WALLPAPER: |
| 2225 | // wallpaper is at the bottom, though the window manager may move it. |
| 2226 | return 2; |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2227 | case TYPE_DOCK_DIVIDER: |
| 2228 | return 2; |
Jason Monk | 8f7f318 | 2015-11-18 16:35:14 -0500 | [diff] [blame] | 2229 | case TYPE_QS_DIALOG: |
| 2230 | return 2; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2231 | case TYPE_PHONE: |
| 2232 | return 3; |
| 2233 | case TYPE_SEARCH_BAR: |
Jorim Jaggi | 225d3b5 | 2015-04-01 11:18:57 -0700 | [diff] [blame] | 2234 | case TYPE_VOICE_INTERACTION_STARTING: |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2235 | return 4; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2236 | case TYPE_VOICE_INTERACTION: |
| 2237 | // voice interaction layer is almost immediately above apps. |
| 2238 | return 5; |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 2239 | case TYPE_INPUT_CONSUMER: |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 2240 | return 6; |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 2241 | case TYPE_SYSTEM_DIALOG: |
| 2242 | return 7; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2243 | case TYPE_TOAST: |
| 2244 | // toasts and the plugged-in battery thing |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 2245 | return 8; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2246 | case TYPE_PRIORITY_PHONE: |
| 2247 | // SIM errors and unlock. Not sure if this really should be in a high layer. |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 2248 | return 9; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2249 | case TYPE_DREAM: |
| 2250 | // used for Dreams (screensavers with TYPE_DREAM windows) |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 2251 | return 10; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2252 | case TYPE_SYSTEM_ALERT: |
| 2253 | // like the ANR / app crashed dialogs |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 2254 | return 11; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2255 | case TYPE_INPUT_METHOD: |
| 2256 | // on-screen keyboards and other such input method user interfaces go here. |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 2257 | return 12; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2258 | case TYPE_INPUT_METHOD_DIALOG: |
| 2259 | // on-screen keyboards and other such input method user interfaces go here. |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 2260 | return 13; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2261 | case TYPE_KEYGUARD_SCRIM: |
| 2262 | // the safety window that shows behind keyguard while keyguard is starting |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2263 | return 14; |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 2264 | case TYPE_STATUS_BAR_SUB_PANEL: |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2265 | return 15; |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 2266 | case TYPE_STATUS_BAR: |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2267 | return 16; |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 2268 | case TYPE_STATUS_BAR_PANEL: |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2269 | return 17; |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 2270 | case TYPE_KEYGUARD_DIALOG: |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2271 | return 18; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2272 | case TYPE_VOLUME_OVERLAY: |
| 2273 | // the on-screen volume indicator and controller shown when the user |
| 2274 | // changes the device volume |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2275 | return 19; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2276 | case TYPE_SYSTEM_OVERLAY: |
| 2277 | // the on-screen volume indicator and controller shown when the user |
| 2278 | // changes the device volume |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2279 | return 20; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2280 | case TYPE_NAVIGATION_BAR: |
| 2281 | // the navigation bar, if available, shows atop most things |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2282 | return 21; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2283 | case TYPE_NAVIGATION_BAR_PANEL: |
| 2284 | // some panels (e.g. search) need to show on top of the navigation bar |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2285 | return 22; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2286 | case TYPE_SYSTEM_ERROR: |
| 2287 | // system-level error dialogs |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2288 | return 23; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2289 | case TYPE_MAGNIFICATION_OVERLAY: |
| 2290 | // used to highlight the magnified portion of a display |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2291 | return 24; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2292 | case TYPE_DISPLAY_OVERLAY: |
| 2293 | // used to simulate secondary display devices |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2294 | return 25; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2295 | case TYPE_DRAG: |
| 2296 | // the drag layer: input for drag-and-drop is associated with this window, |
| 2297 | // which sits above all other focusable windows |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2298 | return 26; |
Svetoslav | 3a5c721 | 2014-10-14 09:54:26 -0700 | [diff] [blame] | 2299 | case TYPE_ACCESSIBILITY_OVERLAY: |
| 2300 | // overlay put by accessibility services to intercept user interaction |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2301 | return 27; |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 2302 | case TYPE_SECURE_SYSTEM_OVERLAY: |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2303 | return 28; |
Filip Gruszczynski | 466f321 | 2015-09-21 17:57:57 -0700 | [diff] [blame] | 2304 | case TYPE_BOOT_PROGRESS: |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2305 | return 29; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2306 | case TYPE_POINTER: |
| 2307 | // the (mouse) pointer layer |
Filip Gruszczynski | e95b0ae | 2015-09-30 10:55:33 -0700 | [diff] [blame] | 2308 | return 30; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2309 | } |
| 2310 | Log.e(TAG, "Unknown window type: " + type); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2311 | return 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2312 | } |
| 2313 | |
| 2314 | /** {@inheritDoc} */ |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 2315 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2316 | public int subWindowTypeToLayerLw(int type) { |
| 2317 | switch (type) { |
| 2318 | case TYPE_APPLICATION_PANEL: |
| 2319 | case TYPE_APPLICATION_ATTACHED_DIALOG: |
| 2320 | return APPLICATION_PANEL_SUBLAYER; |
| 2321 | case TYPE_APPLICATION_MEDIA: |
| 2322 | return APPLICATION_MEDIA_SUBLAYER; |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 2323 | case TYPE_APPLICATION_MEDIA_OVERLAY: |
| 2324 | return APPLICATION_MEDIA_OVERLAY_SUBLAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2325 | case TYPE_APPLICATION_SUB_PANEL: |
| 2326 | return APPLICATION_SUB_PANEL_SUBLAYER; |
Wale Ogunwale | 0a4dc22 | 2015-04-14 12:58:42 -0700 | [diff] [blame] | 2327 | case TYPE_APPLICATION_ABOVE_SUB_PANEL: |
| 2328 | return APPLICATION_ABOVE_SUB_PANEL_SUBLAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2329 | } |
| 2330 | Log.e(TAG, "Unknown sub-window type: " + type); |
| 2331 | return 0; |
| 2332 | } |
| 2333 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 2334 | @Override |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 2335 | public int getMaxWallpaperLayer() { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2336 | return windowTypeToLayerLw(TYPE_STATUS_BAR); |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 2337 | } |
| 2338 | |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 2339 | private int getNavigationBarWidth(int rotation, int uiMode) { |
| 2340 | if ((uiMode & UI_MODE_TYPE_MASK) == UI_MODE_TYPE_CAR) { |
| 2341 | return mNavigationBarWidthForRotationInCarMode[rotation]; |
| 2342 | } else { |
| 2343 | return mNavigationBarWidthForRotationDefault[rotation]; |
| 2344 | } |
| 2345 | } |
| 2346 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 2347 | @Override |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 2348 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, |
| 2349 | int uiMode) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 2350 | if (mHasNavigationBar) { |
| 2351 | // For a basic navigation bar, when we are in landscape mode we place |
| 2352 | // the navigation bar to the side. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 2353 | if (mNavigationBarCanMove && fullWidth > fullHeight) { |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 2354 | return fullWidth - getNavigationBarWidth(rotation, uiMode); |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 2355 | } |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 2356 | } |
| 2357 | return fullWidth; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 2358 | } |
| 2359 | |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 2360 | private int getNavigationBarHeight(int rotation, int uiMode) { |
| 2361 | if ((uiMode & UI_MODE_TYPE_MASK) == UI_MODE_TYPE_CAR) { |
| 2362 | return mNavigationBarHeightForRotationInCarMode[rotation]; |
| 2363 | } else { |
| 2364 | return mNavigationBarHeightForRotationDefault[rotation]; |
| 2365 | } |
| 2366 | } |
| 2367 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2368 | @Override |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 2369 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation, |
| 2370 | int uiMode) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 2371 | if (mHasNavigationBar) { |
| 2372 | // For a basic navigation bar, when we are in portrait mode we place |
| 2373 | // the navigation bar to the bottom. |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 2374 | if (!mNavigationBarCanMove || fullWidth < fullHeight) { |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 2375 | return fullHeight - getNavigationBarHeight(rotation, uiMode); |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame] | 2376 | } |
| 2377 | } |
| 2378 | return fullHeight; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 2379 | } |
| 2380 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2381 | @Override |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 2382 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation, int uiMode) { |
| 2383 | return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation, uiMode); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 2384 | } |
| 2385 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2386 | @Override |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 2387 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation, int uiMode) { |
John Spurlock | 80f00c1 | 2013-06-13 11:10:51 -0400 | [diff] [blame] | 2388 | // There is a separate status bar at the top of the display. We don't count that as part |
| 2389 | // 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] | 2390 | // we do want to exclude it since applications can't generally use that part |
| 2391 | // of the screen. |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 2392 | return getNonDecorDisplayHeight( |
| 2393 | fullWidth, fullHeight, rotation, uiMode) - mStatusBarHeight; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 2394 | } |
| 2395 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 2396 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 2397 | public boolean isForceHiding(WindowManager.LayoutParams attrs) { |
| 2398 | return (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 || |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2399 | (isKeyguardHostWindow(attrs) && |
| 2400 | (mKeyguardDelegate != null && mKeyguardDelegate.isShowing())) || |
Adrian Roos | 69e510d | 2014-07-13 14:57:59 +0200 | [diff] [blame] | 2401 | (attrs.type == TYPE_KEYGUARD_SCRIM); |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 2402 | } |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2403 | |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 2404 | @Override |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 2405 | public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs) { |
| 2406 | return attrs.type == TYPE_STATUS_BAR; |
| 2407 | } |
| 2408 | |
| 2409 | @Override |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 2410 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs) { |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 2411 | switch (attrs.type) { |
| 2412 | case TYPE_STATUS_BAR: |
| 2413 | case TYPE_NAVIGATION_BAR: |
| 2414 | case TYPE_WALLPAPER: |
| 2415 | case TYPE_DREAM: |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2416 | case TYPE_KEYGUARD_SCRIM: |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 2417 | return false; |
| 2418 | default: |
Adrian Roos | 461829d | 2015-06-03 14:41:18 -0700 | [diff] [blame] | 2419 | // Hide only windows below the keyguard host window. |
| 2420 | return windowTypeToLayerLw(win.getBaseType()) |
| 2421 | < windowTypeToLayerLw(TYPE_STATUS_BAR); |
Craig Mautner | a3f4bf5 | 2012-10-10 20:37:48 -0700 | [diff] [blame] | 2422 | } |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 2423 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2424 | |
Craig Mautner | 7d7808f | 2014-09-11 18:02:38 -0700 | [diff] [blame] | 2425 | @Override |
| 2426 | public WindowState getWinShowWhenLockedLw() { |
| 2427 | return mWinShowWhenLocked; |
| 2428 | } |
| 2429 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2430 | /** {@inheritDoc} */ |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2431 | @Override |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 2432 | public View addStartingWindow(IBinder appToken, String packageName, int theme, |
| 2433 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 2434 | int icon, int logo, int windowFlags) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2435 | if (!SHOW_STARTING_ANIMATIONS) { |
| 2436 | return null; |
| 2437 | } |
| 2438 | if (packageName == null) { |
| 2439 | return null; |
| 2440 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2441 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 2442 | WindowManager wm = null; |
| 2443 | View view = null; |
| 2444 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2445 | try { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2446 | Context context = mContext; |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 2447 | if (DEBUG_STARTING_WINDOW) Slog.d(TAG, "addStartingWindow " + packageName |
| 2448 | + ": nonLocalizedLabel=" + nonLocalizedLabel + " theme=" |
| 2449 | + Integer.toHexString(theme)); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 2450 | if (theme != context.getThemeResId() || labelRes != 0) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2451 | try { |
| 2452 | context = context.createPackageContext(packageName, 0); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 2453 | context.setTheme(theme); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2454 | } catch (PackageManager.NameNotFoundException e) { |
| 2455 | // Ignore |
| 2456 | } |
| 2457 | } |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2458 | |
Jorim Jaggi | a16cc15 | 2015-06-01 16:55:05 -0700 | [diff] [blame] | 2459 | PhoneWindow win = new PhoneWindow(context); |
| 2460 | win.setIsStartingWindow(true); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2461 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2462 | Resources r = context.getResources(); |
| 2463 | win.setTitle(r.getText(labelRes, nonLocalizedLabel)); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2464 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2465 | win.setType( |
| 2466 | WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); |
Adrian Roos | 602c68e | 2015-04-24 16:03:47 -0700 | [diff] [blame] | 2467 | |
| 2468 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
| 2469 | // Assumes it's safe to show starting windows of launched apps while |
| 2470 | // the keyguard is being hidden. This is okay because starting windows never show |
| 2471 | // secret information. |
| 2472 | if (mKeyguardHidden) { |
| 2473 | windowFlags |= FLAG_SHOW_WHEN_LOCKED; |
| 2474 | } |
| 2475 | } |
| 2476 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2477 | // Force the window flags: this is a fake window, so it is not really |
| 2478 | // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM |
| 2479 | // flag because we do know that the next window will take input |
| 2480 | // focus, so we want to get the IME window up on top of us right away. |
| 2481 | win.setFlags( |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 2482 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2483 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 2484 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 2485 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 2486 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2487 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 2488 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 2489 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2490 | |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 2491 | win.setDefaultIcon(icon); |
| 2492 | win.setDefaultLogo(logo); |
| 2493 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2494 | win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 2495 | WindowManager.LayoutParams.MATCH_PARENT); |
Craig Mautner | 8e4df6c | 2012-05-23 16:57:23 -0700 | [diff] [blame] | 2496 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2497 | final WindowManager.LayoutParams params = win.getAttributes(); |
| 2498 | params.token = appToken; |
| 2499 | params.packageName = packageName; |
| 2500 | params.windowAnimations = win.getWindowStyle().getResourceId( |
| 2501 | com.android.internal.R.styleable.Window_windowAnimationStyle, 0); |
John Reck | 61375a8 | 2014-09-18 19:27:48 +0000 | [diff] [blame] | 2502 | params.privateFlags |= |
| 2503 | WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED; |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 2504 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 2505 | |
| 2506 | if (!compatInfo.supportsScreen()) { |
| 2507 | params.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_COMPATIBLE_WINDOW; |
| 2508 | } |
| 2509 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2510 | params.setTitle("Starting " + packageName); |
| 2511 | |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 2512 | wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
| 2513 | view = win.getDecorView(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2514 | |
Craig Mautner | 6fbda63 | 2012-07-03 09:26:39 -0700 | [diff] [blame] | 2515 | if (DEBUG_STARTING_WINDOW) Slog.d( |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2516 | TAG, "Adding starting window for " + packageName |
| 2517 | + " / " + appToken + ": " |
| 2518 | + (view.getParent() != null ? view : null)); |
| 2519 | |
| 2520 | wm.addView(view, params); |
| 2521 | |
| 2522 | // Only return the view if it was successfully added to the |
| 2523 | // window manager... which we can tell by it having a parent. |
| 2524 | return view.getParent() != null ? view : null; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2525 | } catch (WindowManager.BadTokenException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2526 | // ignore |
Craig Mautner | 42bf39e | 2014-02-21 16:46:22 -0800 | [diff] [blame] | 2527 | Log.w(TAG, appToken + " already running, starting window not displayed. " + |
| 2528 | e.getMessage()); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 2529 | } catch (RuntimeException e) { |
| 2530 | // don't crash if something else bad happens, for example a |
| 2531 | // failure loading resources because we are loading from an app |
| 2532 | // on external storage that has been unmounted. |
| 2533 | Log.w(TAG, appToken + " failed creating starting window", e); |
Mathias Jeppsson | d1443e9 | 2012-08-24 15:25:32 +0200 | [diff] [blame] | 2534 | } finally { |
| 2535 | if (view != null && view.getParent() == null) { |
| 2536 | Log.w(TAG, "view not successfully added to wm, removing view"); |
| 2537 | wm.removeViewImmediate(view); |
| 2538 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2539 | } |
| 2540 | |
| 2541 | return null; |
| 2542 | } |
| 2543 | |
| 2544 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2545 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2546 | public void removeStartingWindow(IBinder appToken, View window) { |
Craig Mautner | 276a6eb | 2014-11-04 15:32:57 -0800 | [diff] [blame] | 2547 | if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Removing starting window for " + appToken + ": " |
| 2548 | + window + " Callers=" + Debug.getCallers(4)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2549 | |
| 2550 | if (window != null) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 2551 | WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2552 | wm.removeView(window); |
| 2553 | } |
| 2554 | } |
| 2555 | |
| 2556 | /** |
| 2557 | * Preflight adding a window to the system. |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2558 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2559 | * Currently enforces that three window types are singletons: |
| 2560 | * <ul> |
| 2561 | * <li>STATUS_BAR_TYPE</li> |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2562 | * <li>KEYGUARD_TYPE</li> |
| 2563 | * </ul> |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2564 | * |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2565 | * @param win The window to be added |
| 2566 | * @param attrs Information about the window to be added |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2567 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2568 | * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, |
| 2569 | * WindowManagerImpl.ADD_MULTIPLE_SINGLETON |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2570 | */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2571 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2572 | public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) { |
| 2573 | switch (attrs.type) { |
| 2574 | case TYPE_STATUS_BAR: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 2575 | mContext.enforceCallingOrSelfPermission( |
| 2576 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 2577 | "PhoneWindowManager"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2578 | if (mStatusBar != null) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2579 | if (mStatusBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2580 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2581 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2582 | } |
| 2583 | mStatusBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2584 | mStatusBarController.setWindow(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2585 | break; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2586 | case TYPE_NAVIGATION_BAR: |
| 2587 | mContext.enforceCallingOrSelfPermission( |
| 2588 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 2589 | "PhoneWindowManager"); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2590 | if (mNavigationBar != null) { |
| 2591 | if (mNavigationBar.isAlive()) { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2592 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2593 | } |
| 2594 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2595 | mNavigationBar = win; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2596 | mNavigationBarController.setWindow(win); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 2597 | if (DEBUG_LAYOUT) Slog.i(TAG, "NAVIGATION BAR: " + mNavigationBar); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2598 | break; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 2599 | case TYPE_NAVIGATION_BAR_PANEL: |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 2600 | case TYPE_STATUS_BAR_PANEL: |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2601 | case TYPE_STATUS_BAR_SUB_PANEL: |
Jorim Jaggi | 225d3b5 | 2015-04-01 11:18:57 -0700 | [diff] [blame] | 2602 | case TYPE_VOICE_INTERACTION_STARTING: |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2603 | mContext.enforceCallingOrSelfPermission( |
| 2604 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 2605 | "PhoneWindowManager"); |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2606 | break; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2607 | case TYPE_KEYGUARD_SCRIM: |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 2608 | if (mKeyguardScrim != null) { |
| 2609 | return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON; |
| 2610 | } |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2611 | mKeyguardScrim = win; |
| 2612 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2613 | } |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2614 | return WindowManagerGlobal.ADD_OKAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2615 | } |
| 2616 | |
| 2617 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 2618 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2619 | public void removeWindowLw(WindowState win) { |
| 2620 | if (mStatusBar == win) { |
| 2621 | mStatusBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2622 | mStatusBarController.setWindow(null); |
Jim Miller | c0b676d | 2013-03-22 16:11:08 -0700 | [diff] [blame] | 2623 | mKeyguardDelegate.showScrim(); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 2624 | } else if (mKeyguardScrim == win) { |
| 2625 | Log.v(TAG, "Removing keyguard scrim"); |
| 2626 | mKeyguardScrim = null; |
| 2627 | } if (mNavigationBar == win) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2628 | mNavigationBar = null; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 2629 | mNavigationBarController.setWindow(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2630 | } |
| 2631 | } |
| 2632 | |
| 2633 | static final boolean PRINT_ANIM = false; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 2634 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2635 | /** {@inheritDoc} */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2636 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2637 | public int selectAnimationLw(WindowState win, int transit) { |
| 2638 | if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win |
| 2639 | + ": transit=" + transit); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2640 | if (win == mStatusBar) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2641 | boolean isKeyguard = (win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2642 | if (transit == TRANSIT_EXIT |
| 2643 | || transit == TRANSIT_HIDE) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2644 | return isKeyguard ? -1 : R.anim.dock_top_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2645 | } else if (transit == TRANSIT_ENTER |
| 2646 | || transit == TRANSIT_SHOW) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2647 | return isKeyguard ? -1 : R.anim.dock_top_enter; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2648 | } |
| 2649 | } else if (win == mNavigationBar) { |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 2650 | if (win.getAttrs().windowAnimations != 0) { |
| 2651 | return 0; |
| 2652 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2653 | // This can be on either the bottom or the right. |
| 2654 | if (mNavigationBarOnBottom) { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2655 | if (transit == TRANSIT_EXIT |
| 2656 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2657 | return R.anim.dock_bottom_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2658 | } else if (transit == TRANSIT_ENTER |
| 2659 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2660 | return R.anim.dock_bottom_enter; |
| 2661 | } |
| 2662 | } else { |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2663 | if (transit == TRANSIT_EXIT |
| 2664 | || transit == TRANSIT_HIDE) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2665 | return R.anim.dock_right_exit; |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2666 | } else if (transit == TRANSIT_ENTER |
| 2667 | || transit == TRANSIT_SHOW) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2668 | return R.anim.dock_right_enter; |
| 2669 | } |
| 2670 | } |
Filip Gruszczynski | 57f76f1 | 2015-11-04 16:10:54 -0800 | [diff] [blame] | 2671 | } else if (win.getAttrs().type == TYPE_DOCK_DIVIDER) { |
Jorim Jaggi | 81ba11e | 2016-02-03 22:04:22 -0800 | [diff] [blame] | 2672 | return selectDockedDividerAnimationLw(win, transit); |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 2673 | } |
| 2674 | |
| 2675 | if (transit == TRANSIT_PREVIEW_DONE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2676 | if (win.hasAppShownWindows()) { |
| 2677 | if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT"); |
| 2678 | return com.android.internal.R.anim.app_starting_exit; |
| 2679 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 2680 | } else if (win.getAttrs().type == TYPE_DREAM && mDreamingLockscreen |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 2681 | && transit == TRANSIT_ENTER) { |
| 2682 | // Special case: we are animating in a dream, while the keyguard |
| 2683 | // is shown. We don't want an animation on the dream, because |
| 2684 | // we need it shown immediately with the keyguard animating away |
| 2685 | // to reveal it. |
| 2686 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2687 | } |
| 2688 | |
| 2689 | return 0; |
| 2690 | } |
| 2691 | |
Jorim Jaggi | 81ba11e | 2016-02-03 22:04:22 -0800 | [diff] [blame] | 2692 | private int selectDockedDividerAnimationLw(WindowState win, int transit) { |
| 2693 | int insets = mWindowManagerFuncs.getDockedDividerInsetsLw(); |
| 2694 | |
| 2695 | // If the divider is behind the navigation bar, don't animate. |
| 2696 | if (mNavigationBar != null |
| 2697 | && (win.getFrameLw().top + insets >= mNavigationBar.getFrameLw().top |
| 2698 | || win.getFrameLw().left + insets >= mNavigationBar.getFrameLw().left)) { |
| 2699 | return 0; |
| 2700 | } |
| 2701 | if (transit == TRANSIT_ENTER || transit == TRANSIT_SHOW) { |
| 2702 | return R.anim.fade_in; |
| 2703 | } else if (transit == TRANSIT_EXIT) { |
| 2704 | return R.anim.fade_out; |
| 2705 | } else { |
| 2706 | return 0; |
| 2707 | } |
| 2708 | } |
| 2709 | |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 2710 | @Override |
| 2711 | public void selectRotationAnimationLw(int anim[]) { |
| 2712 | if (PRINT_ANIM) Slog.i(TAG, "selectRotationAnimation mTopFullscreen=" |
| 2713 | + mTopFullscreenOpaqueWindowState + " rotationAnimation=" |
| 2714 | + (mTopFullscreenOpaqueWindowState == null ? |
| 2715 | "0" : mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation)); |
| 2716 | if (mTopFullscreenOpaqueWindowState != null && mTopIsFullscreen) { |
| 2717 | switch (mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation) { |
| 2718 | case ROTATION_ANIMATION_CROSSFADE: |
| 2719 | anim[0] = R.anim.rotation_animation_xfade_exit; |
| 2720 | anim[1] = R.anim.rotation_animation_enter; |
| 2721 | break; |
| 2722 | case ROTATION_ANIMATION_JUMPCUT: |
| 2723 | anim[0] = R.anim.rotation_animation_jump_exit; |
| 2724 | anim[1] = R.anim.rotation_animation_enter; |
| 2725 | break; |
| 2726 | case ROTATION_ANIMATION_ROTATE: |
| 2727 | default: |
| 2728 | anim[0] = anim[1] = 0; |
| 2729 | break; |
| 2730 | } |
| 2731 | } else { |
| 2732 | anim[0] = anim[1] = 0; |
| 2733 | } |
| 2734 | } |
| 2735 | |
| 2736 | @Override |
| 2737 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 2738 | boolean forceDefault) { |
| 2739 | switch (exitAnimId) { |
| 2740 | case R.anim.rotation_animation_xfade_exit: |
| 2741 | case R.anim.rotation_animation_jump_exit: |
| 2742 | // These are the only cases that matter. |
| 2743 | if (forceDefault) { |
| 2744 | return false; |
| 2745 | } |
| 2746 | int anim[] = new int[2]; |
| 2747 | selectRotationAnimationLw(anim); |
| 2748 | return (exitAnimId == anim[0] && enterAnimId == anim[1]); |
| 2749 | default: |
| 2750 | return true; |
| 2751 | } |
| 2752 | } |
| 2753 | |
| 2754 | @Override |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 2755 | public Animation createForceHideEnterAnimation(boolean onWallpaper, |
| 2756 | boolean goingToNotificationShade) { |
| 2757 | if (goingToNotificationShade) { |
| 2758 | return AnimationUtils.loadAnimation(mContext, R.anim.lock_screen_behind_enter_fade_in); |
Craig Mautner | b834080 | 2014-11-04 15:32:57 -0800 | [diff] [blame] | 2759 | } |
Craig Mautner | 276a6eb | 2014-11-04 15:32:57 -0800 | [diff] [blame] | 2760 | |
| 2761 | AnimationSet set = (AnimationSet) AnimationUtils.loadAnimation(mContext, onWallpaper ? |
| 2762 | R.anim.lock_screen_behind_enter_wallpaper : |
| 2763 | R.anim.lock_screen_behind_enter); |
| 2764 | |
| 2765 | // TODO: Use XML interpolators when we have log interpolators available in XML. |
| 2766 | final List<Animation> animations = set.getAnimations(); |
| 2767 | for (int i = animations.size() - 1; i >= 0; --i) { |
| 2768 | animations.get(i).setInterpolator(mLogDecelerateInterpolator); |
| 2769 | } |
| 2770 | |
| 2771 | return set; |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 2772 | } |
| 2773 | |
| 2774 | |
| 2775 | @Override |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 2776 | public Animation createForceHideWallpaperExitAnimation(boolean goingToNotificationShade) { |
| 2777 | if (goingToNotificationShade) { |
| 2778 | return null; |
| 2779 | } else { |
| 2780 | return AnimationUtils.loadAnimation(mContext, R.anim.lock_screen_wallpaper_exit); |
| 2781 | } |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 2782 | } |
John Spurlock | c8b46ca | 2013-04-08 12:59:26 -0400 | [diff] [blame] | 2783 | |
| 2784 | private static void awakenDreams() { |
| 2785 | IDreamManager dreamManager = getDreamManager(); |
| 2786 | if (dreamManager != null) { |
| 2787 | try { |
| 2788 | dreamManager.awaken(); |
| 2789 | } catch (RemoteException e) { |
| 2790 | // fine, stay asleep then |
| 2791 | } |
| 2792 | } |
| 2793 | } |
| 2794 | |
| 2795 | static IDreamManager getDreamManager() { |
| 2796 | return IDreamManager.Stub.asInterface( |
| 2797 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
| 2798 | } |
| 2799 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2800 | TelecomManager getTelecommService() { |
| 2801 | return (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2802 | } |
| 2803 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 2804 | static IAudioService getAudioService() { |
| 2805 | IAudioService audioService = IAudioService.Stub.asInterface( |
| 2806 | ServiceManager.checkService(Context.AUDIO_SERVICE)); |
| 2807 | if (audioService == null) { |
| 2808 | Log.w(TAG, "Unable to find IAudioService interface."); |
| 2809 | } |
| 2810 | return audioService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2811 | } |
| 2812 | |
| 2813 | boolean keyguardOn() { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 2814 | return isKeyguardShowingAndNotOccluded() || inKeyguardRestrictedKeyInputMode(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2815 | } |
| 2816 | |
| 2817 | private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { |
| 2818 | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, |
| 2819 | WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, |
| 2820 | }; |
| 2821 | |
| 2822 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2823 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2824 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2825 | final boolean keyguardOn = keyguardOn(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2826 | final int keyCode = event.getKeyCode(); |
| 2827 | final int repeatCount = event.getRepeatCount(); |
| 2828 | final int metaState = event.getMetaState(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2829 | final int flags = event.getFlags(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2830 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 2831 | final boolean canceled = event.isCanceled(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2832 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 2833 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2834 | Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount=" |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2835 | + repeatCount + " keyguardOn=" + keyguardOn + " mHomePressed=" + mHomePressed |
| 2836 | + " canceled=" + canceled); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2837 | } |
| 2838 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2839 | // If we think we might have a volume down & power key chord on the way |
| 2840 | // but we're not sure, then tell the dispatcher to wait a little while and |
| 2841 | // try again later before dispatching. |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 2842 | if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2843 | if (mScreenshotChordVolumeDownKeyTriggered && !mScreenshotChordPowerKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2844 | final long now = SystemClock.uptimeMillis(); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2845 | final long timeoutTime = mScreenshotChordVolumeDownKeyTime |
| 2846 | + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2847 | if (now < timeoutTime) { |
| 2848 | return timeoutTime - now; |
| 2849 | } |
| 2850 | } |
| 2851 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2852 | && mScreenshotChordVolumeDownKeyConsumed) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2853 | if (!down) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2854 | mScreenshotChordVolumeDownKeyConsumed = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2855 | } |
| 2856 | return -1; |
| 2857 | } |
| 2858 | } |
| 2859 | |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2860 | // Cancel any pending meta actions if we see any other keys being pressed between the down |
| 2861 | // of the meta key and its corresponding up. |
Michael Wright | 251e35d | 2014-08-22 15:40:27 -0700 | [diff] [blame] | 2862 | if (mPendingMetaAction && !KeyEvent.isMetaKey(keyCode)) { |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 2863 | mPendingMetaAction = false; |
| 2864 | } |
| 2865 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2866 | // First we always handle the home key here, so applications |
| 2867 | // can never break it, although if keyguard is on, we do let |
| 2868 | // it handle it, because that gives us the correct 5 second |
| 2869 | // timeout. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2870 | if (keyCode == KeyEvent.KEYCODE_HOME) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2871 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2872 | // If we have released the home key, and didn't do anything else |
| 2873 | // while it was pressed, then it is time to go home! |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2874 | if (!down) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2875 | cancelPreloadRecentApps(); |
| 2876 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2877 | mHomePressed = false; |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2878 | if (mHomeConsumed) { |
| 2879 | mHomeConsumed = false; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2880 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2881 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2882 | |
| 2883 | if (canceled) { |
| 2884 | Log.i(TAG, "Ignoring HOME; event canceled."); |
| 2885 | return -1; |
| 2886 | } |
| 2887 | |
Yorke Lee | 4f80324 | 2014-12-15 23:22:06 +0000 | [diff] [blame] | 2888 | // If an incoming call is ringing, HOME is totally disabled. |
| 2889 | // (The user is already on the InCallUI at this point, |
| 2890 | // and his ONLY options are to answer or reject the call.) |
| 2891 | TelecomManager telecomManager = getTelecommService(); |
| 2892 | if (telecomManager != null && telecomManager.isRinging()) { |
| 2893 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); |
| 2894 | return -1; |
| 2895 | } |
| 2896 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2897 | // Delay handling home if a double-tap is possible. |
| 2898 | if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) { |
| 2899 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case |
| 2900 | mHomeDoubleTapPending = true; |
| 2901 | mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable, |
| 2902 | ViewConfiguration.getDoubleTapTimeout()); |
| 2903 | return -1; |
| 2904 | } |
| 2905 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 2906 | handleShortPressOnHome(); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2907 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2908 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2909 | |
| 2910 | // If a system window has focus, then it doesn't make sense |
| 2911 | // right now to interact with applications. |
| 2912 | WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null; |
| 2913 | if (attrs != null) { |
| 2914 | final int type = attrs.type; |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 2915 | if (type == WindowManager.LayoutParams.TYPE_KEYGUARD_SCRIM |
| 2916 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG |
| 2917 | || (attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2918 | // the "app" is keyguard, so give it the key |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2919 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2920 | } |
| 2921 | final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length; |
| 2922 | for (int i=0; i<typeCount; i++) { |
| 2923 | if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) { |
| 2924 | // 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] | 2925 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2926 | } |
| 2927 | } |
| 2928 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2929 | |
| 2930 | // Remember that home is pressed and handle special actions. |
| 2931 | if (repeatCount == 0) { |
| 2932 | mHomePressed = true; |
| 2933 | if (mHomeDoubleTapPending) { |
| 2934 | mHomeDoubleTapPending = false; |
| 2935 | mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); |
| 2936 | handleDoubleTapOnHome(); |
| 2937 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI |
| 2938 | || mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) { |
| 2939 | preloadRecentApps(); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 2940 | } |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2941 | } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { |
| 2942 | if (!keyguardOn) { |
Jaewan Kim | 76b7d0d | 2016-02-12 19:01:02 +0900 | [diff] [blame] | 2943 | handleLongPressOnHome(event.getDeviceId()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2944 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2945 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2946 | return -1; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2947 | } else if (keyCode == KeyEvent.KEYCODE_MENU) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2948 | // Hijack modified menu keys for debugging features |
| 2949 | final int chordBug = KeyEvent.META_SHIFT_ON; |
| 2950 | |
| 2951 | if (down && repeatCount == 0) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2952 | if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2953 | Intent intent = new Intent(Intent.ACTION_BUG_REPORT); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2954 | mContext.sendOrderedBroadcastAsUser(intent, UserHandle.CURRENT, |
| 2955 | null, null, null, 0, null, null); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2956 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2957 | } else if (SHOW_PROCESSES_ON_ALT_MENU && |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2958 | (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2959 | Intent service = new Intent(); |
| 2960 | service.setClassName(mContext, "com.android.server.LoadAverageService"); |
| 2961 | ContentResolver res = mContext.getContentResolver(); |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2962 | boolean shown = Settings.Global.getInt( |
| 2963 | res, Settings.Global.SHOW_PROCESSES, 0) != 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2964 | if (!shown) { |
| 2965 | mContext.startService(service); |
| 2966 | } else { |
| 2967 | mContext.stopService(service); |
| 2968 | } |
Jeff Sharkey | 8d9a1f6 | 2012-10-18 15:38:14 -0700 | [diff] [blame] | 2969 | Settings.Global.putInt( |
| 2970 | res, Settings.Global.SHOW_PROCESSES, shown ? 0 : 1); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2971 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2972 | } |
| 2973 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2974 | } else if (keyCode == KeyEvent.KEYCODE_SEARCH) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2975 | if (down) { |
| 2976 | if (repeatCount == 0) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2977 | mSearchKeyShortcutPending = true; |
| 2978 | mConsumeSearchKeyUp = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2979 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 2980 | } else { |
| 2981 | mSearchKeyShortcutPending = false; |
| 2982 | if (mConsumeSearchKeyUp) { |
| 2983 | mConsumeSearchKeyUp = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2984 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2985 | } |
| 2986 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2987 | return 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2988 | } else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) { |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2989 | if (!keyguardOn) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 2990 | if (down && repeatCount == 0) { |
| 2991 | preloadRecentApps(); |
| 2992 | } else if (!down) { |
| 2993 | toggleRecentApps(); |
Michael Wright | c9ebea7 | 2013-01-16 19:25:02 -0800 | [diff] [blame] | 2994 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 2995 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2996 | return -1; |
Jun Mukai | d21b3c8 | 2015-04-23 14:09:34 -0700 | [diff] [blame] | 2997 | } else if (keyCode == KeyEvent.KEYCODE_N && event.isMetaPressed()) { |
| 2998 | if (down) { |
| 2999 | IStatusBarService service = getStatusBarService(); |
| 3000 | if (service != null) { |
| 3001 | try { |
| 3002 | service.expandNotificationsPanel(); |
| 3003 | } catch (RemoteException e) { |
| 3004 | // do nothing. |
| 3005 | } |
| 3006 | } |
| 3007 | } |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame] | 3008 | } else if (keyCode == KeyEvent.KEYCODE_SLASH && event.isMetaPressed()) { |
| 3009 | if (down) { |
| 3010 | if (repeatCount == 0) { |
Andrei Stingaceanu | c22ab79 | 2016-01-07 12:39:38 +0000 | [diff] [blame] | 3011 | toggleKeyboardShortcutsMenu(); |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame] | 3012 | } |
| 3013 | } |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 3014 | } else if (keyCode == KeyEvent.KEYCODE_ASSIST) { |
| 3015 | if (down) { |
| 3016 | if (repeatCount == 0) { |
| 3017 | mAssistKeyLongPressed = false; |
| 3018 | } else if (repeatCount == 1) { |
| 3019 | mAssistKeyLongPressed = true; |
| 3020 | if (!keyguardOn) { |
| 3021 | launchAssistLongPressAction(); |
| 3022 | } |
| 3023 | } |
| 3024 | } else { |
| 3025 | if (mAssistKeyLongPressed) { |
| 3026 | mAssistKeyLongPressed = false; |
| 3027 | } else { |
| 3028 | if (!keyguardOn) { |
Tim Kilbourn | 0e5f110 | 2015-06-05 16:18:09 -0700 | [diff] [blame] | 3029 | launchAssistAction(null, event.getDeviceId()); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 3030 | } |
| 3031 | } |
| 3032 | } |
| 3033 | return -1; |
Michael Wright | dc63f7b | 2014-08-21 19:05:21 -0700 | [diff] [blame] | 3034 | } else if (keyCode == KeyEvent.KEYCODE_VOICE_ASSIST) { |
| 3035 | if (!down) { |
| 3036 | Intent voiceIntent; |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 3037 | if (!keyguardOn) { |
Michael Wright | dc63f7b | 2014-08-21 19:05:21 -0700 | [diff] [blame] | 3038 | voiceIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); |
| 3039 | } else { |
Dianne Hackborn | b6683c4 | 2015-06-18 17:40:33 -0700 | [diff] [blame] | 3040 | IDeviceIdleController dic = IDeviceIdleController.Stub.asInterface( |
| 3041 | ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER)); |
| 3042 | if (dic != null) { |
| 3043 | try { |
| 3044 | dic.exitIdle("voice-search"); |
| 3045 | } catch (RemoteException e) { |
| 3046 | } |
| 3047 | } |
Michael Wright | dc63f7b | 2014-08-21 19:05:21 -0700 | [diff] [blame] | 3048 | voiceIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE); |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 3049 | voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, true); |
Michael Wright | dc63f7b | 2014-08-21 19:05:21 -0700 | [diff] [blame] | 3050 | } |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 3051 | startActivityAsUser(voiceIntent, UserHandle.CURRENT_OR_SELF); |
Michael Wright | dc63f7b | 2014-08-21 19:05:21 -0700 | [diff] [blame] | 3052 | } |
Jeff Sharkey | 2991fa3 | 2012-12-05 18:06:43 -0800 | [diff] [blame] | 3053 | } else if (keyCode == KeyEvent.KEYCODE_SYSRQ) { |
| 3054 | if (down && repeatCount == 0) { |
| 3055 | mHandler.post(mScreenshotRunnable); |
| 3056 | } |
| 3057 | return -1; |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 3058 | } else if (keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP |
| 3059 | || keyCode == KeyEvent.KEYCODE_BRIGHTNESS_DOWN) { |
| 3060 | if (down) { |
| 3061 | int direction = keyCode == KeyEvent.KEYCODE_BRIGHTNESS_UP ? 1 : -1; |
| 3062 | |
| 3063 | // Disable autobrightness if it's on |
| 3064 | int auto = Settings.System.getIntForUser( |
| 3065 | mContext.getContentResolver(), |
| 3066 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 3067 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 3068 | UserHandle.USER_CURRENT_OR_SELF); |
| 3069 | if (auto != 0) { |
| 3070 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 3071 | Settings.System.SCREEN_BRIGHTNESS_MODE, |
| 3072 | Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL, |
| 3073 | UserHandle.USER_CURRENT_OR_SELF); |
| 3074 | } |
| 3075 | |
| 3076 | int min = mPowerManager.getMinimumScreenBrightnessSetting(); |
| 3077 | int max = mPowerManager.getMaximumScreenBrightnessSetting(); |
| 3078 | int step = (max - min + BRIGHTNESS_STEPS - 1) / BRIGHTNESS_STEPS * direction; |
| 3079 | int brightness = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 3080 | Settings.System.SCREEN_BRIGHTNESS, |
| 3081 | mPowerManager.getDefaultScreenBrightnessSetting(), |
| 3082 | UserHandle.USER_CURRENT_OR_SELF); |
| 3083 | brightness += step; |
| 3084 | // Make sure we don't go beyond the limits. |
| 3085 | brightness = Math.min(max, brightness); |
| 3086 | brightness = Math.max(min, brightness); |
| 3087 | |
| 3088 | Settings.System.putIntForUser(mContext.getContentResolver(), |
| 3089 | Settings.System.SCREEN_BRIGHTNESS, brightness, |
| 3090 | UserHandle.USER_CURRENT_OR_SELF); |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 3091 | startActivityAsUser(new Intent(Intent.ACTION_SHOW_BRIGHTNESS_DIALOG), |
Alan Viverette | 5a39949 | 2014-07-14 16:19:38 -0700 | [diff] [blame] | 3092 | UserHandle.CURRENT_OR_SELF); |
Michael Wright | b854e24 | 2013-02-05 17:54:02 -0800 | [diff] [blame] | 3093 | } |
| 3094 | return -1; |
Jaewan Kim | 765487f | 2016-01-12 14:45:42 +0900 | [diff] [blame] | 3095 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP |
| 3096 | || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN |
| 3097 | || keyCode == KeyEvent.KEYCODE_VOLUME_MUTE) { |
| 3098 | if (mUseTvRouting) { |
| 3099 | // On TVs volume keys never go to the foreground app. |
| 3100 | dispatchDirectAudioEvent(event); |
| 3101 | return -1; |
| 3102 | } |
Michael Wright | ce0c13a | 2014-07-30 10:49:21 -0700 | [diff] [blame] | 3103 | } else if (KeyEvent.isMetaKey(keyCode)) { |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 3104 | if (down) { |
| 3105 | mPendingMetaAction = true; |
| 3106 | } else if (mPendingMetaAction) { |
Tim Kilbourn | 0e5f110 | 2015-06-05 16:18:09 -0700 | [diff] [blame] | 3107 | launchAssistAction(Intent.EXTRA_ASSIST_INPUT_HINT_KEYBOARD, event.getDeviceId()); |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 3108 | } |
| 3109 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3110 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 3111 | |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 3112 | // Shortcuts are invoked through Search+key, so intercept those here |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 3113 | // Any printing key that is chorded with Search should be consumed |
| 3114 | // even if no shortcut was invoked. This prevents text from being |
| 3115 | // inadvertently inserted when using a keyboard that has built-in macro |
| 3116 | // 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] | 3117 | if (mSearchKeyShortcutPending) { |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 3118 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
| 3119 | if (kcm.isPrintingKey(keyCode)) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3120 | mConsumeSearchKeyUp = true; |
| 3121 | mSearchKeyShortcutPending = false; |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 3122 | if (down && repeatCount == 0 && !keyguardOn) { |
| 3123 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState); |
| 3124 | if (shortcutIntent != null) { |
| 3125 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 3126 | try { |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 3127 | startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 3128 | } catch (ActivityNotFoundException ex) { |
| 3129 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 3130 | + "the activity to which it is registered was not found: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3131 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode), ex); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 3132 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 3133 | } else { |
| 3134 | Slog.i(TAG, "Dropping unregistered shortcut key combination: " |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3135 | + "SEARCH+" + KeyEvent.keyCodeToString(keyCode)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3136 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3137 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3138 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3139 | } |
| 3140 | } |
| 3141 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 3142 | // Invoke shortcuts using Meta. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 3143 | if (down && repeatCount == 0 && !keyguardOn |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 3144 | && (metaState & KeyEvent.META_META_ON) != 0) { |
| 3145 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 3146 | if (kcm.isPrintingKey(keyCode)) { |
| 3147 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, |
| 3148 | metaState & ~(KeyEvent.META_META_ON |
| 3149 | | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON)); |
| 3150 | if (shortcutIntent != null) { |
| 3151 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 3152 | try { |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 3153 | startActivityAsUser(shortcutIntent, UserHandle.CURRENT); |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 3154 | } catch (ActivityNotFoundException ex) { |
| 3155 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 3156 | + "the activity to which it is registered was not found: " |
| 3157 | + "META+" + KeyEvent.keyCodeToString(keyCode), ex); |
| 3158 | } |
| 3159 | return -1; |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 3160 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 3161 | } |
| 3162 | } |
| 3163 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3164 | // Handle application launch keys. |
Jeff Brown | 602ab32 | 2012-05-16 13:33:47 -0700 | [diff] [blame] | 3165 | if (down && repeatCount == 0 && !keyguardOn) { |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3166 | String category = sApplicationLaunchKeyCategories.get(keyCode); |
| 3167 | if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 3168 | Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3169 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 3170 | try { |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 3171 | startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3172 | } catch (ActivityNotFoundException ex) { |
| 3173 | Slog.w(TAG, "Dropping application launch key because " |
| 3174 | + "the activity to which it is registered was not found: " |
| 3175 | + "keyCode=" + keyCode + ", category=" + category, ex); |
| 3176 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 3177 | return -1; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 3178 | } |
| 3179 | } |
| 3180 | |
Michael Wright | 61c4675 | 2014-08-21 16:57:33 -0700 | [diff] [blame] | 3181 | // Display task switcher for ALT-TAB. |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 3182 | if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) { |
Michael Wright | d847ad5 | 2015-10-24 13:24:15 +0100 | [diff] [blame] | 3183 | if (mRecentAppsHeldModifiers == 0 && !keyguardOn && isUserSetupComplete()) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 3184 | final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK; |
Michael Wright | 61c4675 | 2014-08-21 16:57:33 -0700 | [diff] [blame] | 3185 | if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON)) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 3186 | mRecentAppsHeldModifiers = shiftlessModifiers; |
| 3187 | showRecentApps(true); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 3188 | return -1; |
| 3189 | } |
| 3190 | } |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 3191 | } else if (!down && mRecentAppsHeldModifiers != 0 |
| 3192 | && (metaState & mRecentAppsHeldModifiers) == 0) { |
| 3193 | mRecentAppsHeldModifiers = 0; |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 3194 | hideRecentApps(true, false); |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 3195 | } |
| 3196 | |
Yohei Yukawa | ae61f71 | 2015-12-09 13:00:10 -0800 | [diff] [blame] | 3197 | // Handle input method switching. |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 3198 | if (down && repeatCount == 0 |
| 3199 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 3200 | || (keyCode == KeyEvent.KEYCODE_SPACE |
Yohei Yukawa | ae61f71 | 2015-12-09 13:00:10 -0800 | [diff] [blame] | 3201 | && (metaState & KeyEvent.META_META_MASK) != 0))) { |
| 3202 | final boolean forwardDirection = (metaState & KeyEvent.META_SHIFT_MASK) == 0; |
| 3203 | mWindowManagerFuncs.switchInputMethod(forwardDirection); |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 3204 | return -1; |
| 3205 | } |
| 3206 | if (mLanguageSwitchKeyPressed && !down |
| 3207 | && (keyCode == KeyEvent.KEYCODE_LANGUAGE_SWITCH |
| 3208 | || keyCode == KeyEvent.KEYCODE_SPACE)) { |
| 3209 | mLanguageSwitchKeyPressed = false; |
| 3210 | return -1; |
| 3211 | } |
| 3212 | |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 3213 | if (isValidGlobalKey(keyCode) |
| 3214 | && mGlobalKeyManager.handleGlobalKey(mContext, keyCode, event)) { |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 3215 | return -1; |
| 3216 | } |
| 3217 | |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 3218 | // Reserve all the META modifier combos for system behavior |
Michael Wright | ce0c13a | 2014-07-30 10:49:21 -0700 | [diff] [blame] | 3219 | if ((metaState & KeyEvent.META_META_ON) != 0) { |
Michael Wright | 6a62e55 | 2014-06-03 19:19:48 -0700 | [diff] [blame] | 3220 | return -1; |
| 3221 | } |
| 3222 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 3223 | // Let the application handle the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3224 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3225 | } |
| 3226 | |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 3227 | /** {@inheritDoc} */ |
| 3228 | @Override |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3229 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 3230 | // Note: This method is only called if the initial down was unhandled. |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 3231 | if (DEBUG_INPUT) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 3232 | Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction() |
| 3233 | + ", flags=" + event.getFlags() |
| 3234 | + ", keyCode=" + event.getKeyCode() |
| 3235 | + ", scanCode=" + event.getScanCode() |
| 3236 | + ", metaState=" + event.getMetaState() |
| 3237 | + ", repeatCount=" + event.getRepeatCount() |
| 3238 | + ", policyFlags=" + policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 3239 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3240 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3241 | KeyEvent fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3242 | if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 3243 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 3244 | final int keyCode = event.getKeyCode(); |
| 3245 | final int metaState = event.getMetaState(); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3246 | final boolean initialDown = event.getAction() == KeyEvent.ACTION_DOWN |
| 3247 | && event.getRepeatCount() == 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3248 | |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 3249 | // Check for fallback actions specified by the key character map. |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3250 | final FallbackAction fallbackAction; |
| 3251 | if (initialDown) { |
| 3252 | fallbackAction = kcm.getFallbackAction(keyCode, metaState); |
| 3253 | } else { |
| 3254 | fallbackAction = mFallbackActions.get(keyCode); |
| 3255 | } |
| 3256 | |
| 3257 | if (fallbackAction != null) { |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 3258 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3259 | Slog.d(TAG, "Fallback: keyCode=" + fallbackAction.keyCode |
| 3260 | + " metaState=" + Integer.toHexString(fallbackAction.metaState)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3261 | } |
| 3262 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3263 | final int flags = event.getFlags() | KeyEvent.FLAG_FALLBACK; |
| 3264 | fallbackEvent = KeyEvent.obtain( |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3265 | event.getDownTime(), event.getEventTime(), |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3266 | event.getAction(), fallbackAction.keyCode, |
| 3267 | event.getRepeatCount(), fallbackAction.metaState, |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3268 | event.getDeviceId(), event.getScanCode(), |
| 3269 | flags, event.getSource(), null); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3270 | |
| 3271 | if (!interceptFallback(win, fallbackEvent, policyFlags)) { |
| 3272 | fallbackEvent.recycle(); |
| 3273 | fallbackEvent = null; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3274 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3275 | |
| 3276 | if (initialDown) { |
| 3277 | mFallbackActions.put(keyCode, fallbackAction); |
| 3278 | } else if (event.getAction() == KeyEvent.ACTION_UP) { |
| 3279 | mFallbackActions.remove(keyCode); |
| 3280 | fallbackAction.recycle(); |
| 3281 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3282 | } |
| 3283 | } |
| 3284 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 3285 | if (DEBUG_INPUT) { |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3286 | if (fallbackEvent == null) { |
| 3287 | Slog.d(TAG, "No fallback."); |
| 3288 | } else { |
| 3289 | Slog.d(TAG, "Performing fallback: " + fallbackEvent); |
| 3290 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 3291 | } |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3292 | return fallbackEvent; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 3293 | } |
| 3294 | |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3295 | private boolean interceptFallback(WindowState win, KeyEvent fallbackEvent, int policyFlags) { |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 3296 | int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags); |
Jeff Brown | fd23e3e | 2012-05-09 13:34:28 -0700 | [diff] [blame] | 3297 | if ((actions & ACTION_PASS_TO_USER) != 0) { |
| 3298 | long delayMillis = interceptKeyBeforeDispatching( |
| 3299 | win, fallbackEvent, policyFlags); |
| 3300 | if (delayMillis == 0) { |
| 3301 | return true; |
| 3302 | } |
| 3303 | } |
| 3304 | return false; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 3305 | } |
| 3306 | |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 3307 | private void launchAssistLongPressAction() { |
| 3308 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 3309 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
| 3310 | |
| 3311 | // launch the search activity |
| 3312 | Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS); |
| 3313 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 3314 | try { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 3315 | // TODO: This only stops the factory-installed search manager. |
Jim Miller | 45308b1 | 2012-06-18 19:23:39 -0700 | [diff] [blame] | 3316 | // Need to formalize an API to handle others |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 3317 | SearchManager searchManager = getSearchManager(); |
| 3318 | if (searchManager != null) { |
| 3319 | searchManager.stopSearch(); |
| 3320 | } |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 3321 | startActivityAsUser(intent, UserHandle.CURRENT); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 3322 | } catch (ActivityNotFoundException e) { |
| 3323 | Slog.w(TAG, "No activity to handle assist long press action.", e); |
| 3324 | } |
| 3325 | } |
| 3326 | |
Tim Kilbourn | 0e5f110 | 2015-06-05 16:18:09 -0700 | [diff] [blame] | 3327 | private void launchAssistAction(String hint, int deviceId) { |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 3328 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST); |
Maurice Lam | 39d1381 | 2015-07-23 20:49:20 -0700 | [diff] [blame] | 3329 | if (!isUserSetupComplete()) { |
| 3330 | // Disable opening assist window during setup |
| 3331 | return; |
| 3332 | } |
Tim Kilbourn | 0e5f110 | 2015-06-05 16:18:09 -0700 | [diff] [blame] | 3333 | Bundle args = null; |
| 3334 | if (deviceId > Integer.MIN_VALUE) { |
| 3335 | args = new Bundle(); |
| 3336 | args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, deviceId); |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 3337 | } |
Jorim Jaggi | 165ce06 | 2015-07-06 16:18:11 -0700 | [diff] [blame] | 3338 | if ((mContext.getResources().getConfiguration().uiMode |
| 3339 | & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) { |
| 3340 | // On TV, use legacy handling until assistants are implemented in the proper way. |
| 3341 | ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)) |
| 3342 | .launchLegacyAssist(hint, UserHandle.myUserId(), args); |
| 3343 | } else { |
| 3344 | try { |
| 3345 | if (hint != null) { |
| 3346 | if (args == null) { |
| 3347 | args = new Bundle(); |
| 3348 | } |
| 3349 | args.putBoolean(hint, true); |
| 3350 | } |
| 3351 | IStatusBarService statusbar = getStatusBarService(); |
| 3352 | if (statusbar != null) { |
| 3353 | statusbar.startAssist(args); |
| 3354 | } |
| 3355 | } catch (RemoteException e) { |
| 3356 | Slog.e(TAG, "RemoteException when starting assist", e); |
| 3357 | // re-acquire status bar service next time it is needed. |
| 3358 | mStatusBarService = null; |
| 3359 | } |
| 3360 | } |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 3361 | } |
| 3362 | |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 3363 | private void startActivityAsUser(Intent intent, UserHandle handle) { |
| 3364 | if (isUserSetupComplete()) { |
| 3365 | mContext.startActivityAsUser(intent, handle); |
| 3366 | } else { |
| 3367 | Slog.i(TAG, "Not starting activity because user setup is in progress: " + intent); |
| 3368 | } |
| 3369 | } |
| 3370 | |
Jeff Brown | de7a8ea | 2012-06-13 18:28:57 -0700 | [diff] [blame] | 3371 | private SearchManager getSearchManager() { |
| 3372 | if (mSearchManager == null) { |
| 3373 | mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); |
| 3374 | } |
| 3375 | return mSearchManager; |
| 3376 | } |
| 3377 | |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 3378 | private void preloadRecentApps() { |
| 3379 | mPreloadedRecentApps = true; |
| 3380 | try { |
| 3381 | IStatusBarService statusbar = getStatusBarService(); |
| 3382 | if (statusbar != null) { |
| 3383 | statusbar.preloadRecentApps(); |
| 3384 | } |
| 3385 | } catch (RemoteException e) { |
| 3386 | Slog.e(TAG, "RemoteException when preloading recent apps", e); |
| 3387 | // re-acquire status bar service next time it is needed. |
| 3388 | mStatusBarService = null; |
| 3389 | } |
| 3390 | } |
| 3391 | |
| 3392 | private void cancelPreloadRecentApps() { |
| 3393 | if (mPreloadedRecentApps) { |
| 3394 | mPreloadedRecentApps = false; |
| 3395 | try { |
| 3396 | IStatusBarService statusbar = getStatusBarService(); |
| 3397 | if (statusbar != null) { |
| 3398 | statusbar.cancelPreloadRecentApps(); |
| 3399 | } |
| 3400 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 3401 | Slog.e(TAG, "RemoteException when cancelling recent apps preload", e); |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 3402 | // re-acquire status bar service next time it is needed. |
| 3403 | mStatusBarService = null; |
| 3404 | } |
| 3405 | } |
| 3406 | } |
| 3407 | |
| 3408 | private void toggleRecentApps() { |
| 3409 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 3410 | try { |
| 3411 | IStatusBarService statusbar = getStatusBarService(); |
| 3412 | if (statusbar != null) { |
| 3413 | statusbar.toggleRecentApps(); |
| 3414 | } |
| 3415 | } catch (RemoteException e) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 3416 | Slog.e(TAG, "RemoteException when toggling recent apps", e); |
| 3417 | // re-acquire status bar service next time it is needed. |
| 3418 | mStatusBarService = null; |
| 3419 | } |
| 3420 | } |
| 3421 | |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 3422 | @Override |
| 3423 | public void showRecentApps() { |
| 3424 | mHandler.removeMessages(MSG_DISPATCH_SHOW_RECENTS); |
| 3425 | mHandler.sendEmptyMessage(MSG_DISPATCH_SHOW_RECENTS); |
| 3426 | } |
| 3427 | |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 3428 | private void showRecentApps(boolean triggeredFromAltTab) { |
| 3429 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 3430 | try { |
| 3431 | IStatusBarService statusbar = getStatusBarService(); |
| 3432 | if (statusbar != null) { |
| 3433 | statusbar.showRecentApps(triggeredFromAltTab); |
| 3434 | } |
| 3435 | } catch (RemoteException e) { |
Jeff Brown | caca881 | 2013-05-09 13:34:33 -0700 | [diff] [blame] | 3436 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
| 3437 | // re-acquire status bar service next time it is needed. |
| 3438 | mStatusBarService = null; |
| 3439 | } |
| 3440 | } |
| 3441 | |
Andrei Stingaceanu | c22ab79 | 2016-01-07 12:39:38 +0000 | [diff] [blame] | 3442 | private void toggleKeyboardShortcutsMenu() { |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame] | 3443 | try { |
| 3444 | IStatusBarService statusbar = getStatusBarService(); |
| 3445 | if (statusbar != null) { |
Andrei Stingaceanu | c22ab79 | 2016-01-07 12:39:38 +0000 | [diff] [blame] | 3446 | statusbar.toggleKeyboardShortcutsMenu(); |
Clara Bayarri | f2debb1 | 2015-07-10 14:47:17 +0100 | [diff] [blame] | 3447 | } |
| 3448 | } catch (RemoteException e) { |
| 3449 | Slog.e(TAG, "RemoteException when showing keyboard shortcuts menu", e); |
| 3450 | } |
| 3451 | } |
| 3452 | |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 3453 | private void hideRecentApps(boolean triggeredFromAltTab, boolean triggeredFromHome) { |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 3454 | mPreloadedRecentApps = false; // preloading no longer needs to be canceled |
| 3455 | try { |
| 3456 | IStatusBarService statusbar = getStatusBarService(); |
| 3457 | if (statusbar != null) { |
Winson Chung | cdcd487 | 2014-08-05 18:00:13 -0700 | [diff] [blame] | 3458 | statusbar.hideRecentApps(triggeredFromAltTab, triggeredFromHome); |
Winson Chung | 1e8d71b | 2014-05-16 17:05:22 -0700 | [diff] [blame] | 3459 | } |
| 3460 | } catch (RemoteException e) { |
| 3461 | Slog.e(TAG, "RemoteException when closing recent apps", e); |
| 3462 | // re-acquire status bar service next time it is needed. |
| 3463 | mStatusBarService = null; |
| 3464 | } |
| 3465 | } |
| 3466 | |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 3467 | void launchHomeFromHotKey() { |
Bryce Lee | 662ed80 | 2015-04-10 20:11:39 +0000 | [diff] [blame] | 3468 | launchHomeFromHotKey(true /* awakenFromDreams */, true /*respectKeyguard*/); |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 3469 | } |
| 3470 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3471 | /** |
| 3472 | * A home key -> launch home action was detected. Take the appropriate action |
| 3473 | * given the situation with the keyguard. |
| 3474 | */ |
Bryce Lee | 662ed80 | 2015-04-10 20:11:39 +0000 | [diff] [blame] | 3475 | void launchHomeFromHotKey(final boolean awakenFromDreams, final boolean respectKeyguard) { |
| 3476 | if (respectKeyguard) { |
| 3477 | if (isKeyguardShowingAndNotOccluded()) { |
| 3478 | // don't launch home if keyguard showing |
| 3479 | return; |
| 3480 | } |
| 3481 | |
| 3482 | if (!mHideLockScreen && mKeyguardDelegate.isInputRestricted()) { |
| 3483 | // when in keyguard restricted mode, must first verify unlock |
| 3484 | // before launching home |
| 3485 | mKeyguardDelegate.verifyUnlock(new OnKeyguardExitResult() { |
| 3486 | @Override |
| 3487 | public void onKeyguardExitResult(boolean success) { |
| 3488 | if (success) { |
| 3489 | try { |
| 3490 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 3491 | } catch (RemoteException e) { |
| 3492 | } |
| 3493 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
| 3494 | startDockOrHome(true /*fromHomeKey*/, awakenFromDreams); |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 3495 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3496 | } |
Bryce Lee | 662ed80 | 2015-04-10 20:11:39 +0000 | [diff] [blame] | 3497 | }); |
| 3498 | return; |
| 3499 | } |
| 3500 | } |
| 3501 | |
| 3502 | // no keyguard stuff to worry about, just launch home! |
| 3503 | try { |
| 3504 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 3505 | } catch (RemoteException e) { |
| 3506 | } |
| 3507 | if (mRecentsVisible) { |
| 3508 | // Hide Recents and notify it to launch Home |
| 3509 | if (awakenFromDreams) { |
| 3510 | awakenDreams(); |
| 3511 | } |
Bryce Lee | 662ed80 | 2015-04-10 20:11:39 +0000 | [diff] [blame] | 3512 | hideRecentApps(false, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3513 | } else { |
Bryce Lee | 662ed80 | 2015-04-10 20:11:39 +0000 | [diff] [blame] | 3514 | // Otherwise, just launch Home |
| 3515 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
| 3516 | startDockOrHome(true /*fromHomeKey*/, awakenFromDreams); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3517 | } |
| 3518 | } |
| 3519 | |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 3520 | private final Runnable mClearHideNavigationFlag = new Runnable() { |
| 3521 | @Override |
| 3522 | public void run() { |
| 3523 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
| 3524 | // Clear flags. |
| 3525 | mForceClearedSystemUiFlags &= |
| 3526 | ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 3527 | } |
| 3528 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3529 | } |
| 3530 | }; |
| 3531 | |
| 3532 | /** |
| 3533 | * Input handler used while nav bar is hidden. Captures any touch on the screen, |
| 3534 | * to determine when the nav bar should be shown and prevent applications from |
| 3535 | * receiving those touches. |
| 3536 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 3537 | final class HideNavInputEventReceiver extends InputEventReceiver { |
| 3538 | public HideNavInputEventReceiver(InputChannel inputChannel, Looper looper) { |
| 3539 | super(inputChannel, looper); |
| 3540 | } |
| 3541 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3542 | @Override |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 3543 | public void onInputEvent(InputEvent event) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3544 | boolean handled = false; |
| 3545 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 3546 | if (event instanceof MotionEvent |
| 3547 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 3548 | final MotionEvent motionEvent = (MotionEvent)event; |
| 3549 | if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3550 | // When the user taps down, we re-show the nav bar. |
| 3551 | boolean changed = false; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 3552 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3553 | // Any user activity always causes us to show the |
| 3554 | // navigation controls, if they had been hidden. |
| 3555 | // We also clear the low profile and only content |
| 3556 | // flags so that tapping on the screen will atomically |
| 3557 | // restore all currently hidden screen decorations. |
| 3558 | int newVal = mResettingSystemUiFlags | |
| 3559 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| 3560 | View.SYSTEM_UI_FLAG_LOW_PROFILE | |
| 3561 | View.SYSTEM_UI_FLAG_FULLSCREEN; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3562 | if (mResettingSystemUiFlags != newVal) { |
| 3563 | mResettingSystemUiFlags = newVal; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3564 | changed = true; |
| 3565 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3566 | // We don't allow the system's nav bar to be hidden |
| 3567 | // again for 1 second, to prevent applications from |
| 3568 | // spamming us and keeping it from being shown. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3569 | newVal = mForceClearedSystemUiFlags | |
| 3570 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3571 | if (mForceClearedSystemUiFlags != newVal) { |
| 3572 | mForceClearedSystemUiFlags = newVal; |
| 3573 | changed = true; |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 3574 | mHandler.postDelayed(mClearHideNavigationFlag, 1000); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3575 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3576 | } |
| 3577 | if (changed) { |
| 3578 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 3579 | } |
| 3580 | } |
| 3581 | } |
| 3582 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 3583 | finishInputEvent(event, handled); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3584 | } |
| 3585 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 3586 | } |
| 3587 | final InputEventReceiver.Factory mHideNavInputEventReceiverFactory = |
| 3588 | new InputEventReceiver.Factory() { |
| 3589 | @Override |
| 3590 | public InputEventReceiver createInputEventReceiver( |
| 3591 | InputChannel inputChannel, Looper looper) { |
| 3592 | return new HideNavInputEventReceiver(inputChannel, looper); |
| 3593 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3594 | }; |
| 3595 | |
| 3596 | @Override |
| 3597 | public int adjustSystemUiVisibilityLw(int visibility) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 3598 | mStatusBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
| 3599 | mNavigationBarController.adjustSystemUiVisibilityLw(mLastSystemUiFlags, visibility); |
Winson Chung | d42a6cf | 2014-06-03 16:24:04 -0700 | [diff] [blame] | 3600 | mRecentsVisible = (visibility & View.RECENT_APPS_VISIBLE) > 0; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 3601 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3602 | // Reset any bits in mForceClearingStatusBarVisibility that |
| 3603 | // are now clear. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3604 | mResettingSystemUiFlags &= visibility; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3605 | // Clear any bits in the new visibility that are currently being |
| 3606 | // force cleared, before reporting it. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3607 | return visibility & ~mResettingSystemUiFlags |
| 3608 | & ~mForceClearedSystemUiFlags; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3609 | } |
| 3610 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3611 | @Override |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 3612 | public boolean getInsetHintLw(WindowManager.LayoutParams attrs, int displayRotation, |
Filip Gruszczynski | 2987f61 | 2015-06-30 15:03:30 -0700 | [diff] [blame] | 3613 | Rect outContentInsets, Rect outStableInsets, Rect outOutsets) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 3614 | final int fl = PolicyControl.getWindowFlags(null, attrs); |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 3615 | final int sysuiVis = PolicyControl.getSystemUiVisibility(null, attrs); |
| 3616 | final int systemUiVisibility = (sysuiVis | attrs.subtreeSystemUiVisibility); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3617 | |
Filip Gruszczynski | 2987f61 | 2015-06-30 15:03:30 -0700 | [diff] [blame] | 3618 | final boolean useOutsets = outOutsets != null && shouldUseOutsets(attrs, fl); |
| 3619 | if (useOutsets) { |
| 3620 | int outset = ScreenShapeHelper.getWindowOutsetBottomPx(mContext.getResources()); |
| 3621 | if (outset > 0) { |
| 3622 | if (displayRotation == Surface.ROTATION_0) { |
| 3623 | outOutsets.bottom += outset; |
| 3624 | } else if (displayRotation == Surface.ROTATION_90) { |
| 3625 | outOutsets.right += outset; |
| 3626 | } else if (displayRotation == Surface.ROTATION_180) { |
| 3627 | outOutsets.top += outset; |
| 3628 | } else if (displayRotation == Surface.ROTATION_270) { |
| 3629 | outOutsets.left += outset; |
| 3630 | } |
| 3631 | } |
| 3632 | } |
| 3633 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3634 | 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] | 3635 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3636 | int availRight, availBottom; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3637 | if (canHideNavigationBar() && |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3638 | (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3639 | availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 3640 | availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
| 3641 | } else { |
| 3642 | availRight = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 3643 | availBottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
| 3644 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3645 | if ((systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 3646 | if ((fl & FLAG_FULLSCREEN) != 0) { |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3647 | outContentInsets.set(mStableFullscreenLeft, mStableFullscreenTop, |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3648 | availRight - mStableFullscreenRight, |
| 3649 | availBottom - mStableFullscreenBottom); |
| 3650 | } else { |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3651 | outContentInsets.set(mStableLeft, mStableTop, |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3652 | availRight - mStableRight, availBottom - mStableBottom); |
| 3653 | } |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3654 | } else if ((fl & FLAG_FULLSCREEN) != 0 || (fl & FLAG_LAYOUT_IN_OVERSCAN) != 0) { |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3655 | outContentInsets.setEmpty(); |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 3656 | } else if ((systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3657 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) { |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3658 | outContentInsets.set(mCurLeft, mCurTop, |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3659 | availRight - mCurRight, availBottom - mCurBottom); |
| 3660 | } else { |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3661 | outContentInsets.set(mCurLeft, mCurTop, |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3662 | availRight - mCurRight, availBottom - mCurBottom); |
| 3663 | } |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3664 | |
| 3665 | outStableInsets.set(mStableLeft, mStableTop, |
| 3666 | availRight - mStableRight, availBottom - mStableBottom); |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 3667 | return mForceShowSystemBars; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3668 | } |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 3669 | outContentInsets.setEmpty(); |
| 3670 | outStableInsets.setEmpty(); |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 3671 | return mForceShowSystemBars; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3672 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 3673 | |
Filip Gruszczynski | 2987f61 | 2015-06-30 15:03:30 -0700 | [diff] [blame] | 3674 | private boolean shouldUseOutsets(WindowManager.LayoutParams attrs, int fl) { |
| 3675 | return attrs.type == TYPE_WALLPAPER || (fl & (WindowManager.LayoutParams.FLAG_FULLSCREEN |
| 3676 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_OVERSCAN)) != 0; |
| 3677 | } |
| 3678 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3679 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3680 | @Override |
| 3681 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 3682 | int displayRotation, int uiMode) { |
Filip Gruszczynski | 2987f61 | 2015-06-30 15:03:30 -0700 | [diff] [blame] | 3683 | mDisplayRotation = displayRotation; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3684 | final int overscanLeft, overscanTop, overscanRight, overscanBottom; |
| 3685 | if (isDefaultDisplay) { |
| 3686 | switch (displayRotation) { |
| 3687 | case Surface.ROTATION_90: |
| 3688 | overscanLeft = mOverscanTop; |
| 3689 | overscanTop = mOverscanRight; |
| 3690 | overscanRight = mOverscanBottom; |
| 3691 | overscanBottom = mOverscanLeft; |
| 3692 | break; |
| 3693 | case Surface.ROTATION_180: |
| 3694 | overscanLeft = mOverscanRight; |
| 3695 | overscanTop = mOverscanBottom; |
| 3696 | overscanRight = mOverscanLeft; |
| 3697 | overscanBottom = mOverscanTop; |
| 3698 | break; |
| 3699 | case Surface.ROTATION_270: |
| 3700 | overscanLeft = mOverscanBottom; |
| 3701 | overscanTop = mOverscanLeft; |
| 3702 | overscanRight = mOverscanTop; |
| 3703 | overscanBottom = mOverscanRight; |
| 3704 | break; |
| 3705 | default: |
| 3706 | overscanLeft = mOverscanLeft; |
| 3707 | overscanTop = mOverscanTop; |
| 3708 | overscanRight = mOverscanRight; |
| 3709 | overscanBottom = mOverscanBottom; |
| 3710 | break; |
| 3711 | } |
| 3712 | } else { |
| 3713 | overscanLeft = 0; |
| 3714 | overscanTop = 0; |
| 3715 | overscanRight = 0; |
| 3716 | overscanBottom = 0; |
| 3717 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 3718 | mOverscanScreenLeft = mRestrictedOverscanScreenLeft = 0; |
| 3719 | mOverscanScreenTop = mRestrictedOverscanScreenTop = 0; |
| 3720 | mOverscanScreenWidth = mRestrictedOverscanScreenWidth = displayWidth; |
| 3721 | mOverscanScreenHeight = mRestrictedOverscanScreenHeight = displayHeight; |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3722 | mSystemLeft = 0; |
| 3723 | mSystemTop = 0; |
| 3724 | mSystemRight = displayWidth; |
| 3725 | mSystemBottom = displayHeight; |
| 3726 | mUnrestrictedScreenLeft = overscanLeft; |
| 3727 | mUnrestrictedScreenTop = overscanTop; |
| 3728 | mUnrestrictedScreenWidth = displayWidth - overscanLeft - overscanRight; |
| 3729 | mUnrestrictedScreenHeight = displayHeight - overscanTop - overscanBottom; |
| 3730 | mRestrictedScreenLeft = mUnrestrictedScreenLeft; |
| 3731 | mRestrictedScreenTop = mUnrestrictedScreenTop; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3732 | mRestrictedScreenWidth = mSystemGestures.screenWidth = mUnrestrictedScreenWidth; |
| 3733 | mRestrictedScreenHeight = mSystemGestures.screenHeight = mUnrestrictedScreenHeight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3734 | mDockLeft = mContentLeft = mVoiceContentLeft = mStableLeft = mStableFullscreenLeft |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3735 | = mCurLeft = mUnrestrictedScreenLeft; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3736 | mDockTop = mContentTop = mVoiceContentTop = mStableTop = mStableFullscreenTop |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3737 | = mCurTop = mUnrestrictedScreenTop; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3738 | mDockRight = mContentRight = mVoiceContentRight = mStableRight = mStableFullscreenRight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3739 | = mCurRight = displayWidth - overscanRight; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 3740 | mDockBottom = mContentBottom = mVoiceContentBottom = mStableBottom = mStableFullscreenBottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 3741 | = mCurBottom = displayHeight - overscanBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3742 | mDockLayer = 0x10000000; |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 3743 | mStatusBarLayer = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3744 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3745 | // start with the current dock rect, which will be (0,0,displayWidth,displayHeight) |
| 3746 | final Rect pf = mTmpParentFrame; |
| 3747 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3748 | final Rect of = mTmpOverscanFrame; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3749 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3750 | final Rect dcf = mTmpDecorFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3751 | pf.left = df.left = of.left = vf.left = mDockLeft; |
| 3752 | pf.top = df.top = of.top = vf.top = mDockTop; |
| 3753 | pf.right = df.right = of.right = vf.right = mDockRight; |
| 3754 | pf.bottom = df.bottom = of.bottom = vf.bottom = mDockBottom; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3755 | dcf.setEmpty(); // Decor frame N/A for system bars. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 3756 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3757 | if (isDefaultDisplay) { |
| 3758 | // For purposes of putting out fake window up to steal focus, we will |
| 3759 | // drive nav being hidden only by whether it is requested. |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 3760 | final int sysui = mLastSystemUiFlags; |
| 3761 | boolean navVisible = (sysui & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 3762 | boolean navTranslucent = (sysui |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3763 | & (View.NAVIGATION_BAR_TRANSLUCENT | View.NAVIGATION_BAR_TRANSPARENT)) != 0; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 3764 | boolean immersive = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0; |
| 3765 | boolean immersiveSticky = (sysui & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
| 3766 | boolean navAllowedHidden = immersive || immersiveSticky; |
| 3767 | navTranslucent &= !immersiveSticky; // transient trumps translucent |
Adrian Roos | 4fb3ee3 | 2014-08-22 19:29:09 +0200 | [diff] [blame] | 3768 | boolean isKeyguardShowing = isStatusBarKeyguard() && !mHideLockScreen; |
| 3769 | if (!isKeyguardShowing) { |
| 3770 | navTranslucent &= areTranslucentBarsAllowed(); |
| 3771 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3772 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3773 | // When the navigation bar isn't visible, we put up a fake |
| 3774 | // input window to catch all touch events. This way we can |
| 3775 | // detect when the user presses anywhere to bring back the nav |
| 3776 | // bar and ensure the application doesn't see the event. |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 3777 | if (navVisible || navAllowedHidden) { |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 3778 | if (mInputConsumer != null) { |
| 3779 | mInputConsumer.dismiss(); |
| 3780 | mInputConsumer = null; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3781 | } |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 3782 | } else if (mInputConsumer == null) { |
| 3783 | mInputConsumer = mWindowManagerFuncs.addInputConsumer(mHandler.getLooper(), |
| 3784 | mHideNavInputEventReceiverFactory); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3785 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 3786 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 3787 | // For purposes of positioning and showing the nav bar, if we have |
| 3788 | // decided that it can't be hidden (because of the screen aspect ratio), |
| 3789 | // then take that into account. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 3790 | navVisible |= !canHideNavigationBar(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3791 | |
Filip Gruszczynski | 83dd955 | 2015-09-17 17:50:36 -0700 | [diff] [blame] | 3792 | boolean updateSysUiVisibility = layoutNavigationBar(displayWidth, displayHeight, |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 3793 | displayRotation, uiMode, overscanRight, overscanBottom, dcf, navVisible, navTranslucent, |
Filip Gruszczynski | 83dd955 | 2015-09-17 17:50:36 -0700 | [diff] [blame] | 3794 | navAllowedHidden); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 3795 | 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] | 3796 | mDockLeft, mDockTop, mDockRight, mDockBottom)); |
Filip Gruszczynski | 83dd955 | 2015-09-17 17:50:36 -0700 | [diff] [blame] | 3797 | updateSysUiVisibility |= layoutStatusBar(pf, df, of, vf, dcf, sysui, isKeyguardShowing); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 3798 | if (updateSysUiVisibility) { |
| 3799 | updateSystemUiVisibilityLw(); |
| 3800 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3801 | } |
| 3802 | } |
| 3803 | |
Filip Gruszczynski | 83dd955 | 2015-09-17 17:50:36 -0700 | [diff] [blame] | 3804 | private boolean layoutStatusBar(Rect pf, Rect df, Rect of, Rect vf, Rect dcf, int sysui, |
| 3805 | boolean isKeyguardShowing) { |
| 3806 | // decide where the status bar goes ahead of time |
| 3807 | if (mStatusBar != null) { |
| 3808 | // apply any navigation bar insets |
| 3809 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 3810 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 3811 | pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft; |
| 3812 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight |
| 3813 | + mUnrestrictedScreenTop; |
| 3814 | vf.left = mStableLeft; |
| 3815 | vf.top = mStableTop; |
| 3816 | vf.right = mStableRight; |
| 3817 | vf.bottom = mStableBottom; |
| 3818 | |
| 3819 | mStatusBarLayer = mStatusBar.getSurfaceLayer(); |
| 3820 | |
| 3821 | // Let the status bar determine its size. |
| 3822 | mStatusBar.computeFrameLw(pf /* parentFrame */, df /* displayFrame */, |
| 3823 | vf /* overlayFrame */, vf /* contentFrame */, vf /* visibleFrame */, |
| 3824 | dcf /* decorFrame */, vf /* stableFrame */, vf /* outsetFrame */); |
| 3825 | |
| 3826 | // For layout, the status bar is always at the top with our fixed height. |
| 3827 | mStableTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3828 | |
| 3829 | boolean statusBarTransient = (sysui & View.STATUS_BAR_TRANSIENT) != 0; |
| 3830 | boolean statusBarTranslucent = (sysui |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 3831 | & (View.STATUS_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSPARENT)) != 0; |
Filip Gruszczynski | 83dd955 | 2015-09-17 17:50:36 -0700 | [diff] [blame] | 3832 | if (!isKeyguardShowing) { |
| 3833 | statusBarTranslucent &= areTranslucentBarsAllowed(); |
| 3834 | } |
| 3835 | |
| 3836 | // If the status bar is hidden, we don't want to cause |
| 3837 | // windows behind it to scroll. |
| 3838 | if (mStatusBar.isVisibleLw() && !statusBarTransient) { |
| 3839 | // Status bar may go away, so the screen area it occupies |
| 3840 | // is available to apps but just covering them when the |
| 3841 | // status bar is visible. |
| 3842 | mDockTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3843 | |
| 3844 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 3845 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 3846 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 3847 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
| 3848 | |
| 3849 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar: " + |
| 3850 | String.format( |
| 3851 | "dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]", |
| 3852 | mDockLeft, mDockTop, mDockRight, mDockBottom, |
| 3853 | mContentLeft, mContentTop, mContentRight, mContentBottom, |
| 3854 | mCurLeft, mCurTop, mCurRight, mCurBottom)); |
| 3855 | } |
| 3856 | if (mStatusBar.isVisibleLw() && !mStatusBar.isAnimatingLw() |
| 3857 | && !statusBarTransient && !statusBarTranslucent |
| 3858 | && !mStatusBarController.wasRecentlyTranslucent()) { |
| 3859 | // If the opaque status bar is currently requested to be visible, |
| 3860 | // and not in the process of animating on or off, then |
| 3861 | // we can tell the app that it is covered by it. |
| 3862 | mSystemTop = mUnrestrictedScreenTop + mStatusBarHeight; |
| 3863 | } |
| 3864 | if (mStatusBarController.checkHiddenLw()) { |
| 3865 | return true; |
| 3866 | } |
| 3867 | } |
| 3868 | return false; |
| 3869 | } |
| 3870 | |
| 3871 | private boolean layoutNavigationBar(int displayWidth, int displayHeight, int displayRotation, |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 3872 | int uiMode, int overscanRight, int overscanBottom, Rect dcf, boolean navVisible, |
Filip Gruszczynski | 83dd955 | 2015-09-17 17:50:36 -0700 | [diff] [blame] | 3873 | boolean navTranslucent, boolean navAllowedHidden) { |
| 3874 | if (mNavigationBar != null) { |
| 3875 | boolean transientNavBarShowing = mNavigationBarController.isTransientShowing(); |
| 3876 | // Force the navigation bar to its appropriate place and |
| 3877 | // size. We need to do this directly, instead of relying on |
| 3878 | // it to bubble up from the nav bar, because this needs to |
| 3879 | // change atomically with screen rotations. |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 3880 | mNavigationBarOnBottom = isNavigationBarOnBottom(displayWidth, displayHeight); |
Filip Gruszczynski | 83dd955 | 2015-09-17 17:50:36 -0700 | [diff] [blame] | 3881 | if (mNavigationBarOnBottom) { |
| 3882 | // It's a system nav bar or a portrait screen; nav bar goes on bottom. |
| 3883 | int top = displayHeight - overscanBottom |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 3884 | - getNavigationBarHeight(displayRotation, uiMode); |
Filip Gruszczynski | 83dd955 | 2015-09-17 17:50:36 -0700 | [diff] [blame] | 3885 | mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom); |
| 3886 | mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top; |
| 3887 | if (transientNavBarShowing) { |
| 3888 | mNavigationBarController.setBarShowingLw(true); |
| 3889 | } else if (navVisible) { |
| 3890 | mNavigationBarController.setBarShowingLw(true); |
| 3891 | mDockBottom = mTmpNavigationFrame.top; |
| 3892 | mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop; |
| 3893 | mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop; |
| 3894 | } else { |
| 3895 | // We currently want to hide the navigation UI. |
| 3896 | mNavigationBarController.setBarShowingLw(false); |
| 3897 | } |
| 3898 | if (navVisible && !navTranslucent && !navAllowedHidden |
| 3899 | && !mNavigationBar.isAnimatingLw() |
| 3900 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
| 3901 | // If the opaque nav bar is currently requested to be visible, |
| 3902 | // and not in the process of animating on or off, then |
| 3903 | // we can tell the app that it is covered by it. |
| 3904 | mSystemBottom = mTmpNavigationFrame.top; |
| 3905 | } |
| 3906 | } else { |
| 3907 | // Landscape screen; nav bar goes to the right. |
| 3908 | int left = displayWidth - overscanRight |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 3909 | - getNavigationBarWidth(displayRotation, uiMode); |
Filip Gruszczynski | 83dd955 | 2015-09-17 17:50:36 -0700 | [diff] [blame] | 3910 | mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight); |
| 3911 | mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left; |
| 3912 | if (transientNavBarShowing) { |
| 3913 | mNavigationBarController.setBarShowingLw(true); |
| 3914 | } else if (navVisible) { |
| 3915 | mNavigationBarController.setBarShowingLw(true); |
| 3916 | mDockRight = mTmpNavigationFrame.left; |
| 3917 | mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft; |
| 3918 | mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft; |
| 3919 | } else { |
| 3920 | // We currently want to hide the navigation UI. |
| 3921 | mNavigationBarController.setBarShowingLw(false); |
| 3922 | } |
| 3923 | if (navVisible && !navTranslucent && !navAllowedHidden |
| 3924 | && !mNavigationBar.isAnimatingLw() |
| 3925 | && !mNavigationBarController.wasRecentlyTranslucent()) { |
| 3926 | // If the nav bar is currently requested to be visible, |
| 3927 | // and not in the process of animating on or off, then |
| 3928 | // we can tell the app that it is covered by it. |
| 3929 | mSystemRight = mTmpNavigationFrame.left; |
| 3930 | } |
| 3931 | } |
| 3932 | // Make sure the content and current rectangles are updated to |
| 3933 | // account for the restrictions from the navigation bar. |
| 3934 | mContentTop = mVoiceContentTop = mCurTop = mDockTop; |
| 3935 | mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom; |
| 3936 | mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft; |
| 3937 | mContentRight = mVoiceContentRight = mCurRight = mDockRight; |
| 3938 | mStatusBarLayer = mNavigationBar.getSurfaceLayer(); |
| 3939 | // And compute the final frame. |
| 3940 | mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, |
| 3941 | mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf, |
| 3942 | mTmpNavigationFrame, mTmpNavigationFrame); |
| 3943 | if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); |
| 3944 | if (mNavigationBarController.checkHiddenLw()) { |
| 3945 | return true; |
| 3946 | } |
| 3947 | } |
| 3948 | return false; |
| 3949 | } |
| 3950 | |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 3951 | private boolean isNavigationBarOnBottom(int displayWidth, int displayHeight) { |
| 3952 | return !mNavigationBarCanMove || displayWidth < displayHeight; |
| 3953 | } |
| 3954 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 3955 | /** {@inheritDoc} */ |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 3956 | @Override |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 3957 | public int getSystemDecorLayerLw() { |
Bryce Lee | 2ed3e5f | 2015-04-01 22:09:19 +0000 | [diff] [blame] | 3958 | if (mStatusBar != null && mStatusBar.isVisibleLw()) { |
| 3959 | return mStatusBar.getSurfaceLayer(); |
| 3960 | } |
| 3961 | |
| 3962 | if (mNavigationBar != null && mNavigationBar.isVisibleLw()) { |
| 3963 | return mNavigationBar.getSurfaceLayer(); |
| 3964 | } |
| 3965 | |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 3966 | return 0; |
| 3967 | } |
| 3968 | |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 3969 | @Override |
| 3970 | public void getContentRectLw(Rect r) { |
| 3971 | r.set(mContentLeft, mContentTop, mContentRight, mContentBottom); |
| 3972 | } |
| 3973 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3974 | void setAttachedWindowFrames(WindowState win, int fl, int adjust, WindowState attached, |
| 3975 | 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] | 3976 | if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) { |
| 3977 | // Here's a special case: if this attached window is a panel that is |
| 3978 | // above the dock window, and the window it is attached to is below |
| 3979 | // the dock window, then the frames we computed for the window it is |
| 3980 | // attached to can not be used because the dock is effectively part |
| 3981 | // of the underlying window and the attached window is floating on top |
| 3982 | // of the whole thing. So, we ignore the attached window and explicitly |
| 3983 | // compute the frames that would be appropriate without the dock. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 3984 | df.left = of.left = cf.left = vf.left = mDockLeft; |
| 3985 | df.top = of.top = cf.top = vf.top = mDockTop; |
| 3986 | df.right = of.right = cf.right = vf.right = mDockRight; |
| 3987 | df.bottom = of.bottom = cf.bottom = vf.bottom = mDockBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3988 | } else { |
| 3989 | // The effective display frame of the attached window depends on |
| 3990 | // whether it is taking care of insetting its content. If not, |
| 3991 | // we need to use the parent's content frame so that the entire |
| 3992 | // window is positioned within that content. Otherwise we can use |
Wale Ogunwale | 393b1c1 | 2014-10-18 16:22:01 -0700 | [diff] [blame] | 3993 | // 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] | 3994 | // positioning its content appropriately. |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 3995 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Wale Ogunwale | 393b1c1 | 2014-10-18 16:22:01 -0700 | [diff] [blame] | 3996 | // Set the content frame of the attached window to the parent's decor frame |
| 3997 | // (same as content frame when IME isn't present) if specifically requested by |
| 3998 | // setting {@link WindowManager.LayoutParams#FLAG_LAYOUT_ATTACHED_IN_DECOR} flag. |
| 3999 | // Otherwise, use the overscan frame. |
| 4000 | cf.set((fl & FLAG_LAYOUT_ATTACHED_IN_DECOR) != 0 |
| 4001 | ? attached.getContentFrameLw() : attached.getOverscanFrameLw()); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4002 | } else { |
| 4003 | // If the window is resizing, then we want to base the content |
| 4004 | // frame on our attached content frame to resize... however, |
| 4005 | // things can be tricky if the attached window is NOT in resize |
| 4006 | // mode, in which case its content frame will be larger. |
| 4007 | // Ungh. So to deal with that, make sure the content frame |
| 4008 | // we end up using is not covering the IM dock. |
| 4009 | cf.set(attached.getContentFrameLw()); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 4010 | if (attached.isVoiceInteraction()) { |
| 4011 | if (cf.left < mVoiceContentLeft) cf.left = mVoiceContentLeft; |
| 4012 | if (cf.top < mVoiceContentTop) cf.top = mVoiceContentTop; |
| 4013 | if (cf.right > mVoiceContentRight) cf.right = mVoiceContentRight; |
| 4014 | if (cf.bottom > mVoiceContentBottom) cf.bottom = mVoiceContentBottom; |
| 4015 | } else if (attached.getSurfaceLayer() < mDockLayer) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4016 | if (cf.left < mContentLeft) cf.left = mContentLeft; |
| 4017 | if (cf.top < mContentTop) cf.top = mContentTop; |
| 4018 | if (cf.right > mContentRight) cf.right = mContentRight; |
| 4019 | if (cf.bottom > mContentBottom) cf.bottom = mContentBottom; |
| 4020 | } |
| 4021 | } |
| 4022 | df.set(insetDecors ? attached.getDisplayFrameLw() : cf); |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4023 | of.set(insetDecors ? attached.getOverscanFrameLw() : cf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4024 | vf.set(attached.getVisibleFrameLw()); |
| 4025 | } |
| 4026 | // The LAYOUT_IN_SCREEN flag is used to determine whether the attached |
| 4027 | // window should be positioned relative to its parent or the entire |
| 4028 | // screen. |
| 4029 | pf.set((fl & FLAG_LAYOUT_IN_SCREEN) == 0 |
| 4030 | ? attached.getFrameLw() : df); |
| 4031 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 4032 | |
| 4033 | private void applyStableConstraints(int sysui, int fl, Rect r) { |
| 4034 | if ((sysui & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 4035 | // If app is requesting a stable layout, don't let the |
| 4036 | // content insets go below the stable values. |
| 4037 | if ((fl & FLAG_FULLSCREEN) != 0) { |
| 4038 | if (r.left < mStableFullscreenLeft) r.left = mStableFullscreenLeft; |
| 4039 | if (r.top < mStableFullscreenTop) r.top = mStableFullscreenTop; |
| 4040 | if (r.right > mStableFullscreenRight) r.right = mStableFullscreenRight; |
| 4041 | if (r.bottom > mStableFullscreenBottom) r.bottom = mStableFullscreenBottom; |
| 4042 | } else { |
| 4043 | if (r.left < mStableLeft) r.left = mStableLeft; |
| 4044 | if (r.top < mStableTop) r.top = mStableTop; |
| 4045 | if (r.right > mStableRight) r.right = mStableRight; |
| 4046 | if (r.bottom > mStableBottom) r.bottom = mStableBottom; |
| 4047 | } |
| 4048 | } |
| 4049 | } |
| 4050 | |
Jorim Jaggi | aa80614 | 2015-05-20 18:04:16 -0700 | [diff] [blame] | 4051 | private boolean canReceiveInput(WindowState win) { |
| 4052 | boolean notFocusable = |
| 4053 | (win.getAttrs().flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) != 0; |
| 4054 | boolean altFocusableIm = |
| 4055 | (win.getAttrs().flags & WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM) != 0; |
| 4056 | boolean notFocusableForIm = notFocusable ^ altFocusableIm; |
| 4057 | return !notFocusableForIm; |
| 4058 | } |
| 4059 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4060 | /** {@inheritDoc} */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4061 | @Override |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4062 | public void layoutWindowLw(WindowState win, WindowState attached) { |
Jorim Jaggi | aa80614 | 2015-05-20 18:04:16 -0700 | [diff] [blame] | 4063 | // We've already done the navigation bar and status bar. If the status bar can receive |
| 4064 | // input, we need to layout it again to accomodate for the IME window. |
| 4065 | if ((win == mStatusBar && !canReceiveInput(win)) || win == mNavigationBar) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4066 | return; |
| 4067 | } |
Jorim Jaggi | aa80614 | 2015-05-20 18:04:16 -0700 | [diff] [blame] | 4068 | final WindowManager.LayoutParams attrs = win.getAttrs(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4069 | final boolean isDefaultDisplay = win.isDefaultDisplay(); |
| 4070 | final boolean needsToOffsetInputMethodTarget = isDefaultDisplay && |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 4071 | (win == mLastInputMethodTargetWindow && mLastInputMethodWindow != null); |
| 4072 | if (needsToOffsetInputMethodTarget) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4073 | 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] | 4074 | offsetInputMethodWindowLw(mLastInputMethodWindow); |
| 4075 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4076 | |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4077 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4078 | final int sim = attrs.softInputMode; |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 4079 | final int sysUiFl = PolicyControl.getSystemUiVisibility(win, null); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4080 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4081 | final Rect pf = mTmpParentFrame; |
| 4082 | final Rect df = mTmpDisplayFrame; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4083 | final Rect of = mTmpOverscanFrame; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4084 | final Rect cf = mTmpContentFrame; |
| 4085 | final Rect vf = mTmpVisibleFrame; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 4086 | final Rect dcf = mTmpDecorFrame; |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 4087 | final Rect sf = mTmpStableFrame; |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 4088 | Rect osf = null; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 4089 | dcf.setEmpty(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4090 | |
| 4091 | final boolean hasNavBar = (isDefaultDisplay && mHasNavigationBar |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 4092 | && mNavigationBar != null && mNavigationBar.isVisibleLw()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 4093 | |
Craig Mautner | f683b56 | 2012-10-02 11:10:57 -0700 | [diff] [blame] | 4094 | final int adjust = sim & SOFT_INPUT_MASK_ADJUST; |
| 4095 | |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 4096 | if (isDefaultDisplay) { |
| 4097 | sf.set(mStableLeft, mStableTop, mStableRight, mStableBottom); |
| 4098 | } else { |
| 4099 | sf.set(mOverscanLeft, mOverscanTop, mOverscanRight, mOverscanBottom); |
| 4100 | } |
| 4101 | |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4102 | if (!isDefaultDisplay) { |
| 4103 | if (attached != null) { |
| 4104 | // If this window is attached to another, our display |
| 4105 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4106 | setAttachedWindowFrames(win, fl, adjust, attached, true, pf, df, of, cf, vf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4107 | } else { |
| 4108 | // Give the window full screen. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4109 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 4110 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 4111 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 4112 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4113 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 4114 | = mOverscanScreenTop + mOverscanScreenHeight; |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4115 | } |
Jorim Jaggi | 225d3b5 | 2015-04-01 11:18:57 -0700 | [diff] [blame] | 4116 | } else if (attrs.type == TYPE_INPUT_METHOD) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4117 | pf.left = df.left = of.left = cf.left = vf.left = mDockLeft; |
| 4118 | pf.top = df.top = of.top = cf.top = vf.top = mDockTop; |
| 4119 | pf.right = df.right = of.right = cf.right = vf.right = mDockRight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 4120 | // IM dock windows layout below the nav bar... |
John Spurlock | 57beb3b | 2013-10-10 10:27:44 -0400 | [diff] [blame] | 4121 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | c68d577 | 2013-10-08 11:47:58 -0400 | [diff] [blame] | 4122 | // ...with content insets above the nav bar |
| 4123 | cf.bottom = vf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4124 | // IM dock windows always go to the bottom of the screen. |
| 4125 | attrs.gravity = Gravity.BOTTOM; |
| 4126 | mDockLayer = win.getSurfaceLayer(); |
Jorim Jaggi | 225d3b5 | 2015-04-01 11:18:57 -0700 | [diff] [blame] | 4127 | } else if (attrs.type == TYPE_VOICE_INTERACTION) { |
Stefan Kuhne | 2f280d06 | 2015-06-18 07:20:33 -1000 | [diff] [blame] | 4128 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
Jorim Jaggi | 225d3b5 | 2015-04-01 11:18:57 -0700 | [diff] [blame] | 4129 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
Stefan Kuhne | 2f280d06 | 2015-06-18 07:20:33 -1000 | [diff] [blame] | 4130 | pf.right = df.right = of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 4131 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Jorim Jaggi | 225d3b5 | 2015-04-01 11:18:57 -0700 | [diff] [blame] | 4132 | cf.bottom = vf.bottom = mStableBottom; |
Stefan Kuhne | 2f280d06 | 2015-06-18 07:20:33 -1000 | [diff] [blame] | 4133 | // Note: In Phone landscape mode, the button bar should also be excluded. |
| 4134 | cf.right = vf.right = mStableRight; |
| 4135 | cf.left = vf.left = mStableLeft; |
Jorim Jaggi | 225d3b5 | 2015-04-01 11:18:57 -0700 | [diff] [blame] | 4136 | cf.top = vf.top = mStableTop; |
Jorim Jaggi | aa80614 | 2015-05-20 18:04:16 -0700 | [diff] [blame] | 4137 | } else if (win == mStatusBar) { |
Jorim Jaggi | e070018 | 2014-08-21 01:12:37 +0200 | [diff] [blame] | 4138 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 4139 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 4140 | pf.right = df.right = of.right = mUnrestrictedScreenWidth + mUnrestrictedScreenLeft; |
| 4141 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenHeight + mUnrestrictedScreenTop; |
| 4142 | cf.left = vf.left = mStableLeft; |
| 4143 | cf.top = vf.top = mStableTop; |
| 4144 | cf.right = vf.right = mStableRight; |
| 4145 | vf.bottom = mStableBottom; |
Adrian Roos | dc5b453 | 2016-01-06 20:49:41 +0100 | [diff] [blame] | 4146 | |
| 4147 | if (adjust == SOFT_INPUT_ADJUST_RESIZE) { |
| 4148 | cf.bottom = mContentBottom; |
| 4149 | } else { |
| 4150 | cf.bottom = mDockBottom; |
| 4151 | vf.bottom = mContentBottom; |
| 4152 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4153 | } else { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 4154 | |
| 4155 | // Default policy decor for the default display |
| 4156 | dcf.left = mSystemLeft; |
| 4157 | dcf.top = mSystemTop; |
| 4158 | dcf.right = mSystemRight; |
| 4159 | dcf.bottom = mSystemBottom; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 4160 | final boolean inheritTranslucentDecor = (attrs.privateFlags |
| 4161 | & WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR) != 0; |
John Spurlock | 65567d4 | 2013-10-08 10:08:32 -0400 | [diff] [blame] | 4162 | final boolean isAppWindow = |
| 4163 | attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW && |
| 4164 | attrs.type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 4165 | final boolean topAtRest = |
| 4166 | win == mTopFullscreenOpaqueWindowState && !win.isAnimatingLw(); |
| 4167 | if (isAppWindow && !inheritTranslucentDecor && !topAtRest) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 4168 | if ((sysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0 |
| 4169 | && (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 4170 | && (fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) == 0 |
| 4171 | && (fl & WindowManager.LayoutParams. |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 4172 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0 |
| 4173 | && !mForceWindowDrawsStatusBarBackground) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 4174 | // Ensure policy decor includes status bar |
| 4175 | dcf.top = mStableTop; |
| 4176 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 4177 | if ((fl & WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION) == 0 |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 4178 | && (sysUiFl & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0 |
| 4179 | && (fl & WindowManager.LayoutParams. |
| 4180 | FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) == 0) { |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 4181 | // Ensure policy decor includes navigation bar |
| 4182 | dcf.bottom = mStableBottom; |
| 4183 | dcf.right = mStableRight; |
| 4184 | } |
| 4185 | } |
| 4186 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4187 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) |
| 4188 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 4189 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4190 | + "): IN_SCREEN, INSET_DECOR"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4191 | // This is the case for a normal activity window: we want it |
| 4192 | // to cover all of the screen space, and it can take care of |
| 4193 | // moving its contents to account for screen decorations that |
| 4194 | // intrude into that space. |
| 4195 | if (attached != null) { |
| 4196 | // If this window is attached to another, our display |
| 4197 | // frame is the same as the one we are attached to. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4198 | 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] | 4199 | } else { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 4200 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 4201 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 4202 | // Status bar panels are the only windows who can go on top of |
| 4203 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 4204 | // permission, so they have the same privileges as the status |
| 4205 | // bar itself. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 4206 | // |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 4207 | // However, they should still dodge the navigation bar if it exists. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 4208 | |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4209 | pf.left = df.left = of.left = hasNavBar |
| 4210 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 4211 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 4212 | pf.right = df.right = of.right = hasNavBar |
| 4213 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
| 4214 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 4215 | pf.bottom = df.bottom = of.bottom = hasNavBar |
| 4216 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
| 4217 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 4218 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4219 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 4220 | "Laying out status bar window: (%d,%d - %d,%d)", |
| 4221 | pf.left, pf.top, pf.right, pf.bottom)); |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 4222 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 4223 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 4224 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 4225 | // Asking to layout into the overscan region, so give it that pure |
| 4226 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4227 | pf.left = df.left = of.left = mOverscanScreenLeft; |
| 4228 | pf.top = df.top = of.top = mOverscanScreenTop; |
| 4229 | pf.right = df.right = of.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 4230 | pf.bottom = df.bottom = of.bottom = mOverscanScreenTop |
| 4231 | + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 4232 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 4233 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4234 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 4235 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4236 | // Asking for layout as if the nav bar is hidden, lets the |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 4237 | // application extend into the unrestricted overscan screen area. We |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4238 | // only do this for application windows to ensure no window that |
| 4239 | // can be above the nav bar can do this. |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 4240 | pf.left = df.left = mOverscanScreenLeft; |
| 4241 | pf.top = df.top = mOverscanScreenTop; |
| 4242 | pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 4243 | pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4244 | // We need to tell the app about where the frame inside the overscan |
| 4245 | // is, so it can inset its content by that amount -- it didn't ask |
| 4246 | // to actually extend itself into the overscan region. |
| 4247 | of.left = mUnrestrictedScreenLeft; |
| 4248 | of.top = mUnrestrictedScreenTop; |
| 4249 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 4250 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 4251 | } else { |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 4252 | pf.left = df.left = mRestrictedOverscanScreenLeft; |
| 4253 | pf.top = df.top = mRestrictedOverscanScreenTop; |
| 4254 | pf.right = df.right = mRestrictedOverscanScreenLeft |
| 4255 | + mRestrictedOverscanScreenWidth; |
| 4256 | pf.bottom = df.bottom = mRestrictedOverscanScreenTop |
| 4257 | + mRestrictedOverscanScreenHeight; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4258 | // We need to tell the app about where the frame inside the overscan |
| 4259 | // is, so it can inset its content by that amount -- it didn't ask |
| 4260 | // to actually extend itself into the overscan region. |
| 4261 | of.left = mUnrestrictedScreenLeft; |
| 4262 | of.top = mUnrestrictedScreenTop; |
| 4263 | of.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 4264 | of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 4265 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4266 | |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 4267 | if ((fl & FLAG_FULLSCREEN) == 0) { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 4268 | if (win.isVoiceInteraction()) { |
| 4269 | cf.left = mVoiceContentLeft; |
| 4270 | cf.top = mVoiceContentTop; |
| 4271 | cf.right = mVoiceContentRight; |
| 4272 | cf.bottom = mVoiceContentBottom; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4273 | } else { |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 4274 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
| 4275 | cf.left = mDockLeft; |
| 4276 | cf.top = mDockTop; |
| 4277 | cf.right = mDockRight; |
| 4278 | cf.bottom = mDockBottom; |
| 4279 | } else { |
| 4280 | cf.left = mContentLeft; |
| 4281 | cf.top = mContentTop; |
| 4282 | cf.right = mContentRight; |
| 4283 | cf.bottom = mContentBottom; |
| 4284 | } |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4285 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4286 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4287 | // Full screen windows are always given a layout that is as if the |
| 4288 | // status bar and other transient decors are gone. This is to avoid |
| 4289 | // bad states when moving from a window that is not hding the |
| 4290 | // status bar to one that is. |
| 4291 | cf.left = mRestrictedScreenLeft; |
| 4292 | cf.top = mRestrictedScreenTop; |
| 4293 | cf.right = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 4294 | cf.bottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4295 | } |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 4296 | applyStableConstraints(sysUiFl, fl, cf); |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 4297 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 4298 | vf.left = mCurLeft; |
| 4299 | vf.top = mCurTop; |
| 4300 | vf.right = mCurRight; |
| 4301 | vf.bottom = mCurBottom; |
| 4302 | } else { |
| 4303 | vf.set(cf); |
| 4304 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4305 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4306 | } else if ((fl & FLAG_LAYOUT_IN_SCREEN) != 0 || (sysUiFl |
| 4307 | & (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 4308 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4309 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 4310 | "): IN_SCREEN"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4311 | // A window that has requested to fill the entire screen just |
| 4312 | // gets everything, period. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 4313 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
John Spurlock | 67a0f85 | 2015-06-15 15:35:47 -0400 | [diff] [blame] | 4314 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL |
| 4315 | || attrs.type == TYPE_VOLUME_OVERLAY) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4316 | pf.left = df.left = of.left = cf.left = hasNavBar |
| 4317 | ? mDockLeft : mUnrestrictedScreenLeft; |
| 4318 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 4319 | pf.right = df.right = of.right = cf.right = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 4320 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 4321 | : mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4322 | pf.bottom = df.bottom = of.bottom = cf.bottom = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 4323 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 4324 | : mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4325 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 4326 | "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)", |
| 4327 | pf.left, pf.top, pf.right, pf.bottom)); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 4328 | } else if (attrs.type == TYPE_NAVIGATION_BAR |
| 4329 | || attrs.type == TYPE_NAVIGATION_BAR_PANEL) { |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 4330 | // The navigation bar has Real Ultimate Power. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4331 | pf.left = df.left = of.left = mUnrestrictedScreenLeft; |
| 4332 | pf.top = df.top = of.top = mUnrestrictedScreenTop; |
| 4333 | pf.right = df.right = of.right = mUnrestrictedScreenLeft |
| 4334 | + mUnrestrictedScreenWidth; |
| 4335 | pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop |
| 4336 | + mUnrestrictedScreenHeight; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4337 | if (DEBUG_LAYOUT) Slog.v(TAG, String.format( |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 4338 | "Laying out navigation bar window: (%d,%d - %d,%d)", |
| 4339 | pf.left, pf.top, pf.right, pf.bottom)); |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 4340 | } else if ((attrs.type == TYPE_SECURE_SYSTEM_OVERLAY |
| 4341 | || attrs.type == TYPE_BOOT_PROGRESS) |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 4342 | && ((fl & FLAG_FULLSCREEN) != 0)) { |
| 4343 | // Fullscreen secure system overlays get what they ask for. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4344 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 4345 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 4346 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 4347 | + mOverscanScreenWidth; |
| 4348 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 4349 | + mOverscanScreenHeight; |
Craig Mautner | 165be0c | 2015-01-27 15:16:58 -0800 | [diff] [blame] | 4350 | } else if (attrs.type == TYPE_BOOT_PROGRESS) { |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 4351 | // Boot progress screen always covers entire display. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4352 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 4353 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 4354 | pf.right = df.right = of.right = cf.right = mOverscanScreenLeft |
| 4355 | + mOverscanScreenWidth; |
| 4356 | pf.bottom = df.bottom = of.bottom = cf.bottom = mOverscanScreenTop |
| 4357 | + mOverscanScreenHeight; |
John Spurlock | ef4adae | 2013-08-26 17:58:58 -0400 | [diff] [blame] | 4358 | } else if (attrs.type == TYPE_WALLPAPER) { |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 4359 | // The wallpaper also has Real Ultimate Power, but we want to tell |
| 4360 | // it about the overscan area. |
| 4361 | pf.left = df.left = mOverscanScreenLeft; |
| 4362 | pf.top = df.top = mOverscanScreenTop; |
| 4363 | pf.right = df.right = mOverscanScreenLeft + mOverscanScreenWidth; |
| 4364 | pf.bottom = df.bottom = mOverscanScreenTop + mOverscanScreenHeight; |
| 4365 | of.left = cf.left = mUnrestrictedScreenLeft; |
| 4366 | of.top = cf.top = mUnrestrictedScreenTop; |
| 4367 | of.right = cf.right = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 4368 | of.bottom = cf.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 4369 | } else if ((fl & FLAG_LAYOUT_IN_OVERSCAN) != 0 |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 4370 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 4371 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 4372 | // Asking to layout into the overscan region, so give it that pure |
| 4373 | // unrestricted area. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4374 | pf.left = df.left = of.left = cf.left = mOverscanScreenLeft; |
| 4375 | pf.top = df.top = of.top = cf.top = mOverscanScreenTop; |
| 4376 | pf.right = df.right = of.right = cf.right |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 4377 | = mOverscanScreenLeft + mOverscanScreenWidth; |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4378 | pf.bottom = df.bottom = of.bottom = cf.bottom |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 4379 | = mOverscanScreenTop + mOverscanScreenHeight; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 4380 | } else if (canHideNavigationBar() |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 4381 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Craig Mautner | beac106 | 2014-06-03 14:38:57 -0700 | [diff] [blame] | 4382 | && (attrs.type == TYPE_STATUS_BAR |
| 4383 | || attrs.type == TYPE_TOAST |
Jorim Jaggi | 81fe2d1 | 2015-12-21 14:45:18 +0100 | [diff] [blame] | 4384 | || attrs.type == TYPE_DOCK_DIVIDER |
Jorim Jaggi | 2fdeeab | 2015-04-01 15:13:03 -0700 | [diff] [blame] | 4385 | || attrs.type == TYPE_VOICE_INTERACTION_STARTING |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 4386 | || (attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 4387 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW))) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4388 | // Asking for layout as if the nav bar is hidden, lets the |
| 4389 | // application extend into the unrestricted screen area. We |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 4390 | // 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] | 4391 | // can be above the nav bar can do this. |
| 4392 | // XXX This assumes that an app asking for this will also |
| 4393 | // ask for layout in only content. We can't currently figure out |
| 4394 | // 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] | 4395 | pf.left = df.left = of.left = cf.left = mUnrestrictedScreenLeft; |
| 4396 | pf.top = df.top = of.top = cf.top = mUnrestrictedScreenTop; |
| 4397 | pf.right = df.right = of.right = cf.right = mUnrestrictedScreenLeft |
| 4398 | + mUnrestrictedScreenWidth; |
| 4399 | pf.bottom = df.bottom = of.bottom = cf.bottom = mUnrestrictedScreenTop |
| 4400 | + mUnrestrictedScreenHeight; |
Jorim Jaggi | 9f6798a | 2016-02-10 22:16:06 -0800 | [diff] [blame] | 4401 | } else if ((sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) != 0) { |
| 4402 | pf.left = df.left = of.left = mRestrictedScreenLeft; |
| 4403 | pf.top = df.top = of.top = mRestrictedScreenTop; |
| 4404 | pf.right = df.right = of.right = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 4405 | pf.bottom = df.bottom = of.bottom = mRestrictedScreenTop |
| 4406 | + mRestrictedScreenHeight; |
| 4407 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
| 4408 | cf.left = mDockLeft; |
| 4409 | cf.top = mDockTop; |
| 4410 | cf.right = mDockRight; |
| 4411 | cf.bottom = mDockBottom; |
| 4412 | } else { |
| 4413 | cf.left = mContentLeft; |
| 4414 | cf.top = mContentTop; |
| 4415 | cf.right = mContentRight; |
| 4416 | cf.bottom = mContentBottom; |
| 4417 | } |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 4418 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4419 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 4420 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 4421 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 4422 | + mRestrictedScreenWidth; |
| 4423 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 4424 | + mRestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 4425 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4426 | |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 4427 | applyStableConstraints(sysUiFl, fl, cf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4428 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 4429 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 4430 | vf.left = mCurLeft; |
| 4431 | vf.top = mCurTop; |
| 4432 | vf.right = mCurRight; |
| 4433 | vf.bottom = mCurBottom; |
| 4434 | } else { |
| 4435 | vf.set(cf); |
| 4436 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4437 | } else if (attached != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4438 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 4439 | "): attached to " + attached); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4440 | // A child window should be placed inside of the same visible |
| 4441 | // frame that its parent had. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4442 | 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] | 4443 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4444 | if (DEBUG_LAYOUT) Slog.v(TAG, "layoutWindowLw(" + attrs.getTitle() + |
| 4445 | "): normal window"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4446 | // Otherwise, a normal window must be placed inside the content |
| 4447 | // of all screen decorations. |
John Spurlock | 67a0f85 | 2015-06-15 15:35:47 -0400 | [diff] [blame] | 4448 | if (attrs.type == TYPE_STATUS_BAR_PANEL || attrs.type == TYPE_VOLUME_OVERLAY) { |
| 4449 | // Status bar panels and the volume dialog are the only windows who can go on |
| 4450 | // top of the status bar. They are protected by the STATUS_BAR_SERVICE |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 4451 | // permission, so they have the same privileges as the status |
| 4452 | // bar itself. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4453 | pf.left = df.left = of.left = cf.left = mRestrictedScreenLeft; |
| 4454 | pf.top = df.top = of.top = cf.top = mRestrictedScreenTop; |
| 4455 | pf.right = df.right = of.right = cf.right = mRestrictedScreenLeft |
| 4456 | + mRestrictedScreenWidth; |
| 4457 | pf.bottom = df.bottom = of.bottom = cf.bottom = mRestrictedScreenTop |
| 4458 | + mRestrictedScreenHeight; |
John Spurlock | 67a0f85 | 2015-06-15 15:35:47 -0400 | [diff] [blame] | 4459 | } else if (attrs.type == TYPE_TOAST || attrs.type == TYPE_SYSTEM_ALERT) { |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 4460 | // These dialogs are stable to interim decor changes. |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 4461 | pf.left = df.left = of.left = cf.left = mStableLeft; |
| 4462 | pf.top = df.top = of.top = cf.top = mStableTop; |
| 4463 | pf.right = df.right = of.right = cf.right = mStableRight; |
| 4464 | pf.bottom = df.bottom = of.bottom = cf.bottom = mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4465 | } else { |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 4466 | pf.left = mContentLeft; |
| 4467 | pf.top = mContentTop; |
| 4468 | pf.right = mContentRight; |
| 4469 | pf.bottom = mContentBottom; |
Dianne Hackborn | 20d9474 | 2014-05-29 18:35:45 -0700 | [diff] [blame] | 4470 | if (win.isVoiceInteraction()) { |
| 4471 | df.left = of.left = cf.left = mVoiceContentLeft; |
| 4472 | df.top = of.top = cf.top = mVoiceContentTop; |
| 4473 | df.right = of.right = cf.right = mVoiceContentRight; |
| 4474 | df.bottom = of.bottom = cf.bottom = mVoiceContentBottom; |
| 4475 | } else if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4476 | df.left = of.left = cf.left = mDockLeft; |
| 4477 | df.top = of.top = cf.top = mDockTop; |
| 4478 | df.right = of.right = cf.right = mDockRight; |
| 4479 | df.bottom = of.bottom = cf.bottom = mDockBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 4480 | } else { |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4481 | df.left = of.left = cf.left = mContentLeft; |
| 4482 | df.top = of.top = cf.top = mContentTop; |
| 4483 | df.right = of.right = cf.right = mContentRight; |
| 4484 | df.bottom = of.bottom = cf.bottom = mContentBottom; |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 4485 | } |
| 4486 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 4487 | vf.left = mCurLeft; |
| 4488 | vf.top = mCurTop; |
| 4489 | vf.right = mCurRight; |
| 4490 | vf.bottom = mCurBottom; |
| 4491 | } else { |
| 4492 | vf.set(cf); |
| 4493 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 4494 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4495 | } |
| 4496 | } |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4497 | |
Craig Mautner | b816bed | 2013-07-23 10:26:17 -0700 | [diff] [blame] | 4498 | // TYPE_SYSTEM_ERROR is above the NavigationBar so it can't be allowed to extend over it. |
| 4499 | if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0 && attrs.type != TYPE_SYSTEM_ERROR) { |
Dianne Hackborn | 067e5f6 | 2014-09-07 23:14:30 -0700 | [diff] [blame] | 4500 | df.left = df.top = -10000; |
| 4501 | df.right = df.bottom = 10000; |
| 4502 | if (attrs.type != TYPE_WALLPAPER) { |
| 4503 | of.left = of.top = cf.left = cf.top = vf.left = vf.top = -10000; |
| 4504 | of.right = of.bottom = cf.right = cf.bottom = vf.right = vf.bottom = 10000; |
| 4505 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4506 | } |
| 4507 | |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 4508 | // If the device has a chin (e.g. some watches), a dead area at the bottom of the screen we |
| 4509 | // need to provide information to the clients that want to pretend that you can draw there. |
Filip Gruszczynski | b0c673b | 2015-06-05 09:43:06 -0700 | [diff] [blame] | 4510 | // We only want to apply outsets to certain types of windows. For example, we never want to |
| 4511 | // apply the outsets to floating dialogs, because they wouldn't make sense there. |
Filip Gruszczynski | 2987f61 | 2015-06-30 15:03:30 -0700 | [diff] [blame] | 4512 | final boolean useOutsets = shouldUseOutsets(attrs, fl); |
Filip Gruszczynski | b0c673b | 2015-06-05 09:43:06 -0700 | [diff] [blame] | 4513 | if (isDefaultDisplay && useOutsets) { |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 4514 | osf = mTmpOutsetFrame; |
| 4515 | osf.set(cf.left, cf.top, cf.right, cf.bottom); |
| 4516 | int outset = ScreenShapeHelper.getWindowOutsetBottomPx(mContext.getResources()); |
| 4517 | if (outset > 0) { |
Filip Gruszczynski | 2987f61 | 2015-06-30 15:03:30 -0700 | [diff] [blame] | 4518 | int rotation = mDisplayRotation; |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 4519 | if (rotation == Surface.ROTATION_0) { |
| 4520 | osf.bottom += outset; |
| 4521 | } else if (rotation == Surface.ROTATION_90) { |
| 4522 | osf.right += outset; |
| 4523 | } else if (rotation == Surface.ROTATION_180) { |
| 4524 | osf.top -= outset; |
| 4525 | } else if (rotation == Surface.ROTATION_270) { |
| 4526 | osf.left -= outset; |
| 4527 | } |
| 4528 | if (DEBUG_LAYOUT) Slog.v(TAG, "applying bottom outset of " + outset |
| 4529 | + " with rotation " + rotation + ", result: " + osf); |
| 4530 | } |
| 4531 | } |
| 4532 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4533 | 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] | 4534 | + ": sim=#" + Integer.toHexString(sim) |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 4535 | + " attach=" + attached + " type=" + attrs.type |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 4536 | + String.format(" flags=0x%08x", fl) |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 4537 | + " pf=" + pf.toShortString() + " df=" + df.toShortString() |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 4538 | + " of=" + of.toShortString() |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 4539 | + " cf=" + cf.toShortString() + " vf=" + vf.toShortString() |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 4540 | + " dcf=" + dcf.toShortString() |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 4541 | + " sf=" + sf.toShortString() |
| 4542 | + " osf=" + (osf == null ? "null" : osf.toShortString())); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4543 | |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 4544 | win.computeFrameLw(pf, df, of, cf, vf, dcf, sf, osf); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 4545 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4546 | // Dock windows carve out the bottom of the screen, so normal windows |
| 4547 | // can't appear underneath them. |
Craig Mautner | 8bd206b | 2012-10-03 10:32:02 -0700 | [diff] [blame] | 4548 | if (attrs.type == TYPE_INPUT_METHOD && win.isVisibleOrBehindKeyguardLw() |
| 4549 | && !win.getGivenInsetsPendingLw()) { |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 4550 | setLastInputMethodWindowLw(null, null); |
| 4551 | offsetInputMethodWindowLw(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4552 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 4553 | if (attrs.type == TYPE_VOICE_INTERACTION && win.isVisibleOrBehindKeyguardLw() |
| 4554 | && !win.getGivenInsetsPendingLw()) { |
| 4555 | offsetVoiceInputWindowLw(win); |
| 4556 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4557 | } |
| 4558 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 4559 | private void offsetInputMethodWindowLw(WindowState win) { |
Craig Mautner | 4774f6a | 2015-03-23 11:42:55 -0700 | [diff] [blame] | 4560 | int top = Math.max(win.getDisplayFrameLw().top, win.getContentFrameLw().top); |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 4561 | top += win.getGivenContentInsetsLw().top; |
| 4562 | if (mContentBottom > top) { |
| 4563 | mContentBottom = top; |
| 4564 | } |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 4565 | if (mVoiceContentBottom > top) { |
| 4566 | mVoiceContentBottom = top; |
| 4567 | } |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 4568 | top = win.getVisibleFrameLw().top; |
| 4569 | top += win.getGivenVisibleInsetsLw().top; |
| 4570 | if (mCurBottom > top) { |
| 4571 | mCurBottom = top; |
| 4572 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4573 | if (DEBUG_LAYOUT) Slog.v(TAG, "Input method: mDockBottom=" |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 4574 | + mDockBottom + " mContentBottom=" |
| 4575 | + mContentBottom + " mCurBottom=" + mCurBottom); |
| 4576 | } |
| 4577 | |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 4578 | private void offsetVoiceInputWindowLw(WindowState win) { |
Craig Mautner | 4774f6a | 2015-03-23 11:42:55 -0700 | [diff] [blame] | 4579 | int top = Math.max(win.getDisplayFrameLw().top, win.getContentFrameLw().top); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 4580 | top += win.getGivenContentInsetsLw().top; |
| 4581 | if (mVoiceContentBottom > top) { |
| 4582 | mVoiceContentBottom = top; |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 4583 | } |
| 4584 | } |
| 4585 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4586 | /** {@inheritDoc} */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 4587 | @Override |
| 4588 | public void finishLayoutLw() { |
| 4589 | return; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4590 | } |
| 4591 | |
| 4592 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 4593 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 4594 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4595 | mTopFullscreenOpaqueWindowState = null; |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 4596 | mTopFullscreenOpaqueOrDimmingWindowState = null; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 4597 | mTopDockedOpaqueWindowState = null; |
| 4598 | mTopDockedOpaqueOrDimmingWindowState = null; |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 4599 | mAppsToBeHidden.clear(); |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4600 | mAppsThatDismissKeyguard.clear(); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4601 | mForceStatusBar = false; |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 4602 | mForceStatusBarFromKeyguard = false; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 4603 | mForceStatusBarTransparent = false; |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 4604 | mForcingShowNavBar = false; |
| 4605 | mForcingShowNavBarLayer = -1; |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 4606 | |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4607 | mHideLockScreen = false; |
| 4608 | mAllowLockscreenWhenOn = false; |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 4609 | mDismissKeyguard = DISMISS_KEYGUARD_NONE; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 4610 | mShowingLockscreen = false; |
| 4611 | mShowingDream = false; |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4612 | mWinShowWhenLocked = null; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4613 | mKeyguardSecure = isKeyguardSecure(); |
| 4614 | mKeyguardSecureIncludingHidden = mKeyguardSecure |
| 4615 | && (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4616 | } |
| 4617 | |
| 4618 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 4619 | @Override |
Yohei Yukawa | d1a0922 | 2015-06-30 16:22:05 -0700 | [diff] [blame] | 4620 | public void applyPostLayoutPolicyLw(WindowState win, WindowManager.LayoutParams attrs, |
| 4621 | WindowState attached) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4622 | if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw=" |
| 4623 | + win.isVisibleOrBehindKeyguardLw()); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4624 | final int fl = PolicyControl.getWindowFlags(win, attrs); |
John Spurlock | 414c1f0 | 2013-12-04 13:47:36 -0500 | [diff] [blame] | 4625 | if (mTopFullscreenOpaqueWindowState == null |
| 4626 | && win.isVisibleLw() && attrs.type == TYPE_INPUT_METHOD) { |
| 4627 | mForcingShowNavBar = true; |
| 4628 | mForcingShowNavBarLayer = win.getSurfaceLayer(); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 4629 | } |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 4630 | if (attrs.type == TYPE_STATUS_BAR) { |
| 4631 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
| 4632 | mForceStatusBarFromKeyguard = true; |
Jorim Jaggi | e1de9f6 | 2015-09-23 14:59:50 -0700 | [diff] [blame] | 4633 | mShowingLockscreen = true; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 4634 | } |
| 4635 | if ((attrs.privateFlags & PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT) != 0) { |
| 4636 | mForceStatusBarTransparent = true; |
| 4637 | } |
Jorim Jaggi | afd4a55 | 2014-04-08 15:13:05 +0200 | [diff] [blame] | 4638 | } |
Adrian Roos | 602c68e | 2015-04-24 16:03:47 -0700 | [diff] [blame] | 4639 | |
| 4640 | boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW |
| 4641 | && attrs.type < FIRST_SYSTEM_WINDOW; |
| 4642 | final boolean showWhenLocked = (fl & FLAG_SHOW_WHEN_LOCKED) != 0; |
| 4643 | final boolean dismissKeyguard = (fl & FLAG_DISMISS_KEYGUARD) != 0; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 4644 | final int stackId = win.getStackId(); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4645 | if (mTopFullscreenOpaqueWindowState == null && |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 4646 | win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4647 | if ((fl & FLAG_FORCE_NOT_FULLSCREEN) != 0) { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4648 | if ((attrs.privateFlags & PRIVATE_FLAG_KEYGUARD) != 0) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 4649 | mForceStatusBarFromKeyguard = true; |
| 4650 | } else { |
| 4651 | mForceStatusBar = true; |
| 4652 | } |
| 4653 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 4654 | if (attrs.type == TYPE_DREAM) { |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 4655 | // If the lockscreen was showing when the dream started then wait |
| 4656 | // for the dream to draw before hiding the lockscreen. |
| 4657 | if (!mDreamingLockscreen |
| 4658 | || (win.isVisibleLw() && win.hasDrawnLw())) { |
| 4659 | mShowingDream = true; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4660 | appWindow = true; |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 4661 | } |
| 4662 | } |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4663 | |
Yohei Yukawa | d1a0922 | 2015-06-30 16:22:05 -0700 | [diff] [blame] | 4664 | final IApplicationToken appToken = win.getAppToken(); |
| 4665 | |
| 4666 | // For app windows that are not attached, we decide if all windows in the app they |
| 4667 | // represent should be hidden or if we should hide the lockscreen. For attached app |
| 4668 | // windows we defer the decision to the window it is attached to. |
| 4669 | if (appWindow && attached == null) { |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4670 | if (showWhenLocked) { |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4671 | // Remove any previous windows with the same appToken. |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4672 | mAppsToBeHidden.remove(appToken); |
| 4673 | mAppsThatDismissKeyguard.remove(appToken); |
Craig Mautner | ca0a124 | 2014-12-02 12:25:14 -0800 | [diff] [blame] | 4674 | if (mAppsToBeHidden.isEmpty()) { |
Craig Mautner | 192d604 | 2014-12-02 23:24:48 -0800 | [diff] [blame] | 4675 | if (dismissKeyguard && !mKeyguardSecure) { |
| 4676 | mAppsThatDismissKeyguard.add(appToken); |
Selim Cinek | 90b5e07 | 2015-08-28 17:05:56 -0700 | [diff] [blame] | 4677 | } else if (win.isDrawnLw() || win.hasAppShownWindows()) { |
Craig Mautner | ca0a124 | 2014-12-02 12:25:14 -0800 | [diff] [blame] | 4678 | mWinShowWhenLocked = win; |
| 4679 | mHideLockScreen = true; |
| 4680 | mForceStatusBarFromKeyguard = false; |
Craig Mautner | ca0a124 | 2014-12-02 12:25:14 -0800 | [diff] [blame] | 4681 | } |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4682 | } |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4683 | } else if (dismissKeyguard) { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4684 | if (mKeyguardSecure) { |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4685 | mAppsToBeHidden.add(appToken); |
| 4686 | } else { |
| 4687 | mAppsToBeHidden.remove(appToken); |
| 4688 | } |
| 4689 | mAppsThatDismissKeyguard.add(appToken); |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 4690 | } else { |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4691 | mAppsToBeHidden.add(appToken); |
Craig Mautner | 2bc789b | 2014-03-19 19:48:38 -0700 | [diff] [blame] | 4692 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 4693 | if (isFullscreen(attrs) && StackId.normallyFullscreenWindows(stackId)) { |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4694 | if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win); |
| 4695 | mTopFullscreenOpaqueWindowState = win; |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 4696 | if (mTopFullscreenOpaqueOrDimmingWindowState == null) { |
| 4697 | mTopFullscreenOpaqueOrDimmingWindowState = win; |
| 4698 | } |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4699 | if (!mAppsThatDismissKeyguard.isEmpty() && |
| 4700 | mDismissKeyguard == DISMISS_KEYGUARD_NONE) { |
| 4701 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 4702 | "Setting mDismissKeyguard true by win " + win); |
tingna_sung | e785ffa | 2015-05-12 13:23:15 +0800 | [diff] [blame] | 4703 | mDismissKeyguard = (mWinDismissingKeyguard == win |
| 4704 | && mSecureDismissingKeyguard == mKeyguardSecure) |
| 4705 | ? DISMISS_KEYGUARD_CONTINUE : DISMISS_KEYGUARD_START; |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4706 | mWinDismissingKeyguard = win; |
tingna_sung | e785ffa | 2015-05-12 13:23:15 +0800 | [diff] [blame] | 4707 | mSecureDismissingKeyguard = mKeyguardSecure; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4708 | mForceStatusBarFromKeyguard = mShowingLockscreen && mKeyguardSecure; |
Selim Cinek | 90b5e07 | 2015-08-28 17:05:56 -0700 | [diff] [blame] | 4709 | } else if (mAppsToBeHidden.isEmpty() && showWhenLocked |
| 4710 | && (win.isDrawnLw() || win.hasAppShownWindows())) { |
Jorim Jaggi | c13fcac | 2014-09-11 17:36:57 +0200 | [diff] [blame] | 4711 | if (DEBUG_LAYOUT) Slog.v(TAG, |
| 4712 | "Setting mHideLockScreen to true by win " + win); |
| 4713 | mHideLockScreen = true; |
| 4714 | mForceStatusBarFromKeyguard = false; |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4715 | } |
Craig Mautner | 00156ec | 2014-03-06 22:29:02 -0800 | [diff] [blame] | 4716 | if ((fl & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) { |
Craig Mautner | ab55e52 | 2014-03-03 13:26:03 -0800 | [diff] [blame] | 4717 | mAllowLockscreenWhenOn = true; |
| 4718 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4719 | } |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4720 | |
| 4721 | if (mWinShowWhenLocked != null && |
Adrian Roos | 602c68e | 2015-04-24 16:03:47 -0700 | [diff] [blame] | 4722 | mWinShowWhenLocked.getAppToken() != win.getAppToken() && |
| 4723 | (attrs.flags & FLAG_SHOW_WHEN_LOCKED) == 0) { |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4724 | win.hideLw(false); |
| 4725 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4726 | } |
Adrian Roos | 602c68e | 2015-04-24 16:03:47 -0700 | [diff] [blame] | 4727 | } else if (mTopFullscreenOpaqueWindowState == null && mWinShowWhenLocked == null) { |
| 4728 | // No TopFullscreenOpaqueWindow is showing, but we found a SHOW_WHEN_LOCKED window |
| 4729 | // that is being hidden in an animation - keep the |
| 4730 | // keyguard hidden until the new window shows up and |
| 4731 | // we know whether to show the keyguard or not. |
Adrian Roos | b85e1ec | 2015-05-29 15:23:18 -0700 | [diff] [blame] | 4732 | if (win.isAnimatingLw() && appWindow && showWhenLocked && mKeyguardHidden) { |
Adrian Roos | 602c68e | 2015-04-24 16:03:47 -0700 | [diff] [blame] | 4733 | mHideLockScreen = true; |
| 4734 | mWinShowWhenLocked = win; |
| 4735 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4736 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 4737 | |
| 4738 | // Keep track of the window if it's dimming but not necessarily fullscreen. |
| 4739 | final boolean reallyVisible = win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw(); |
| 4740 | if (mTopFullscreenOpaqueOrDimmingWindowState == null && reallyVisible |
| 4741 | && win.isDimming() && StackId.normallyFullscreenWindows(stackId)) { |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 4742 | mTopFullscreenOpaqueOrDimmingWindowState = win; |
| 4743 | } |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 4744 | |
| 4745 | // We need to keep track of the top "fullscreen" opaque window for the docked stack |
| 4746 | // separately, because both the "real fullscreen" opaque window and the one for the docked |
| 4747 | // stack can control View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR. |
| 4748 | if (mTopDockedOpaqueWindowState == null && reallyVisible && appWindow && attached == null |
| 4749 | && isFullscreen(attrs) && stackId == DOCKED_STACK_ID) { |
| 4750 | mTopDockedOpaqueWindowState = win; |
| 4751 | if (mTopDockedOpaqueOrDimmingWindowState == null) { |
| 4752 | mTopDockedOpaqueOrDimmingWindowState = win; |
| 4753 | } |
| 4754 | } |
| 4755 | |
| 4756 | // Also keep track of any windows that are dimming but not necessarily fullscreen in the |
| 4757 | // docked stack. |
| 4758 | if (mTopDockedOpaqueOrDimmingWindowState == null && reallyVisible && win.isDimming() |
| 4759 | && stackId == DOCKED_STACK_ID) { |
| 4760 | mTopDockedOpaqueOrDimmingWindowState = win; |
| 4761 | } |
| 4762 | } |
| 4763 | |
| 4764 | private boolean isFullscreen(WindowManager.LayoutParams attrs) { |
| 4765 | return attrs.x == 0 && attrs.y == 0 |
| 4766 | && attrs.width == WindowManager.LayoutParams.MATCH_PARENT |
| 4767 | && attrs.height == WindowManager.LayoutParams.MATCH_PARENT; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 4768 | } |
| 4769 | |
| 4770 | /** {@inheritDoc} */ |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 4771 | @Override |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 4772 | public int finishPostLayoutPolicyLw() { |
Craig Mautner | c5e73bf | 2015-04-21 15:41:26 +0000 | [diff] [blame] | 4773 | if (mWinShowWhenLocked != null && mTopFullscreenOpaqueWindowState != null && |
| 4774 | mWinShowWhenLocked.getAppToken() != mTopFullscreenOpaqueWindowState.getAppToken() |
| 4775 | && isKeyguardLocked()) { |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 4776 | // A dialog is dismissing the keyguard. Put the wallpaper behind it and hide the |
| 4777 | // fullscreen window. |
| 4778 | // TODO: Make sure FLAG_SHOW_WALLPAPER is restored when dialog is dismissed. Or not. |
| 4779 | mWinShowWhenLocked.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 4780 | mTopFullscreenOpaqueWindowState.hideLw(false); |
| 4781 | mTopFullscreenOpaqueWindowState = mWinShowWhenLocked; |
| 4782 | } |
| 4783 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4784 | int changes = 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4785 | boolean topIsFullscreen = false; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 4786 | |
| 4787 | final WindowManager.LayoutParams lp = (mTopFullscreenOpaqueWindowState != null) |
| 4788 | ? mTopFullscreenOpaqueWindowState.getAttrs() |
| 4789 | : null; |
| 4790 | |
Jeff Brown | c8018eb | 2012-10-29 21:33:27 -0700 | [diff] [blame] | 4791 | // If we are not currently showing a dream then remember the current |
| 4792 | // lockscreen state. We will use this to determine whether the dream |
| 4793 | // started while the lockscreen was showing and remember this state |
| 4794 | // while the dream is showing. |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 4795 | if (!mShowingDream) { |
| 4796 | mDreamingLockscreen = mShowingLockscreen; |
Jeff Brown | 061ea99 | 2015-04-17 19:55:47 -0700 | [diff] [blame] | 4797 | if (mDreamingSleepTokenNeeded) { |
| 4798 | mDreamingSleepTokenNeeded = false; |
| 4799 | mHandler.obtainMessage(MSG_UPDATE_DREAMING_SLEEP_TOKEN, 0, 1).sendToTarget(); |
| 4800 | } |
| 4801 | } else { |
| 4802 | if (!mDreamingSleepTokenNeeded) { |
| 4803 | mDreamingSleepTokenNeeded = true; |
| 4804 | mHandler.obtainMessage(MSG_UPDATE_DREAMING_SLEEP_TOKEN, 1, 1).sendToTarget(); |
| 4805 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 4806 | } |
| 4807 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4808 | if (mStatusBar != null) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4809 | if (DEBUG_LAYOUT) Slog.i(TAG, "force=" + mForceStatusBar |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 4810 | + " forcefkg=" + mForceStatusBarFromKeyguard |
Dianne Hackborn | d70bc2f | 2009-10-06 23:25:51 -0700 | [diff] [blame] | 4811 | + " top=" + mTopFullscreenOpaqueWindowState); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 4812 | boolean shouldBeTransparent = mForceStatusBarTransparent |
| 4813 | && !mForceStatusBar |
| 4814 | && !mForceStatusBarFromKeyguard; |
| 4815 | if (!shouldBeTransparent) { |
| 4816 | mStatusBarController.setShowTransparent(false /* transparent */); |
| 4817 | } else if (!mStatusBar.isVisibleLw()) { |
| 4818 | mStatusBarController.setShowTransparent(true /* transparent */); |
| 4819 | } |
| 4820 | if (mForceStatusBar || mForceStatusBarFromKeyguard || mForceStatusBarTransparent) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4821 | if (DEBUG_LAYOUT) Slog.v(TAG, "Showing status bar: forced"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4822 | if (mStatusBarController.setBarShowingLw(true)) { |
| 4823 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 4824 | } |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 4825 | // Maintain fullscreen layout until incoming animation is complete. |
| 4826 | topIsFullscreen = mTopIsFullscreen && mStatusBar.isAnimatingLw(); |
John Spurlock | f92b616 | 2013-11-11 15:01:16 -0500 | [diff] [blame] | 4827 | // Transient status bar on the lockscreen is not allowed |
| 4828 | if (mForceStatusBarFromKeyguard && mStatusBarController.isTransientShowing()) { |
| 4829 | mStatusBarController.updateVisibilityLw(false /*transientAllowed*/, |
| 4830 | mLastSystemUiFlags, mLastSystemUiFlags); |
| 4831 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4832 | } else if (mTopFullscreenOpaqueWindowState != null) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4833 | final int fl = PolicyControl.getWindowFlags(null, lp); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4834 | if (localLOGV) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4835 | Slog.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw() |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 4836 | + " shown position: " |
| 4837 | + mTopFullscreenOpaqueWindowState.getShownPositionLw()); |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4838 | Slog.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs() |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4839 | + " lp.flags=0x" + Integer.toHexString(fl)); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4840 | } |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 4841 | topIsFullscreen = (fl & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0 |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4842 | || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4843 | // The subtle difference between the window for mTopFullscreenOpaqueWindowState |
Mark Doliner | d0646dc | 2014-08-27 16:04:02 -0700 | [diff] [blame] | 4844 | // and mTopIsFullscreen is that mTopIsFullscreen is set only if the window |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 4845 | // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the |
| 4846 | // case though. |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4847 | if (mStatusBarController.isTransientShowing()) { |
| 4848 | if (mStatusBarController.setBarShowingLw(true)) { |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 4849 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 4850 | } |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 4851 | } else if (topIsFullscreen |
| 4852 | && !mWindowManagerInternal.isStackVisible(FREEFORM_WORKSPACE_STACK_ID) |
| 4853 | && !mWindowManagerInternal.isStackVisible(DOCKED_STACK_ID)) { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4854 | if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar"); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 4855 | if (mStatusBarController.setBarShowingLw(false)) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 4856 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4857 | } else { |
Craig Mautner | c5a6e44 | 2013-06-05 17:22:35 -0700 | [diff] [blame] | 4858 | if (DEBUG_LAYOUT) Slog.v(TAG, "Status bar already hiding"); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 4859 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4860 | } else { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 4861 | 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] | 4862 | if (mStatusBarController.setBarShowingLw(true)) { |
| 4863 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 4864 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4865 | } |
| 4866 | } |
| 4867 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 4868 | |
Craig Mautner | 81defc7 | 2013-10-29 11:10:42 -0700 | [diff] [blame] | 4869 | if (mTopIsFullscreen != topIsFullscreen) { |
| 4870 | if (!topIsFullscreen) { |
| 4871 | // Force another layout when status bar becomes fully shown. |
| 4872 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 4873 | } |
| 4874 | mTopIsFullscreen = topIsFullscreen; |
| 4875 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 4876 | |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 4877 | // Hide the key guard if a visible window explicitly specifies that it wants to be |
| 4878 | // displayed when the screen is locked. |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4879 | if (mKeyguardDelegate != null && mStatusBar != null) { |
| 4880 | if (localLOGV) Slog.v(TAG, "finishPostLayoutPolicyLw: mHideKeyguard=" |
| 4881 | + mHideLockScreen); |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4882 | if (mDismissKeyguard != DISMISS_KEYGUARD_NONE && !mKeyguardSecure) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4883 | mKeyguardHidden = true; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4884 | if (setKeyguardOccludedLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4885 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 4886 | | FINISH_LAYOUT_REDO_CONFIG |
| 4887 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 4888 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4889 | if (mKeyguardDelegate.isShowing()) { |
| 4890 | mHandler.post(new Runnable() { |
| 4891 | @Override |
| 4892 | public void run() { |
| 4893 | mKeyguardDelegate.keyguardDone(false, false); |
| 4894 | } |
| 4895 | }); |
| 4896 | } |
| 4897 | } else if (mHideLockScreen) { |
| 4898 | mKeyguardHidden = true; |
Jorim Jaggi | 7d85ea9 | 2015-05-20 17:20:40 -0700 | [diff] [blame] | 4899 | mWinDismissingKeyguard = null; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4900 | if (setKeyguardOccludedLw(true)) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4901 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 4902 | | FINISH_LAYOUT_REDO_CONFIG |
| 4903 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 4904 | } |
| 4905 | } else if (mDismissKeyguard != DISMISS_KEYGUARD_NONE) { |
Jorim Jaggi | 7d85ea9 | 2015-05-20 17:20:40 -0700 | [diff] [blame] | 4906 | mKeyguardHidden = false; |
| 4907 | if (setKeyguardOccludedLw(false)) { |
| 4908 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 4909 | | FINISH_LAYOUT_REDO_CONFIG |
| 4910 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 4911 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4912 | if (mDismissKeyguard == DISMISS_KEYGUARD_START) { |
| 4913 | // Only launch the next keyguard unlock window once per window. |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4914 | mHandler.post(new Runnable() { |
| 4915 | @Override |
| 4916 | public void run() { |
| 4917 | mKeyguardDelegate.dismiss(); |
| 4918 | } |
| 4919 | }); |
| 4920 | } |
| 4921 | } else { |
| 4922 | mWinDismissingKeyguard = null; |
tingna_sung | e785ffa | 2015-05-12 13:23:15 +0800 | [diff] [blame] | 4923 | mSecureDismissingKeyguard = false; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4924 | mKeyguardHidden = false; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4925 | if (setKeyguardOccludedLw(false)) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 4926 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 4927 | | FINISH_LAYOUT_REDO_CONFIG |
| 4928 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 4929 | } |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 4930 | } |
| 4931 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4932 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4933 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4934 | // If the navigation bar has been hidden or shown, we need to do another |
| 4935 | // layout pass to update that window. |
| 4936 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 4937 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4938 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 4939 | // update since mAllowLockscreenWhenOn might have changed |
| 4940 | updateLockScreenTimeout(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4941 | return changes; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4942 | } |
| 4943 | |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4944 | /** |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4945 | * Updates the occluded state of the Keyguard. |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4946 | * |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4947 | * @return Whether the flags have changed and we have to redo the layout. |
| 4948 | */ |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4949 | private boolean setKeyguardOccludedLw(boolean isOccluded) { |
| 4950 | boolean wasOccluded = mKeyguardOccluded; |
| 4951 | boolean showing = mKeyguardDelegate.isShowing(); |
| 4952 | if (wasOccluded && !isOccluded && showing) { |
| 4953 | mKeyguardOccluded = false; |
| 4954 | mKeyguardDelegate.setOccluded(false); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4955 | mStatusBar.getAttrs().privateFlags |= PRIVATE_FLAG_KEYGUARD; |
| 4956 | mStatusBar.getAttrs().flags |= FLAG_SHOW_WALLPAPER; |
| 4957 | return true; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 4958 | } else if (!wasOccluded && isOccluded && showing) { |
| 4959 | mKeyguardOccluded = true; |
| 4960 | mKeyguardDelegate.setOccluded(true); |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4961 | mStatusBar.getAttrs().privateFlags &= ~PRIVATE_FLAG_KEYGUARD; |
| 4962 | mStatusBar.getAttrs().flags &= ~FLAG_SHOW_WALLPAPER; |
| 4963 | return true; |
| 4964 | } else { |
| 4965 | return false; |
| 4966 | } |
| 4967 | } |
| 4968 | |
| 4969 | private boolean isStatusBarKeyguard() { |
| 4970 | return mStatusBar != null |
| 4971 | && (mStatusBar.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0; |
| 4972 | } |
| 4973 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4974 | @Override |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4975 | public boolean allowAppAnimationsLw() { |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 4976 | if (isStatusBarKeyguard() || mShowingDream) { |
Craig Mautner | 2881630 | 2013-10-10 20:31:00 -0700 | [diff] [blame] | 4977 | // 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] | 4978 | return false; |
| 4979 | } |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 4980 | return true; |
| 4981 | } |
| 4982 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4983 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4984 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus) { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4985 | mFocusedWindow = newFocus; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4986 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4987 | // If the navigation bar has been hidden or shown, we need to do another |
| 4988 | // layout pass to update that window. |
| 4989 | return FINISH_LAYOUT_REDO_LAYOUT; |
| 4990 | } |
| 4991 | return 0; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4992 | } |
| 4993 | |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 4994 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 4995 | @Override |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 4996 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
| 4997 | // lid changed state |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 4998 | final int newLidState = lidOpen ? LID_OPEN : LID_CLOSED; |
| 4999 | if (newLidState == mLidState) { |
| 5000 | return; |
| 5001 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5002 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5003 | mLidState = newLidState; |
| 5004 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5005 | updateRotation(true); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5006 | |
| 5007 | if (lidOpen) { |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 5008 | wakeUp(SystemClock.uptimeMillis(), mAllowTheaterModeWakeFromLidSwitch, |
| 5009 | "android.policy:LID"); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 5010 | } else if (!mLidControlsSleep) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 5011 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 5012 | } |
| 5013 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5014 | |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 5015 | @Override |
| 5016 | public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered) { |
| 5017 | int lensCoverState = lensCovered ? CAMERA_LENS_COVERED : CAMERA_LENS_UNCOVERED; |
| 5018 | if (mCameraLensCoverState == lensCoverState) { |
| 5019 | return; |
| 5020 | } |
| 5021 | if (mCameraLensCoverState == CAMERA_LENS_COVERED && |
| 5022 | lensCoverState == CAMERA_LENS_UNCOVERED) { |
| 5023 | Intent intent; |
| 5024 | final boolean keyguardActive = mKeyguardDelegate == null ? false : |
| 5025 | mKeyguardDelegate.isShowing(); |
| 5026 | if (keyguardActive) { |
| 5027 | intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE); |
| 5028 | } else { |
| 5029 | intent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); |
| 5030 | } |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 5031 | wakeUp(whenNanos / 1000000, mAllowTheaterModeWakeFromCameraLens, |
| 5032 | "android.policy:CAMERA_COVER"); |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 5033 | startActivityAsUser(intent, UserHandle.CURRENT_OR_SELF); |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 5034 | } |
| 5035 | mCameraLensCoverState = lensCoverState; |
| 5036 | } |
| 5037 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 5038 | void setHdmiPlugged(boolean plugged) { |
| 5039 | if (mHdmiPlugged != plugged) { |
| 5040 | mHdmiPlugged = plugged; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 5041 | updateRotation(true, true); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 5042 | Intent intent = new Intent(ACTION_HDMI_PLUGGED); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 5043 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 5044 | intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 5045 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 5046 | } |
| 5047 | } |
| 5048 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 5049 | void initializeHdmiState() { |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 5050 | boolean plugged = false; |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 5051 | // watch for HDMI plug messages if the hdmi switch exists |
| 5052 | if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) { |
| 5053 | mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi"); |
| 5054 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 5055 | final String filename = "/sys/class/switch/hdmi/state"; |
| 5056 | FileReader reader = null; |
| 5057 | try { |
| 5058 | reader = new FileReader(filename); |
| 5059 | char[] buf = new char[15]; |
| 5060 | int n = reader.read(buf); |
| 5061 | if (n > 1) { |
| 5062 | plugged = 0 != Integer.parseInt(new String(buf, 0, n-1)); |
| 5063 | } |
| 5064 | } catch (IOException ex) { |
| 5065 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 5066 | } catch (NumberFormatException ex) { |
| 5067 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 5068 | } finally { |
| 5069 | if (reader != null) { |
| 5070 | try { |
| 5071 | reader.close(); |
| 5072 | } catch (IOException ex) { |
| 5073 | } |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 5074 | } |
| 5075 | } |
| 5076 | } |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 5077 | // This dance forces the code in setHdmiPlugged to run. |
| 5078 | // Always do this so the sticky intent is stuck (to false) if there is no hdmi. |
| 5079 | mHdmiPlugged = !plugged; |
| 5080 | setHdmiPlugged(!mHdmiPlugged); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 5081 | } |
| 5082 | |
Dianne Hackborn | c0e3f24 | 2011-08-19 14:19:10 -0700 | [diff] [blame] | 5083 | final Object mScreenshotLock = new Object(); |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 5084 | ServiceConnection mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 5085 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5086 | final Runnable mScreenshotTimeout = new Runnable() { |
| 5087 | @Override public void run() { |
| 5088 | synchronized (mScreenshotLock) { |
| 5089 | if (mScreenshotConnection != null) { |
| 5090 | mContext.unbindService(mScreenshotConnection); |
| 5091 | mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 5092 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 5093 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5094 | } |
| 5095 | }; |
| 5096 | |
| 5097 | // Assume this is called from the Handler thread. |
| 5098 | private void takeScreenshot() { |
| 5099 | synchronized (mScreenshotLock) { |
| 5100 | if (mScreenshotConnection != null) { |
| 5101 | return; |
| 5102 | } |
| 5103 | ComponentName cn = new ComponentName("com.android.systemui", |
| 5104 | "com.android.systemui.screenshot.TakeScreenshotService"); |
| 5105 | Intent intent = new Intent(); |
| 5106 | intent.setComponent(cn); |
| 5107 | ServiceConnection conn = new ServiceConnection() { |
| 5108 | @Override |
| 5109 | public void onServiceConnected(ComponentName name, IBinder service) { |
| 5110 | synchronized (mScreenshotLock) { |
| 5111 | if (mScreenshotConnection != this) { |
| 5112 | return; |
| 5113 | } |
| 5114 | Messenger messenger = new Messenger(service); |
| 5115 | Message msg = Message.obtain(null, 1); |
| 5116 | final ServiceConnection myConn = this; |
| 5117 | Handler h = new Handler(mHandler.getLooper()) { |
| 5118 | @Override |
| 5119 | public void handleMessage(Message msg) { |
| 5120 | synchronized (mScreenshotLock) { |
| 5121 | if (mScreenshotConnection == myConn) { |
| 5122 | mContext.unbindService(mScreenshotConnection); |
| 5123 | mScreenshotConnection = null; |
| 5124 | mHandler.removeCallbacks(mScreenshotTimeout); |
| 5125 | } |
| 5126 | } |
| 5127 | } |
| 5128 | }; |
| 5129 | msg.replyTo = new Messenger(h); |
Winson Chung | a63bb84 | 2011-10-17 10:26:28 -0700 | [diff] [blame] | 5130 | msg.arg1 = msg.arg2 = 0; |
| 5131 | if (mStatusBar != null && mStatusBar.isVisibleLw()) |
| 5132 | msg.arg1 = 1; |
| 5133 | if (mNavigationBar != null && mNavigationBar.isVisibleLw()) |
| 5134 | msg.arg2 = 1; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5135 | try { |
| 5136 | messenger.send(msg); |
| 5137 | } catch (RemoteException e) { |
| 5138 | } |
| 5139 | } |
| 5140 | } |
| 5141 | @Override |
| 5142 | public void onServiceDisconnected(ComponentName name) {} |
| 5143 | }; |
Amith Yamasani | 27b89e6 | 2013-01-16 12:30:11 -0800 | [diff] [blame] | 5144 | if (mContext.bindServiceAsUser( |
| 5145 | intent, conn, Context.BIND_AUTO_CREATE, UserHandle.CURRENT)) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5146 | mScreenshotConnection = conn; |
| 5147 | mHandler.postDelayed(mScreenshotTimeout, 10000); |
| 5148 | } |
| 5149 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 5150 | } |
| 5151 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5152 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 5153 | @Override |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 5154 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) { |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 5155 | if (!mSystemBooted) { |
| 5156 | // If we have not yet booted, don't let key events do anything. |
| 5157 | return 0; |
| 5158 | } |
| 5159 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 5160 | final boolean interactive = (policyFlags & FLAG_INTERACTIVE) != 0; |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 5161 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 5162 | final boolean canceled = event.isCanceled(); |
| 5163 | final int keyCode = event.getKeyCode(); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 5164 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 5165 | final boolean isInjected = (policyFlags & WindowManagerPolicy.FLAG_INJECTED) != 0; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 5166 | |
Mike Lockwood | c72b15f | 2009-11-28 20:58:22 -0500 | [diff] [blame] | 5167 | // If screen is off then we treat the case where the keyguard is open but hidden |
| 5168 | // the same as if it were open and in front. |
| 5169 | // This will prevent any keys other than the power button from waking the screen |
| 5170 | // when the keyguard is hidden by another activity. |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5171 | final boolean keyguardActive = (mKeyguardDelegate == null ? false : |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 5172 | (interactive ? |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 5173 | isKeyguardShowingAndNotOccluded() : |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5174 | mKeyguardDelegate.isShowing())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5175 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 5176 | if (DEBUG_INPUT) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 5177 | Log.d(TAG, "interceptKeyTq keycode=" + keyCode |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 5178 | + " interactive=" + interactive + " keyguardActive=" + keyguardActive |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 5179 | + " policyFlags=" + Integer.toHexString(policyFlags)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5180 | } |
| 5181 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 5182 | // Basic policy based on interactive state. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5183 | int result; |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 5184 | boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0 |
| 5185 | || event.isWakeKey(); |
Michael Wright | fc01f04 | 2014-09-08 14:12:24 -0700 | [diff] [blame] | 5186 | if (interactive || (isInjected && !isWakeKey)) { |
RoboErik | de9ba39 | 2014-09-26 12:51:01 -0700 | [diff] [blame] | 5187 | // When the device is interactive or the key is injected pass the |
| 5188 | // key to the application. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5189 | result = ACTION_PASS_TO_USER; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5190 | isWakeKey = false; |
Michael Wright | fc01f04 | 2014-09-08 14:12:24 -0700 | [diff] [blame] | 5191 | } else if (!interactive && shouldDispatchInputWhenNonInteractive()) { |
| 5192 | // If we're currently dozing with the screen on and the keyguard showing, pass the key |
| 5193 | // to the application but preserve its wake key status to make sure we still move |
| 5194 | // from dozing to fully interactive if we would normally go from off to fully |
| 5195 | // interactive. |
| 5196 | result = ACTION_PASS_TO_USER; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5197 | } else { |
| 5198 | // When the screen is off and the key is not injected, determine whether |
| 5199 | // to wake the device but don't pass the key to the application. |
| 5200 | result = 0; |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 5201 | if (isWakeKey && (!down || !isWakeKeyWhenScreenOff(keyCode))) { |
| 5202 | isWakeKey = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5203 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5204 | } |
| 5205 | |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 5206 | // If the key would be handled globally, just return the result, don't worry about special |
| 5207 | // key processing. |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5208 | if (isValidGlobalKey(keyCode) |
| 5209 | && mGlobalKeyManager.shouldHandleGlobalKey(keyCode, event)) { |
Michael Wright | 85b1af6 | 2014-06-04 14:51:58 -0700 | [diff] [blame] | 5210 | if (isWakeKey) { |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 5211 | wakeUp(event.getEventTime(), mAllowTheaterModeWakeFromKey, "android.policy:KEY"); |
Michael Wright | 85b1af6 | 2014-06-04 14:51:58 -0700 | [diff] [blame] | 5212 | } |
Justin Koh | d378ad7 | 2013-04-01 12:18:26 -0700 | [diff] [blame] | 5213 | return result; |
| 5214 | } |
| 5215 | |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 5216 | boolean useHapticFeedback = down |
| 5217 | && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 |
| 5218 | && event.getRepeatCount() == 0; |
| 5219 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5220 | // Handle special keys. |
| 5221 | switch (keyCode) { |
| 5222 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 5223 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 5224 | case KeyEvent.KEYCODE_VOLUME_MUTE: { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5225 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { |
| 5226 | if (down) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5227 | if (interactive && !mScreenshotChordVolumeDownKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5228 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5229 | mScreenshotChordVolumeDownKeyTriggered = true; |
| 5230 | mScreenshotChordVolumeDownKeyTime = event.getDownTime(); |
| 5231 | mScreenshotChordVolumeDownKeyConsumed = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5232 | cancelPendingPowerKeyAction(); |
| 5233 | interceptScreenshotChord(); |
| 5234 | } |
| 5235 | } else { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5236 | mScreenshotChordVolumeDownKeyTriggered = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5237 | cancelPendingScreenshotChordAction(); |
| 5238 | } |
| 5239 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { |
| 5240 | if (down) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5241 | if (interactive && !mScreenshotChordVolumeUpKeyTriggered |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5242 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5243 | mScreenshotChordVolumeUpKeyTriggered = true; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5244 | cancelPendingPowerKeyAction(); |
| 5245 | cancelPendingScreenshotChordAction(); |
| 5246 | } |
| 5247 | } else { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5248 | mScreenshotChordVolumeUpKeyTriggered = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 5249 | cancelPendingScreenshotChordAction(); |
| 5250 | } |
| 5251 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5252 | if (down) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 5253 | TelecomManager telecomManager = getTelecommService(); |
| 5254 | if (telecomManager != null) { |
| 5255 | if (telecomManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 5256 | // If an incoming call is ringing, either VOLUME key means |
| 5257 | // "silence ringer". We handle these keys here, rather than |
| 5258 | // in the InCallScreen, to make sure we'll respond to them |
| 5259 | // even if the InCallScreen hasn't come to the foreground yet. |
| 5260 | // Look for the DOWN event here, to agree with the "fallback" |
| 5261 | // behavior in the InCallScreen. |
| 5262 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 5263 | + " VOLUME key-down while ringing: Silence ringer!"); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5264 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 5265 | // Silence the ringer. (It's safe to call this |
| 5266 | // even if the ringer has already been silenced.) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 5267 | telecomManager.silenceRinger(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5268 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 5269 | // And *don't* pass this key thru to the current activity |
| 5270 | // (which is probably the InCallScreen.) |
| 5271 | result &= ~ACTION_PASS_TO_USER; |
| 5272 | break; |
| 5273 | } |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 5274 | if (telecomManager.isInCall() |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 5275 | && (result & ACTION_PASS_TO_USER) == 0) { |
| 5276 | // 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] | 5277 | // the application, just pass it to the session service. |
| 5278 | |
| 5279 | MediaSessionLegacyHelper.getHelper(mContext) |
RoboErik | 3c45c29 | 2014-07-08 16:47:31 -0700 | [diff] [blame] | 5280 | .sendVolumeKeyEvent(event, false); |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 5281 | break; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5282 | } |
| 5283 | } |
Jaewan Kim | 765487f | 2016-01-12 14:45:42 +0900 | [diff] [blame] | 5284 | } |
| 5285 | if (mUseTvRouting) { |
| 5286 | // On TVs, defer special key handlings to |
| 5287 | // {@link interceptKeyBeforeDispatching()}. |
| 5288 | result |= ACTION_PASS_TO_USER; |
| 5289 | } else if ((result & ACTION_PASS_TO_USER) == 0) { |
| 5290 | // If we aren't passing to the user and no one else |
| 5291 | // handled it send it to the session manager to |
| 5292 | // figure out. |
| 5293 | MediaSessionLegacyHelper.getHelper(mContext) |
| 5294 | .sendVolumeKeyEvent(event, true); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5295 | } |
| 5296 | break; |
| 5297 | } |
| 5298 | |
| 5299 | case KeyEvent.KEYCODE_ENDCALL: { |
| 5300 | result &= ~ACTION_PASS_TO_USER; |
| 5301 | if (down) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 5302 | TelecomManager telecomManager = getTelecommService(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5303 | boolean hungUp = false; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 5304 | if (telecomManager != null) { |
| 5305 | hungUp = telecomManager.endCall(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5306 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5307 | if (interactive && !hungUp) { |
| 5308 | mEndCallKeyHandled = false; |
| 5309 | mHandler.postDelayed(mEndCallLongPress, |
| 5310 | ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout()); |
| 5311 | } else { |
| 5312 | mEndCallKeyHandled = true; |
| 5313 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5314 | } else { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5315 | if (!mEndCallKeyHandled) { |
| 5316 | mHandler.removeCallbacks(mEndCallLongPress); |
| 5317 | if (!canceled) { |
| 5318 | if ((mEndcallBehavior |
| 5319 | & Settings.System.END_BUTTON_BEHAVIOR_HOME) != 0) { |
| 5320 | if (goHome()) { |
| 5321 | break; |
| 5322 | } |
Dianne Hackborn | 0041e97 | 2009-07-24 17:14:43 -0700 | [diff] [blame] | 5323 | } |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5324 | if ((mEndcallBehavior |
| 5325 | & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { |
| 5326 | mPowerManager.goToSleep(event.getEventTime(), |
| 5327 | PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, 0); |
| 5328 | isWakeKey = false; |
| 5329 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5330 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5331 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5332 | } |
| 5333 | break; |
| 5334 | } |
| 5335 | |
| 5336 | case KeyEvent.KEYCODE_POWER: { |
| 5337 | result &= ~ACTION_PASS_TO_USER; |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5338 | isWakeKey = false; // wake-up will be handled separately |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5339 | if (down) { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5340 | interceptPowerKeyDown(event, interactive); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5341 | } else { |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5342 | interceptPowerKeyUp(event, interactive, canceled); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5343 | } |
| 5344 | break; |
| 5345 | } |
| 5346 | |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 5347 | case KeyEvent.KEYCODE_SLEEP: { |
| 5348 | result &= ~ACTION_PASS_TO_USER; |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 5349 | isWakeKey = false; |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 5350 | if (!mPowerManager.isInteractive()) { |
| 5351 | useHapticFeedback = false; // suppress feedback if already non-interactive |
| 5352 | } |
Nick Vaccaro | b593a81 | 2015-05-15 11:23:05 -0700 | [diff] [blame] | 5353 | if (down) { |
| 5354 | sleepPress(event.getEventTime()); |
| 5355 | } else { |
| 5356 | sleepRelease(event.getEventTime()); |
| 5357 | } |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 5358 | break; |
| 5359 | } |
| 5360 | |
Nick Armstrong-Crews | 56ecfcc | 2015-09-07 21:46:50 -0700 | [diff] [blame] | 5361 | case KeyEvent.KEYCODE_SOFT_SLEEP: { |
| 5362 | result &= ~ACTION_PASS_TO_USER; |
| 5363 | isWakeKey = false; |
| 5364 | if (!down) { |
| 5365 | mPowerManagerInternal.setUserInactiveOverrideFromWindowManager(); |
| 5366 | } |
| 5367 | break; |
| 5368 | } |
| 5369 | |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 5370 | case KeyEvent.KEYCODE_WAKEUP: { |
| 5371 | result &= ~ACTION_PASS_TO_USER; |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5372 | isWakeKey = true; |
Jeff Brown | 6212a49 | 2014-03-07 13:58:47 -0800 | [diff] [blame] | 5373 | break; |
| 5374 | } |
| 5375 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5376 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 5377 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 5378 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5379 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 5380 | case KeyEvent.KEYCODE_MUTE: |
| 5381 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 5382 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 5383 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 5384 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 5385 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 5386 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
| 5387 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: { |
RoboErik | de9ba39 | 2014-09-26 12:51:01 -0700 | [diff] [blame] | 5388 | if (MediaSessionLegacyHelper.getHelper(mContext).isGlobalPriorityActive()) { |
| 5389 | // If the global session is active pass all media keys to it |
| 5390 | // instead of the active window. |
| 5391 | result &= ~ACTION_PASS_TO_USER; |
| 5392 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5393 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 5394 | // Only do this if we would otherwise not pass it to the user. In that |
| 5395 | // case, the PhoneWindow class will do the same thing, except it will |
| 5396 | // 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] | 5397 | // Note that we need to make a copy of the key event here because the |
| 5398 | // original key event will be recycled when we return. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5399 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 5400 | Message msg = mHandler.obtainMessage(MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK, |
| 5401 | new KeyEvent(event)); |
| 5402 | msg.setAsynchronous(true); |
| 5403 | msg.sendToTarget(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5404 | } |
| 5405 | break; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 5406 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5407 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5408 | case KeyEvent.KEYCODE_CALL: { |
| 5409 | if (down) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 5410 | TelecomManager telecomManager = getTelecommService(); |
| 5411 | if (telecomManager != null) { |
| 5412 | if (telecomManager.isRinging()) { |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 5413 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 5414 | + " CALL key-down while ringing: Answer the call!"); |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 5415 | telecomManager.acceptRingingCall(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5416 | |
Santos Cordon | 6848f72 | 2014-05-21 15:22:12 -0700 | [diff] [blame] | 5417 | // And *don't* pass this key thru to the current activity |
| 5418 | // (which is presumably the InCallScreen.) |
| 5419 | result &= ~ACTION_PASS_TO_USER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5420 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5421 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 5422 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 5423 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5424 | } |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 5425 | case KeyEvent.KEYCODE_VOICE_ASSIST: { |
| 5426 | // Only do this if we would otherwise not pass it to the user. In that case, |
| 5427 | // interceptKeyBeforeDispatching would apply a similar but different policy in |
| 5428 | // order to invoke voice assist actions. Note that we need to make a copy of the |
| 5429 | // key event here because the original key event will be recycled when we return. |
| 5430 | if ((result & ACTION_PASS_TO_USER) == 0 && !down) { |
| 5431 | mBroadcastWakeLock.acquire(); |
| 5432 | Message msg = mHandler.obtainMessage(MSG_LAUNCH_VOICE_ASSIST_WITH_WAKE_LOCK, |
| 5433 | keyguardActive ? 1 : 0, 0); |
| 5434 | msg.setAsynchronous(true); |
| 5435 | msg.sendToTarget(); |
| 5436 | } |
Jaewan Kim | 4911787 | 2016-01-19 17:24:08 +0900 | [diff] [blame] | 5437 | break; |
| 5438 | } |
| 5439 | case KeyEvent.KEYCODE_WINDOW: { |
| 5440 | if (mShortPressWindowBehavior == SHORT_PRESS_WINDOW_PICTURE_IN_PICTURE) { |
| 5441 | if (!down) { |
Jaewan Kim | c552b04 | 2016-01-18 16:08:45 +0900 | [diff] [blame] | 5442 | requestTvPictureInPicture(event); |
Jaewan Kim | 4911787 | 2016-01-19 17:24:08 +0900 | [diff] [blame] | 5443 | } |
| 5444 | result &= ~ACTION_PASS_TO_USER; |
| 5445 | } |
| 5446 | break; |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 5447 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5448 | } |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 5449 | |
Jeff Brown | bae8e77 | 2014-06-12 19:59:45 -0700 | [diff] [blame] | 5450 | if (useHapticFeedback) { |
| 5451 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
| 5452 | } |
| 5453 | |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 5454 | if (isWakeKey) { |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 5455 | wakeUp(event.getEventTime(), mAllowTheaterModeWakeFromKey, "android.policy:KEY"); |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 5456 | } |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 5457 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5458 | return result; |
| 5459 | } |
| 5460 | |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 5461 | /** |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 5462 | * Returns true if the key can have global actions attached to it. |
| 5463 | * We reserve all power management keys for the system since they require |
| 5464 | * very careful handling. |
| 5465 | */ |
| 5466 | private static boolean isValidGlobalKey(int keyCode) { |
| 5467 | switch (keyCode) { |
| 5468 | case KeyEvent.KEYCODE_POWER: |
| 5469 | case KeyEvent.KEYCODE_WAKEUP: |
| 5470 | case KeyEvent.KEYCODE_SLEEP: |
| 5471 | return false; |
| 5472 | default: |
| 5473 | return true; |
| 5474 | } |
| 5475 | } |
| 5476 | |
| 5477 | /** |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 5478 | * When the screen is off we ignore some keys that might otherwise typically |
| 5479 | * be considered wake keys. We filter them out here. |
| 5480 | * |
| 5481 | * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it |
| 5482 | * is always considered a wake key. |
| 5483 | */ |
| 5484 | private boolean isWakeKeyWhenScreenOff(int keyCode) { |
| 5485 | switch (keyCode) { |
| 5486 | // ignore volume keys unless docked |
| 5487 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 5488 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 5489 | case KeyEvent.KEYCODE_VOLUME_MUTE: |
| 5490 | return mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED; |
| 5491 | |
| 5492 | // ignore media and camera keys |
| 5493 | case KeyEvent.KEYCODE_MUTE: |
| 5494 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 5495 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 5496 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 5497 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 5498 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 5499 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 5500 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 5501 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 5502 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
| 5503 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: |
Jaekyun Seok | bfdad8e | 2013-07-08 13:53:21 +0900 | [diff] [blame] | 5504 | case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK: |
Jeff Brown | 1c2e494 | 2012-11-06 16:32:01 -0800 | [diff] [blame] | 5505 | case KeyEvent.KEYCODE_CAMERA: |
| 5506 | return false; |
| 5507 | } |
| 5508 | return true; |
| 5509 | } |
| 5510 | |
| 5511 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 5512 | /** {@inheritDoc} */ |
| 5513 | @Override |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 5514 | public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags) { |
| 5515 | if ((policyFlags & FLAG_WAKE) != 0) { |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 5516 | if (wakeUp(whenNanos / 1000000, mAllowTheaterModeWakeFromMotion, |
| 5517 | "android.policy:MOTION")) { |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 5518 | return 0; |
| 5519 | } |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 5520 | } |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 5521 | |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 5522 | if (shouldDispatchInputWhenNonInteractive()) { |
| 5523 | return ACTION_PASS_TO_USER; |
| 5524 | } |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 5525 | |
Bryce Lee | 812d702 | 2014-11-10 13:33:28 -0800 | [diff] [blame] | 5526 | // If we have not passed the action up and we are in theater mode without dreaming, |
| 5527 | // there will be no dream to intercept the touch and wake into ambient. The device should |
| 5528 | // wake up in this case. |
| 5529 | if (isTheaterModeEnabled() && (policyFlags & FLAG_WAKE) != 0) { |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 5530 | wakeUp(whenNanos / 1000000, mAllowTheaterModeWakeFromMotionWhenNotDreaming, |
| 5531 | "android.policy:MOTION"); |
Bryce Lee | 812d702 | 2014-11-10 13:33:28 -0800 | [diff] [blame] | 5532 | } |
| 5533 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 5534 | return 0; |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 5535 | } |
| 5536 | |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 5537 | private boolean shouldDispatchInputWhenNonInteractive() { |
Joe LaPenna | f2b9b2d | 2015-11-17 22:22:37 +0000 | [diff] [blame] | 5538 | // Send events to keyguard while the screen is on. |
| 5539 | if (isKeyguardShowingAndNotOccluded() && mDisplay != null |
| 5540 | && mDisplay.getState() != Display.STATE_OFF) { |
Bryce Lee | 5c13832 | 2014-11-03 08:26:09 -0800 | [diff] [blame] | 5541 | return true; |
| 5542 | } |
| 5543 | |
| 5544 | // Send events to a dozing dream even if the screen is off since the dream |
| 5545 | // is in control of the state of the screen. |
| 5546 | IDreamManager dreamManager = getDreamManager(); |
| 5547 | |
| 5548 | try { |
| 5549 | if (dreamManager != null && dreamManager.isDreaming()) { |
| 5550 | return true; |
| 5551 | } |
| 5552 | } catch (RemoteException e) { |
| 5553 | Slog.e(TAG, "RemoteException when checking if dreaming", e); |
| 5554 | } |
| 5555 | |
| 5556 | // Otherwise, consume events since the user can't see what is being |
| 5557 | // interacted with. |
| 5558 | return false; |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 5559 | } |
| 5560 | |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 5561 | private void dispatchDirectAudioEvent(KeyEvent event) { |
| 5562 | if (event.getAction() != KeyEvent.ACTION_DOWN) { |
| 5563 | return; |
| 5564 | } |
| 5565 | int keyCode = event.getKeyCode(); |
John Spurlock | b94f2d6 | 2015-03-17 14:11:57 -0400 | [diff] [blame] | 5566 | int flags = AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND |
| 5567 | | AudioManager.FLAG_FROM_KEY; |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 5568 | String pkgName = mContext.getOpPackageName(); |
| 5569 | switch (keyCode) { |
| 5570 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 5571 | try { |
John Spurlock | ee5ad72 | 2015-03-03 16:17:21 -0500 | [diff] [blame] | 5572 | getAudioService().adjustSuggestedStreamVolume(AudioManager.ADJUST_RAISE, |
John Spurlock | 9087433 | 2015-03-10 16:00:54 -0400 | [diff] [blame] | 5573 | AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName, TAG); |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 5574 | } catch (RemoteException e) { |
| 5575 | Log.e(TAG, "Error dispatching volume up in dispatchTvAudioEvent.", e); |
| 5576 | } |
| 5577 | break; |
| 5578 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
| 5579 | try { |
John Spurlock | ee5ad72 | 2015-03-03 16:17:21 -0500 | [diff] [blame] | 5580 | getAudioService().adjustSuggestedStreamVolume(AudioManager.ADJUST_LOWER, |
John Spurlock | 9087433 | 2015-03-10 16:00:54 -0400 | [diff] [blame] | 5581 | AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName, TAG); |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 5582 | } catch (RemoteException e) { |
| 5583 | Log.e(TAG, "Error dispatching volume down in dispatchTvAudioEvent.", e); |
| 5584 | } |
| 5585 | break; |
| 5586 | case KeyEvent.KEYCODE_VOLUME_MUTE: |
| 5587 | try { |
| 5588 | if (event.getRepeatCount() == 0) { |
John Spurlock | ee5ad72 | 2015-03-03 16:17:21 -0500 | [diff] [blame] | 5589 | getAudioService().adjustSuggestedStreamVolume( |
| 5590 | AudioManager.ADJUST_TOGGLE_MUTE, |
John Spurlock | 9087433 | 2015-03-10 16:00:54 -0400 | [diff] [blame] | 5591 | AudioManager.USE_DEFAULT_STREAM_TYPE, flags, pkgName, TAG); |
RoboErik | 001c59c | 2015-01-26 15:53:51 -0800 | [diff] [blame] | 5592 | } |
| 5593 | } catch (RemoteException e) { |
| 5594 | Log.e(TAG, "Error dispatching mute in dispatchTvAudioEvent.", e); |
| 5595 | } |
| 5596 | break; |
| 5597 | } |
| 5598 | } |
| 5599 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 5600 | void dispatchMediaKeyWithWakeLock(KeyEvent event) { |
| 5601 | if (DEBUG_INPUT) { |
| 5602 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: " + event); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5603 | } |
| 5604 | |
Jeff Brown | 4001365 | 2012-05-16 21:22:36 -0700 | [diff] [blame] | 5605 | if (mHavePendingMediaKeyRepeatWithWakeLock) { |
| 5606 | if (DEBUG_INPUT) { |
| 5607 | Slog.d(TAG, "dispatchMediaKeyWithWakeLock: canceled repeat"); |
| 5608 | } |
| 5609 | |
| 5610 | mHandler.removeMessages(MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK); |
| 5611 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 5612 | mBroadcastWakeLock.release(); // pending repeat was holding onto the wake lock |
| 5613 | } |
| 5614 | |
| 5615 | dispatchMediaKeyWithWakeLockToAudioService(event); |
| 5616 | |
| 5617 | if (event.getAction() == KeyEvent.ACTION_DOWN |
| 5618 | && event.getRepeatCount() == 0) { |
| 5619 | mHavePendingMediaKeyRepeatWithWakeLock = true; |
| 5620 | |
| 5621 | Message msg = mHandler.obtainMessage( |
| 5622 | MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK, event); |
| 5623 | msg.setAsynchronous(true); |
| 5624 | mHandler.sendMessageDelayed(msg, ViewConfiguration.getKeyRepeatTimeout()); |
| 5625 | } else { |
| 5626 | mBroadcastWakeLock.release(); |
| 5627 | } |
| 5628 | } |
| 5629 | |
| 5630 | void dispatchMediaKeyRepeatWithWakeLock(KeyEvent event) { |
| 5631 | mHavePendingMediaKeyRepeatWithWakeLock = false; |
| 5632 | |
| 5633 | KeyEvent repeatEvent = KeyEvent.changeTimeRepeat(event, |
| 5634 | SystemClock.uptimeMillis(), 1, event.getFlags() | KeyEvent.FLAG_LONG_PRESS); |
| 5635 | if (DEBUG_INPUT) { |
| 5636 | Slog.d(TAG, "dispatchMediaKeyRepeatWithWakeLock: " + repeatEvent); |
| 5637 | } |
| 5638 | |
| 5639 | dispatchMediaKeyWithWakeLockToAudioService(repeatEvent); |
| 5640 | mBroadcastWakeLock.release(); |
| 5641 | } |
| 5642 | |
| 5643 | void dispatchMediaKeyWithWakeLockToAudioService(KeyEvent event) { |
| 5644 | if (ActivityManagerNative.isSystemReady()) { |
RoboErik | 430fc48 | 2014-06-12 15:49:20 -0700 | [diff] [blame] | 5645 | MediaSessionLegacyHelper.getHelper(mContext).sendMediaButtonEvent(event, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5646 | } |
| 5647 | } |
| 5648 | |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 5649 | void launchVoiceAssistWithWakeLock(boolean keyguardActive) { |
Dianne Hackborn | b6683c4 | 2015-06-18 17:40:33 -0700 | [diff] [blame] | 5650 | IDeviceIdleController dic = IDeviceIdleController.Stub.asInterface( |
| 5651 | ServiceManager.getService(Context.DEVICE_IDLE_CONTROLLER)); |
| 5652 | if (dic != null) { |
| 5653 | try { |
| 5654 | dic.exitIdle("voice-search"); |
| 5655 | } catch (RemoteException e) { |
| 5656 | } |
| 5657 | } |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 5658 | Intent voiceIntent = |
| 5659 | new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE); |
| 5660 | voiceIntent.putExtra(RecognizerIntent.EXTRA_SECURE, keyguardActive); |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 5661 | startActivityAsUser(voiceIntent, UserHandle.CURRENT_OR_SELF); |
Michael Wright | 869a67c | 2014-08-26 19:33:06 -0700 | [diff] [blame] | 5662 | mBroadcastWakeLock.release(); |
| 5663 | } |
| 5664 | |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 5665 | BroadcastReceiver mDockReceiver = new BroadcastReceiver() { |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 5666 | @Override |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 5667 | public void onReceive(Context context, Intent intent) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 5668 | if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { |
| 5669 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 5670 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 5671 | } else { |
| 5672 | try { |
| 5673 | IUiModeManager uiModeService = IUiModeManager.Stub.asInterface( |
| 5674 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 5675 | mUiMode = uiModeService.getCurrentModeType(); |
| 5676 | } catch (RemoteException e) { |
| 5677 | } |
Dianne Hackborn | 80fa166 | 2009-10-07 14:02:10 -0700 | [diff] [blame] | 5678 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 5679 | updateRotation(true); |
Craig Mautner | eee29c4 | 2013-01-17 14:44:34 -0800 | [diff] [blame] | 5680 | synchronized (mLock) { |
| 5681 | updateOrientationListenerLp(); |
| 5682 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 5683 | } |
| 5684 | }; |
| 5685 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 5686 | BroadcastReceiver mDreamReceiver = new BroadcastReceiver() { |
| 5687 | @Override |
| 5688 | public void onReceive(Context context, Intent intent) { |
| 5689 | if (Intent.ACTION_DREAMING_STARTED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5690 | if (mKeyguardDelegate != null) { |
| 5691 | mKeyguardDelegate.onDreamingStarted(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 5692 | } |
| 5693 | } else if (Intent.ACTION_DREAMING_STOPPED.equals(intent.getAction())) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5694 | if (mKeyguardDelegate != null) { |
| 5695 | mKeyguardDelegate.onDreamingStopped(); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 5696 | } |
| 5697 | } |
| 5698 | } |
| 5699 | }; |
| 5700 | |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5701 | BroadcastReceiver mMultiuserReceiver = new BroadcastReceiver() { |
| 5702 | @Override |
| 5703 | public void onReceive(Context context, Intent intent) { |
| 5704 | if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { |
| 5705 | // tickle the settings observer: this first ensures that we're |
| 5706 | // observing the relevant settings for the newly-active user, |
| 5707 | // and then updates our own bookkeeping based on the now- |
| 5708 | // current user. |
| 5709 | mSettingsObserver.onChange(false); |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 5710 | |
| 5711 | // force a re-application of focused window sysui visibility. |
| 5712 | // the window may never have been shown for this user |
| 5713 | // e.g. the keyguard when going through the new-user setup flow |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 5714 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
John Spurlock | ce479d8 | 2012-11-29 09:52:21 -0500 | [diff] [blame] | 5715 | mLastSystemUiFlags = 0; |
| 5716 | updateSystemUiVisibilityLw(); |
| 5717 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 5718 | } |
| 5719 | } |
| 5720 | }; |
| 5721 | |
Adrian Roos | ddc8b27 | 2015-05-21 16:28:27 -0700 | [diff] [blame] | 5722 | private final Runnable mHiddenNavPanic = new Runnable() { |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 5723 | @Override |
| 5724 | public void run() { |
Adrian Roos | ddc8b27 | 2015-05-21 16:28:27 -0700 | [diff] [blame] | 5725 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
| 5726 | if (!isUserSetupComplete()) { |
| 5727 | // Swipe-up for navigation bar is disabled during setup |
| 5728 | return; |
| 5729 | } |
| 5730 | mPendingPanicGestureUptime = SystemClock.uptimeMillis(); |
| 5731 | mNavigationBarController.showTransient(); |
| 5732 | } |
John Spurlock | d9b70bd | 2014-02-06 17:02:44 -0500 | [diff] [blame] | 5733 | } |
| 5734 | }; |
| 5735 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 5736 | private void requestTransientBars(WindowState swipeTarget) { |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 5737 | synchronized (mWindowManagerFuncs.getWindowManagerLock()) { |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 5738 | if (!isUserSetupComplete()) { |
| 5739 | // Swipe-up for navigation bar is disabled during setup |
| 5740 | return; |
| 5741 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5742 | boolean sb = mStatusBarController.checkShowTransientBarLw(); |
| 5743 | boolean nb = mNavigationBarController.checkShowTransientBarLw(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5744 | if (sb || nb) { |
Adrian Roos | 62b65e4 | 2015-02-25 18:05:34 +0100 | [diff] [blame] | 5745 | // Don't show status bar when swiping on already visible navigation bar |
| 5746 | if (!nb && swipeTarget == mNavigationBar) { |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 5747 | if (DEBUG) Slog.d(TAG, "Not showing transient bar, wrong swipe target"); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5748 | return; |
| 5749 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 5750 | if (sb) mStatusBarController.showTransient(); |
| 5751 | if (nb) mNavigationBarController.showTransient(); |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 5752 | mImmersiveModeConfirmation.confirmCurrentPrompt(); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5753 | updateSystemUiVisibilityLw(); |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 5754 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 5755 | } |
| 5756 | } |
| 5757 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5758 | // Called on the PowerManager's Notifier thread. |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5759 | @Override |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 5760 | public void startedGoingToSleep(int why) { |
| 5761 | if (DEBUG_WAKEUP) Slog.i(TAG, "Started going to sleep... (why=" + why + ")"); |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 5762 | if (mKeyguardDelegate != null) { |
| 5763 | mKeyguardDelegate.onStartedGoingToSleep(why); |
| 5764 | } |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 5765 | } |
| 5766 | |
| 5767 | // Called on the PowerManager's Notifier thread. |
| 5768 | @Override |
| 5769 | public void finishedGoingToSleep(int why) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 5770 | EventLog.writeEvent(70000, 0); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 5771 | if (DEBUG_WAKEUP) Slog.i(TAG, "Finished going to sleep... (why=" + why + ")"); |
Chris Wren | 9bb290b | 2015-06-29 12:02:13 -0400 | [diff] [blame] | 5772 | MetricsLogger.histogram(mContext, "screen_timeout", mLockScreenTimeout / 1000); |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5773 | |
| 5774 | // We must get this work done here because the power manager will drop |
| 5775 | // 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] | 5776 | synchronized (mLock) { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5777 | mAwake = false; |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5778 | updateWakeGestureListenerLp(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5779 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5780 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5781 | } |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5782 | if (mKeyguardDelegate != null) { |
Jorim Jaggi | d175b6c | 2015-05-27 15:39:09 -0700 | [diff] [blame] | 5783 | mKeyguardDelegate.onFinishedGoingToSleep(why); |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5784 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5785 | } |
| 5786 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5787 | // Called on the PowerManager's Notifier thread. |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5788 | @Override |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 5789 | public void startedWakingUp() { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 5790 | EventLog.writeEvent(70000, 1); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 5791 | if (DEBUG_WAKEUP) Slog.i(TAG, "Started waking up..."); |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 5792 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5793 | // Since goToSleep performs these functions synchronously, we must |
| 5794 | // do the same here. We cannot post this work to a handler because |
| 5795 | // that might cause it to become reordered with respect to what |
| 5796 | // may happen in a future call to goToSleep. |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5797 | synchronized (mLock) { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5798 | mAwake = true; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5799 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 5800 | updateWakeGestureListenerLp(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5801 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 5802 | updateLockScreenTimeout(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 5803 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5804 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5805 | if (mKeyguardDelegate != null) { |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 5806 | mKeyguardDelegate.onStartedWakingUp(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5807 | } |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5808 | } |
| 5809 | |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 5810 | // Called on the PowerManager's Notifier thread. |
| 5811 | @Override |
| 5812 | public void finishedWakingUp() { |
| 5813 | if (DEBUG_WAKEUP) Slog.i(TAG, "Finished waking up..."); |
| 5814 | } |
| 5815 | |
| 5816 | private void wakeUpFromPowerKey(long eventTime) { |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 5817 | wakeUp(eventTime, mAllowTheaterModeWakeFromPowerKey, "android.policy:POWER"); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 5818 | } |
| 5819 | |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 5820 | private boolean wakeUp(long wakeTime, boolean wakeInTheaterMode, String reason) { |
Bryce Lee | d389684 | 2015-06-23 17:06:51 -0700 | [diff] [blame] | 5821 | final boolean theaterModeEnabled = isTheaterModeEnabled(); |
| 5822 | if (!wakeInTheaterMode && theaterModeEnabled) { |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 5823 | return false; |
| 5824 | } |
| 5825 | |
Bryce Lee | d389684 | 2015-06-23 17:06:51 -0700 | [diff] [blame] | 5826 | if (theaterModeEnabled) { |
| 5827 | Settings.Global.putInt(mContext.getContentResolver(), |
| 5828 | Settings.Global.THEATER_MODE_ON, 0); |
| 5829 | } |
| 5830 | |
Dianne Hackborn | 280a64e | 2015-07-13 14:48:08 -0700 | [diff] [blame] | 5831 | mPowerManager.wakeUp(wakeTime, reason); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 5832 | return true; |
| 5833 | } |
| 5834 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5835 | private void finishKeyguardDrawn() { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5836 | synchronized (mLock) { |
Jorim Jaggi | f325548 | 2015-07-24 12:32:42 -0700 | [diff] [blame] | 5837 | if (!mScreenOnEarly || mKeyguardDrawComplete) { |
Stefan Kuhne | 9326dc1 | 2015-06-12 09:25:32 -1000 | [diff] [blame] | 5838 | return; // We are not awake yet or we have already informed of this event. |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5839 | } |
| 5840 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5841 | mKeyguardDrawComplete = true; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5842 | if (mKeyguardDelegate != null) { |
| 5843 | mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT); |
| 5844 | } |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 5845 | mWindowManagerDrawComplete = false; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5846 | } |
| 5847 | |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 5848 | // ... eventually calls finishWindowsDrawn which will finalize our screen turn on |
| 5849 | // as well as enabling the orientation change logic/sensor. |
| 5850 | mWindowManagerInternal.waitForAllWindowsDrawn(mWindowManagerDrawCallback, |
| 5851 | WAITING_FOR_DRAWN_TIMEOUT); |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5852 | } |
| 5853 | |
| 5854 | // Called on the DisplayManager's DisplayPowerController thread. |
| 5855 | @Override |
| 5856 | public void screenTurnedOff() { |
| 5857 | if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turned off..."); |
| 5858 | |
Jeff Brown | 48d1b14 | 2015-06-10 16:36:03 -0700 | [diff] [blame] | 5859 | updateScreenOffSleepToken(true); |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5860 | synchronized (mLock) { |
| 5861 | mScreenOnEarly = false; |
| 5862 | mScreenOnFully = false; |
Jorim Jaggi | 95c6dae | 2015-07-29 15:17:23 -0700 | [diff] [blame] | 5863 | mKeyguardDrawComplete = false; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5864 | mWindowManagerDrawComplete = false; |
| 5865 | mScreenOnListener = null; |
| 5866 | updateOrientationListenerLp(); |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 5867 | |
| 5868 | if (mKeyguardDelegate != null) { |
| 5869 | mKeyguardDelegate.onScreenTurnedOff(); |
| 5870 | } |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5871 | } |
| 5872 | } |
| 5873 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5874 | // Called on the DisplayManager's DisplayPowerController thread. |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5875 | @Override |
| 5876 | public void screenTurningOn(final ScreenOnListener screenOnListener) { |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5877 | if (DEBUG_WAKEUP) Slog.i(TAG, "Screen turning on..."); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5878 | |
Jeff Brown | 48d1b14 | 2015-06-10 16:36:03 -0700 | [diff] [blame] | 5879 | updateScreenOffSleepToken(false); |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5880 | synchronized (mLock) { |
| 5881 | mScreenOnEarly = true; |
| 5882 | mScreenOnFully = false; |
Jorim Jaggi | 95c6dae | 2015-07-29 15:17:23 -0700 | [diff] [blame] | 5883 | mKeyguardDrawComplete = false; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5884 | mWindowManagerDrawComplete = false; |
| 5885 | mScreenOnListener = screenOnListener; |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5886 | |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 5887 | if (mKeyguardDelegate != null) { |
Jorim Jaggi | a4b51bc | 2015-08-10 18:20:43 -0700 | [diff] [blame] | 5888 | mHandler.removeMessages(MSG_KEYGUARD_DRAWN_TIMEOUT); |
| 5889 | mHandler.sendEmptyMessageDelayed(MSG_KEYGUARD_DRAWN_TIMEOUT, 1000); |
Jorim Jaggi | 4cfdcf5 | 2015-07-09 12:13:59 -0700 | [diff] [blame] | 5890 | mKeyguardDelegate.onScreenTurningOn(mKeyguardDrawnCallback); |
| 5891 | } else { |
| 5892 | if (DEBUG_WAKEUP) Slog.d(TAG, |
| 5893 | "null mKeyguardDelegate: setting mKeyguardDrawComplete."); |
| 5894 | finishKeyguardDrawn(); |
| 5895 | } |
| 5896 | } |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5897 | } |
| 5898 | |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 5899 | // Called on the DisplayManager's DisplayPowerController thread. |
| 5900 | @Override |
| 5901 | public void screenTurnedOn() { |
| 5902 | synchronized (mLock) { |
| 5903 | if (mKeyguardDelegate != null) { |
| 5904 | mKeyguardDelegate.onScreenTurnedOn(); |
| 5905 | } |
| 5906 | } |
| 5907 | } |
| 5908 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5909 | private void finishWindowsDrawn() { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5910 | synchronized (mLock) { |
| 5911 | if (!mScreenOnEarly || mWindowManagerDrawComplete) { |
Stefan Kuhne | 9326dc1 | 2015-06-12 09:25:32 -1000 | [diff] [blame] | 5912 | return; // Screen is not turned on or we did already handle this case earlier. |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5913 | } |
| 5914 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5915 | mWindowManagerDrawComplete = true; |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5916 | } |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5917 | |
| 5918 | finishScreenTurningOn(); |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5919 | } |
| 5920 | |
Craig Mautner | 8a0da01 | 2014-05-31 15:13:37 -0700 | [diff] [blame] | 5921 | private void finishScreenTurningOn() { |
Stefan Kuhne | 9326dc1 | 2015-06-12 09:25:32 -1000 | [diff] [blame] | 5922 | synchronized (mLock) { |
| 5923 | // We have just finished drawing screen content. Since the orientation listener |
| 5924 | // gets only installed when all windows are drawn, we try to install it again. |
| 5925 | updateOrientationListenerLp(); |
| 5926 | } |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5927 | final ScreenOnListener listener; |
| 5928 | final boolean enableScreen; |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5929 | synchronized (mLock) { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5930 | if (DEBUG_WAKEUP) Slog.d(TAG, |
| 5931 | "finishScreenTurningOn: mAwake=" + mAwake |
| 5932 | + ", mScreenOnEarly=" + mScreenOnEarly |
| 5933 | + ", mScreenOnFully=" + mScreenOnFully |
| 5934 | + ", mKeyguardDrawComplete=" + mKeyguardDrawComplete |
| 5935 | + ", mWindowManagerDrawComplete=" + mWindowManagerDrawComplete); |
| 5936 | |
| 5937 | if (mScreenOnFully || !mScreenOnEarly || !mWindowManagerDrawComplete |
| 5938 | || (mAwake && !mKeyguardDrawComplete)) { |
| 5939 | return; // spurious or not ready yet |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5940 | } |
| 5941 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5942 | if (DEBUG_WAKEUP) Slog.i(TAG, "Finished screen turning on..."); |
| 5943 | listener = mScreenOnListener; |
Craig Mautner | 13f6ea7 | 2014-06-23 14:57:02 -0700 | [diff] [blame] | 5944 | mScreenOnListener = null; |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5945 | mScreenOnFully = true; |
| 5946 | |
| 5947 | // Remember the first time we draw the keyguard so we know when we're done with |
| 5948 | // the main part of booting and can enable the screen and hide boot messages. |
| 5949 | if (!mKeyguardDrawnOnce && mAwake) { |
| 5950 | mKeyguardDrawnOnce = true; |
| 5951 | enableScreen = true; |
| 5952 | if (mBootMessageNeedsHiding) { |
| 5953 | mBootMessageNeedsHiding = false; |
| 5954 | hideBootMessages(); |
| 5955 | } |
| 5956 | } else { |
| 5957 | enableScreen = false; |
| 5958 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5959 | } |
| 5960 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5961 | if (listener != null) { |
| 5962 | listener.onScreenOn(); |
| 5963 | } |
Jeff Brown | 4fc4527 | 2012-10-10 18:28:14 -0700 | [diff] [blame] | 5964 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5965 | if (enableScreen) { |
| 5966 | try { |
| 5967 | mWindowManager.enableScreenIfNeeded(); |
| 5968 | } catch (RemoteException unhandled) { |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 5969 | } |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 5970 | } |
| 5971 | } |
| 5972 | |
| 5973 | private void handleHideBootMessage() { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5974 | synchronized (mLock) { |
| 5975 | if (!mKeyguardDrawnOnce) { |
| 5976 | mBootMessageNeedsHiding = true; |
| 5977 | return; // keyguard hasn't drawn the first time yet, not done booting |
| 5978 | } |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 5979 | } |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5980 | |
| 5981 | if (mBootMsgDialog != null) { |
| 5982 | if (DEBUG_WAKEUP) Slog.d(TAG, "handleHideBootMessage: dismissing"); |
| 5983 | mBootMsgDialog.dismiss(); |
| 5984 | mBootMsgDialog = null; |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 5985 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5986 | } |
| 5987 | |
| 5988 | @Override |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 5989 | public boolean isScreenOn() { |
| 5990 | return mScreenOnFully; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 5991 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 5992 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 5993 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 5994 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5995 | public void enableKeyguard(boolean enabled) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 5996 | if (mKeyguardDelegate != null) { |
| 5997 | mKeyguardDelegate.setKeyguardEnabled(enabled); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 5998 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 5999 | } |
| 6000 | |
| 6001 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6002 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6003 | public void exitKeyguardSecurely(OnKeyguardExitResult callback) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 6004 | if (mKeyguardDelegate != null) { |
| 6005 | mKeyguardDelegate.verifyUnlock(callback); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 6006 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6007 | } |
| 6008 | |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 6009 | private boolean isKeyguardShowingAndNotOccluded() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 6010 | if (mKeyguardDelegate == null) return false; |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 6011 | return mKeyguardDelegate.isShowing() && !mKeyguardOccluded; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6012 | } |
| 6013 | |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 6014 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6015 | @Override |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 6016 | public boolean isKeyguardLocked() { |
| 6017 | return keyguardOn(); |
| 6018 | } |
| 6019 | |
| 6020 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6021 | @Override |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 6022 | public boolean isKeyguardSecure() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 6023 | if (mKeyguardDelegate == null) return false; |
| 6024 | return mKeyguardDelegate.isSecure(); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 6025 | } |
| 6026 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6027 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6028 | @Override |
Adrian Roos | 461829d | 2015-06-03 14:41:18 -0700 | [diff] [blame] | 6029 | public boolean isKeyguardShowingOrOccluded() { |
| 6030 | return mKeyguardDelegate == null ? false : mKeyguardDelegate.isShowing(); |
| 6031 | } |
| 6032 | |
| 6033 | /** {@inheritDoc} */ |
| 6034 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6035 | public boolean inKeyguardRestrictedKeyInputMode() { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 6036 | if (mKeyguardDelegate == null) return false; |
| 6037 | return mKeyguardDelegate.isInputRestricted(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6038 | } |
| 6039 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6040 | @Override |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 6041 | public void dismissKeyguardLw() { |
RoboErik | 8a2cfc3 | 2014-05-16 11:19:38 -0700 | [diff] [blame] | 6042 | if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()) { |
Craig Mautner | c0d2d0a | 2014-10-31 16:25:15 -0700 | [diff] [blame] | 6043 | if (DEBUG_KEYGUARD) Slog.d(TAG, "PWM.dismissKeyguardLw"); |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 6044 | mHandler.post(new Runnable() { |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6045 | @Override |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 6046 | public void run() { |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 6047 | // ask the keyguard to prompt the user to authenticate if necessary |
| 6048 | mKeyguardDelegate.dismiss(); |
| 6049 | } |
| 6050 | }); |
| 6051 | } |
| 6052 | } |
| 6053 | |
| 6054 | public void notifyActivityDrawnForKeyguardLw() { |
| 6055 | if (mKeyguardDelegate != null) { |
| 6056 | mHandler.post(new Runnable() { |
| 6057 | @Override |
| 6058 | public void run() { |
| 6059 | mKeyguardDelegate.onActivityDrawn(); |
Daniel Sandler | 1ce80439 | 2012-11-07 15:07:12 -0500 | [diff] [blame] | 6060 | } |
| 6061 | }); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 6062 | } |
| 6063 | } |
| 6064 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 6065 | @Override |
| 6066 | public boolean isKeyguardDrawnLw() { |
| 6067 | synchronized (mLock) { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 6068 | return mKeyguardDrawnOnce; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 6069 | } |
| 6070 | } |
| 6071 | |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 6072 | @Override |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 6073 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 6074 | if (mKeyguardDelegate != null) { |
Craig Mautner | c0d2d0a | 2014-10-31 16:25:15 -0700 | [diff] [blame] | 6075 | if (DEBUG_KEYGUARD) Slog.d(TAG, "PWM.startKeyguardExitAnimation"); |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 6076 | mKeyguardDelegate.startKeyguardExitAnimation(startTime, fadeoutDuration); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 6077 | } |
| 6078 | } |
| 6079 | |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 6080 | @Override |
| 6081 | public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, |
| 6082 | Rect outInsets) { |
| 6083 | outInsets.setEmpty(); |
Jorim Jaggi | 82c9dc9 | 2016-02-05 15:10:33 -0800 | [diff] [blame] | 6084 | |
| 6085 | // Navigation bar and status bar. |
| 6086 | getNonDecorInsetsLw(displayRotation, displayWidth, displayHeight, outInsets); |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 6087 | if (mStatusBar != null) { |
| 6088 | outInsets.top = mStatusBarHeight; |
| 6089 | } |
Jorim Jaggi | 82c9dc9 | 2016-02-05 15:10:33 -0800 | [diff] [blame] | 6090 | } |
| 6091 | |
| 6092 | @Override |
| 6093 | public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight, |
| 6094 | Rect outInsets) { |
| 6095 | outInsets.setEmpty(); |
| 6096 | |
| 6097 | // Only navigation bar |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 6098 | if (mNavigationBar != null) { |
| 6099 | if (isNavigationBarOnBottom(displayWidth, displayHeight)) { |
| 6100 | outInsets.bottom = getNavigationBarHeight(displayRotation, mUiMode); |
| 6101 | } else { |
| 6102 | outInsets.right = getNavigationBarWidth(displayRotation, mUiMode); |
| 6103 | } |
| 6104 | } |
| 6105 | } |
| 6106 | |
Jorim Jaggi | 5060bd8 | 2016-02-19 17:12:19 -0800 | [diff] [blame] | 6107 | @Override |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 6108 | public boolean isNavBarForcedShownLw(WindowState windowState) { |
| 6109 | return mForceShowSystemBars |
| 6110 | && !windowState.getFrameLw().equals(windowState.getDisplayFrameLw()); |
| 6111 | } |
| 6112 | |
| 6113 | @Override |
Jorim Jaggi | 5060bd8 | 2016-02-19 17:12:19 -0800 | [diff] [blame] | 6114 | public boolean isDockSideAllowed(int dockSide) { |
| 6115 | |
| 6116 | // We do not allow all dock sides at which the navigation bar touches the docked stack. |
| 6117 | if (!mNavigationBarCanMove) { |
| 6118 | return dockSide == DOCKED_TOP || dockSide == DOCKED_LEFT || dockSide == DOCKED_RIGHT; |
| 6119 | } else { |
| 6120 | return dockSide == DOCKED_TOP || dockSide == DOCKED_LEFT; |
| 6121 | } |
| 6122 | } |
| 6123 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6124 | void sendCloseSystemWindows() { |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 6125 | PhoneWindow.sendCloseSystemWindows(mContext, null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6126 | } |
| 6127 | |
| 6128 | void sendCloseSystemWindows(String reason) { |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 6129 | PhoneWindow.sendCloseSystemWindows(mContext, reason); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6130 | } |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 6131 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6132 | @Override |
| 6133 | public int rotationForOrientationLw(int orientation, int lastRotation) { |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 6134 | if (false) { |
| 6135 | Slog.v(TAG, "rotationForOrientationLw(orient=" |
| 6136 | + orientation + ", last=" + lastRotation |
| 6137 | + "); user=" + mUserRotation + " " |
| 6138 | + ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) |
| 6139 | ? "USER_ROTATION_LOCKED" : "") |
| 6140 | ); |
| 6141 | } |
| 6142 | |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 6143 | if (mForceDefaultOrientation) { |
| 6144 | return Surface.ROTATION_0; |
| 6145 | } |
| 6146 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 6147 | synchronized (mLock) { |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 6148 | int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 |
| 6149 | if (sensorRotation < 0) { |
Jeff Brown | 0f862b4 | 2012-09-27 21:11:01 -0700 | [diff] [blame] | 6150 | sensorRotation = lastRotation; |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 6151 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6152 | |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 6153 | final int preferredRotation; |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 6154 | if (mLidState == LID_OPEN && mLidOpenRotation >= 0) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6155 | // Ignore sensor when lid switch is open and rotation is forced. |
| 6156 | preferredRotation = mLidOpenRotation; |
| 6157 | } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 6158 | && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6159 | // Ignore sensor when in car dock unless explicitly enabled. |
| 6160 | // This case can override the behavior of NOSENSOR, and can also |
| 6161 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 6162 | preferredRotation = mCarDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6163 | ? sensorRotation : mCarDockRotation; |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 6164 | } else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 6165 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 6166 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 6167 | && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6168 | // Ignore sensor when in desk dock unless explicitly enabled. |
| 6169 | // This case can override the behavior of NOSENSOR, and can also |
| 6170 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 6171 | preferredRotation = mDeskDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6172 | ? sensorRotation : mDeskDockRotation; |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 6173 | } else if (mHdmiPlugged && mDemoHdmiRotationLock) { |
| 6174 | // Ignore sensor when plugged into HDMI when demo HDMI rotation lock enabled. |
Jeff Brown | eb3e4b9 | 2011-12-06 19:54:24 -0800 | [diff] [blame] | 6175 | // Note that the dock orientation overrides the HDMI orientation. |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 6176 | preferredRotation = mDemoHdmiRotation; |
| 6177 | } else if (mHdmiPlugged && mDockMode == Intent.EXTRA_DOCK_STATE_UNDOCKED |
| 6178 | && mUndockedHdmiRotation >= 0) { |
| 6179 | // Ignore sensor when plugged into HDMI and an undocked orientation has |
| 6180 | // been specified in the configuration (only for legacy devices without |
| 6181 | // full multi-display support). |
| 6182 | // Note that the dock orientation overrides the HDMI orientation. |
| 6183 | preferredRotation = mUndockedHdmiRotation; |
Chong Zhang | ae6119ff | 2014-11-11 18:54:39 -0800 | [diff] [blame] | 6184 | } else if (mDemoRotationLock) { |
| 6185 | // Ignore sensor when demo rotation lock is enabled. |
| 6186 | // Note that the dock orientation and HDMI rotation lock override this. |
| 6187 | preferredRotation = mDemoRotation; |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 6188 | } else if (orientation == ActivityInfo.SCREEN_ORIENTATION_LOCKED) { |
| 6189 | // Application just wants to remain locked in the last rotation. |
| 6190 | preferredRotation = lastRotation; |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 6191 | } else if (!mSupportAutoRotation) { |
| 6192 | // If we don't support auto-rotation then bail out here and ignore |
| 6193 | // the sensor and any rotation lock settings. |
| 6194 | preferredRotation = -1; |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 6195 | } else if ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_FREE |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6196 | && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 6197 | || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED |
| 6198 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE |
| 6199 | || orientation == ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT |
| 6200 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER)) |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6201 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 6202 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 6203 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 6204 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { |
| 6205 | // Otherwise, use sensor only if requested by the application or enabled |
| 6206 | // by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR. |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 6207 | if (mAllowAllRotations < 0) { |
| 6208 | // Can't read this during init() because the context doesn't |
| 6209 | // have display metrics at that time so we cannot determine |
| 6210 | // tablet vs. phone then. |
| 6211 | mAllowAllRotations = mContext.getResources().getBoolean( |
| 6212 | com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; |
| 6213 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6214 | if (sensorRotation != Surface.ROTATION_180 |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 6215 | || mAllowAllRotations == 1 |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 6216 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 6217 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_USER) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6218 | preferredRotation = sensorRotation; |
| 6219 | } else { |
| 6220 | preferredRotation = lastRotation; |
| 6221 | } |
Jeff Brown | 207673cd | 2012-06-05 17:47:11 -0700 | [diff] [blame] | 6222 | } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED |
| 6223 | && orientation != ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { |
| 6224 | // Apply rotation lock. Does not apply to NOSENSOR. |
| 6225 | // The idea is that the user rotation expresses a weak preference for the direction |
| 6226 | // of gravity and as NOSENSOR is never affected by gravity, then neither should |
| 6227 | // 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] | 6228 | preferredRotation = mUserRotation; |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 6229 | } else { |
| 6230 | // No overriding preference. |
| 6231 | // We will do exactly what the application asked us to do. |
| 6232 | preferredRotation = -1; |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6233 | } |
| 6234 | |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 6235 | switch (orientation) { |
| 6236 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 6237 | // Return portrait unless overridden. |
| 6238 | if (isAnyPortrait(preferredRotation)) { |
| 6239 | return preferredRotation; |
| 6240 | } |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 6241 | return mPortraitRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 6242 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6243 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 6244 | // Return landscape unless overridden. |
| 6245 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 6246 | return preferredRotation; |
| 6247 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6248 | return mLandscapeRotation; |
| 6249 | |
| 6250 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 6251 | // Return reverse portrait unless overridden. |
| 6252 | if (isAnyPortrait(preferredRotation)) { |
| 6253 | return preferredRotation; |
| 6254 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6255 | return mUpsideDownRotation; |
| 6256 | |
| 6257 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 6258 | // Return seascape unless overridden. |
| 6259 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 6260 | return preferredRotation; |
| 6261 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6262 | return mSeascapeRotation; |
| 6263 | |
| 6264 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 6265 | case ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6266 | // Return either landscape rotation. |
| 6267 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 6268 | return preferredRotation; |
| 6269 | } |
| 6270 | if (isLandscapeOrSeascape(lastRotation)) { |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 6271 | return lastRotation; |
| 6272 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6273 | return mLandscapeRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6274 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6275 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
Dianne Hackborn | b9ec1ac | 2013-04-10 17:34:25 -0700 | [diff] [blame] | 6276 | case ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT: |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6277 | // Return either portrait rotation. |
| 6278 | if (isAnyPortrait(preferredRotation)) { |
| 6279 | return preferredRotation; |
| 6280 | } |
| 6281 | if (isAnyPortrait(lastRotation)) { |
| 6282 | return lastRotation; |
| 6283 | } |
| 6284 | return mPortraitRotation; |
| 6285 | |
| 6286 | default: |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 6287 | // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, |
| 6288 | // just return the preferred orientation we already calculated. |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6289 | if (preferredRotation >= 0) { |
| 6290 | return preferredRotation; |
| 6291 | } |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 6292 | return Surface.ROTATION_0; |
Daniel Sandler | e7e5ac2 | 2011-02-22 16:10:21 -0500 | [diff] [blame] | 6293 | } |
| 6294 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 6295 | } |
| 6296 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6297 | @Override |
| 6298 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation) { |
| 6299 | switch (orientation) { |
| 6300 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
| 6301 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
| 6302 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
| 6303 | return isAnyPortrait(rotation); |
| 6304 | |
| 6305 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
| 6306 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
| 6307 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
| 6308 | return isLandscapeOrSeascape(rotation); |
| 6309 | |
| 6310 | default: |
| 6311 | return true; |
| 6312 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 6313 | } |
| 6314 | |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 6315 | @Override |
| 6316 | public void setRotationLw(int rotation) { |
| 6317 | mOrientationListener.setCurrentRotation(rotation); |
| 6318 | } |
| 6319 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6320 | private boolean isLandscapeOrSeascape(int rotation) { |
| 6321 | return rotation == mLandscapeRotation || rotation == mSeascapeRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 6322 | } |
| 6323 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6324 | private boolean isAnyPortrait(int rotation) { |
| 6325 | return rotation == mPortraitRotation || rotation == mUpsideDownRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 6326 | } |
| 6327 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6328 | @Override |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 6329 | public int getUserRotationMode() { |
| 6330 | return Settings.System.getIntForUser(mContext.getContentResolver(), |
Brett Chabot | 7e55c40 | 2013-05-16 19:38:08 -0700 | [diff] [blame] | 6331 | Settings.System.ACCELEROMETER_ROTATION, 0, UserHandle.USER_CURRENT) != 0 ? |
| 6332 | WindowManagerPolicy.USER_ROTATION_FREE : |
| 6333 | WindowManagerPolicy.USER_ROTATION_LOCKED; |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 6334 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 6335 | |
| 6336 | // 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] | 6337 | @Override |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 6338 | public void setUserRotationMode(int mode, int rot) { |
| 6339 | ContentResolver res = mContext.getContentResolver(); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 6340 | |
| 6341 | // mUserRotationMode and mUserRotation will be assigned by the content observer |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 6342 | if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 6343 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 6344 | Settings.System.USER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 6345 | rot, |
| 6346 | UserHandle.USER_CURRENT); |
| 6347 | Settings.System.putIntForUser(res, |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 6348 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 6349 | 0, |
| 6350 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 6351 | } else { |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 6352 | Settings.System.putIntForUser(res, |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 6353 | Settings.System.ACCELEROMETER_ROTATION, |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 6354 | 1, |
| 6355 | UserHandle.USER_CURRENT); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 6356 | } |
| 6357 | } |
| 6358 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6359 | @Override |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 6360 | public void setSafeMode(boolean safeMode) { |
| 6361 | mSafeMode = safeMode; |
| 6362 | performHapticFeedbackLw(null, safeMode |
| 6363 | ? HapticFeedbackConstants.SAFE_MODE_ENABLED |
| 6364 | : HapticFeedbackConstants.SAFE_MODE_DISABLED, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6365 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6366 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 6367 | static long[] getLongIntArray(Resources r, int resid) { |
| 6368 | int[] ar = r.getIntArray(resid); |
| 6369 | if (ar == null) { |
| 6370 | return null; |
| 6371 | } |
| 6372 | long[] out = new long[ar.length]; |
| 6373 | for (int i=0; i<ar.length; i++) { |
| 6374 | out[i] = ar[i]; |
| 6375 | } |
| 6376 | return out; |
| 6377 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6378 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6379 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6380 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6381 | public void systemReady() { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 6382 | mKeyguardDelegate = new KeyguardServiceDelegate(mContext); |
Mike Lockwood | ed8902d | 2013-11-15 11:01:47 -0800 | [diff] [blame] | 6383 | mKeyguardDelegate.onSystemReady(); |
| 6384 | |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 6385 | readCameraLensCoverState(); |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 6386 | updateUiMode(); |
Adrian Roos | 3542f7d | 2015-07-13 15:57:53 -0700 | [diff] [blame] | 6387 | boolean bindKeyguardNow; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 6388 | synchronized (mLock) { |
| 6389 | updateOrientationListenerLp(); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 6390 | mSystemReady = true; |
| 6391 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6392 | @Override |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 6393 | public void run() { |
| 6394 | updateSettings(); |
| 6395 | } |
| 6396 | }); |
Adrian Roos | 3542f7d | 2015-07-13 15:57:53 -0700 | [diff] [blame] | 6397 | |
| 6398 | bindKeyguardNow = mDeferBindKeyguard; |
| 6399 | if (bindKeyguardNow) { |
| 6400 | // systemBooted ran but wasn't able to bind to the Keyguard, we'll do it now. |
| 6401 | mDeferBindKeyguard = false; |
| 6402 | } |
| 6403 | } |
| 6404 | |
| 6405 | if (bindKeyguardNow) { |
| 6406 | mKeyguardDelegate.bindService(mContext); |
| 6407 | mKeyguardDelegate.onBootCompleted(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6408 | } |
Michael Wright | a4d22d7 | 2015-09-16 23:19:26 +0100 | [diff] [blame] | 6409 | mSystemGestures.systemReady(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6410 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 6411 | |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 6412 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6413 | @Override |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 6414 | public void systemBooted() { |
Adrian Roos | 3542f7d | 2015-07-13 15:57:53 -0700 | [diff] [blame] | 6415 | boolean bindKeyguardNow = false; |
| 6416 | synchronized (mLock) { |
| 6417 | // Time to bind Keyguard; take care to only bind it once, either here if ready or |
| 6418 | // in systemReady if not. |
| 6419 | if (mKeyguardDelegate != null) { |
| 6420 | bindKeyguardNow = true; |
| 6421 | } else { |
| 6422 | // Because mKeyguardDelegate is null, we know that the synchronized block in |
| 6423 | // systemReady didn't run yet and setting this will actually have an effect. |
| 6424 | mDeferBindKeyguard = true; |
| 6425 | } |
| 6426 | } |
| 6427 | if (bindKeyguardNow) { |
Jason Monk | 5eeebf5 | 2014-09-26 12:36:51 -0400 | [diff] [blame] | 6428 | mKeyguardDelegate.bindService(mContext); |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 6429 | mKeyguardDelegate.onBootCompleted(); |
| 6430 | } |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 6431 | synchronized (mLock) { |
| 6432 | mSystemBooted = true; |
| 6433 | } |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 6434 | startedWakingUp(); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 6435 | screenTurningOn(null); |
Jorim Jaggi | c049607 | 2015-08-19 15:14:52 -0700 | [diff] [blame] | 6436 | screenTurnedOn(); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 6437 | } |
| 6438 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 6439 | ProgressDialog mBootMsgDialog = null; |
| 6440 | |
| 6441 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6442 | @Override |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 6443 | public void showBootMessage(final CharSequence msg, final boolean always) { |
| 6444 | mHandler.post(new Runnable() { |
| 6445 | @Override public void run() { |
| 6446 | if (mBootMsgDialog == null) { |
Craig Stout | 4c0cb8a | 2014-04-04 13:03:10 -0700 | [diff] [blame] | 6447 | int theme; |
Jaewan Kim | 4911787 | 2016-01-19 17:24:08 +0900 | [diff] [blame] | 6448 | if (mContext.getPackageManager().hasSystemFeature(FEATURE_WATCH)) { |
Craig Stout | 4c0cb8a | 2014-04-04 13:03:10 -0700 | [diff] [blame] | 6449 | theme = com.android.internal.R.style.Theme_Micro_Dialog_Alert; |
Jaewan Kim | 4911787 | 2016-01-19 17:24:08 +0900 | [diff] [blame] | 6450 | } else if (mContext.getPackageManager().hasSystemFeature(FEATURE_TELEVISION)) { |
Craig Stout | 4c0cb8a | 2014-04-04 13:03:10 -0700 | [diff] [blame] | 6451 | theme = com.android.internal.R.style.Theme_Leanback_Dialog_Alert; |
| 6452 | } else { |
| 6453 | theme = 0; |
| 6454 | } |
Vinod Krishnan | fa8fc41 | 2014-04-18 14:35:53 -0700 | [diff] [blame] | 6455 | |
| 6456 | mBootMsgDialog = new ProgressDialog(mContext, theme) { |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 6457 | // This dialog will consume all events coming in to |
| 6458 | // it, to avoid it trying to do things too early in boot. |
| 6459 | @Override public boolean dispatchKeyEvent(KeyEvent event) { |
| 6460 | return true; |
| 6461 | } |
| 6462 | @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 6463 | return true; |
| 6464 | } |
| 6465 | @Override public boolean dispatchTouchEvent(MotionEvent ev) { |
| 6466 | return true; |
| 6467 | } |
| 6468 | @Override public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 6469 | return true; |
| 6470 | } |
| 6471 | @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 6472 | return true; |
| 6473 | } |
| 6474 | @Override public boolean dispatchPopulateAccessibilityEvent( |
| 6475 | AccessibilityEvent event) { |
| 6476 | return true; |
| 6477 | } |
| 6478 | }; |
Jeff Hao | 9f60c08 | 2014-10-28 18:51:07 -0700 | [diff] [blame] | 6479 | if (mContext.getPackageManager().isUpgrade()) { |
| 6480 | mBootMsgDialog.setTitle(R.string.android_upgrading_title); |
| 6481 | } else { |
| 6482 | mBootMsgDialog.setTitle(R.string.android_start_title); |
| 6483 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 6484 | mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); |
| 6485 | mBootMsgDialog.setIndeterminate(true); |
| 6486 | mBootMsgDialog.getWindow().setType( |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 6487 | WindowManager.LayoutParams.TYPE_BOOT_PROGRESS); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 6488 | mBootMsgDialog.getWindow().addFlags( |
| 6489 | WindowManager.LayoutParams.FLAG_DIM_BEHIND |
| 6490 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); |
| 6491 | mBootMsgDialog.getWindow().setDimAmount(1); |
Dianne Hackborn | d9efb95 | 2011-12-07 14:56:51 -0800 | [diff] [blame] | 6492 | WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes(); |
| 6493 | lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 6494 | mBootMsgDialog.getWindow().setAttributes(lp); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 6495 | mBootMsgDialog.setCancelable(false); |
| 6496 | mBootMsgDialog.show(); |
| 6497 | } |
| 6498 | mBootMsgDialog.setMessage(msg); |
| 6499 | } |
| 6500 | }); |
| 6501 | } |
| 6502 | |
| 6503 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6504 | @Override |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 6505 | public void hideBootMessages() { |
Craig Mautner | a631d49 | 2014-08-05 15:16:01 -0700 | [diff] [blame] | 6506 | mHandler.sendEmptyMessage(MSG_HIDE_BOOT_MESSAGE); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 6507 | } |
| 6508 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 6509 | /** {@inheritDoc} */ |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6510 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 6511 | public void userActivity() { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6512 | // *************************************** |
| 6513 | // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE |
| 6514 | // *************************************** |
| 6515 | // THIS IS CALLED FROM DEEP IN THE POWER MANAGER |
| 6516 | // WITH ITS LOCKS HELD. |
| 6517 | // |
| 6518 | // This code must be VERY careful about the locks |
| 6519 | // it acquires. |
| 6520 | // In fact, the current code acquires way too many, |
| 6521 | // and probably has lurking deadlocks. |
| 6522 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 6523 | synchronized (mScreenLockTimeout) { |
| 6524 | if (mLockScreenTimerActive) { |
| 6525 | // reset the timer |
| 6526 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 6527 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 6528 | } |
| 6529 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 6530 | } |
| 6531 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 6532 | class ScreenLockTimeout implements Runnable { |
| 6533 | Bundle options; |
| 6534 | |
| 6535 | @Override |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 6536 | public void run() { |
| 6537 | synchronized (this) { |
| 6538 | if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 6539 | if (mKeyguardDelegate != null) { |
| 6540 | mKeyguardDelegate.doKeyguardTimeout(options); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 6541 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 6542 | mLockScreenTimerActive = false; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 6543 | options = null; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 6544 | } |
| 6545 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 6546 | |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 6547 | public void setLockOptions(Bundle options) { |
| 6548 | this.options = options; |
| 6549 | } |
| 6550 | } |
| 6551 | |
| 6552 | ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout(); |
| 6553 | |
Jose Lima | 9546b20 | 2014-07-02 17:21:51 -0700 | [diff] [blame] | 6554 | @Override |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 6555 | public void lockNow(Bundle options) { |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 6556 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); |
| 6557 | mHandler.removeCallbacks(mScreenLockTimeout); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 6558 | if (options != null) { |
| 6559 | // In case multiple calls are made to lockNow, we don't wipe out the options |
| 6560 | // until the runnable actually executes. |
| 6561 | mScreenLockTimeout.setLockOptions(options); |
| 6562 | } |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 6563 | mHandler.post(mScreenLockTimeout); |
| 6564 | } |
| 6565 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 6566 | private void updateLockScreenTimeout() { |
| 6567 | synchronized (mScreenLockTimeout) { |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 6568 | boolean enable = (mAllowLockscreenWhenOn && mAwake && |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 6569 | mKeyguardDelegate != null && mKeyguardDelegate.isSecure()); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 6570 | if (mLockScreenTimerActive != enable) { |
| 6571 | if (enable) { |
| 6572 | if (localLOGV) Log.v(TAG, "setting lockscreen timer"); |
Jim Miller | 2967f48 | 2016-01-07 15:05:32 -0800 | [diff] [blame] | 6573 | mHandler.removeCallbacks(mScreenLockTimeout); // remove any pending requests |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 6574 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 6575 | } else { |
| 6576 | if (localLOGV) Log.v(TAG, "clearing lockscreen timer"); |
| 6577 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 6578 | } |
| 6579 | mLockScreenTimerActive = enable; |
| 6580 | } |
| 6581 | } |
| 6582 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6583 | |
Jeff Brown | 061ea99 | 2015-04-17 19:55:47 -0700 | [diff] [blame] | 6584 | private void updateDreamingSleepToken(boolean acquire) { |
| 6585 | if (acquire) { |
| 6586 | if (mDreamingSleepToken == null) { |
| 6587 | mDreamingSleepToken = mActivityManagerInternal.acquireSleepToken("Dream"); |
| 6588 | } |
| 6589 | } else { |
| 6590 | if (mDreamingSleepToken != null) { |
| 6591 | mDreamingSleepToken.release(); |
Jeff Brown | 48d1b14 | 2015-06-10 16:36:03 -0700 | [diff] [blame] | 6592 | mDreamingSleepToken = null; |
| 6593 | } |
| 6594 | } |
| 6595 | } |
| 6596 | |
| 6597 | private void updateScreenOffSleepToken(boolean acquire) { |
| 6598 | if (acquire) { |
| 6599 | if (mScreenOffSleepToken == null) { |
| 6600 | mScreenOffSleepToken = mActivityManagerInternal.acquireSleepToken("ScreenOff"); |
| 6601 | } |
| 6602 | } else { |
| 6603 | if (mScreenOffSleepToken != null) { |
| 6604 | mScreenOffSleepToken.release(); |
| 6605 | mScreenOffSleepToken = null; |
Jeff Brown | 061ea99 | 2015-04-17 19:55:47 -0700 | [diff] [blame] | 6606 | } |
| 6607 | } |
| 6608 | } |
| 6609 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6610 | /** {@inheritDoc} */ |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6611 | @Override |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6612 | public void enableScreenAfterBoot() { |
| 6613 | readLidState(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 6614 | applyLidSwitchState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6615 | updateRotation(true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6616 | } |
Dianne Hackborn | f54c8f9 | 2009-09-19 14:03:57 -0700 | [diff] [blame] | 6617 | |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 6618 | private void applyLidSwitchState() { |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 6619 | if (mLidState == LID_CLOSED && mLidControlsSleep) { |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 6620 | mPowerManager.goToSleep(SystemClock.uptimeMillis(), |
Jeff Brown | c12035c | 2014-08-13 18:52:25 -0700 | [diff] [blame] | 6621 | PowerManager.GO_TO_SLEEP_REASON_LID_SWITCH, |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 6622 | PowerManager.GO_TO_SLEEP_FLAG_NO_DOZE); |
Edward Savage-Jones | 7def60d | 2015-11-13 13:27:03 +0100 | [diff] [blame] | 6623 | } else if (mLidState == LID_CLOSED && mLidControlsScreenLock) { |
| 6624 | mWindowManagerFuncs.lockDeviceNow(); |
Jeff Brown | c458ce9 | 2012-04-30 14:58:40 -0700 | [diff] [blame] | 6625 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 6626 | |
| 6627 | synchronized (mLock) { |
| 6628 | updateWakeGestureListenerLp(); |
| 6629 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6630 | } |
| 6631 | |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 6632 | void updateUiMode() { |
| 6633 | if (mUiModeManager == null) { |
| 6634 | mUiModeManager = IUiModeManager.Stub.asInterface( |
| 6635 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 6636 | } |
| 6637 | try { |
| 6638 | mUiMode = mUiModeManager.getCurrentModeType(); |
| 6639 | } catch (RemoteException e) { |
| 6640 | } |
| 6641 | } |
| 6642 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 6643 | void updateRotation(boolean alwaysSendConfiguration) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6644 | try { |
| 6645 | //set orientation on WindowManager |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 6646 | mWindowManager.updateRotation(alwaysSendConfiguration, false); |
| 6647 | } catch (RemoteException e) { |
| 6648 | // Ignore |
| 6649 | } |
| 6650 | } |
| 6651 | |
| 6652 | void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout) { |
| 6653 | try { |
| 6654 | //set orientation on WindowManager |
| 6655 | mWindowManager.updateRotation(alwaysSendConfiguration, forceRelayout); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6656 | } catch (RemoteException e) { |
| 6657 | // Ignore |
| 6658 | } |
| 6659 | } |
| 6660 | |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6661 | /** |
| 6662 | * Return an Intent to launch the currently active dock app as home. Returns |
| 6663 | * null if the standard home should be launched, which is the case if any of the following is |
| 6664 | * true: |
| 6665 | * <ul> |
| 6666 | * <li>The device is not in either car mode or desk mode |
keunyoung | a771049 | 2015-09-23 11:33:58 -0700 | [diff] [blame] | 6667 | * <li>The device is in car mode but mEnableCarDockHomeCapture is false |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6668 | * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false |
| 6669 | * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME |
| 6670 | * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME |
| 6671 | * </ul> |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6672 | * @return A dock intent. |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6673 | */ |
| 6674 | Intent createHomeDockIntent() { |
| 6675 | Intent intent = null; |
| 6676 | |
| 6677 | // What home does is based on the mode, not the dock state. That |
| 6678 | // is, when in car mode you should be taken to car home regardless |
| 6679 | // of whether we are actually in a car dock. |
| 6680 | if (mUiMode == Configuration.UI_MODE_TYPE_CAR) { |
keunyoung | a771049 | 2015-09-23 11:33:58 -0700 | [diff] [blame] | 6681 | if (mEnableCarDockHomeCapture) { |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6682 | intent = mCarDockIntent; |
| 6683 | } |
| 6684 | } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { |
| 6685 | if (ENABLE_DESK_DOCK_HOME_CAPTURE) { |
| 6686 | intent = mDeskDockIntent; |
| 6687 | } |
Jeff Brown | 4f5fa28 | 2014-06-12 19:19:15 -0700 | [diff] [blame] | 6688 | } else if (mUiMode == Configuration.UI_MODE_TYPE_WATCH |
| 6689 | && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 6690 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK |
| 6691 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK)) { |
| 6692 | // Always launch dock home from home when watch is docked, if it exists. |
| 6693 | intent = mDeskDockIntent; |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6694 | } |
| 6695 | |
| 6696 | if (intent == null) { |
| 6697 | return null; |
| 6698 | } |
| 6699 | |
| 6700 | ActivityInfo ai = null; |
| 6701 | ResolveInfo info = mContext.getPackageManager().resolveActivityAsUser( |
| 6702 | intent, |
John Spurlock | f56bef1 | 2013-07-09 09:51:46 -0400 | [diff] [blame] | 6703 | PackageManager.MATCH_DEFAULT_ONLY | PackageManager.GET_META_DATA, |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 6704 | mCurrentUserId); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6705 | if (info != null) { |
| 6706 | ai = info.activityInfo; |
| 6707 | } |
| 6708 | if (ai != null |
| 6709 | && ai.metaData != null |
| 6710 | && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { |
| 6711 | intent = new Intent(intent); |
| 6712 | intent.setClassName(ai.packageName, ai.name); |
| 6713 | return intent; |
| 6714 | } |
| 6715 | |
| 6716 | return null; |
| 6717 | } |
| 6718 | |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 6719 | void startDockOrHome(boolean fromHomeKey, boolean awakenFromDreams) { |
| 6720 | if (awakenFromDreams) { |
| 6721 | awakenDreams(); |
| 6722 | } |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6723 | |
| 6724 | Intent dock = createHomeDockIntent(); |
| 6725 | if (dock != null) { |
| 6726 | try { |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 6727 | if (fromHomeKey) { |
| 6728 | dock.putExtra(WindowManagerPolicy.EXTRA_FROM_HOME_KEY, fromHomeKey); |
| 6729 | } |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 6730 | startActivityAsUser(dock, UserHandle.CURRENT); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6731 | return; |
| 6732 | } catch (ActivityNotFoundException e) { |
| 6733 | } |
| 6734 | } |
| 6735 | |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 6736 | Intent intent; |
| 6737 | |
| 6738 | if (fromHomeKey) { |
| 6739 | intent = new Intent(mHomeIntent); |
| 6740 | intent.putExtra(WindowManagerPolicy.EXTRA_FROM_HOME_KEY, fromHomeKey); |
| 6741 | } else { |
| 6742 | intent = mHomeIntent; |
| 6743 | } |
| 6744 | |
Bryce Lee | 9fc0b6f | 2015-03-19 21:37:45 +0000 | [diff] [blame] | 6745 | startActivityAsUser(intent, UserHandle.CURRENT); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 6746 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6747 | |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 6748 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6749 | * goes to the home screen |
| 6750 | * @return whether it did anything |
| 6751 | */ |
| 6752 | boolean goHome() { |
Bart Sears | 8b1c27c | 2015-03-18 23:51:02 +0000 | [diff] [blame] | 6753 | if (!isUserSetupComplete()) { |
| 6754 | Slog.i(TAG, "Not going home because user setup is in progress."); |
| 6755 | return false; |
| 6756 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6757 | if (false) { |
| 6758 | // This code always brings home to the front. |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 6759 | try { |
| 6760 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 6761 | } catch (RemoteException e) { |
| 6762 | } |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 6763 | sendCloseSystemWindows(); |
Filip Gruszczynski | a483a1d | 2015-03-17 19:06:58 +0000 | [diff] [blame] | 6764 | startDockOrHome(false /*fromHomeKey*/, true /* awakenFromDreams */); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6765 | } else { |
| 6766 | // This code brings home to the front or, if it is already |
| 6767 | // at the front, puts the device to sleep. |
| 6768 | try { |
Wink Saville | d2e6a33 | 2010-02-12 12:12:06 -0800 | [diff] [blame] | 6769 | if (SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1) { |
| 6770 | /// Roll back EndcallBehavior as the cupcake design to pass P1 lab entry. |
| 6771 | Log.d(TAG, "UTS-TEST-MODE"); |
| 6772 | } else { |
| 6773 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 6774 | sendCloseSystemWindows(); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6775 | Intent dock = createHomeDockIntent(); |
| 6776 | if (dock != null) { |
| 6777 | int result = ActivityManagerNative.getDefault() |
| 6778 | .startActivityAsUser(null, null, dock, |
| 6779 | dock.resolveTypeIfNeeded(mContext.getContentResolver()), |
| 6780 | null, null, 0, |
| 6781 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
Jeff Hao | 1b012d3 | 2014-08-20 10:35:34 -0700 | [diff] [blame] | 6782 | null, null, UserHandle.USER_CURRENT); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 6783 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
| 6784 | return false; |
| 6785 | } |
| 6786 | } |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 6787 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6788 | int result = ActivityManagerNative.getDefault() |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 6789 | .startActivityAsUser(null, null, mHomeIntent, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6790 | mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 6791 | null, null, 0, |
| 6792 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
Jeff Hao | 1b012d3 | 2014-08-20 10:35:34 -0700 | [diff] [blame] | 6793 | null, null, UserHandle.USER_CURRENT); |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 6794 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6795 | return false; |
| 6796 | } |
| 6797 | } catch (RemoteException ex) { |
| 6798 | // bummer, the activity manager, which is in this process, is dead |
| 6799 | } |
| 6800 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6801 | return true; |
| 6802 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6803 | |
| 6804 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 6805 | public void setCurrentOrientationLw(int newOrientation) { |
| 6806 | synchronized (mLock) { |
| 6807 | if (newOrientation != mCurrentAppOrientation) { |
| 6808 | mCurrentAppOrientation = newOrientation; |
| 6809 | updateOrientationListenerLp(); |
| 6810 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6811 | } |
| 6812 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6813 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 6814 | private void performAuditoryFeedbackForAccessibilityIfNeed() { |
| 6815 | if (!isGlobalAccessibilityGestureEnabled()) { |
| 6816 | return; |
| 6817 | } |
| 6818 | AudioManager audioManager = (AudioManager) mContext.getSystemService( |
| 6819 | Context.AUDIO_SERVICE); |
| 6820 | if (audioManager.isSilentMode()) { |
| 6821 | return; |
| 6822 | } |
| 6823 | Ringtone ringTone = RingtoneManager.getRingtone(mContext, |
| 6824 | Settings.System.DEFAULT_NOTIFICATION_URI); |
| 6825 | ringTone.setStreamType(AudioManager.STREAM_MUSIC); |
| 6826 | ringTone.play(); |
| 6827 | } |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6828 | |
Bryce Lee | 584a445 | 2014-10-21 15:55:55 -0700 | [diff] [blame] | 6829 | private boolean isTheaterModeEnabled() { |
| 6830 | return Settings.Global.getInt(mContext.getContentResolver(), |
| 6831 | Settings.Global.THEATER_MODE_ON, 0) == 1; |
| 6832 | } |
| 6833 | |
Svetoslav Ganov | 7befb7d | 2012-09-27 16:49:23 -0700 | [diff] [blame] | 6834 | private boolean isGlobalAccessibilityGestureEnabled() { |
| 6835 | return Settings.Global.getInt(mContext.getContentResolver(), |
| 6836 | Settings.Global.ENABLE_ACCESSIBILITY_GLOBAL_GESTURE_ENABLED, 0) == 1; |
| 6837 | } |
| 6838 | |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6839 | @Override |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 6840 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { |
Svetoslav Ganov | 9617921 | 2012-10-10 14:17:45 -0700 | [diff] [blame] | 6841 | if (!mVibrator.hasVibrator()) { |
| 6842 | return false; |
| 6843 | } |
Christopher Tate | 5e08af0 | 2012-09-21 17:17:22 -0700 | [diff] [blame] | 6844 | final boolean hapticsDisabled = Settings.System.getIntForUser(mContext.getContentResolver(), |
| 6845 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0, UserHandle.USER_CURRENT) == 0; |
Jeff Brown | 82379ba | 2014-07-25 19:03:28 -0700 | [diff] [blame] | 6846 | if (hapticsDisabled && !always) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6847 | return false; |
| 6848 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6849 | long[] pattern = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6850 | switch (effectId) { |
| 6851 | case HapticFeedbackConstants.LONG_PRESS: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6852 | pattern = mLongPressVibePattern; |
| 6853 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 6854 | case HapticFeedbackConstants.VIRTUAL_KEY: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6855 | pattern = mVirtualKeyVibePattern; |
| 6856 | break; |
| 6857 | case HapticFeedbackConstants.KEYBOARD_TAP: |
| 6858 | pattern = mKeyboardTapVibePattern; |
| 6859 | break; |
Fabrice Di Meglio | eeff63a | 2013-08-05 12:07:24 -0700 | [diff] [blame] | 6860 | case HapticFeedbackConstants.CLOCK_TICK: |
| 6861 | pattern = mClockTickVibePattern; |
| 6862 | break; |
Fabrice Di Meglio | bd9152f | 2013-10-01 11:21:31 -0700 | [diff] [blame] | 6863 | case HapticFeedbackConstants.CALENDAR_DATE: |
| 6864 | pattern = mCalendarDateVibePattern; |
| 6865 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 6866 | case HapticFeedbackConstants.SAFE_MODE_DISABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6867 | pattern = mSafeModeDisabledVibePattern; |
| 6868 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 6869 | case HapticFeedbackConstants.SAFE_MODE_ENABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6870 | pattern = mSafeModeEnabledVibePattern; |
| 6871 | break; |
Mady Mellor | e860891 | 2015-06-05 09:02:55 -0700 | [diff] [blame] | 6872 | case HapticFeedbackConstants.CONTEXT_CLICK: |
| 6873 | pattern = mContextClickVibePattern; |
Mady Mellor | e82067b | 2015-04-30 09:58:35 -0700 | [diff] [blame] | 6874 | break; |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6875 | default: |
| 6876 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6877 | } |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 6878 | int owningUid; |
| 6879 | String owningPackage; |
| 6880 | if (win != null) { |
| 6881 | owningUid = win.getOwningUid(); |
| 6882 | owningPackage = win.getOwningPackage(); |
| 6883 | } else { |
| 6884 | owningUid = android.os.Process.myUid(); |
Dianne Hackborn | 95d7853 | 2013-09-11 09:51:14 -0700 | [diff] [blame] | 6885 | owningPackage = mContext.getOpPackageName(); |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 6886 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6887 | if (pattern.length == 1) { |
| 6888 | // One-shot vibration |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 6889 | mVibrator.vibrate(owningUid, owningPackage, pattern[0], VIBRATION_ATTRIBUTES); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6890 | } else { |
| 6891 | // Pattern vibration |
John Spurlock | 7b41467 | 2014-07-18 13:02:39 -0400 | [diff] [blame] | 6892 | mVibrator.vibrate(owningUid, owningPackage, pattern, -1, VIBRATION_ATTRIBUTES); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 6893 | } |
| 6894 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6895 | } |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 6896 | |
| 6897 | @Override |
| 6898 | public void keepScreenOnStartedLw() { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 6899 | } |
| 6900 | |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 6901 | @Override |
| 6902 | public void keepScreenOnStoppedLw() { |
Jim Miller | ab95454 | 2014-10-10 18:21:49 -0700 | [diff] [blame] | 6903 | if (isKeyguardShowingAndNotOccluded()) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 6904 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 6905 | } |
| 6906 | } |
Mike Lockwood | fcb3924 | 2009-10-21 23:01:07 -0400 | [diff] [blame] | 6907 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6908 | private int updateSystemUiVisibilityLw() { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 6909 | // If there is no window focused, there will be nobody to handle the events |
| 6910 | // 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] | 6911 | final WindowState win = mFocusedWindow != null ? mFocusedWindow |
| 6912 | : mTopFullscreenOpaqueWindowState; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6913 | if (win == null) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6914 | return 0; |
| 6915 | } |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 6916 | if ((win.getAttrs().privateFlags & PRIVATE_FLAG_KEYGUARD) != 0 && mHideLockScreen == true) { |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 6917 | // We are updating at a point where the keyguard has gotten |
| 6918 | // focus, but we were last in a state where the top window is |
| 6919 | // hiding it. This is probably because the keyguard as been |
| 6920 | // shown while the top window was displayed, so we want to ignore |
| 6921 | // it here because this is just a very transient change and it |
| 6922 | // will quickly lose focus once it correctly gets hidden. |
| 6923 | return 0; |
| 6924 | } |
John Spurlock | 32beb2c | 2013-03-11 10:16:47 -0400 | [diff] [blame] | 6925 | |
John Spurlock | 1db8b68 | 2014-02-18 11:18:59 -0500 | [diff] [blame] | 6926 | int tmpVisibility = PolicyControl.getSystemUiVisibility(win, null) |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 6927 | & ~mResettingSystemUiFlags |
| 6928 | & ~mForceClearedSystemUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6929 | if (mForcingShowNavBar && win.getSurfaceLayer() < mForcingShowNavBarLayer) { |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 6930 | tmpVisibility &= ~PolicyControl.adjustClearableFlags(win, View.SYSTEM_UI_CLEARABLE_FLAGS); |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 6931 | } |
Thanh Hai Mai | 6c009f5 | 2015-09-01 16:27:32 -0700 | [diff] [blame] | 6932 | |
| 6933 | if (mUiMode == Configuration.UI_MODE_TYPE_CAR) { |
| 6934 | tmpVisibility |= StatusBarManager.DISABLE_RECENT; |
| 6935 | } |
| 6936 | |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 6937 | final int fullscreenVisibility = updateLightStatusBarLw(0 /* vis */, |
| 6938 | mTopFullscreenOpaqueWindowState, mTopFullscreenOpaqueOrDimmingWindowState); |
| 6939 | final int dockedVisibility = updateLightStatusBarLw(0 /* vis */, |
| 6940 | mTopDockedOpaqueWindowState, mTopDockedOpaqueOrDimmingWindowState); |
| 6941 | mWindowManagerFuncs.getStackBounds(HOME_STACK_ID, mNonDockedStackBounds); |
| 6942 | mWindowManagerFuncs.getStackBounds(DOCKED_STACK_ID, mDockedStackBounds); |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6943 | final int visibility = updateSystemBarsLw(win, mLastSystemUiFlags, tmpVisibility); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 6944 | final int diff = visibility ^ mLastSystemUiFlags; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 6945 | final int fullscreenDiff = fullscreenVisibility ^ mLastFullscreenStackSysUiFlags; |
| 6946 | final int dockedDiff = dockedVisibility ^ mLastDockedStackSysUiFlags; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6947 | final boolean needsMenu = win.getNeedsMenuLw(mTopFullscreenOpaqueWindowState); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 6948 | if (diff == 0 && fullscreenDiff == 0 && dockedDiff == 0 && mLastFocusNeedsMenu == needsMenu |
| 6949 | && mFocusedApp == win.getAppToken() |
| 6950 | && mLastNonDockedStackBounds.equals(mNonDockedStackBounds) |
| 6951 | && mLastDockedStackBounds.equals(mDockedStackBounds)) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6952 | return 0; |
| 6953 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 6954 | mLastSystemUiFlags = visibility; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 6955 | mLastFullscreenStackSysUiFlags = fullscreenVisibility; |
| 6956 | mLastDockedStackSysUiFlags = dockedVisibility; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 6957 | mLastFocusNeedsMenu = needsMenu; |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6958 | mFocusedApp = win.getAppToken(); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 6959 | final Rect fullscreenStackBounds = new Rect(mNonDockedStackBounds); |
| 6960 | final Rect dockedStackBounds = new Rect(mDockedStackBounds); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6961 | mHandler.post(new Runnable() { |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 6962 | @Override |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6963 | public void run() { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 6964 | StatusBarManagerInternal statusbar = getStatusBarManagerInternal(); |
| 6965 | if (statusbar != null) { |
| 6966 | statusbar.setSystemUiVisibility(visibility, fullscreenVisibility, |
| 6967 | dockedVisibility, 0xffffffff, fullscreenStackBounds, |
| 6968 | dockedStackBounds, win.toString()); |
| 6969 | statusbar.topAppWindowChanged(needsMenu); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 6970 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 6971 | } |
| 6972 | }); |
| 6973 | return diff; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 6974 | } |
| 6975 | |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 6976 | private int updateLightStatusBarLw(int vis, WindowState opaque, WindowState opaqueOrDimming) { |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 6977 | WindowState statusColorWin = isStatusBarKeyguard() && !mHideLockScreen |
| 6978 | ? mStatusBar |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 6979 | : opaqueOrDimming; |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 6980 | |
| 6981 | if (statusColorWin != null) { |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 6982 | if (statusColorWin == opaque) { |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 6983 | // If the top fullscreen-or-dimming window is also the top fullscreen, respect |
| 6984 | // its light flag. |
| 6985 | vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
| 6986 | vis |= PolicyControl.getSystemUiVisibility(statusColorWin, null) |
| 6987 | & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
| 6988 | } else if (statusColorWin != null && statusColorWin.isDimming()) { |
| 6989 | // Otherwise if it's dimming, clear the light flag. |
| 6990 | vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
| 6991 | } |
| 6992 | } |
| 6993 | return vis; |
| 6994 | } |
| 6995 | |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 6996 | private int updateSystemBarsLw(WindowState win, int oldVis, int vis) { |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 6997 | final boolean dockedStackVisible = mWindowManagerInternal.isStackVisible(DOCKED_STACK_ID); |
| 6998 | final boolean freeformStackVisible = |
| 6999 | mWindowManagerInternal.isStackVisible(FREEFORM_WORKSPACE_STACK_ID); |
Jorim Jaggi | 9511b0f | 2016-01-29 19:12:44 -0800 | [diff] [blame] | 7000 | final boolean resizing = mWindowManagerInternal.isDockedDividerResizing(); |
| 7001 | |
| 7002 | // We need to force system bars when the docked stack is visible, when the freeform stack |
| 7003 | // is visible but also when we are resizing for the transitions when docked stack |
| 7004 | // visibility changes. |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 7005 | mForceShowSystemBars = dockedStackVisible || freeformStackVisible || resizing; |
| 7006 | final boolean forceOpaqueSystemBars = mForceShowSystemBars && !mForceStatusBarFromKeyguard; |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 7007 | |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 7008 | // apply translucent bar vis flags |
Jorim Jaggi | 380ecb8 | 2014-03-14 17:25:20 +0100 | [diff] [blame] | 7009 | WindowState transWin = isStatusBarKeyguard() && !mHideLockScreen |
| 7010 | ? mStatusBar |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 7011 | : mTopFullscreenOpaqueWindowState; |
| 7012 | vis = mStatusBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 7013 | vis = mNavigationBarController.applyTranslucentFlagLw(transWin, vis, oldVis); |
| 7014 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 7015 | // prevent status bar interaction from clearing certain flags |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 7016 | int type = win.getAttrs().type; |
| 7017 | boolean statusBarHasFocus = type == TYPE_STATUS_BAR; |
John Spurlock | 08ffcf5 | 2014-07-11 10:13:46 -0400 | [diff] [blame] | 7018 | if (statusBarHasFocus && !isStatusBarKeyguard()) { |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 7019 | int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
| 7020 | | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
John Spurlock | cfc359a | 2013-09-05 10:42:03 -0400 | [diff] [blame] | 7021 | | View.SYSTEM_UI_FLAG_IMMERSIVE |
Jorim Jaggi | 73fef8d | 2015-02-16 17:32:28 +0100 | [diff] [blame] | 7022 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
| 7023 | | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; |
John Spurlock | 08ffcf5 | 2014-07-11 10:13:46 -0400 | [diff] [blame] | 7024 | if (mHideLockScreen) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 7025 | flags |= View.STATUS_BAR_TRANSLUCENT | View.NAVIGATION_BAR_TRANSLUCENT; |
| 7026 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 7027 | vis = (vis & ~flags) | (oldVis & flags); |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 7028 | } |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 7029 | |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 7030 | if ((!areTranslucentBarsAllowed() && transWin != mStatusBar) |
| 7031 | || forceOpaqueSystemBars) { |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 7032 | vis &= ~(View.NAVIGATION_BAR_TRANSLUCENT | View.STATUS_BAR_TRANSLUCENT |
| 7033 | | View.SYSTEM_UI_TRANSPARENT); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 7034 | } |
| 7035 | |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 7036 | if (mForceWindowDrawsStatusBarBackground) { |
| 7037 | vis |= View.STATUS_BAR_TRANSPARENT; |
| 7038 | vis &= ~View.STATUS_BAR_TRANSLUCENT; |
| 7039 | } |
| 7040 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 7041 | // update status bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 7042 | boolean immersiveSticky = |
| 7043 | (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 7044 | final boolean hideStatusBarWM = |
| 7045 | mTopFullscreenOpaqueWindowState != null |
| 7046 | && (PolicyControl.getWindowFlags(mTopFullscreenOpaqueWindowState, null) |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 7047 | & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 7048 | final boolean hideStatusBarSysui = |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 7049 | (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 7050 | final boolean hideNavBarSysui = |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 7051 | (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 7052 | |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 7053 | final boolean transientStatusBarAllowed = mStatusBar != null |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 7054 | && (statusBarHasFocus || (!mForceShowSystemBars |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 7055 | && (hideStatusBarWM || (hideStatusBarSysui && immersiveSticky)))); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 7056 | |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 7057 | final boolean transientNavBarAllowed = mNavigationBar != null |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 7058 | && !mForceShowSystemBars && hideNavBarSysui && immersiveSticky; |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 7059 | |
Adrian Roos | ddc8b27 | 2015-05-21 16:28:27 -0700 | [diff] [blame] | 7060 | final long now = SystemClock.uptimeMillis(); |
| 7061 | final boolean pendingPanic = mPendingPanicGestureUptime != 0 |
| 7062 | && now - mPendingPanicGestureUptime <= PANIC_GESTURE_EXPIRATION; |
| 7063 | if (pendingPanic && hideNavBarSysui && !isStatusBarKeyguard() && mKeyguardDrawComplete) { |
| 7064 | // The user performed the panic gesture recently, we're about to hide the bars, |
| 7065 | // we're no longer on the Keyguard and the screen is ready. We can now request the bars. |
| 7066 | mPendingPanicGestureUptime = 0; |
| 7067 | mStatusBarController.showTransient(); |
| 7068 | mNavigationBarController.showTransient(); |
| 7069 | } |
| 7070 | |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 7071 | final boolean denyTransientStatus = mStatusBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 7072 | && !transientStatusBarAllowed && hideStatusBarSysui; |
Wale Ogunwale | 6e94a9e | 2015-10-07 15:35:49 -0700 | [diff] [blame] | 7073 | final boolean denyTransientNav = mNavigationBarController.isTransientShowRequested() |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 7074 | && !transientNavBarAllowed; |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 7075 | if (denyTransientStatus || denyTransientNav || mForceShowSystemBars) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 7076 | // clear the clearable flags instead |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 7077 | clearClearableFlagsLw(); |
tiger_huang | c58d756 | 2014-10-23 20:24:19 +0800 | [diff] [blame] | 7078 | vis &= ~View.SYSTEM_UI_CLEARABLE_FLAGS; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 7079 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 7080 | |
Selim Cinek | f98702e | 2015-05-20 22:48:40 -0700 | [diff] [blame] | 7081 | final boolean immersive = (vis & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0; |
| 7082 | immersiveSticky = (vis & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0; |
| 7083 | final boolean navAllowedHidden = immersive || immersiveSticky; |
| 7084 | |
Selim Cinek | d662361 | 2015-05-22 18:56:22 -0700 | [diff] [blame] | 7085 | if (hideNavBarSysui && !navAllowedHidden && windowTypeToLayerLw(win.getBaseType()) |
| 7086 | > windowTypeToLayerLw(TYPE_INPUT_CONSUMER)) { |
Selim Cinek | f98702e | 2015-05-20 22:48:40 -0700 | [diff] [blame] | 7087 | // We can't hide the navbar from this window otherwise the input consumer would not get |
| 7088 | // the input events. |
| 7089 | vis = (vis & ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION); |
| 7090 | } |
| 7091 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 7092 | vis = mStatusBarController.updateVisibilityLw(transientStatusBarAllowed, oldVis, vis); |
| 7093 | |
| 7094 | // update navigation bar |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 7095 | boolean oldImmersiveMode = isImmersiveMode(oldVis); |
| 7096 | boolean newImmersiveMode = isImmersiveMode(vis); |
| 7097 | if (win != null && oldImmersiveMode != newImmersiveMode) { |
John Spurlock | 79da833 | 2013-09-20 12:04:47 -0400 | [diff] [blame] | 7098 | final String pkg = win.getOwningPackage(); |
Maurice Lam | 99c6e07 | 2014-04-28 18:24:28 -0700 | [diff] [blame] | 7099 | mImmersiveModeConfirmation.immersiveModeChanged(pkg, newImmersiveMode, |
| 7100 | isUserSetupComplete()); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 7101 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 7102 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 7103 | vis = mNavigationBarController.updateVisibilityLw(transientNavBarAllowed, oldVis, vis); |
| 7104 | |
John Spurlock | e1f366f | 2013-08-05 12:22:40 -0400 | [diff] [blame] | 7105 | return vis; |
John Spurlock | ad3e6cb | 2013-04-30 08:47:43 -0400 | [diff] [blame] | 7106 | } |
| 7107 | |
John Spurlock | f1a3664 | 2013-10-12 17:50:42 -0400 | [diff] [blame] | 7108 | private void clearClearableFlagsLw() { |
| 7109 | int newVal = mResettingSystemUiFlags | View.SYSTEM_UI_CLEARABLE_FLAGS; |
| 7110 | if (newVal != mResettingSystemUiFlags) { |
| 7111 | mResettingSystemUiFlags = newVal; |
| 7112 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 7113 | } |
| 7114 | } |
| 7115 | |
| 7116 | private boolean isImmersiveMode(int vis) { |
| 7117 | 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] | 7118 | return mNavigationBar != null |
| 7119 | && (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0 |
Daniel Sandler | 900ece5 | 2013-10-18 15:53:27 -0400 | [diff] [blame] | 7120 | && (vis & flags) != 0 |
| 7121 | && canHideNavigationBar(); |
John Spurlock | 34e13d9 | 2013-08-10 06:52:28 -0400 | [diff] [blame] | 7122 | } |
| 7123 | |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 7124 | /** |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 7125 | * @return whether the navigation or status bar can be made translucent |
| 7126 | * |
| 7127 | * This should return true unless touch exploration is not enabled or |
| 7128 | * R.boolean.config_enableTranslucentDecor is false. |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 7129 | */ |
Daniel Sandler | dd73ee4 | 2013-10-11 22:19:59 -0400 | [diff] [blame] | 7130 | private boolean areTranslucentBarsAllowed() { |
Alan Viverette | 817f3cd | 2015-08-13 11:40:14 -0400 | [diff] [blame] | 7131 | return mTranslucentDecorEnabled; |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 7132 | } |
| 7133 | |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 7134 | // Use this instead of checking config_showNavigationBar so that it can be consistently |
| 7135 | // overridden by qemu.hw.mainkeys in the emulator. |
Craig Mautner | eda6729 | 2013-04-28 13:50:14 -0700 | [diff] [blame] | 7136 | @Override |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 7137 | public boolean hasNavigationBar() { |
| 7138 | return mHasNavigationBar; |
| 7139 | } |
| 7140 | |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 7141 | @Override |
| 7142 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target) { |
| 7143 | mLastInputMethodWindow = ime; |
| 7144 | mLastInputMethodTargetWindow = target; |
| 7145 | } |
| 7146 | |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 7147 | @Override |
Satoshi Kataoka | 658c7b8 | 2013-10-10 17:03:51 +0900 | [diff] [blame] | 7148 | public int getInputMethodWindowVisibleHeightLw() { |
| 7149 | return mDockBottom - mCurBottom; |
| 7150 | } |
| 7151 | |
| 7152 | @Override |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 7153 | public void setCurrentUserLw(int newUserId) { |
Craig Mautner | d625ab2 | 2013-09-06 13:40:31 -0700 | [diff] [blame] | 7154 | mCurrentUserId = newUserId; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 7155 | if (mKeyguardDelegate != null) { |
| 7156 | mKeyguardDelegate.setCurrentUser(newUserId); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 7157 | } |
John Spurlock | 13451a2 | 2012-09-28 14:40:41 -0400 | [diff] [blame] | 7158 | if (mStatusBarService != null) { |
| 7159 | try { |
| 7160 | mStatusBarService.setCurrentUser(newUserId); |
| 7161 | } catch (RemoteException e) { |
| 7162 | // oh well |
| 7163 | } |
| 7164 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 7165 | setLastInputMethodWindowLw(null, null); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 7166 | } |
| 7167 | |
| 7168 | @Override |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 7169 | public boolean canMagnifyWindow(int windowType) { |
| 7170 | switch (windowType) { |
| 7171 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD: |
| 7172 | case WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG: |
| 7173 | case WindowManager.LayoutParams.TYPE_NAVIGATION_BAR: |
| 7174 | case WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY: { |
| 7175 | return false; |
| 7176 | } |
| 7177 | } |
| 7178 | return true; |
| 7179 | } |
| 7180 | |
| 7181 | @Override |
| 7182 | public boolean isTopLevelWindow(int windowType) { |
| 7183 | if (windowType >= WindowManager.LayoutParams.FIRST_SUB_WINDOW |
| 7184 | && windowType <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 7185 | return (windowType == WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG); |
| 7186 | } |
| 7187 | return true; |
| 7188 | } |
| 7189 | |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 7190 | @Override |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 7191 | public void dump(String prefix, PrintWriter pw, String[] args) { |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7192 | pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 7193 | pw.print(" mSystemReady="); pw.print(mSystemReady); |
| 7194 | pw.print(" mSystemBooted="); pw.println(mSystemBooted); |
Jeff Brown | 2e7760e | 2012-04-11 15:14:55 -0700 | [diff] [blame] | 7195 | pw.print(prefix); pw.print("mLidState="); pw.print(mLidState); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7196 | pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 7197 | pw.print(" mCameraLensCoverState="); pw.print(mCameraLensCoverState); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7198 | pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 7199 | if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 |
| 7200 | || mForceClearedSystemUiFlags != 0) { |
| 7201 | pw.print(prefix); pw.print("mLastSystemUiFlags=0x"); |
| 7202 | pw.print(Integer.toHexString(mLastSystemUiFlags)); |
| 7203 | pw.print(" mResettingSystemUiFlags=0x"); |
| 7204 | pw.print(Integer.toHexString(mResettingSystemUiFlags)); |
| 7205 | pw.print(" mForceClearedSystemUiFlags=0x"); |
| 7206 | pw.println(Integer.toHexString(mForceClearedSystemUiFlags)); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 7207 | } |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 7208 | if (mLastFocusNeedsMenu) { |
| 7209 | pw.print(prefix); pw.print("mLastFocusNeedsMenu="); |
| 7210 | pw.println(mLastFocusNeedsMenu); |
| 7211 | } |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 7212 | pw.print(prefix); pw.print("mWakeGestureEnabledSetting="); |
| 7213 | pw.println(mWakeGestureEnabledSetting); |
| 7214 | |
Jeff Brown | bcdfc62 | 2014-03-06 19:13:04 -0800 | [diff] [blame] | 7215 | pw.print(prefix); pw.print("mSupportAutoRotation="); pw.println(mSupportAutoRotation); |
Daniel Sandler | 6396c72 | 2013-04-16 20:19:09 -0400 | [diff] [blame] | 7216 | pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); |
| 7217 | pw.print(" mDockMode="); pw.print(mDockMode); |
keunyoung | a771049 | 2015-09-23 11:33:58 -0700 | [diff] [blame] | 7218 | pw.print(" mEnableCarDockHomeCapture="); pw.print(mEnableCarDockHomeCapture); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7219 | pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); |
| 7220 | pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); |
| 7221 | pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); |
| 7222 | pw.print(" mUserRotation="); pw.print(mUserRotation); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 7223 | pw.print(" mAllowAllRotations="); pw.println(mAllowAllRotations); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 7224 | pw.print(prefix); pw.print("mCurrentAppOrientation="); pw.println(mCurrentAppOrientation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7225 | pw.print(prefix); pw.print("mCarDockEnablesAccelerometer="); |
| 7226 | pw.print(mCarDockEnablesAccelerometer); |
| 7227 | pw.print(" mDeskDockEnablesAccelerometer="); |
| 7228 | pw.println(mDeskDockEnablesAccelerometer); |
| 7229 | pw.print(prefix); pw.print("mLidKeyboardAccessibility="); |
| 7230 | pw.print(mLidKeyboardAccessibility); |
| 7231 | pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); |
Edward Savage-Jones | 7def60d | 2015-11-13 13:27:03 +0100 | [diff] [blame] | 7232 | pw.print(" mLidControlsScreenLock="); pw.println(mLidControlsScreenLock); |
Dianne Hackborn | 6e2281d | 2012-06-19 17:48:32 -0700 | [diff] [blame] | 7233 | pw.print(" mLidControlsSleep="); pw.println(mLidControlsSleep); |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 7234 | pw.print(prefix); |
| 7235 | pw.print("mShortPressOnPowerBehavior="); pw.print(mShortPressOnPowerBehavior); |
| 7236 | pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior); |
Jeff Brown | 13f00f0 | 2014-10-31 14:45:50 -0700 | [diff] [blame] | 7237 | pw.print(prefix); |
| 7238 | pw.print("mDoublePressOnPowerBehavior="); pw.print(mDoublePressOnPowerBehavior); |
| 7239 | pw.print(" mTriplePressOnPowerBehavior="); pw.println(mTriplePressOnPowerBehavior); |
Jeff Brown | 6d8fd27 | 2014-05-20 21:24:38 -0700 | [diff] [blame] | 7240 | pw.print(prefix); pw.print("mHasSoftInput="); pw.println(mHasSoftInput); |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 7241 | pw.print(prefix); pw.print("mAwake="); pw.println(mAwake); |
| 7242 | pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly); |
| 7243 | pw.print(" mScreenOnFully="); pw.println(mScreenOnFully); |
| 7244 | pw.print(prefix); pw.print("mKeyguardDrawComplete="); pw.print(mKeyguardDrawComplete); |
| 7245 | pw.print(" mWindowManagerDrawComplete="); pw.println(mWindowManagerDrawComplete); |
| 7246 | pw.print(prefix); pw.print("mOrientationSensorEnabled="); |
| 7247 | pw.println(mOrientationSensorEnabled); |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 7248 | pw.print(prefix); pw.print("mOverscanScreen=("); pw.print(mOverscanScreenLeft); |
| 7249 | pw.print(","); pw.print(mOverscanScreenTop); |
| 7250 | pw.print(") "); pw.print(mOverscanScreenWidth); |
| 7251 | pw.print("x"); pw.println(mOverscanScreenHeight); |
| 7252 | if (mOverscanLeft != 0 || mOverscanTop != 0 |
| 7253 | || mOverscanRight != 0 || mOverscanBottom != 0) { |
| 7254 | pw.print(prefix); pw.print("mOverscan left="); pw.print(mOverscanLeft); |
| 7255 | pw.print(" top="); pw.print(mOverscanTop); |
| 7256 | pw.print(" right="); pw.print(mOverscanRight); |
| 7257 | pw.print(" bottom="); pw.println(mOverscanBottom); |
| 7258 | } |
Dianne Hackborn | 31344084 | 2013-02-19 19:22:59 -0800 | [diff] [blame] | 7259 | pw.print(prefix); pw.print("mRestrictedOverscanScreen=("); |
| 7260 | pw.print(mRestrictedOverscanScreenLeft); |
| 7261 | pw.print(","); pw.print(mRestrictedOverscanScreenTop); |
| 7262 | pw.print(") "); pw.print(mRestrictedOverscanScreenWidth); |
| 7263 | pw.print("x"); pw.println(mRestrictedOverscanScreenHeight); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7264 | pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft); |
| 7265 | pw.print(","); pw.print(mUnrestrictedScreenTop); |
| 7266 | pw.print(") "); pw.print(mUnrestrictedScreenWidth); |
| 7267 | pw.print("x"); pw.println(mUnrestrictedScreenHeight); |
| 7268 | pw.print(prefix); pw.print("mRestrictedScreen=("); pw.print(mRestrictedScreenLeft); |
| 7269 | pw.print(","); pw.print(mRestrictedScreenTop); |
| 7270 | pw.print(") "); pw.print(mRestrictedScreenWidth); |
| 7271 | pw.print("x"); pw.println(mRestrictedScreenHeight); |
Dianne Hackborn | 5b5cc4d | 2012-05-16 13:15:00 -0700 | [diff] [blame] | 7272 | pw.print(prefix); pw.print("mStableFullscreen=("); pw.print(mStableFullscreenLeft); |
| 7273 | pw.print(","); pw.print(mStableFullscreenTop); |
| 7274 | pw.print(")-("); pw.print(mStableFullscreenRight); |
| 7275 | pw.print(","); pw.print(mStableFullscreenBottom); pw.println(")"); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 7276 | pw.print(prefix); pw.print("mStable=("); pw.print(mStableLeft); |
| 7277 | pw.print(","); pw.print(mStableTop); |
| 7278 | pw.print(")-("); pw.print(mStableRight); |
| 7279 | pw.print(","); pw.print(mStableBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 7280 | pw.print(prefix); pw.print("mSystem=("); pw.print(mSystemLeft); |
| 7281 | pw.print(","); pw.print(mSystemTop); |
| 7282 | pw.print(")-("); pw.print(mSystemRight); |
| 7283 | pw.print(","); pw.print(mSystemBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7284 | pw.print(prefix); pw.print("mCur=("); pw.print(mCurLeft); |
| 7285 | pw.print(","); pw.print(mCurTop); |
| 7286 | pw.print(")-("); pw.print(mCurRight); |
| 7287 | pw.print(","); pw.print(mCurBottom); pw.println(")"); |
| 7288 | pw.print(prefix); pw.print("mContent=("); pw.print(mContentLeft); |
| 7289 | pw.print(","); pw.print(mContentTop); |
| 7290 | pw.print(")-("); pw.print(mContentRight); |
| 7291 | pw.print(","); pw.print(mContentBottom); pw.println(")"); |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 7292 | pw.print(prefix); pw.print("mVoiceContent=("); pw.print(mVoiceContentLeft); |
| 7293 | pw.print(","); pw.print(mVoiceContentTop); |
| 7294 | pw.print(")-("); pw.print(mVoiceContentRight); |
| 7295 | pw.print(","); pw.print(mVoiceContentBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7296 | pw.print(prefix); pw.print("mDock=("); pw.print(mDockLeft); |
| 7297 | pw.print(","); pw.print(mDockTop); |
| 7298 | pw.print(")-("); pw.print(mDockRight); |
| 7299 | pw.print(","); pw.print(mDockBottom); pw.println(")"); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 7300 | pw.print(prefix); pw.print("mDockLayer="); pw.print(mDockLayer); |
| 7301 | pw.print(" mStatusBarLayer="); pw.println(mStatusBarLayer); |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 7302 | pw.print(prefix); pw.print("mShowingLockscreen="); pw.print(mShowingLockscreen); |
| 7303 | pw.print(" mShowingDream="); pw.print(mShowingDream); |
Jeff Brown | 061ea99 | 2015-04-17 19:55:47 -0700 | [diff] [blame] | 7304 | pw.print(" mDreamingLockscreen="); pw.print(mDreamingLockscreen); |
| 7305 | pw.print(" mDreamingSleepToken="); pw.println(mDreamingSleepToken); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 7306 | if (mLastInputMethodWindow != null) { |
| 7307 | pw.print(prefix); pw.print("mLastInputMethodWindow="); |
| 7308 | pw.println(mLastInputMethodWindow); |
| 7309 | } |
| 7310 | if (mLastInputMethodTargetWindow != null) { |
| 7311 | pw.print(prefix); pw.print("mLastInputMethodTargetWindow="); |
| 7312 | pw.println(mLastInputMethodTargetWindow); |
| 7313 | } |
| 7314 | if (mStatusBar != null) { |
| 7315 | pw.print(prefix); pw.print("mStatusBar="); |
Dianne Hackborn | ae6688b | 2015-02-11 17:02:41 -0800 | [diff] [blame] | 7316 | pw.print(mStatusBar); pw.print(" isStatusBarKeyguard="); |
| 7317 | pw.println(isStatusBarKeyguard()); |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 7318 | } |
| 7319 | if (mNavigationBar != null) { |
| 7320 | pw.print(prefix); pw.print("mNavigationBar="); |
| 7321 | pw.println(mNavigationBar); |
| 7322 | } |
Dianne Hackborn | 2ea9bae | 2012-11-02 18:43:48 -0700 | [diff] [blame] | 7323 | if (mFocusedWindow != null) { |
| 7324 | pw.print(prefix); pw.print("mFocusedWindow="); |
| 7325 | pw.println(mFocusedWindow); |
| 7326 | } |
| 7327 | if (mFocusedApp != null) { |
| 7328 | pw.print(prefix); pw.print("mFocusedApp="); |
| 7329 | pw.println(mFocusedApp); |
| 7330 | } |
| 7331 | if (mWinDismissingKeyguard != null) { |
| 7332 | pw.print(prefix); pw.print("mWinDismissingKeyguard="); |
| 7333 | pw.println(mWinDismissingKeyguard); |
| 7334 | } |
| 7335 | if (mTopFullscreenOpaqueWindowState != null) { |
| 7336 | pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); |
| 7337 | pw.println(mTopFullscreenOpaqueWindowState); |
| 7338 | } |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 7339 | if (mTopFullscreenOpaqueOrDimmingWindowState != null) { |
| 7340 | pw.print(prefix); pw.print("mTopFullscreenOpaqueOrDimmingWindowState="); |
| 7341 | pw.println(mTopFullscreenOpaqueOrDimmingWindowState); |
| 7342 | } |
Dianne Hackborn | 891d3fb | 2013-01-09 18:31:37 -0800 | [diff] [blame] | 7343 | if (mForcingShowNavBar) { |
| 7344 | pw.print(prefix); pw.print("mForcingShowNavBar="); |
| 7345 | pw.println(mForcingShowNavBar); pw.print( "mForcingShowNavBarLayer="); |
| 7346 | pw.println(mForcingShowNavBarLayer); |
| 7347 | } |
Dianne Hackborn | 7ad4438 | 2012-10-18 17:46:00 -0700 | [diff] [blame] | 7348 | pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7349 | pw.print(" mHideLockScreen="); pw.println(mHideLockScreen); |
Dianne Hackborn | 4c1e318 | 2012-10-05 18:37:54 -0700 | [diff] [blame] | 7350 | pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar); |
| 7351 | pw.print(" mForceStatusBarFromKeyguard="); |
| 7352 | pw.println(mForceStatusBarFromKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7353 | pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 7354 | pw.print(" mWinDismissingKeyguard="); pw.print(mWinDismissingKeyguard); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7355 | pw.print(" mHomePressed="); pw.println(mHomePressed); |
| 7356 | pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); |
| 7357 | pw.print(" mLockScreenTimeout="); pw.print(mLockScreenTimeout); |
| 7358 | pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive); |
| 7359 | pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior); |
| 7360 | pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior); |
| 7361 | pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior); |
| 7362 | pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation); |
| 7363 | pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); |
| 7364 | pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); |
| 7365 | pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); |
Jeff Brown | c82c89ed | 2013-04-17 17:18:15 -0700 | [diff] [blame] | 7366 | pw.print(prefix); pw.print("mDemoHdmiRotation="); pw.print(mDemoHdmiRotation); |
| 7367 | pw.print(" mDemoHdmiRotationLock="); pw.println(mDemoHdmiRotationLock); |
| 7368 | pw.print(prefix); pw.print("mUndockedHdmiRotation="); pw.println(mUndockedHdmiRotation); |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 7369 | |
Tim Kilbourn | d7c0c2e | 2014-05-29 16:08:10 -0700 | [diff] [blame] | 7370 | mGlobalKeyManager.dump(prefix, pw); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 7371 | mStatusBarController.dump(pw, prefix); |
| 7372 | mNavigationBarController.dump(pw, prefix); |
John Spurlock | c6d1c60 | 2014-01-17 15:22:06 -0500 | [diff] [blame] | 7373 | PolicyControl.dump(prefix, pw); |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 7374 | |
Jeff Brown | a20dda4 | 2014-05-27 20:57:24 -0700 | [diff] [blame] | 7375 | if (mWakeGestureListener != null) { |
| 7376 | mWakeGestureListener.dump(pw, prefix); |
| 7377 | } |
Jeff Brown | 600f003 | 2014-05-22 17:06:00 -0700 | [diff] [blame] | 7378 | if (mOrientationListener != null) { |
| 7379 | mOrientationListener.dump(pw, prefix); |
| 7380 | } |
Filip Gruszczynski | cfb3185 | 2015-02-25 21:47:12 +0000 | [diff] [blame] | 7381 | if (mBurnInProtectionHelper != null) { |
| 7382 | mBurnInProtectionHelper.dump(prefix, pw); |
| 7383 | } |
Jorim Jaggi | 84dc08a | 2015-09-11 17:45:22 -0700 | [diff] [blame] | 7384 | if (mKeyguardDelegate != null) { |
| 7385 | mKeyguardDelegate.dump(prefix, pw); |
| 7386 | } |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 7387 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 7388 | } |