The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1 | /* |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2 | * |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | package com.android.internal.policy.impl; |
| 17 | |
| 18 | import android.app.Activity; |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 19 | import android.app.ActivityManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 20 | import android.app.ActivityManagerNative; |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 21 | import android.app.IUiModeManager; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 22 | import android.app.ProgressDialog; |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 23 | import android.app.UiModeManager; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 24 | import android.content.ActivityNotFoundException; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 25 | import android.content.BroadcastReceiver; |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 26 | import android.content.ComponentName; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 27 | import android.content.ContentResolver; |
| 28 | import android.content.Context; |
| 29 | import android.content.Intent; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 30 | import android.content.IntentFilter; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 31 | import android.content.ServiceConnection; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 32 | import android.content.pm.ActivityInfo; |
| 33 | import android.content.pm.PackageManager; |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 34 | import android.content.res.CompatibilityInfo; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 35 | import android.content.res.Configuration; |
| 36 | import android.content.res.Resources; |
| 37 | import android.database.ContentObserver; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 38 | import android.graphics.PixelFormat; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 39 | import android.graphics.Rect; |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 40 | import android.graphics.RectF; |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 41 | import android.media.AudioManager; |
| 42 | import android.media.IAudioService; |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 43 | import android.os.BatteryManager; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 44 | import android.os.Bundle; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 45 | import android.os.Handler; |
| 46 | import android.os.IBinder; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 47 | import android.os.IRemoteCallback; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 48 | import android.os.LocalPowerManager; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 49 | import android.os.Looper; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 50 | import android.os.Message; |
| 51 | import android.os.Messenger; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 52 | import android.os.PowerManager; |
| 53 | import android.os.RemoteException; |
| 54 | import android.os.ServiceManager; |
| 55 | import android.os.SystemClock; |
| 56 | import android.os.SystemProperties; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 57 | import android.os.UEventObserver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 58 | import android.os.Vibrator; |
| 59 | import android.provider.Settings; |
| 60 | |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 61 | import com.android.internal.R; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 62 | import com.android.internal.app.ShutdownThread; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 63 | import com.android.internal.policy.PolicyManager; |
Joe Onorato | 0cbda99 | 2010-05-02 16:28:15 -0700 | [diff] [blame] | 64 | import com.android.internal.statusbar.IStatusBarService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 65 | import com.android.internal.telephony.ITelephony; |
Dianne Hackborn | 6019c9d | 2010-03-01 21:43:11 -0800 | [diff] [blame] | 66 | import com.android.internal.widget.PointerLocationView; |
| 67 | |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 68 | import android.speech.RecognizerIntent; |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 69 | import android.util.DisplayMetrics; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 70 | import android.util.EventLog; |
| 71 | import android.util.Log; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 72 | import android.util.Slog; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 73 | import android.util.SparseArray; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 74 | import android.view.Display; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 75 | import android.view.Gravity; |
| 76 | import android.view.HapticFeedbackConstants; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 77 | import android.view.IApplicationToken; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 78 | import android.view.IWindowManager; |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 79 | import android.view.InputChannel; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 80 | import android.view.InputDevice; |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 81 | import android.view.InputEvent; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 82 | import android.view.InputEventReceiver; |
Jeff Brown | 6b53e8d | 2010-11-10 16:03:06 -0800 | [diff] [blame] | 83 | import android.view.KeyCharacterMap; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 84 | import android.view.KeyEvent; |
| 85 | import android.view.MotionEvent; |
| 86 | import android.view.WindowOrientationListener; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 87 | import android.view.Surface; |
| 88 | import android.view.View; |
| 89 | import android.view.ViewConfiguration; |
| 90 | import android.view.Window; |
| 91 | import android.view.WindowManager; |
| 92 | import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; |
| 93 | import static android.view.WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN; |
| 94 | import static android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN; |
| 95 | import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
| 96 | import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR; |
| 97 | import static android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 98 | import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 99 | import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 100 | import static android.view.WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 101 | import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; |
| 102 | import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 103 | import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 104 | import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 105 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 106 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 107 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; |
| 108 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL; |
| 109 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; |
Christopher Tate | a53146c | 2010-09-07 11:57:52 -0700 | [diff] [blame] | 110 | import static android.view.WindowManager.LayoutParams.TYPE_DRAG; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 111 | import static android.view.WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 112 | import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD; |
| 113 | import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; |
| 114 | import static android.view.WindowManager.LayoutParams.TYPE_PHONE; |
| 115 | import static android.view.WindowManager.LayoutParams.TYPE_PRIORITY_PHONE; |
| 116 | import static android.view.WindowManager.LayoutParams.TYPE_SEARCH_BAR; |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 117 | import static android.view.WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 118 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; |
| 119 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 120 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL; |
Dianne Hackborn | 6a294ce | 2009-12-03 11:37:44 -0800 | [diff] [blame] | 121 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 122 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; |
| 123 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; |
| 124 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; |
| 125 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; |
| 126 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; |
| 127 | import static android.view.WindowManager.LayoutParams.TYPE_TOAST; |
Dianne Hackborn | e8ecde1 | 2011-08-03 18:55:19 -0700 | [diff] [blame] | 128 | import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY; |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 129 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 130 | import static android.view.WindowManager.LayoutParams.TYPE_POINTER; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 131 | import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 132 | import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 133 | import android.view.WindowManagerImpl; |
| 134 | import android.view.WindowManagerPolicy; |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 135 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_ABSENT; |
| 136 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_OPEN; |
| 137 | import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED; |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 138 | import android.view.KeyCharacterMap.FallbackAction; |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 139 | import android.view.accessibility.AccessibilityEvent; |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 140 | import android.view.animation.Animation; |
| 141 | import android.view.animation.AnimationUtils; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 142 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 143 | import java.io.File; |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 144 | import java.io.FileDescriptor; |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 145 | import java.io.FileReader; |
| 146 | import java.io.IOException; |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 147 | import java.io.PrintWriter; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 148 | import java.util.ArrayList; |
| 149 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 150 | /** |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 151 | * WindowManagerPolicy implementation for the Android phone UI. This |
| 152 | * introduces a new method suffix, Lp, for an internal lock of the |
| 153 | * PhoneWindowManager. This is used to protect some internal state, and |
| 154 | * can be acquired with either thw Lw and Li lock held, so has the restrictions |
| 155 | * of both of those when held. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 156 | */ |
| 157 | public class PhoneWindowManager implements WindowManagerPolicy { |
| 158 | static final String TAG = "WindowManager"; |
| 159 | static final boolean DEBUG = false; |
Joe Onorato | 43a1765 | 2011-04-06 19:22:23 -0700 | [diff] [blame] | 160 | static final boolean localLOGV = false; |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 161 | static final boolean DEBUG_LAYOUT = false; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 162 | static final boolean DEBUG_FALLBACK = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 163 | static final boolean SHOW_STARTING_ANIMATIONS = true; |
| 164 | static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 165 | |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 166 | // Whether to allow dock apps with METADATA_DOCK_HOME to temporarily take over the Home key. |
| 167 | // No longer recommended for desk docks; still useful in car docks. |
| 168 | static final boolean ENABLE_CAR_DOCK_HOME_CAPTURE = true; |
| 169 | static final boolean ENABLE_DESK_DOCK_HOME_CAPTURE = false; |
| 170 | |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 171 | // Should screen savers use their own timeout, or the SCREEN_OFF_TIMEOUT? |
| 172 | static final boolean SEPARATE_TIMEOUT_FOR_SCREEN_SAVER = false; |
| 173 | |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 174 | static final int LONG_PRESS_POWER_NOTHING = 0; |
| 175 | static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1; |
| 176 | static final int LONG_PRESS_POWER_SHUT_OFF = 2; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 177 | |
| 178 | // These need to match the documentation/constant in |
| 179 | // core/res/res/values/config.xml |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 180 | static final int LONG_PRESS_HOME_NOTHING = 0; |
| 181 | static final int LONG_PRESS_HOME_RECENT_DIALOG = 1; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 182 | static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 2; |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 183 | static final int LONG_PRESS_HOME_VOICE_SEARCH = 3; |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 184 | |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 185 | // wallpaper is at the bottom, though the window manager may move it. |
Dianne Hackborn | 3c3bd44 | 2009-08-19 17:09:46 -0700 | [diff] [blame] | 186 | static final int WALLPAPER_LAYER = 2; |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 187 | static final int APPLICATION_LAYER = 2; |
| 188 | static final int PHONE_LAYER = 3; |
| 189 | static final int SEARCH_BAR_LAYER = 4; |
Dianne Hackborn | e8ecde1 | 2011-08-03 18:55:19 -0700 | [diff] [blame] | 190 | static final int SYSTEM_DIALOG_LAYER = 5; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 191 | // toasts and the plugged-in battery thing |
Dianne Hackborn | e8ecde1 | 2011-08-03 18:55:19 -0700 | [diff] [blame] | 192 | static final int TOAST_LAYER = 6; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 193 | // SIM errors and unlock. Not sure if this really should be in a high layer. |
Dianne Hackborn | e8ecde1 | 2011-08-03 18:55:19 -0700 | [diff] [blame] | 194 | static final int PRIORITY_PHONE_LAYER = 7; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 195 | // like the ANR / app crashed dialogs |
Dianne Hackborn | e8ecde1 | 2011-08-03 18:55:19 -0700 | [diff] [blame] | 196 | static final int SYSTEM_ALERT_LAYER = 8; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 197 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | 38cc896 | 2011-10-13 11:33:55 -0700 | [diff] [blame] | 198 | static final int INPUT_METHOD_LAYER = 9; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 199 | // on-screen keyboards and other such input method user interfaces go here. |
Dianne Hackborn | 38cc896 | 2011-10-13 11:33:55 -0700 | [diff] [blame] | 200 | static final int INPUT_METHOD_DIALOG_LAYER = 10; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 201 | // the keyguard; nothing on top of these can take focus, since they are |
| 202 | // responsible for power management when displayed. |
Dianne Hackborn | 38cc896 | 2011-10-13 11:33:55 -0700 | [diff] [blame] | 203 | static final int KEYGUARD_LAYER = 11; |
| 204 | static final int KEYGUARD_DIALOG_LAYER = 12; |
| 205 | static final int STATUS_BAR_SUB_PANEL_LAYER = 13; |
| 206 | static final int STATUS_BAR_LAYER = 14; |
| 207 | static final int STATUS_BAR_PANEL_LAYER = 15; |
Dianne Hackborn | e8ecde1 | 2011-08-03 18:55:19 -0700 | [diff] [blame] | 208 | // the on-screen volume indicator and controller shown when the user |
| 209 | // changes the device volume |
Dianne Hackborn | 38cc896 | 2011-10-13 11:33:55 -0700 | [diff] [blame] | 210 | static final int VOLUME_OVERLAY_LAYER = 16; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 211 | // things in here CAN NOT take focus, but are shown on top of everything else. |
Dianne Hackborn | 38cc896 | 2011-10-13 11:33:55 -0700 | [diff] [blame] | 212 | static final int SYSTEM_OVERLAY_LAYER = 17; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 213 | // the navigation bar, if available, shows atop most things |
Dianne Hackborn | 38cc896 | 2011-10-13 11:33:55 -0700 | [diff] [blame] | 214 | static final int NAVIGATION_BAR_LAYER = 18; |
| 215 | // system-level error dialogs |
| 216 | static final int SYSTEM_ERROR_LAYER = 19; |
Christopher Tate | a53146c | 2010-09-07 11:57:52 -0700 | [diff] [blame] | 217 | // the drag layer: input for drag-and-drop is associated with this window, |
| 218 | // which sits above all other focusable windows |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 219 | static final int DRAG_LAYER = 20; |
Dianne Hackborn | e8ecde1 | 2011-08-03 18:55:19 -0700 | [diff] [blame] | 220 | static final int SECURE_SYSTEM_OVERLAY_LAYER = 21; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 221 | static final int BOOT_PROGRESS_LAYER = 22; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 222 | // the (mouse) pointer layer |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 223 | static final int POINTER_LAYER = 23; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 224 | static final int HIDDEN_NAV_CONSUMER_LAYER = 24; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 225 | |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 226 | static final int APPLICATION_MEDIA_SUBLAYER = -2; |
| 227 | static final int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 228 | static final int APPLICATION_PANEL_SUBLAYER = 1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 229 | static final int APPLICATION_SUB_PANEL_SUBLAYER = 2; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 230 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 231 | static public final String SYSTEM_DIALOG_REASON_KEY = "reason"; |
| 232 | static public final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions"; |
| 233 | static public final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps"; |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 234 | static public final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 235 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 236 | /** |
| 237 | * These are the system UI flags that, when changing, can cause the layout |
| 238 | * of the screen to change. |
| 239 | */ |
| 240 | static final int SYSTEM_UI_CHANGING_LAYOUT = |
| 241 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN; |
| 242 | |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 243 | private static final int BTN_MOUSE = 0x110; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 244 | |
| 245 | /* Table of Application Launch keys. Maps from key codes to intent categories. |
| 246 | * |
| 247 | * These are special keys that are used to launch particular kinds of applications, |
| 248 | * such as a web browser. HID defines nearly a hundred of them in the Consumer (0x0C) |
| 249 | * usage page. We don't support quite that many yet... |
| 250 | */ |
| 251 | static SparseArray<String> sApplicationLaunchKeyCategories; |
| 252 | static { |
| 253 | sApplicationLaunchKeyCategories = new SparseArray<String>(); |
| 254 | sApplicationLaunchKeyCategories.append( |
| 255 | KeyEvent.KEYCODE_EXPLORER, Intent.CATEGORY_APP_BROWSER); |
| 256 | sApplicationLaunchKeyCategories.append( |
| 257 | KeyEvent.KEYCODE_ENVELOPE, Intent.CATEGORY_APP_EMAIL); |
| 258 | sApplicationLaunchKeyCategories.append( |
| 259 | KeyEvent.KEYCODE_CONTACTS, Intent.CATEGORY_APP_CONTACTS); |
| 260 | sApplicationLaunchKeyCategories.append( |
| 261 | KeyEvent.KEYCODE_CALENDAR, Intent.CATEGORY_APP_CALENDAR); |
| 262 | sApplicationLaunchKeyCategories.append( |
| 263 | KeyEvent.KEYCODE_MUSIC, Intent.CATEGORY_APP_MUSIC); |
| 264 | sApplicationLaunchKeyCategories.append( |
| 265 | KeyEvent.KEYCODE_CALCULATOR, Intent.CATEGORY_APP_CALCULATOR); |
| 266 | } |
| 267 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 268 | /** |
| 269 | * Lock protecting internal state. Must not call out into window |
| 270 | * manager with lock held. (This lock will be acquired in places |
| 271 | * where the window manager is calling in with its own lock held.) |
| 272 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 273 | final Object mLock = new Object(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 274 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 275 | Context mContext; |
| 276 | IWindowManager mWindowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 277 | WindowManagerFuncs mWindowManagerFuncs; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 278 | LocalPowerManager mPowerManager; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 279 | IStatusBarService mStatusBarService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 280 | Vibrator mVibrator; // Vibrator for giving feedback of orientation changes |
| 281 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 282 | // Vibrator pattern for haptic feedback of a long press. |
| 283 | long[] mLongPressVibePattern; |
| 284 | |
| 285 | // Vibrator pattern for haptic feedback of virtual key press. |
| 286 | long[] mVirtualKeyVibePattern; |
| 287 | |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 288 | // Vibrator pattern for a short vibration. |
| 289 | long[] mKeyboardTapVibePattern; |
| 290 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 291 | // Vibrator pattern for haptic feedback during boot when safe mode is disabled. |
| 292 | long[] mSafeModeDisabledVibePattern; |
| 293 | |
| 294 | // Vibrator pattern for haptic feedback during boot when safe mode is enabled. |
| 295 | long[] mSafeModeEnabledVibePattern; |
Romain Guy | 8154cd3 | 2010-03-29 14:41:15 -0700 | [diff] [blame] | 296 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 297 | /** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */ |
| 298 | boolean mEnableShiftMenuBugReports = false; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 299 | |
| 300 | boolean mHeadless; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 301 | boolean mSafeMode; |
| 302 | WindowState mStatusBar = null; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 303 | boolean mHasSystemNavBar; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 304 | int mStatusBarHeight; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 305 | final ArrayList<WindowState> mStatusBarPanels = new ArrayList<WindowState>(); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 306 | WindowState mNavigationBar = null; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 307 | boolean mHasNavigationBar = false; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 308 | boolean mCanHideNavigationBar = false; |
| 309 | boolean mNavigationBarOnBottom = true; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 310 | int mNavigationBarWidth = 0, mNavigationBarHeight = 0; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 311 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 312 | WindowState mKeyguard = null; |
| 313 | KeyguardViewMediator mKeyguardMediator; |
| 314 | GlobalActions mGlobalActions; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 315 | volatile boolean mPowerKeyHandled; // accessed from input reader and handler thread |
| 316 | boolean mPendingPowerKeyUpCanceled; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 317 | Handler mHandler; |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 318 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 319 | static final int RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS = 0; |
| 320 | static final int RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW = 1; |
| 321 | static final int RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH = 2; |
| 322 | |
| 323 | RecentApplicationsDialog mRecentAppsDialog; |
| 324 | int mRecentAppsDialogHeldModifiers; |
| 325 | |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 326 | int mLidOpen = LID_ABSENT; |
| 327 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 328 | boolean mSystemReady; |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 329 | boolean mSystemBooted; |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 330 | boolean mHdmiPlugged; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 331 | int mExternalDisplayWidth; |
| 332 | int mExternalDisplayHeight; |
Joe Onorato | 44fcb83 | 2011-12-14 20:59:30 -0800 | [diff] [blame] | 333 | int mUiMode; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 334 | int mDockMode = Intent.EXTRA_DOCK_STATE_UNDOCKED; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 335 | int mLidOpenRotation; |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 336 | int mCarDockRotation; |
| 337 | int mDeskDockRotation; |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 338 | int mHdmiRotation; |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 339 | |
| 340 | int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; |
| 341 | int mUserRotation = Surface.ROTATION_0; |
| 342 | |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 343 | int mAllowAllRotations = -1; |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 344 | boolean mCarDockEnablesAccelerometer; |
| 345 | boolean mDeskDockEnablesAccelerometer; |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 346 | int mLidKeyboardAccessibility; |
| 347 | int mLidNavigationAccessibility; |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 348 | int mLongPressOnPowerBehavior = -1; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 349 | boolean mScreenOnEarly = false; |
| 350 | boolean mScreenOnFully = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 351 | boolean mOrientationSensorEnabled = false; |
| 352 | int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
| 353 | static final int DEFAULT_ACCELEROMETER_ROTATION = 0; |
| 354 | int mAccelerometerDefault = DEFAULT_ACCELEROMETER_ROTATION; |
| 355 | boolean mHasSoftInput = false; |
| 356 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 357 | int mPointerLocationMode = 0; // guarded by mLock |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 358 | |
| 359 | // The last window we were told about in focusChanged. |
| 360 | WindowState mFocusedWindow; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 361 | IApplicationToken mFocusedApp; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 362 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 363 | private static final class PointerLocationInputEventReceiver extends InputEventReceiver { |
| 364 | private final PointerLocationView mView; |
| 365 | |
| 366 | public PointerLocationInputEventReceiver(InputChannel inputChannel, Looper looper, |
| 367 | PointerLocationView view) { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 368 | super(inputChannel, looper); |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 369 | mView = view; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 370 | } |
| 371 | |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 372 | @Override |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 373 | public void onInputEvent(InputEvent event) { |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 374 | boolean handled = false; |
| 375 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 376 | if (event instanceof MotionEvent |
| 377 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 378 | final MotionEvent motionEvent = (MotionEvent)event; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 379 | mView.addPointerEvent(motionEvent); |
| 380 | handled = true; |
Jeff Brown | 93ed4e3 | 2010-09-23 13:51:48 -0700 | [diff] [blame] | 381 | } |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 382 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 383 | finishInputEvent(event, handled); |
Jeff Brown | a41ca77 | 2010-08-11 14:46:32 -0700 | [diff] [blame] | 384 | } |
| 385 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 386 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 387 | |
| 388 | // Pointer location view state, only modified on the mHandler Looper. |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 389 | PointerLocationInputEventReceiver mPointerLocationInputEventReceiver; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 390 | PointerLocationView mPointerLocationView; |
| 391 | InputChannel mPointerLocationInputChannel; |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 392 | |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 393 | // The current size of the screen; really; (ir)regardless of whether the status |
| 394 | // bar can be hidden or not |
| 395 | int mUnrestrictedScreenLeft, mUnrestrictedScreenTop; |
| 396 | int mUnrestrictedScreenWidth, mUnrestrictedScreenHeight; |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 397 | // The current size of the screen; these may be different than (0,0)-(dw,dh) |
| 398 | // if the status bar can't be hidden; in that case it effectively carves out |
| 399 | // that area of the display from all other windows. |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 400 | int mRestrictedScreenLeft, mRestrictedScreenTop; |
| 401 | int mRestrictedScreenWidth, mRestrictedScreenHeight; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 402 | // For applications requesting stable content insets, these are them. |
| 403 | int mStableLeft, mStableTop, mStableRight, mStableBottom; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 404 | // During layout, the current screen borders with all outer decoration |
| 405 | // (status bar, input method dock) accounted for. |
| 406 | int mCurLeft, mCurTop, mCurRight, mCurBottom; |
| 407 | // During layout, the frame in which content should be displayed |
| 408 | // to the user, accounting for all screen decoration except for any |
| 409 | // space they deem as available for other content. This is usually |
| 410 | // the same as mCur*, but may be larger if the screen decor has supplied |
| 411 | // content insets. |
| 412 | int mContentLeft, mContentTop, mContentRight, mContentBottom; |
Dianne Hackborn | 8e11ef0 | 2010-11-18 19:47:42 -0800 | [diff] [blame] | 413 | // 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] | 414 | // windows are placed. |
| 415 | int mDockLeft, mDockTop, mDockRight, mDockBottom; |
| 416 | // During layout, the layer at which the doc window is placed. |
| 417 | int mDockLayer; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 418 | int mLastSystemUiFlags; |
| 419 | // Bits that we are in the process of clearing, so we want to prevent |
| 420 | // them from being set by applications until everything has been updated |
| 421 | // to have them clear. |
| 422 | int mResettingSystemUiFlags = 0; |
| 423 | // Bits that we are currently always keeping cleared. |
| 424 | int mForceClearedSystemUiFlags = 0; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 425 | // What we last reported to system UI about whether the compatibility |
| 426 | // menu needs to be displayed. |
| 427 | boolean mLastFocusNeedsMenu = false; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 428 | |
| 429 | FakeWindow mHideNavFakeWindow = null; |
| 430 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 431 | static final Rect mTmpParentFrame = new Rect(); |
| 432 | static final Rect mTmpDisplayFrame = new Rect(); |
| 433 | static final Rect mTmpContentFrame = new Rect(); |
| 434 | static final Rect mTmpVisibleFrame = new Rect(); |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 435 | static final Rect mTmpNavigationFrame = new Rect(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 436 | |
| 437 | WindowState mTopFullscreenOpaqueWindowState; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 438 | boolean mTopIsFullscreen; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 439 | boolean mForceStatusBar; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 440 | boolean mHideLockScreen; |
| 441 | boolean mDismissKeyguard; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 442 | boolean mHomePressed; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 443 | boolean mHomeLongPressed; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 444 | Intent mHomeIntent; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 445 | Intent mCarDockIntent; |
| 446 | Intent mDeskDockIntent; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 447 | int mShortcutKeyPressed = -1; |
| 448 | boolean mConsumeShortcutKeyUp; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 449 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 450 | // support for activating the lock screen while the screen is on |
| 451 | boolean mAllowLockscreenWhenOn; |
| 452 | int mLockScreenTimeout; |
| 453 | boolean mLockScreenTimerActive; |
| 454 | |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 455 | // visual screen saver support |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 456 | int mScreenSaverTimeout = 0; |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 457 | boolean mScreenSaverEnabledByUser = false; |
| 458 | boolean mScreenSaverMayRun = true; // false if a wakelock is held |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 459 | boolean mPluggedIn; |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 460 | |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 461 | // 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] | 462 | int mEndcallBehavior; |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 463 | |
| 464 | // Behavior of POWER button while in-call and screen on. |
| 465 | // (See Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR.) |
| 466 | int mIncallPowerBehavior; |
| 467 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 468 | Display mDisplay; |
| 469 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 470 | int mLandscapeRotation = 0; // default landscape rotation |
| 471 | int mSeascapeRotation = 0; // "other" landscape rotation, 180 degrees from mLandscapeRotation |
| 472 | int mPortraitRotation = 0; // default portrait rotation |
| 473 | int mUpsideDownRotation = 0; // "other" portrait rotation |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 474 | |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 475 | // What we do when the user long presses on home |
| 476 | private int mLongPressOnHomeBehavior = -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 477 | |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 478 | // Screenshot trigger states |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 479 | // Time to volume and power must be pressed within this interval of each other. |
| 480 | private static final long SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS = 150; |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 481 | private boolean mScreenshotChordEnabled; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 482 | private boolean mVolumeDownKeyTriggered; |
| 483 | private long mVolumeDownKeyTime; |
| 484 | private boolean mVolumeDownKeyConsumedByScreenshotChord; |
| 485 | private boolean mVolumeUpKeyTriggered; |
| 486 | private boolean mPowerKeyTriggered; |
| 487 | private long mPowerKeyTime; |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 488 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 489 | ShortcutManager mShortcutManager; |
| 490 | PowerManager.WakeLock mBroadcastWakeLock; |
| 491 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 492 | final KeyCharacterMap.FallbackAction mFallbackAction = new KeyCharacterMap.FallbackAction(); |
| 493 | |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 494 | private static final int MSG_ENABLE_POINTER_LOCATION = 1; |
| 495 | private static final int MSG_DISABLE_POINTER_LOCATION = 2; |
| 496 | |
| 497 | private class PolicyHandler extends Handler { |
| 498 | @Override |
| 499 | public void handleMessage(Message msg) { |
| 500 | switch (msg.what) { |
| 501 | case MSG_ENABLE_POINTER_LOCATION: |
| 502 | enablePointerLocation(); |
| 503 | break; |
| 504 | case MSG_DISABLE_POINTER_LOCATION: |
| 505 | disablePointerLocation(); |
| 506 | break; |
| 507 | } |
| 508 | } |
| 509 | } |
| 510 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 511 | private UEventObserver mHDMIObserver = new UEventObserver() { |
| 512 | @Override |
| 513 | public void onUEvent(UEventObserver.UEvent event) { |
| 514 | setHdmiPlugged("1".equals(event.get("SWITCH_STATE"))); |
| 515 | } |
| 516 | }; |
| 517 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 518 | class SettingsObserver extends ContentObserver { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 519 | SettingsObserver(Handler handler) { |
| 520 | super(handler); |
| 521 | } |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 522 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 523 | void observe() { |
| 524 | ContentResolver resolver = mContext.getContentResolver(); |
| 525 | resolver.registerContentObserver(Settings.System.getUriFor( |
| 526 | Settings.System.END_BUTTON_BEHAVIOR), false, this); |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 527 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
| 528 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR), false, this); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 529 | resolver.registerContentObserver(Settings.System.getUriFor( |
| 530 | Settings.System.ACCELEROMETER_ROTATION), false, this); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 531 | resolver.registerContentObserver(Settings.System.getUriFor( |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 532 | Settings.System.USER_ROTATION), false, this); |
| 533 | resolver.registerContentObserver(Settings.System.getUriFor( |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 534 | Settings.System.SCREEN_OFF_TIMEOUT), false, this); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 535 | resolver.registerContentObserver(Settings.System.getUriFor( |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 536 | Settings.System.WINDOW_ORIENTATION_LISTENER_LOG), false, this); |
| 537 | resolver.registerContentObserver(Settings.System.getUriFor( |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 538 | Settings.System.POINTER_LOCATION), false, this); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 539 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
| 540 | Settings.Secure.DEFAULT_INPUT_METHOD), false, this); |
Dianne Hackborn | 03759ed | 2009-03-27 16:04:08 -0700 | [diff] [blame] | 541 | resolver.registerContentObserver(Settings.System.getUriFor( |
| 542 | "fancy_rotation_anim"), false, this); |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 543 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
| 544 | Settings.Secure.SCREENSAVER_ENABLED), false, this); |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 545 | if (SEPARATE_TIMEOUT_FOR_SCREEN_SAVER) { |
| 546 | resolver.registerContentObserver(Settings.Secure.getUriFor( |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 547 | "screensaver_timeout"), false, this); |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 548 | } // otherwise SCREEN_OFF_TIMEOUT will do nicely |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 549 | updateSettings(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | @Override public void onChange(boolean selfChange) { |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 553 | updateSettings(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 554 | updateRotation(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 555 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 556 | } |
| 557 | |
| 558 | class MyOrientationListener extends WindowOrientationListener { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 559 | MyOrientationListener(Context context) { |
| 560 | super(context); |
| 561 | } |
| 562 | |
| 563 | @Override |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 564 | public void onProposedRotationChanged(int rotation) { |
| 565 | if (localLOGV) Log.v(TAG, "onProposedRotationChanged, rotation=" + rotation); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 566 | updateRotation(false); |
| 567 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 568 | } |
| 569 | MyOrientationListener mOrientationListener; |
| 570 | |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 571 | /* |
| 572 | * We always let the sensor be switched on by default except when |
| 573 | * the user has explicitly disabled sensor based rotation or when the |
| 574 | * screen is switched off. |
| 575 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 576 | boolean needSensorRunningLp() { |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 577 | if (mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 578 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 579 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT |
| 580 | || mCurrentAppOrientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 581 | // If the application has explicitly requested to follow the |
| 582 | // orientation, then we need to turn the sensor or. |
| 583 | return true; |
| 584 | } |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 585 | if ((mCarDockEnablesAccelerometer && mDockMode == Intent.EXTRA_DOCK_STATE_CAR) || |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 586 | (mDeskDockEnablesAccelerometer && (mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 587 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 588 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK))) { |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 589 | // enable accelerometer if we are docked in a dock that enables accelerometer |
| 590 | // orientation management, |
| 591 | return true; |
| 592 | } |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 593 | if (mAccelerometerDefault == 0) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 594 | // If the setting for using the sensor by default is enabled, then |
| 595 | // we will always leave it on. Note that the user could go to |
| 596 | // a window that forces an orientation that does not use the |
| 597 | // sensor and in theory we could turn it off... however, when next |
| 598 | // turning it on we won't have a good value for the current |
| 599 | // orientation for a little bit, which can cause orientation |
| 600 | // changes to lag, so we'd like to keep it always on. (It will |
| 601 | // still be turned off when the screen is off.) |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 602 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 603 | } |
Suchi Amalapurapu | a9e1b16 | 2009-03-24 22:24:47 -0700 | [diff] [blame] | 604 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | /* |
| 608 | * Various use cases for invoking this function |
| 609 | * screen turning off, should always disable listeners if already enabled |
| 610 | * screen turned on and current app has sensor based orientation, enable listeners |
| 611 | * if not already enabled |
| 612 | * screen turned on and current app does not have sensor orientation, disable listeners if |
| 613 | * already enabled |
| 614 | * screen turning on and current app has sensor based orientation, enable listeners if needed |
| 615 | * screen turning on and current app has nosensor based orientation, do nothing |
| 616 | */ |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 617 | void updateOrientationListenerLp() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 618 | if (!mOrientationListener.canDetectOrientation()) { |
| 619 | // If sensor is turned off or nonexistent for some reason |
| 620 | return; |
| 621 | } |
| 622 | //Could have been invoked due to screen turning on or off or |
| 623 | //change of the currently visible window's orientation |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 624 | if (localLOGV) Log.v(TAG, "Screen status="+mScreenOnEarly+ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 625 | ", current orientation="+mCurrentAppOrientation+ |
| 626 | ", SensorEnabled="+mOrientationSensorEnabled); |
| 627 | boolean disable = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 628 | if (mScreenOnEarly) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 629 | if (needSensorRunningLp()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 630 | disable = false; |
| 631 | //enable listener if not already enabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 632 | if (!mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 633 | mOrientationListener.enable(); |
Dianne Hackborn | 0572658 | 2009-09-22 17:28:24 -0700 | [diff] [blame] | 634 | if(localLOGV) Log.v(TAG, "Enabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 635 | mOrientationSensorEnabled = true; |
| 636 | } |
| 637 | } |
| 638 | } |
| 639 | //check if sensors need to be disabled |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 640 | if (disable && mOrientationSensorEnabled) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 641 | mOrientationListener.disable(); |
Dianne Hackborn | 0572658 | 2009-09-22 17:28:24 -0700 | [diff] [blame] | 642 | if(localLOGV) Log.v(TAG, "Disabling listeners"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 643 | mOrientationSensorEnabled = false; |
| 644 | } |
| 645 | } |
| 646 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 647 | private void interceptPowerKeyDown(boolean handled) { |
| 648 | mPowerKeyHandled = handled; |
| 649 | if (!handled) { |
| 650 | mHandler.postDelayed(mPowerLongPress, ViewConfiguration.getGlobalActionKeyTimeout()); |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | private boolean interceptPowerKeyUp(boolean canceled) { |
| 655 | if (!mPowerKeyHandled) { |
| 656 | mHandler.removeCallbacks(mPowerLongPress); |
| 657 | return !canceled; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 658 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 659 | return false; |
| 660 | } |
| 661 | |
| 662 | private void cancelPendingPowerKeyAction() { |
| 663 | if (!mPowerKeyHandled) { |
| 664 | mHandler.removeCallbacks(mPowerLongPress); |
| 665 | } |
Jeff Brown | ff20471 | 2011-10-25 21:27:54 -0700 | [diff] [blame] | 666 | if (mPowerKeyTriggered) { |
| 667 | mPendingPowerKeyUpCanceled = true; |
| 668 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 669 | } |
| 670 | |
| 671 | private void interceptScreenshotChord() { |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 672 | if (mScreenshotChordEnabled |
| 673 | && mVolumeDownKeyTriggered && mPowerKeyTriggered && !mVolumeUpKeyTriggered) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 674 | final long now = SystemClock.uptimeMillis(); |
| 675 | if (now <= mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS |
| 676 | && now <= mPowerKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS) { |
| 677 | mVolumeDownKeyConsumedByScreenshotChord = true; |
| 678 | cancelPendingPowerKeyAction(); |
| 679 | |
| 680 | mHandler.postDelayed(mScreenshotChordLongPress, |
| 681 | ViewConfiguration.getGlobalActionKeyTimeout()); |
| 682 | } |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | private void cancelPendingScreenshotChordAction() { |
| 687 | mHandler.removeCallbacks(mScreenshotChordLongPress); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | private final Runnable mPowerLongPress = new Runnable() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 691 | public void run() { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 692 | // The context isn't read |
| 693 | if (mLongPressOnPowerBehavior < 0) { |
| 694 | mLongPressOnPowerBehavior = mContext.getResources().getInteger( |
| 695 | com.android.internal.R.integer.config_longPressOnPowerBehavior); |
Joe Onorato | d208e70 | 2010-10-08 16:22:43 -0400 | [diff] [blame] | 696 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 697 | switch (mLongPressOnPowerBehavior) { |
| 698 | case LONG_PRESS_POWER_NOTHING: |
| 699 | break; |
| 700 | case LONG_PRESS_POWER_GLOBAL_ACTIONS: |
| 701 | mPowerKeyHandled = true; |
| 702 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 703 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
| 704 | showGlobalActionsDialog(); |
| 705 | break; |
| 706 | case LONG_PRESS_POWER_SHUT_OFF: |
| 707 | mPowerKeyHandled = true; |
| 708 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 709 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); |
| 710 | ShutdownThread.shutdown(mContext, true); |
| 711 | break; |
| 712 | } |
| 713 | } |
| 714 | }; |
| 715 | |
| 716 | private final Runnable mScreenshotChordLongPress = new Runnable() { |
| 717 | public void run() { |
| 718 | takeScreenshot(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 719 | } |
| 720 | }; |
| 721 | |
| 722 | void showGlobalActionsDialog() { |
| 723 | if (mGlobalActions == null) { |
| 724 | mGlobalActions = new GlobalActions(mContext); |
| 725 | } |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 726 | final boolean keyguardShowing = keyguardIsShowingTq(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 727 | mGlobalActions.showDialog(keyguardShowing, isDeviceProvisioned()); |
| 728 | if (keyguardShowing) { |
| 729 | // since it took two seconds of long press to bring this up, |
| 730 | // poke the wake lock so they have some time to see the dialog. |
| 731 | mKeyguardMediator.pokeWakelock(); |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | boolean isDeviceProvisioned() { |
| 736 | return Settings.Secure.getInt( |
| 737 | mContext.getContentResolver(), Settings.Secure.DEVICE_PROVISIONED, 0) != 0; |
| 738 | } |
| 739 | |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 740 | private void handleLongPressOnHome() { |
Jim Miller | ee969aa | 2010-08-26 20:17:43 -0700 | [diff] [blame] | 741 | // We can't initialize this in init() since the configuration hasn't been loaded yet. |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 742 | if (mLongPressOnHomeBehavior < 0) { |
| 743 | mLongPressOnHomeBehavior |
Joe Onorato | 50262e5 | 2010-11-26 14:04:54 -0800 | [diff] [blame] | 744 | = mContext.getResources().getInteger(R.integer.config_longPressOnHomeBehavior); |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 745 | if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING || |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 746 | mLongPressOnHomeBehavior > LONG_PRESS_HOME_RECENT_SYSTEM_UI) { |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 747 | mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING; |
| 748 | } |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 749 | if (hasNavigationBar()) { |
| 750 | mLongPressOnHomeBehavior = LONG_PRESS_HOME_VOICE_SEARCH; |
| 751 | } |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 752 | } |
| 753 | |
| 754 | if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) { |
| 755 | performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); |
| 756 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 757 | |
| 758 | // Eat the longpress so it won't dismiss the recent apps dialog when |
| 759 | // the user lets go of the home key |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 760 | mHomeLongPressed = true; |
Jim Miller | ee969aa | 2010-08-26 20:17:43 -0700 | [diff] [blame] | 761 | } |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 762 | |
Joe Onorato | 46b0d68 | 2010-11-22 17:37:27 -0800 | [diff] [blame] | 763 | if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_DIALOG) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 764 | showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 765 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) { |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 766 | try { |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 767 | mStatusBarService.toggleRecentApps(); |
| 768 | } catch (RemoteException e) { |
| 769 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 770 | } |
Michael Jurka | 7a34895 | 2012-02-27 13:07:58 -0800 | [diff] [blame] | 771 | } else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_VOICE_SEARCH) { |
| 772 | Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH); |
| 773 | try { |
| 774 | intent.setFlags( |
| 775 | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
| 776 | mContext.startActivity(intent); |
| 777 | } catch (ActivityNotFoundException e) { |
| 778 | Log.e(TAG, "Unable to launch. tag=" + TAG + " intent=" + intent, e); |
| 779 | } catch (SecurityException e) { |
| 780 | Log.e(TAG, "PhoneWindowManager does not have the permission to launch " + |
| 781 | "tag=" + TAG + " intent=" + intent, e); |
| 782 | } |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 783 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 784 | } |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 785 | |
| 786 | /** |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 787 | * Create (if necessary) and show or dismiss the recent apps dialog according |
| 788 | * according to the requested behavior. |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 789 | */ |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 790 | void showOrHideRecentAppsDialog(final int behavior) { |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 791 | mHandler.post(new Runnable() { |
| 792 | @Override |
| 793 | public void run() { |
| 794 | if (mRecentAppsDialog == null) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 795 | mRecentAppsDialog = new RecentApplicationsDialog(mContext); |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 796 | } |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 797 | if (mRecentAppsDialog.isShowing()) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 798 | switch (behavior) { |
| 799 | case RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS: |
| 800 | mRecentAppsDialog.dismiss(); |
| 801 | break; |
| 802 | case RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH: |
| 803 | mRecentAppsDialog.dismissAndSwitch(); |
| 804 | break; |
| 805 | case RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW: |
| 806 | default: |
| 807 | break; |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 808 | } |
| 809 | } else { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 810 | switch (behavior) { |
| 811 | case RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS: |
| 812 | mRecentAppsDialog.show(); |
| 813 | break; |
| 814 | case RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW: |
| 815 | try { |
| 816 | mWindowManager.setInTouchMode(false); |
| 817 | } catch (RemoteException e) { |
| 818 | } |
| 819 | mRecentAppsDialog.show(); |
| 820 | break; |
| 821 | case RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH: |
| 822 | default: |
| 823 | break; |
| 824 | } |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 825 | } |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 826 | } |
| 827 | }); |
Patrick Dubroy | ece9452 | 2011-02-23 18:35:01 -0800 | [diff] [blame] | 828 | } |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 829 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 830 | /** {@inheritDoc} */ |
| 831 | public void init(Context context, IWindowManager windowManager, |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 832 | WindowManagerFuncs windowManagerFuncs, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 833 | LocalPowerManager powerManager) { |
| 834 | mContext = context; |
| 835 | mWindowManager = windowManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 836 | mWindowManagerFuncs = windowManagerFuncs; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 837 | mPowerManager = powerManager; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 838 | mHeadless = "1".equals(SystemProperties.get("ro.config.headless", "0")); |
| 839 | if (!mHeadless) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 840 | // don't create KeyguardViewMediator if headless |
| 841 | mKeyguardMediator = new KeyguardViewMediator(context, this, powerManager); |
| 842 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 843 | mHandler = new PolicyHandler(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 844 | mOrientationListener = new MyOrientationListener(mContext); |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 845 | try { |
| 846 | mOrientationListener.setCurrentRotation(windowManager.getRotation()); |
| 847 | } catch (RemoteException ex) { } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 848 | SettingsObserver settingsObserver = new SettingsObserver(mHandler); |
| 849 | settingsObserver.observe(); |
| 850 | mShortcutManager = new ShortcutManager(context, mHandler); |
| 851 | mShortcutManager.observe(); |
Joe Onorato | 44fcb83 | 2011-12-14 20:59:30 -0800 | [diff] [blame] | 852 | mUiMode = context.getResources().getInteger( |
| 853 | com.android.internal.R.integer.config_defaultUiModeType); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 854 | mHomeIntent = new Intent(Intent.ACTION_MAIN, null); |
| 855 | mHomeIntent.addCategory(Intent.CATEGORY_HOME); |
| 856 | mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 857 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 858 | mCarDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 859 | mCarDockIntent.addCategory(Intent.CATEGORY_CAR_DOCK); |
| 860 | mCarDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 861 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
| 862 | mDeskDockIntent = new Intent(Intent.ACTION_MAIN, null); |
| 863 | mDeskDockIntent.addCategory(Intent.CATEGORY_DESK_DOCK); |
| 864 | mDeskDockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 865 | | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); |
Jim Miller | e6ad1a8 | 2010-08-20 19:25:39 -0700 | [diff] [blame] | 866 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 867 | PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); |
| 868 | mBroadcastWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, |
| 869 | "PhoneWindowManager.mBroadcastWakeLock"); |
| 870 | mEnableShiftMenuBugReports = "1".equals(SystemProperties.get("ro.debuggable")); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 871 | mLidOpenRotation = readRotation( |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 872 | com.android.internal.R.integer.config_lidOpenRotation); |
| 873 | mCarDockRotation = readRotation( |
| 874 | com.android.internal.R.integer.config_carDockRotation); |
| 875 | mDeskDockRotation = readRotation( |
| 876 | com.android.internal.R.integer.config_deskDockRotation); |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 877 | mCarDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 878 | com.android.internal.R.bool.config_carDockEnablesAccelerometer); |
| 879 | mDeskDockEnablesAccelerometer = mContext.getResources().getBoolean( |
| 880 | com.android.internal.R.bool.config_deskDockEnablesAccelerometer); |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 881 | mLidKeyboardAccessibility = mContext.getResources().getInteger( |
| 882 | com.android.internal.R.integer.config_lidKeyboardAccessibility); |
| 883 | mLidNavigationAccessibility = mContext.getResources().getInteger( |
| 884 | com.android.internal.R.integer.config_lidNavigationAccessibility); |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 885 | // register for dock events |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 886 | IntentFilter filter = new IntentFilter(); |
| 887 | filter.addAction(UiModeManager.ACTION_ENTER_CAR_MODE); |
| 888 | filter.addAction(UiModeManager.ACTION_EXIT_CAR_MODE); |
| 889 | filter.addAction(UiModeManager.ACTION_ENTER_DESK_MODE); |
| 890 | filter.addAction(UiModeManager.ACTION_EXIT_DESK_MODE); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 891 | filter.addAction(Intent.ACTION_DOCK_EVENT); |
| 892 | Intent intent = context.registerReceiver(mDockReceiver, filter); |
| 893 | if (intent != null) { |
| 894 | // Retrieve current sticky dock event broadcast. |
| 895 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 896 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 897 | } |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 898 | |
| 899 | // watch the plug to know whether to trigger the screen saver |
| 900 | filter = new IntentFilter(); |
| 901 | filter.addAction(Intent.ACTION_BATTERY_CHANGED); |
| 902 | intent = context.registerReceiver(mPowerReceiver, filter); |
| 903 | if (intent != null) { |
| 904 | mPluggedIn = (0 != intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0)); |
| 905 | } |
| 906 | |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 907 | mVibrator = new Vibrator(); |
| 908 | mLongPressVibePattern = getLongIntArray(mContext.getResources(), |
| 909 | com.android.internal.R.array.config_longPressVibePattern); |
| 910 | mVirtualKeyVibePattern = getLongIntArray(mContext.getResources(), |
| 911 | com.android.internal.R.array.config_virtualKeyVibePattern); |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 912 | mKeyboardTapVibePattern = getLongIntArray(mContext.getResources(), |
| 913 | com.android.internal.R.array.config_keyboardTapVibePattern); |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 914 | mSafeModeDisabledVibePattern = getLongIntArray(mContext.getResources(), |
| 915 | com.android.internal.R.array.config_safeModeDisabledVibePattern); |
| 916 | mSafeModeEnabledVibePattern = getLongIntArray(mContext.getResources(), |
| 917 | com.android.internal.R.array.config_safeModeEnabledVibePattern); |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 918 | |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 919 | mScreenshotChordEnabled = mContext.getResources().getBoolean( |
| 920 | com.android.internal.R.bool.config_enableScreenshotChord); |
| 921 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 922 | // Controls rotation and the like. |
| 923 | initializeHdmiState(); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 924 | |
| 925 | // Match current screen state. |
| 926 | if (mPowerManager.isScreenOn()) { |
| 927 | screenTurningOn(null); |
| 928 | } else { |
| 929 | screenTurnedOff(WindowManagerPolicy.OFF_BECAUSE_OF_USER); |
| 930 | } |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 931 | } |
| 932 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 933 | public void setInitialDisplaySize(Display display, int width, int height) { |
| 934 | mDisplay = display; |
| 935 | |
| 936 | int shortSize, longSize; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 937 | if (width > height) { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 938 | shortSize = height; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 939 | longSize = width; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 940 | mLandscapeRotation = Surface.ROTATION_0; |
| 941 | mSeascapeRotation = Surface.ROTATION_180; |
| 942 | if (mContext.getResources().getBoolean( |
| 943 | com.android.internal.R.bool.config_reverseDefaultRotation)) { |
| 944 | mPortraitRotation = Surface.ROTATION_90; |
| 945 | mUpsideDownRotation = Surface.ROTATION_270; |
| 946 | } else { |
| 947 | mPortraitRotation = Surface.ROTATION_270; |
| 948 | mUpsideDownRotation = Surface.ROTATION_90; |
| 949 | } |
| 950 | } else { |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 951 | shortSize = width; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 952 | longSize = height; |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 953 | mPortraitRotation = Surface.ROTATION_0; |
| 954 | mUpsideDownRotation = Surface.ROTATION_180; |
| 955 | if (mContext.getResources().getBoolean( |
| 956 | com.android.internal.R.bool.config_reverseDefaultRotation)) { |
| 957 | mLandscapeRotation = Surface.ROTATION_270; |
| 958 | mSeascapeRotation = Surface.ROTATION_90; |
| 959 | } else { |
| 960 | mLandscapeRotation = Surface.ROTATION_90; |
| 961 | mSeascapeRotation = Surface.ROTATION_270; |
| 962 | } |
| 963 | } |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 964 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 965 | mExternalDisplayWidth = mDisplay.getRawExternalWidth(); |
| 966 | mExternalDisplayHeight = mDisplay.getRawExternalHeight(); |
| 967 | |
| 968 | mStatusBarHeight = mContext.getResources().getDimensionPixelSize( |
| 969 | com.android.internal.R.dimen.status_bar_height); |
| 970 | mNavigationBarHeight = mContext.getResources().getDimensionPixelSize( |
| 971 | com.android.internal.R.dimen.navigation_bar_height); |
| 972 | mNavigationBarWidth = mContext.getResources().getDimensionPixelSize( |
| 973 | com.android.internal.R.dimen.navigation_bar_width); |
| 974 | |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 975 | // Determine whether the status bar can hide based on the size |
Daniel Sandler | c8cb329 | 2012-04-05 23:56:05 -0400 | [diff] [blame] | 976 | // of the screen. We assume sizes >= 600dp are tablets where we |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 977 | // will use the system bar. |
Daniel Sandler | c8cb329 | 2012-04-05 23:56:05 -0400 | [diff] [blame] | 978 | // XXX: This will change to 720dp soon. |
Daniel Sandler | 631cb3d5 | 2011-06-03 01:25:43 -0400 | [diff] [blame] | 979 | int shortSizeDp = shortSize |
| 980 | * DisplayMetrics.DENSITY_DEFAULT |
| 981 | / DisplayMetrics.DENSITY_DEVICE; |
Daniel Sandler | c8cb329 | 2012-04-05 23:56:05 -0400 | [diff] [blame] | 982 | mHasSystemNavBar = shortSizeDp >= 600; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 983 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 984 | if (!mHasSystemNavBar) { |
| 985 | mHasNavigationBar = mContext.getResources().getBoolean( |
| 986 | com.android.internal.R.bool.config_showNavigationBar); |
| 987 | // Allow a system property to override this. Used by the emulator. |
| 988 | // See also hasNavigationBar(). |
| 989 | String navBarOverride = SystemProperties.get("qemu.hw.mainkeys"); |
| 990 | if (! "".equals(navBarOverride)) { |
| 991 | if (navBarOverride.equals("1")) mHasNavigationBar = false; |
| 992 | else if (navBarOverride.equals("0")) mHasNavigationBar = true; |
| 993 | } |
| 994 | } else { |
| 995 | mHasNavigationBar = false; |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 996 | } |
| 997 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 998 | if (mHasSystemNavBar) { |
| 999 | // The system bar is always at the bottom. If you are watching |
| 1000 | // a video in landscape, we don't need to hide it if we can still |
| 1001 | // show a 16:9 aspect ratio with it. |
| 1002 | int longSizeDp = longSize |
| 1003 | * DisplayMetrics.DENSITY_DEFAULT |
| 1004 | / DisplayMetrics.DENSITY_DEVICE; |
| 1005 | int barHeightDp = mNavigationBarHeight |
| 1006 | * DisplayMetrics.DENSITY_DEFAULT |
| 1007 | / DisplayMetrics.DENSITY_DEVICE; |
| 1008 | int aspect = ((shortSizeDp-barHeightDp) * 16) / longSizeDp; |
| 1009 | // We have computed the aspect ratio with the bar height taken |
| 1010 | // out to be 16:aspect. If this is less than 9, then hiding |
| 1011 | // the navigation bar will provide more useful space for wide |
| 1012 | // screen movies. |
| 1013 | mCanHideNavigationBar = aspect < 9; |
| 1014 | } else if (mHasNavigationBar) { |
| 1015 | // The navigation bar is at the right in landscape; it seems always |
| 1016 | // useful to hide it for showing a video. |
| 1017 | mCanHideNavigationBar = true; |
| 1018 | } else { |
| 1019 | mCanHideNavigationBar = false; |
| 1020 | } |
Erik Gilling | 9a41ef8 | 2011-09-26 19:21:03 -0700 | [diff] [blame] | 1021 | |
| 1022 | if ("portrait".equals(SystemProperties.get("persist.demo.hdmirotation"))) { |
| 1023 | mHdmiRotation = mPortraitRotation; |
| 1024 | } else { |
| 1025 | mHdmiRotation = mLandscapeRotation; |
| 1026 | } |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1027 | } |
| 1028 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1029 | public void updateSettings() { |
| 1030 | ContentResolver resolver = mContext.getContentResolver(); |
| 1031 | boolean updateRotation = false; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1032 | synchronized (mLock) { |
| 1033 | mEndcallBehavior = Settings.System.getInt(resolver, |
David Brown | baf8d09 | 2010-03-08 21:52:59 -0800 | [diff] [blame] | 1034 | Settings.System.END_BUTTON_BEHAVIOR, |
| 1035 | Settings.System.END_BUTTON_BEHAVIOR_DEFAULT); |
| 1036 | mIncallPowerBehavior = Settings.Secure.getInt(resolver, |
| 1037 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR, |
| 1038 | Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_DEFAULT); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1039 | int accelerometerDefault = Settings.System.getInt(resolver, |
| 1040 | Settings.System.ACCELEROMETER_ROTATION, DEFAULT_ACCELEROMETER_ROTATION); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1041 | |
| 1042 | // set up rotation lock state |
Daniel Sandler | 1b815d6 | 2010-11-05 10:24:27 -0400 | [diff] [blame] | 1043 | mUserRotationMode = (accelerometerDefault == 0) |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1044 | ? WindowManagerPolicy.USER_ROTATION_LOCKED |
| 1045 | : WindowManagerPolicy.USER_ROTATION_FREE; |
| 1046 | mUserRotation = Settings.System.getInt(resolver, |
| 1047 | Settings.System.USER_ROTATION, |
| 1048 | Surface.ROTATION_0); |
| 1049 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1050 | if (mAccelerometerDefault != accelerometerDefault) { |
| 1051 | mAccelerometerDefault = accelerometerDefault; |
| 1052 | updateOrientationListenerLp(); |
| 1053 | } |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1054 | |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 1055 | mOrientationListener.setLogEnabled( |
| 1056 | Settings.System.getInt(resolver, |
| 1057 | Settings.System.WINDOW_ORIENTATION_LISTENER_LOG, 0) != 0); |
| 1058 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1059 | if (mSystemReady) { |
| 1060 | int pointerLocation = Settings.System.getInt(resolver, |
| 1061 | Settings.System.POINTER_LOCATION, 0); |
| 1062 | if (mPointerLocationMode != pointerLocation) { |
| 1063 | mPointerLocationMode = pointerLocation; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1064 | mHandler.sendEmptyMessage(pointerLocation != 0 ? |
| 1065 | MSG_ENABLE_POINTER_LOCATION : MSG_DISABLE_POINTER_LOCATION); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1066 | } |
| 1067 | } |
| 1068 | // use screen off timeout setting as the timeout for the lockscreen |
| 1069 | mLockScreenTimeout = Settings.System.getInt(resolver, |
| 1070 | Settings.System.SCREEN_OFF_TIMEOUT, 0); |
| 1071 | String imId = Settings.Secure.getString(resolver, |
| 1072 | Settings.Secure.DEFAULT_INPUT_METHOD); |
| 1073 | boolean hasSoftInput = imId != null && imId.length() > 0; |
| 1074 | if (mHasSoftInput != hasSoftInput) { |
| 1075 | mHasSoftInput = hasSoftInput; |
| 1076 | updateRotation = true; |
| 1077 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1078 | |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 1079 | mScreenSaverEnabledByUser = 0 != Settings.Secure.getInt(resolver, |
| 1080 | Settings.Secure.SCREENSAVER_ENABLED, 1); |
| 1081 | |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 1082 | if (SEPARATE_TIMEOUT_FOR_SCREEN_SAVER) { |
| 1083 | mScreenSaverTimeout = Settings.Secure.getInt(resolver, |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 1084 | "screensaver_timeout", 0); |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 1085 | } else { |
| 1086 | mScreenSaverTimeout = Settings.System.getInt(resolver, |
| 1087 | Settings.System.SCREEN_OFF_TIMEOUT, 0); |
| 1088 | if (mScreenSaverTimeout > 0) { |
| 1089 | // We actually want to activate the screensaver just before the |
| 1090 | // power manager's screen timeout |
| 1091 | mScreenSaverTimeout -= 5000; |
| 1092 | } |
| 1093 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1094 | updateScreenSaverTimeoutLocked(); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1095 | } |
| 1096 | if (updateRotation) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1097 | updateRotation(true); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1098 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1099 | } |
| 1100 | |
| 1101 | private void enablePointerLocation() { |
| 1102 | if (mPointerLocationView == null) { |
| 1103 | mPointerLocationView = new PointerLocationView(mContext); |
| 1104 | mPointerLocationView.setPrintCoords(false); |
| 1105 | |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1106 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 1107 | WindowManager.LayoutParams.MATCH_PARENT, |
| 1108 | WindowManager.LayoutParams.MATCH_PARENT); |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1109 | lp.type = WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1110 | lp.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN |
| 1111 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE |
| 1112 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1113 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1114 | lp.format = PixelFormat.TRANSLUCENT; |
| 1115 | lp.setTitle("PointerLocation"); |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1116 | WindowManager wm = (WindowManager) |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1117 | mContext.getSystemService(Context.WINDOW_SERVICE); |
Jeff Brown | cc4f7db | 2011-08-30 20:34:48 -0700 | [diff] [blame] | 1118 | lp.inputFeatures |= WindowManager.LayoutParams.INPUT_FEATURE_NO_INPUT_CHANNEL; |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1119 | wm.addView(mPointerLocationView, lp); |
| 1120 | |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 1121 | mPointerLocationInputChannel = |
| 1122 | mWindowManagerFuncs.monitorInput("PointerLocationView"); |
| 1123 | mPointerLocationInputEventReceiver = |
| 1124 | new PointerLocationInputEventReceiver(mPointerLocationInputChannel, |
| 1125 | Looper.myLooper(), mPointerLocationView); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1126 | } |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 1127 | } |
Jeff Brown | 7082516 | 2012-03-28 17:27:48 -0700 | [diff] [blame] | 1128 | |
| 1129 | private void disablePointerLocation() { |
| 1130 | if (mPointerLocationInputEventReceiver != null) { |
| 1131 | mPointerLocationInputEventReceiver.dispose(); |
| 1132 | mPointerLocationInputEventReceiver = null; |
| 1133 | } |
| 1134 | |
| 1135 | if (mPointerLocationInputChannel != null) { |
| 1136 | mPointerLocationInputChannel.dispose(); |
| 1137 | mPointerLocationInputChannel = null; |
| 1138 | } |
| 1139 | |
| 1140 | if (mPointerLocationView != null) { |
| 1141 | WindowManager wm = (WindowManager) |
| 1142 | mContext.getSystemService(Context.WINDOW_SERVICE); |
| 1143 | wm.removeView(mPointerLocationView); |
| 1144 | mPointerLocationView = null; |
| 1145 | } |
| 1146 | } |
| 1147 | |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1148 | private int readRotation(int resID) { |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1149 | try { |
| 1150 | int rotation = mContext.getResources().getInteger(resID); |
| 1151 | switch (rotation) { |
| 1152 | case 0: |
| 1153 | return Surface.ROTATION_0; |
| 1154 | case 90: |
| 1155 | return Surface.ROTATION_90; |
| 1156 | case 180: |
| 1157 | return Surface.ROTATION_180; |
| 1158 | case 270: |
| 1159 | return Surface.ROTATION_270; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1160 | } |
| 1161 | } catch (Resources.NotFoundException e) { |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1162 | // fall through |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 1163 | } |
Mike Lockwood | 2d1efbd | 2009-09-16 12:15:53 -0400 | [diff] [blame] | 1164 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1165 | } |
| 1166 | |
| 1167 | /** {@inheritDoc} */ |
| 1168 | public int checkAddPermission(WindowManager.LayoutParams attrs) { |
| 1169 | int type = attrs.type; |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 1170 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1171 | if (type < WindowManager.LayoutParams.FIRST_SYSTEM_WINDOW |
| 1172 | || type > WindowManager.LayoutParams.LAST_SYSTEM_WINDOW) { |
| 1173 | return WindowManagerImpl.ADD_OKAY; |
| 1174 | } |
| 1175 | String permission = null; |
| 1176 | switch (type) { |
| 1177 | case TYPE_TOAST: |
| 1178 | // XXX right now the app process has complete control over |
| 1179 | // this... should introduce a token to let the system |
| 1180 | // monitor/control what they are doing. |
| 1181 | break; |
| 1182 | case TYPE_INPUT_METHOD: |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1183 | case TYPE_WALLPAPER: |
| 1184 | // The window manager will check these. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1185 | break; |
| 1186 | case TYPE_PHONE: |
| 1187 | case TYPE_PRIORITY_PHONE: |
| 1188 | case TYPE_SYSTEM_ALERT: |
| 1189 | case TYPE_SYSTEM_ERROR: |
| 1190 | case TYPE_SYSTEM_OVERLAY: |
| 1191 | permission = android.Manifest.permission.SYSTEM_ALERT_WINDOW; |
| 1192 | break; |
| 1193 | default: |
| 1194 | permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; |
| 1195 | } |
| 1196 | if (permission != null) { |
| 1197 | if (mContext.checkCallingOrSelfPermission(permission) |
| 1198 | != PackageManager.PERMISSION_GRANTED) { |
| 1199 | return WindowManagerImpl.ADD_PERMISSION_DENIED; |
| 1200 | } |
| 1201 | } |
| 1202 | return WindowManagerImpl.ADD_OKAY; |
| 1203 | } |
| 1204 | |
| 1205 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs) { |
| 1206 | switch (attrs.type) { |
| 1207 | case TYPE_SYSTEM_OVERLAY: |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1208 | case TYPE_SECURE_SYSTEM_OVERLAY: |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1209 | case TYPE_TOAST: |
| 1210 | // These types of windows can't receive input events. |
| 1211 | attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1212 | | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 1213 | attrs.flags &= ~WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1214 | break; |
| 1215 | } |
| 1216 | } |
| 1217 | |
| 1218 | void readLidState() { |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 1219 | mLidOpen = mWindowManagerFuncs.getLidState(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1220 | } |
| 1221 | |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 1222 | private int determineHiddenState(int mode, int hiddenValue, int visibleValue) { |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1223 | if (mLidOpen != LID_ABSENT) { |
| 1224 | switch (mode) { |
| 1225 | case 1: |
| 1226 | return mLidOpen == LID_OPEN ? visibleValue : hiddenValue; |
| 1227 | case 2: |
| 1228 | return mLidOpen == LID_OPEN ? hiddenValue : visibleValue; |
| 1229 | } |
Dianne Hackborn | 2862fff | 2009-09-15 22:56:29 -0700 | [diff] [blame] | 1230 | } |
| 1231 | return visibleValue; |
| 1232 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1233 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1234 | /** {@inheritDoc} */ |
| 1235 | public void adjustConfigurationLw(Configuration config) { |
| 1236 | readLidState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1237 | updateKeyboardVisibility(); |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1238 | |
| 1239 | if (config.keyboard == Configuration.KEYBOARD_NOKEYS) { |
| 1240 | config.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES; |
| 1241 | } else { |
| 1242 | config.hardKeyboardHidden = determineHiddenState(mLidKeyboardAccessibility, |
| 1243 | Configuration.HARDKEYBOARDHIDDEN_YES, Configuration.HARDKEYBOARDHIDDEN_NO); |
| 1244 | } |
| 1245 | |
| 1246 | if (config.navigation == Configuration.NAVIGATION_NONAV) { |
| 1247 | config.navigationHidden = Configuration.NAVIGATIONHIDDEN_YES; |
| 1248 | } else { |
| 1249 | config.navigationHidden = determineHiddenState(mLidNavigationAccessibility, |
| 1250 | Configuration.NAVIGATIONHIDDEN_YES, Configuration.NAVIGATIONHIDDEN_NO); |
| 1251 | } |
| 1252 | |
| 1253 | if (mHasSoftInput || config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) { |
| 1254 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO; |
| 1255 | } else { |
| 1256 | config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES; |
| 1257 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1258 | } |
Jeff Brown | d04a88c | 2011-01-16 14:05:47 -0800 | [diff] [blame] | 1259 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1260 | /** {@inheritDoc} */ |
| 1261 | public int windowTypeToLayerLw(int type) { |
| 1262 | if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { |
| 1263 | return APPLICATION_LAYER; |
| 1264 | } |
| 1265 | switch (type) { |
| 1266 | case TYPE_STATUS_BAR: |
| 1267 | return STATUS_BAR_LAYER; |
| 1268 | case TYPE_STATUS_BAR_PANEL: |
| 1269 | return STATUS_BAR_PANEL_LAYER; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1270 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1271 | return STATUS_BAR_SUB_PANEL_LAYER; |
Dianne Hackborn | 6a294ce | 2009-12-03 11:37:44 -0800 | [diff] [blame] | 1272 | case TYPE_SYSTEM_DIALOG: |
| 1273 | return SYSTEM_DIALOG_LAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1274 | case TYPE_SEARCH_BAR: |
| 1275 | return SEARCH_BAR_LAYER; |
| 1276 | case TYPE_PHONE: |
| 1277 | return PHONE_LAYER; |
| 1278 | case TYPE_KEYGUARD: |
| 1279 | return KEYGUARD_LAYER; |
| 1280 | case TYPE_KEYGUARD_DIALOG: |
| 1281 | return KEYGUARD_DIALOG_LAYER; |
| 1282 | case TYPE_SYSTEM_ALERT: |
| 1283 | return SYSTEM_ALERT_LAYER; |
| 1284 | case TYPE_SYSTEM_ERROR: |
| 1285 | return SYSTEM_ERROR_LAYER; |
| 1286 | case TYPE_INPUT_METHOD: |
| 1287 | return INPUT_METHOD_LAYER; |
| 1288 | case TYPE_INPUT_METHOD_DIALOG: |
| 1289 | return INPUT_METHOD_DIALOG_LAYER; |
Dianne Hackborn | e8ecde1 | 2011-08-03 18:55:19 -0700 | [diff] [blame] | 1290 | case TYPE_VOLUME_OVERLAY: |
| 1291 | return VOLUME_OVERLAY_LAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1292 | case TYPE_SYSTEM_OVERLAY: |
| 1293 | return SYSTEM_OVERLAY_LAYER; |
Jeff Brown | 3b2b354 | 2010-10-15 00:54:27 -0700 | [diff] [blame] | 1294 | case TYPE_SECURE_SYSTEM_OVERLAY: |
| 1295 | return SECURE_SYSTEM_OVERLAY_LAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1296 | case TYPE_PRIORITY_PHONE: |
| 1297 | return PRIORITY_PHONE_LAYER; |
| 1298 | case TYPE_TOAST: |
| 1299 | return TOAST_LAYER; |
Dianne Hackborn | b7cd8b9 | 2009-08-08 20:53:03 -0700 | [diff] [blame] | 1300 | case TYPE_WALLPAPER: |
| 1301 | return WALLPAPER_LAYER; |
Christopher Tate | a53146c | 2010-09-07 11:57:52 -0700 | [diff] [blame] | 1302 | case TYPE_DRAG: |
| 1303 | return DRAG_LAYER; |
Jeff Brown | 83c0968 | 2010-12-23 17:50:18 -0800 | [diff] [blame] | 1304 | case TYPE_POINTER: |
| 1305 | return POINTER_LAYER; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1306 | case TYPE_NAVIGATION_BAR: |
| 1307 | return NAVIGATION_BAR_LAYER; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1308 | case TYPE_BOOT_PROGRESS: |
| 1309 | return BOOT_PROGRESS_LAYER; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1310 | case TYPE_HIDDEN_NAV_CONSUMER: |
| 1311 | return HIDDEN_NAV_CONSUMER_LAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1312 | } |
| 1313 | Log.e(TAG, "Unknown window type: " + type); |
| 1314 | return APPLICATION_LAYER; |
| 1315 | } |
| 1316 | |
| 1317 | /** {@inheritDoc} */ |
| 1318 | public int subWindowTypeToLayerLw(int type) { |
| 1319 | switch (type) { |
| 1320 | case TYPE_APPLICATION_PANEL: |
| 1321 | case TYPE_APPLICATION_ATTACHED_DIALOG: |
| 1322 | return APPLICATION_PANEL_SUBLAYER; |
| 1323 | case TYPE_APPLICATION_MEDIA: |
| 1324 | return APPLICATION_MEDIA_SUBLAYER; |
Dianne Hackborn | 5cb8d79 | 2009-05-21 17:34:15 -0700 | [diff] [blame] | 1325 | case TYPE_APPLICATION_MEDIA_OVERLAY: |
| 1326 | return APPLICATION_MEDIA_OVERLAY_SUBLAYER; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1327 | case TYPE_APPLICATION_SUB_PANEL: |
| 1328 | return APPLICATION_SUB_PANEL_SUBLAYER; |
| 1329 | } |
| 1330 | Log.e(TAG, "Unknown sub-window type: " + type); |
| 1331 | return 0; |
| 1332 | } |
| 1333 | |
Dianne Hackborn | abe0da0 | 2009-09-18 01:55:39 -0700 | [diff] [blame] | 1334 | public int getMaxWallpaperLayer() { |
| 1335 | return STATUS_BAR_LAYER; |
| 1336 | } |
| 1337 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1338 | public boolean hasSystemNavBar() { |
| 1339 | return mHasSystemNavBar; |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 1340 | } |
| 1341 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1342 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame^] | 1343 | if (mHasNavigationBar) { |
| 1344 | // For a basic navigation bar, when we are in landscape mode we place |
| 1345 | // the navigation bar to the side. |
| 1346 | if (fullWidth > fullHeight) { |
| 1347 | return fullWidth - mNavigationBarWidth; |
| 1348 | } |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1349 | } |
| 1350 | return fullWidth; |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1351 | } |
| 1352 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1353 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame^] | 1354 | if (mHasSystemNavBar) { |
| 1355 | // For the system navigation bar, we always place it at the bottom. |
| 1356 | return fullHeight - mNavigationBarHeight; |
| 1357 | } |
| 1358 | if (mHasNavigationBar) { |
| 1359 | // For a basic navigation bar, when we are in portrait mode we place |
| 1360 | // the navigation bar to the bottom. |
| 1361 | if (fullWidth < fullHeight) { |
| 1362 | return fullHeight - mNavigationBarHeight; |
| 1363 | } |
| 1364 | } |
| 1365 | return fullHeight; |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1366 | } |
| 1367 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1368 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation) { |
| 1369 | return getNonDecorDisplayWidth(fullWidth, fullHeight, rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 1370 | } |
| 1371 | |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 1372 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation) { |
Dianne Hackborn | 077ee85 | 2012-04-09 16:27:07 -0700 | [diff] [blame^] | 1373 | // If we don't have a system nav bar, then there is a separate status |
| 1374 | // bar at the top of the display. We don't count that as part of the |
| 1375 | // fixed decor, since it can hide; however, for purposes of configurations, |
| 1376 | // we do want to exclude it since applications can't generally use that part |
| 1377 | // of the screen. |
| 1378 | if (!mHasSystemNavBar) { |
| 1379 | return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation) - mStatusBarHeight; |
| 1380 | } |
| 1381 | return getNonDecorDisplayHeight(fullWidth, fullHeight, rotation); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 1382 | } |
| 1383 | |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1384 | public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs) { |
| 1385 | return attrs.type == WindowManager.LayoutParams.TYPE_KEYGUARD; |
| 1386 | } |
| 1387 | |
| 1388 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs) { |
| 1389 | return attrs.type != WindowManager.LayoutParams.TYPE_STATUS_BAR |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1390 | && attrs.type != WindowManager.LayoutParams.TYPE_NAVIGATION_BAR |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1391 | && attrs.type != WindowManager.LayoutParams.TYPE_WALLPAPER; |
| 1392 | } |
| 1393 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1394 | /** {@inheritDoc} */ |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1395 | public View addStartingWindow(IBinder appToken, String packageName, int theme, |
| 1396 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, |
| 1397 | int icon, int windowFlags) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1398 | if (!SHOW_STARTING_ANIMATIONS) { |
| 1399 | return null; |
| 1400 | } |
| 1401 | if (packageName == null) { |
| 1402 | return null; |
| 1403 | } |
| 1404 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1405 | try { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1406 | Context context = mContext; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1407 | //Log.i(TAG, "addStartingWindow " + packageName + ": nonLocalizedLabel=" |
| 1408 | // + nonLocalizedLabel + " theme=" + Integer.toHexString(theme)); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1409 | if (theme != context.getThemeResId() || labelRes != 0) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1410 | try { |
| 1411 | context = context.createPackageContext(packageName, 0); |
Dianne Hackborn | 247fe74 | 2011-01-08 17:25:57 -0800 | [diff] [blame] | 1412 | context.setTheme(theme); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1413 | } catch (PackageManager.NameNotFoundException e) { |
| 1414 | // Ignore |
| 1415 | } |
| 1416 | } |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1417 | |
| 1418 | Window win = PolicyManager.makeNewWindow(context); |
| 1419 | if (win.getWindowStyle().getBoolean( |
| 1420 | com.android.internal.R.styleable.Window_windowDisablePreview, false)) { |
| 1421 | return null; |
| 1422 | } |
| 1423 | |
| 1424 | Resources r = context.getResources(); |
| 1425 | win.setTitle(r.getText(labelRes, nonLocalizedLabel)); |
| 1426 | |
| 1427 | win.setType( |
| 1428 | WindowManager.LayoutParams.TYPE_APPLICATION_STARTING); |
| 1429 | // Force the window flags: this is a fake window, so it is not really |
| 1430 | // touchable or focusable by the user. We also add in the ALT_FOCUSABLE_IM |
| 1431 | // flag because we do know that the next window will take input |
| 1432 | // focus, so we want to get the IME window up on top of us right away. |
| 1433 | win.setFlags( |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1434 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1435 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1436 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1437 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 1438 | windowFlags| |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1439 | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE| |
| 1440 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE| |
| 1441 | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); |
| 1442 | |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1443 | if (!compatInfo.supportsScreen()) { |
| 1444 | win.addFlags(WindowManager.LayoutParams.FLAG_COMPATIBLE_WINDOW); |
| 1445 | } |
| 1446 | |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1447 | win.setLayout(WindowManager.LayoutParams.MATCH_PARENT, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 1448 | WindowManager.LayoutParams.MATCH_PARENT); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1449 | |
| 1450 | final WindowManager.LayoutParams params = win.getAttributes(); |
| 1451 | params.token = appToken; |
| 1452 | params.packageName = packageName; |
| 1453 | params.windowAnimations = win.getWindowStyle().getResourceId( |
| 1454 | com.android.internal.R.styleable.Window_windowAnimationStyle, 0); |
Dianne Hackborn | 5d927c2 | 2011-09-02 12:22:18 -0700 | [diff] [blame] | 1455 | params.privateFlags |= |
| 1456 | WindowManager.LayoutParams.PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1457 | params.setTitle("Starting " + packageName); |
| 1458 | |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1459 | WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1460 | View view = win.getDecorView(); |
| 1461 | |
| 1462 | if (win.isFloating()) { |
| 1463 | // Whoops, there is no way to display an animation/preview |
| 1464 | // of such a thing! After all that work... let's skip it. |
| 1465 | // (Note that we must do this here because it is in |
| 1466 | // getDecorView() where the theme is evaluated... maybe |
| 1467 | // we should peek the floating attribute from the theme |
| 1468 | // earlier.) |
| 1469 | return null; |
| 1470 | } |
| 1471 | |
| 1472 | if (localLOGV) Log.v( |
| 1473 | TAG, "Adding starting window for " + packageName |
| 1474 | + " / " + appToken + ": " |
| 1475 | + (view.getParent() != null ? view : null)); |
| 1476 | |
| 1477 | wm.addView(view, params); |
| 1478 | |
| 1479 | // Only return the view if it was successfully added to the |
| 1480 | // window manager... which we can tell by it having a parent. |
| 1481 | return view.getParent() != null ? view : null; |
| 1482 | } catch (WindowManagerImpl.BadTokenException e) { |
| 1483 | // ignore |
| 1484 | Log.w(TAG, appToken + " already running, starting window not displayed"); |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 1485 | } catch (RuntimeException e) { |
| 1486 | // don't crash if something else bad happens, for example a |
| 1487 | // failure loading resources because we are loading from an app |
| 1488 | // on external storage that has been unmounted. |
| 1489 | Log.w(TAG, appToken + " failed creating starting window", e); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1490 | } |
| 1491 | |
| 1492 | return null; |
| 1493 | } |
| 1494 | |
| 1495 | /** {@inheritDoc} */ |
| 1496 | public void removeStartingWindow(IBinder appToken, View window) { |
| 1497 | // RuntimeException e = new RuntimeException(); |
| 1498 | // Log.i(TAG, "remove " + appToken + " " + window, e); |
| 1499 | |
| 1500 | if (localLOGV) Log.v( |
| 1501 | TAG, "Removing starting window for " + appToken + ": " + window); |
| 1502 | |
| 1503 | if (window != null) { |
Dianne Hackborn | 5fd2169 | 2011-06-07 14:09:47 -0700 | [diff] [blame] | 1504 | WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1505 | wm.removeView(window); |
| 1506 | } |
| 1507 | } |
| 1508 | |
| 1509 | /** |
| 1510 | * Preflight adding a window to the system. |
| 1511 | * |
| 1512 | * Currently enforces that three window types are singletons: |
| 1513 | * <ul> |
| 1514 | * <li>STATUS_BAR_TYPE</li> |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1515 | * <li>KEYGUARD_TYPE</li> |
| 1516 | * </ul> |
| 1517 | * |
| 1518 | * @param win The window to be added |
| 1519 | * @param attrs Information about the window to be added |
| 1520 | * |
| 1521 | * @return If ok, WindowManagerImpl.ADD_OKAY. If too many singletons, WindowManagerImpl.ADD_MULTIPLE_SINGLETON |
| 1522 | */ |
| 1523 | public int prepareAddWindowLw(WindowState win, WindowManager.LayoutParams attrs) { |
| 1524 | switch (attrs.type) { |
| 1525 | case TYPE_STATUS_BAR: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1526 | mContext.enforceCallingOrSelfPermission( |
| 1527 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1528 | "PhoneWindowManager"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1529 | if (mStatusBar != null) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1530 | if (mStatusBar.isAlive()) { |
| 1531 | return WindowManagerImpl.ADD_MULTIPLE_SINGLETON; |
| 1532 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1533 | } |
| 1534 | mStatusBar = win; |
| 1535 | break; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1536 | case TYPE_NAVIGATION_BAR: |
| 1537 | mContext.enforceCallingOrSelfPermission( |
| 1538 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1539 | "PhoneWindowManager"); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1540 | if (mNavigationBar != null) { |
| 1541 | if (mNavigationBar.isAlive()) { |
| 1542 | return WindowManagerImpl.ADD_MULTIPLE_SINGLETON; |
| 1543 | } |
| 1544 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1545 | mNavigationBar = win; |
| 1546 | if (DEBUG_LAYOUT) Log.i(TAG, "NAVIGATION BAR: " + mNavigationBar); |
| 1547 | break; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1548 | case TYPE_STATUS_BAR_PANEL: |
Joe Onorato | 8bc6c51 | 2010-06-04 16:21:12 -0400 | [diff] [blame] | 1549 | mContext.enforceCallingOrSelfPermission( |
| 1550 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1551 | "PhoneWindowManager"); |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1552 | mStatusBarPanels.add(win); |
| 1553 | break; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 1554 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 1555 | mContext.enforceCallingOrSelfPermission( |
| 1556 | android.Manifest.permission.STATUS_BAR_SERVICE, |
| 1557 | "PhoneWindowManager"); |
| 1558 | mStatusBarPanels.add(win); |
| 1559 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1560 | case TYPE_KEYGUARD: |
| 1561 | if (mKeyguard != null) { |
| 1562 | return WindowManagerImpl.ADD_MULTIPLE_SINGLETON; |
| 1563 | } |
| 1564 | mKeyguard = win; |
| 1565 | break; |
| 1566 | } |
| 1567 | return WindowManagerImpl.ADD_OKAY; |
| 1568 | } |
| 1569 | |
| 1570 | /** {@inheritDoc} */ |
| 1571 | public void removeWindowLw(WindowState win) { |
| 1572 | if (mStatusBar == win) { |
| 1573 | mStatusBar = null; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1574 | } else if (mKeyguard == win) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1575 | mKeyguard = null; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 1576 | } else if (mNavigationBar == win) { |
| 1577 | mNavigationBar = null; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 1578 | } else { |
| 1579 | mStatusBarPanels.remove(win); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1580 | } |
| 1581 | } |
| 1582 | |
| 1583 | static final boolean PRINT_ANIM = false; |
| 1584 | |
| 1585 | /** {@inheritDoc} */ |
| 1586 | public int selectAnimationLw(WindowState win, int transit) { |
| 1587 | if (PRINT_ANIM) Log.i(TAG, "selectAnimation in " + win |
| 1588 | + ": transit=" + transit); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 1589 | if (win == mStatusBar) { |
| 1590 | if (transit == TRANSIT_EXIT || transit == TRANSIT_HIDE) { |
| 1591 | return R.anim.dock_top_exit; |
| 1592 | } else if (transit == TRANSIT_ENTER || transit == TRANSIT_SHOW) { |
| 1593 | return R.anim.dock_top_enter; |
| 1594 | } |
| 1595 | } else if (win == mNavigationBar) { |
| 1596 | // This can be on either the bottom or the right. |
| 1597 | if (mNavigationBarOnBottom) { |
| 1598 | if (transit == TRANSIT_EXIT || transit == TRANSIT_HIDE) { |
| 1599 | return R.anim.dock_bottom_exit; |
| 1600 | } else if (transit == TRANSIT_ENTER || transit == TRANSIT_SHOW) { |
| 1601 | return R.anim.dock_bottom_enter; |
| 1602 | } |
| 1603 | } else { |
| 1604 | if (transit == TRANSIT_EXIT || transit == TRANSIT_HIDE) { |
| 1605 | return R.anim.dock_right_exit; |
| 1606 | } else if (transit == TRANSIT_ENTER || transit == TRANSIT_SHOW) { |
| 1607 | return R.anim.dock_right_enter; |
| 1608 | } |
| 1609 | } |
| 1610 | } if (transit == TRANSIT_PREVIEW_DONE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1611 | if (win.hasAppShownWindows()) { |
| 1612 | if (PRINT_ANIM) Log.i(TAG, "**** STARTING EXIT"); |
| 1613 | return com.android.internal.R.anim.app_starting_exit; |
| 1614 | } |
| 1615 | } |
| 1616 | |
| 1617 | return 0; |
| 1618 | } |
| 1619 | |
Dianne Hackborn | 01ad2f4 | 2009-09-24 19:24:56 -0700 | [diff] [blame] | 1620 | public Animation createForceHideEnterAnimation() { |
| 1621 | return AnimationUtils.loadAnimation(mContext, |
| 1622 | com.android.internal.R.anim.lock_screen_behind_enter); |
| 1623 | } |
| 1624 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1625 | static ITelephony getTelephonyService() { |
Mike Lockwood | f5f4ec9 | 2011-11-08 14:05:31 -0800 | [diff] [blame] | 1626 | return ITelephony.Stub.asInterface( |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1627 | ServiceManager.checkService(Context.TELEPHONY_SERVICE)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1628 | } |
| 1629 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 1630 | static IAudioService getAudioService() { |
| 1631 | IAudioService audioService = IAudioService.Stub.asInterface( |
| 1632 | ServiceManager.checkService(Context.AUDIO_SERVICE)); |
| 1633 | if (audioService == null) { |
| 1634 | Log.w(TAG, "Unable to find IAudioService interface."); |
| 1635 | } |
| 1636 | return audioService; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1637 | } |
| 1638 | |
| 1639 | boolean keyguardOn() { |
| 1640 | return keyguardIsShowingTq() || inKeyguardRestrictedKeyInputMode(); |
| 1641 | } |
| 1642 | |
| 1643 | private static final int[] WINDOW_TYPES_WHERE_HOME_DOESNT_WORK = { |
| 1644 | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, |
| 1645 | WindowManager.LayoutParams.TYPE_SYSTEM_ERROR, |
| 1646 | }; |
| 1647 | |
| 1648 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1649 | @Override |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1650 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1651 | final boolean keyguardOn = keyguardOn(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1652 | final int keyCode = event.getKeyCode(); |
| 1653 | final int repeatCount = event.getRepeatCount(); |
| 1654 | final int metaState = event.getMetaState(); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1655 | final int flags = event.getFlags(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1656 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 1657 | final boolean canceled = event.isCanceled(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1658 | |
| 1659 | if (false) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1660 | Log.d(TAG, "interceptKeyTi keyCode=" + keyCode + " down=" + down + " repeatCount=" |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1661 | + repeatCount + " keyguardOn=" + keyguardOn + " mHomePressed=" + mHomePressed); |
| 1662 | } |
| 1663 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1664 | // If we think we might have a volume down & power key chord on the way |
| 1665 | // but we're not sure, then tell the dispatcher to wait a little while and |
| 1666 | // try again later before dispatching. |
Christopher Tate | e90585f | 2012-03-05 18:56:25 -0800 | [diff] [blame] | 1667 | if (mScreenshotChordEnabled && (flags & KeyEvent.FLAG_FALLBACK) == 0) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1668 | if (mVolumeDownKeyTriggered && !mPowerKeyTriggered) { |
| 1669 | final long now = SystemClock.uptimeMillis(); |
| 1670 | final long timeoutTime = mVolumeDownKeyTime + SCREENSHOT_CHORD_DEBOUNCE_DELAY_MILLIS; |
| 1671 | if (now < timeoutTime) { |
| 1672 | return timeoutTime - now; |
| 1673 | } |
| 1674 | } |
| 1675 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN |
| 1676 | && mVolumeDownKeyConsumedByScreenshotChord) { |
| 1677 | if (!down) { |
| 1678 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 1679 | } |
| 1680 | return -1; |
| 1681 | } |
| 1682 | } |
| 1683 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1684 | // First we always handle the home key here, so applications |
| 1685 | // can never break it, although if keyguard is on, we do let |
| 1686 | // it handle it, because that gives us the correct 5 second |
| 1687 | // timeout. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1688 | if (keyCode == KeyEvent.KEYCODE_HOME) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1689 | |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1690 | // If we have released the home key, and didn't do anything else |
| 1691 | // while it was pressed, then it is time to go home! |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1692 | if (!down) { |
| 1693 | final boolean homeWasLongPressed = mHomeLongPressed; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1694 | mHomePressed = false; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1695 | mHomeLongPressed = false; |
| 1696 | if (!homeWasLongPressed) { |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1697 | try { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1698 | mStatusBarService.cancelPreloadRecentApps(); |
| 1699 | } catch (RemoteException e) { |
| 1700 | Slog.e(TAG, "RemoteException when showing recent apps", e); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1701 | } |
| 1702 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1703 | mHomePressed = false; |
| 1704 | if (!canceled) { |
| 1705 | // If an incoming call is ringing, HOME is totally disabled. |
| 1706 | // (The user is already on the InCallScreen at this point, |
| 1707 | // and his ONLY options are to answer or reject the call.) |
| 1708 | boolean incomingRinging = false; |
| 1709 | try { |
| 1710 | ITelephony telephonyService = getTelephonyService(); |
| 1711 | if (telephonyService != null) { |
| 1712 | incomingRinging = telephonyService.isRinging(); |
| 1713 | } |
| 1714 | } catch (RemoteException ex) { |
| 1715 | Log.w(TAG, "RemoteException from getPhoneInterface()", ex); |
| 1716 | } |
| 1717 | |
| 1718 | if (incomingRinging) { |
| 1719 | Log.i(TAG, "Ignoring HOME; there's a ringing incoming call."); |
| 1720 | } else { |
| 1721 | launchHomeFromHotKey(); |
| 1722 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1723 | } else { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1724 | Log.i(TAG, "Ignoring HOME; event canceled."); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1725 | } |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1726 | return -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1727 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1728 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1729 | |
| 1730 | // If a system window has focus, then it doesn't make sense |
| 1731 | // right now to interact with applications. |
| 1732 | WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null; |
| 1733 | if (attrs != null) { |
| 1734 | final int type = attrs.type; |
| 1735 | if (type == WindowManager.LayoutParams.TYPE_KEYGUARD |
| 1736 | || type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG) { |
| 1737 | // the "app" is keyguard, so give it the key |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1738 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1739 | } |
| 1740 | final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length; |
| 1741 | for (int i=0; i<typeCount; i++) { |
| 1742 | if (type == WINDOW_TYPES_WHERE_HOME_DOESNT_WORK[i]) { |
| 1743 | // 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] | 1744 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1745 | } |
| 1746 | } |
| 1747 | } |
Jeff Brown | 98392ef | 2011-09-12 18:24:59 -0700 | [diff] [blame] | 1748 | if (down) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1749 | if (!mHomePressed) { |
| 1750 | try { |
| 1751 | mStatusBarService.preloadRecentApps(); |
| 1752 | } catch (RemoteException e) { |
| 1753 | Slog.e(TAG, "RemoteException when preloading recent apps", e); |
| 1754 | } |
| 1755 | } |
Jeff Brown | 98392ef | 2011-09-12 18:24:59 -0700 | [diff] [blame] | 1756 | if (repeatCount == 0) { |
| 1757 | mHomePressed = true; |
| 1758 | } else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) { |
| 1759 | if (!keyguardOn) { |
| 1760 | handleLongPressOnHome(); |
| 1761 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1762 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1763 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1764 | return -1; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1765 | } else if (keyCode == KeyEvent.KEYCODE_MENU) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1766 | // Hijack modified menu keys for debugging features |
| 1767 | final int chordBug = KeyEvent.META_SHIFT_ON; |
| 1768 | |
| 1769 | if (down && repeatCount == 0) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1770 | if (mEnableShiftMenuBugReports && (metaState & chordBug) == chordBug) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1771 | Intent intent = new Intent(Intent.ACTION_BUG_REPORT); |
| 1772 | mContext.sendOrderedBroadcast(intent, null); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1773 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1774 | } else if (SHOW_PROCESSES_ON_ALT_MENU && |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1775 | (metaState & KeyEvent.META_ALT_ON) == KeyEvent.META_ALT_ON) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1776 | Intent service = new Intent(); |
| 1777 | service.setClassName(mContext, "com.android.server.LoadAverageService"); |
| 1778 | ContentResolver res = mContext.getContentResolver(); |
| 1779 | boolean shown = Settings.System.getInt( |
| 1780 | res, Settings.System.SHOW_PROCESSES, 0) != 0; |
| 1781 | if (!shown) { |
| 1782 | mContext.startService(service); |
| 1783 | } else { |
| 1784 | mContext.stopService(service); |
| 1785 | } |
| 1786 | Settings.System.putInt( |
| 1787 | res, Settings.System.SHOW_PROCESSES, shown ? 0 : 1); |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1788 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1789 | } |
| 1790 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1791 | } else if (keyCode == KeyEvent.KEYCODE_SEARCH) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1792 | if (down) { |
| 1793 | if (repeatCount == 0) { |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1794 | mShortcutKeyPressed = keyCode; |
| 1795 | mConsumeShortcutKeyUp = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1796 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1797 | } else if (keyCode == mShortcutKeyPressed) { |
| 1798 | mShortcutKeyPressed = -1; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1799 | if (mConsumeShortcutKeyUp) { |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1800 | mConsumeShortcutKeyUp = false; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1801 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1802 | } |
| 1803 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1804 | return 0; |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1805 | } else if (keyCode == KeyEvent.KEYCODE_APP_SWITCH) { |
Jeff Brown | da3d5a9 | 2011-03-29 15:11:34 -0700 | [diff] [blame] | 1806 | if (down && repeatCount == 0) { |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 1807 | showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_SHOW_OR_DISMISS); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1808 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1809 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1810 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 1811 | |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 1812 | // Shortcuts are invoked through Search+key, so intercept those here |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 1813 | // Any printing key that is chorded with Search should be consumed |
| 1814 | // even if no shortcut was invoked. This prevents text from being |
| 1815 | // inadvertently inserted when using a keyboard that has built-in macro |
| 1816 | // shortcut keys (that emit Search+x) and some of them are not registered. |
| 1817 | if (mShortcutKeyPressed != -1) { |
| 1818 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
| 1819 | if (kcm.isPrintingKey(keyCode)) { |
| 1820 | mConsumeShortcutKeyUp = true; |
| 1821 | if (down && repeatCount == 0 && !keyguardOn) { |
| 1822 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, metaState); |
| 1823 | if (shortcutIntent != null) { |
| 1824 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
Jeff Brown | f0a3cc5 | 2011-01-26 18:42:46 -0800 | [diff] [blame] | 1825 | try { |
| 1826 | mContext.startActivity(shortcutIntent); |
| 1827 | } catch (ActivityNotFoundException ex) { |
| 1828 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 1829 | + "the activity to which it is registered was not found: " |
| 1830 | + KeyEvent.keyCodeToString(mShortcutKeyPressed) |
| 1831 | + "+" + KeyEvent.keyCodeToString(keyCode), ex); |
| 1832 | } |
Jeff Brown | caab4d0 | 2010-12-09 22:13:41 -0800 | [diff] [blame] | 1833 | } else { |
| 1834 | Slog.i(TAG, "Dropping unregistered shortcut key combination: " |
| 1835 | + KeyEvent.keyCodeToString(mShortcutKeyPressed) |
| 1836 | + "+" + KeyEvent.keyCodeToString(keyCode)); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1837 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1838 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1839 | return -1; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1840 | } |
| 1841 | } |
| 1842 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 1843 | // Invoke shortcuts using Meta. |
| 1844 | if (down && repeatCount == 0 |
| 1845 | && (metaState & KeyEvent.META_META_ON) != 0) { |
| 1846 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
| 1847 | Intent shortcutIntent = mShortcutManager.getIntent(kcm, keyCode, |
| 1848 | metaState & ~(KeyEvent.META_META_ON |
| 1849 | | KeyEvent.META_META_LEFT_ON | KeyEvent.META_META_RIGHT_ON)); |
| 1850 | if (shortcutIntent != null) { |
| 1851 | shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 1852 | try { |
| 1853 | mContext.startActivity(shortcutIntent); |
| 1854 | } catch (ActivityNotFoundException ex) { |
| 1855 | Slog.w(TAG, "Dropping shortcut key combination because " |
| 1856 | + "the activity to which it is registered was not found: " |
| 1857 | + "META+" + KeyEvent.keyCodeToString(keyCode), ex); |
| 1858 | } |
| 1859 | return -1; |
| 1860 | } |
| 1861 | } |
| 1862 | |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1863 | // Handle application launch keys. |
| 1864 | if (down && repeatCount == 0) { |
| 1865 | String category = sApplicationLaunchKeyCategories.get(keyCode); |
| 1866 | if (category != null) { |
Dianne Hackborn | f5b8671 | 2011-12-05 17:42:41 -0800 | [diff] [blame] | 1867 | Intent intent = Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, category); |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1868 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
| 1869 | try { |
| 1870 | mContext.startActivity(intent); |
| 1871 | } catch (ActivityNotFoundException ex) { |
| 1872 | Slog.w(TAG, "Dropping application launch key because " |
| 1873 | + "the activity to which it is registered was not found: " |
| 1874 | + "keyCode=" + keyCode + ", category=" + category, ex); |
| 1875 | } |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 1876 | return -1; |
Jeff Brown | 6651a63 | 2011-11-28 12:59:11 -0800 | [diff] [blame] | 1877 | } |
| 1878 | } |
| 1879 | |
Jeff Brown | 68b909d | 2011-12-07 16:36:01 -0800 | [diff] [blame] | 1880 | // Display task switcher for ALT-TAB or Meta-TAB. |
| 1881 | if (down && repeatCount == 0 && keyCode == KeyEvent.KEYCODE_TAB) { |
| 1882 | if (mRecentAppsDialogHeldModifiers == 0) { |
| 1883 | final int shiftlessModifiers = event.getModifiers() & ~KeyEvent.META_SHIFT_MASK; |
| 1884 | if (KeyEvent.metaStateHasModifiers(shiftlessModifiers, KeyEvent.META_ALT_ON) |
| 1885 | || KeyEvent.metaStateHasModifiers( |
| 1886 | shiftlessModifiers, KeyEvent.META_META_ON)) { |
| 1887 | mRecentAppsDialogHeldModifiers = shiftlessModifiers; |
| 1888 | showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_EXIT_TOUCH_MODE_AND_SHOW); |
| 1889 | return -1; |
| 1890 | } |
| 1891 | } |
| 1892 | } else if (!down && mRecentAppsDialogHeldModifiers != 0 |
| 1893 | && (metaState & mRecentAppsDialogHeldModifiers) == 0) { |
| 1894 | mRecentAppsDialogHeldModifiers = 0; |
| 1895 | showOrHideRecentAppsDialog(RECENT_APPS_BEHAVIOR_DISMISS_AND_SWITCH); |
| 1896 | } |
| 1897 | |
| 1898 | // Let the application handle the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1899 | return 0; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1900 | } |
| 1901 | |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1902 | /** {@inheritDoc} */ |
| 1903 | @Override |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1904 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags) { |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 1905 | // Note: This method is only called if the initial down was unhandled. |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1906 | if (DEBUG_FALLBACK) { |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1907 | Slog.d(TAG, "Unhandled key: win=" + win + ", action=" + event.getAction() |
| 1908 | + ", flags=" + event.getFlags() |
| 1909 | + ", keyCode=" + event.getKeyCode() |
| 1910 | + ", scanCode=" + event.getScanCode() |
| 1911 | + ", metaState=" + event.getMetaState() |
| 1912 | + ", repeatCount=" + event.getRepeatCount() |
| 1913 | + ", policyFlags=" + policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1914 | } |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1915 | |
| 1916 | if ((event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 1917 | final KeyCharacterMap kcm = event.getKeyCharacterMap(); |
Jeff Brown | c1fb48d | 2010-12-08 16:52:09 -0800 | [diff] [blame] | 1918 | final int keyCode = event.getKeyCode(); |
| 1919 | final int metaState = event.getMetaState(); |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1920 | |
Jeff Brown | 5487500 | 2011-04-06 15:33:01 -0700 | [diff] [blame] | 1921 | // Check for fallback actions specified by the key character map. |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1922 | if (getFallbackAction(kcm, keyCode, metaState, mFallbackAction)) { |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1923 | if (DEBUG_FALLBACK) { |
| 1924 | Slog.d(TAG, "Fallback: keyCode=" + mFallbackAction.keyCode |
| 1925 | + " metaState=" + Integer.toHexString(mFallbackAction.metaState)); |
| 1926 | } |
| 1927 | |
| 1928 | int flags = event.getFlags() | KeyEvent.FLAG_FALLBACK; |
| 1929 | KeyEvent fallbackEvent = KeyEvent.obtain( |
| 1930 | event.getDownTime(), event.getEventTime(), |
| 1931 | event.getAction(), mFallbackAction.keyCode, |
| 1932 | event.getRepeatCount(), mFallbackAction.metaState, |
| 1933 | event.getDeviceId(), event.getScanCode(), |
| 1934 | flags, event.getSource(), null); |
| 1935 | int actions = interceptKeyBeforeQueueing(fallbackEvent, policyFlags, true); |
| 1936 | if ((actions & ACTION_PASS_TO_USER) != 0) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1937 | long delayMillis = interceptKeyBeforeDispatching( |
| 1938 | win, fallbackEvent, policyFlags); |
| 1939 | if (delayMillis == 0) { |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1940 | if (DEBUG_FALLBACK) { |
| 1941 | Slog.d(TAG, "Performing fallback."); |
| 1942 | } |
| 1943 | return fallbackEvent; |
| 1944 | } |
| 1945 | } |
| 1946 | fallbackEvent.recycle(); |
| 1947 | } |
| 1948 | } |
| 1949 | |
| 1950 | if (DEBUG_FALLBACK) { |
| 1951 | Slog.d(TAG, "No fallback."); |
| 1952 | } |
| 1953 | return null; |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1954 | } |
| 1955 | |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1956 | private boolean getFallbackAction(KeyCharacterMap kcm, int keyCode, int metaState, |
| 1957 | FallbackAction outFallbackAction) { |
| 1958 | // Consult the key character map for specific fallback actions. |
| 1959 | // For example, map NUMPAD_1 to MOVE_HOME when NUMLOCK is not pressed. |
Jeff Brown | cc0c159 | 2011-02-19 05:07:28 -0800 | [diff] [blame] | 1960 | return kcm.getFallbackAction(keyCode, metaState, outFallbackAction); |
Jeff Brown | 6f2fba4 | 2011-02-19 01:08:02 -0800 | [diff] [blame] | 1961 | } |
| 1962 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1963 | /** |
| 1964 | * A home key -> launch home action was detected. Take the appropriate action |
| 1965 | * given the situation with the keyguard. |
| 1966 | */ |
| 1967 | void launchHomeFromHotKey() { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 1968 | if (mKeyguardMediator != null && mKeyguardMediator.isShowingAndNotHidden()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1969 | // don't launch home if keyguard showing |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 1970 | } else if (!mHideLockScreen && mKeyguardMediator.isInputRestricted()) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1971 | // when in keyguard restricted mode, must first verify unlock |
| 1972 | // before launching home |
| 1973 | mKeyguardMediator.verifyUnlock(new OnKeyguardExitResult() { |
| 1974 | public void onKeyguardExitResult(boolean success) { |
| 1975 | if (success) { |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 1976 | try { |
| 1977 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 1978 | } catch (RemoteException e) { |
| 1979 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 1980 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 1981 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1982 | } |
| 1983 | } |
| 1984 | }); |
| 1985 | } else { |
| 1986 | // no keyguard stuff to worry about, just launch home! |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 1987 | try { |
| 1988 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 1989 | } catch (RemoteException e) { |
| 1990 | } |
Joe Onorato | f275f0c | 2009-11-24 16:11:13 -0500 | [diff] [blame] | 1991 | sendCloseSystemWindows(SYSTEM_DIALOG_REASON_HOME_KEY); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 1992 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1993 | } |
| 1994 | } |
| 1995 | |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 1996 | /** |
| 1997 | * A delayed callback use to determine when it is okay to re-allow applications |
| 1998 | * to use certain system UI flags. This is used to prevent applications from |
| 1999 | * spamming system UI changes that prevent the navigation bar from being shown. |
| 2000 | */ |
| 2001 | final Runnable mAllowSystemUiDelay = new Runnable() { |
| 2002 | @Override public void run() { |
| 2003 | } |
| 2004 | }; |
| 2005 | |
| 2006 | /** |
| 2007 | * Input handler used while nav bar is hidden. Captures any touch on the screen, |
| 2008 | * to determine when the nav bar should be shown and prevent applications from |
| 2009 | * receiving those touches. |
| 2010 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2011 | final class HideNavInputEventReceiver extends InputEventReceiver { |
| 2012 | public HideNavInputEventReceiver(InputChannel inputChannel, Looper looper) { |
| 2013 | super(inputChannel, looper); |
| 2014 | } |
| 2015 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2016 | @Override |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2017 | public void onInputEvent(InputEvent event) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2018 | boolean handled = false; |
| 2019 | try { |
Jeff Brown | 4952dfd | 2011-11-30 19:23:22 -0800 | [diff] [blame] | 2020 | if (event instanceof MotionEvent |
| 2021 | && (event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 2022 | final MotionEvent motionEvent = (MotionEvent)event; |
| 2023 | if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2024 | // When the user taps down, we re-show the nav bar. |
| 2025 | boolean changed = false; |
| 2026 | synchronized (mLock) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2027 | // Any user activity always causes us to show the |
| 2028 | // navigation controls, if they had been hidden. |
| 2029 | // We also clear the low profile and only content |
| 2030 | // flags so that tapping on the screen will atomically |
| 2031 | // restore all currently hidden screen decorations. |
| 2032 | int newVal = mResettingSystemUiFlags | |
| 2033 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | |
| 2034 | View.SYSTEM_UI_FLAG_LOW_PROFILE | |
| 2035 | View.SYSTEM_UI_FLAG_FULLSCREEN; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2036 | if (mResettingSystemUiFlags != newVal) { |
| 2037 | mResettingSystemUiFlags = newVal; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2038 | changed = true; |
| 2039 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2040 | // We don't allow the system's nav bar to be hidden |
| 2041 | // again for 1 second, to prevent applications from |
| 2042 | // spamming us and keeping it from being shown. |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2043 | newVal = mForceClearedSystemUiFlags | |
| 2044 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2045 | if (mForceClearedSystemUiFlags != newVal) { |
| 2046 | mForceClearedSystemUiFlags = newVal; |
| 2047 | changed = true; |
| 2048 | mHandler.postDelayed(new Runnable() { |
| 2049 | @Override public void run() { |
| 2050 | synchronized (mLock) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2051 | // Clear flags. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2052 | mForceClearedSystemUiFlags &= |
| 2053 | ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; |
| 2054 | } |
| 2055 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 2056 | } |
| 2057 | }, 1000); |
| 2058 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2059 | } |
| 2060 | if (changed) { |
| 2061 | mWindowManagerFuncs.reevaluateStatusBarVisibility(); |
| 2062 | } |
| 2063 | } |
| 2064 | } |
| 2065 | } finally { |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2066 | finishInputEvent(event, handled); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2067 | } |
| 2068 | } |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2069 | } |
| 2070 | final InputEventReceiver.Factory mHideNavInputEventReceiverFactory = |
| 2071 | new InputEventReceiver.Factory() { |
| 2072 | @Override |
| 2073 | public InputEventReceiver createInputEventReceiver( |
| 2074 | InputChannel inputChannel, Looper looper) { |
| 2075 | return new HideNavInputEventReceiver(inputChannel, looper); |
| 2076 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2077 | }; |
| 2078 | |
| 2079 | @Override |
| 2080 | public int adjustSystemUiVisibilityLw(int visibility) { |
| 2081 | // Reset any bits in mForceClearingStatusBarVisibility that |
| 2082 | // are now clear. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2083 | mResettingSystemUiFlags &= visibility; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2084 | // Clear any bits in the new visibility that are currently being |
| 2085 | // force cleared, before reporting it. |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2086 | return visibility & ~mResettingSystemUiFlags |
| 2087 | & ~mForceClearedSystemUiFlags; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2088 | } |
| 2089 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2090 | public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset) { |
| 2091 | final int fl = attrs.flags; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2092 | |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 2093 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_FULLSCREEN | FLAG_LAYOUT_INSET_DECOR)) |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2094 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2095 | int availRight, availBottom; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2096 | if (mCanHideNavigationBar && |
| 2097 | (attrs.systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2098 | availRight = mUnrestrictedScreenLeft + mUnrestrictedScreenWidth; |
| 2099 | availBottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight; |
| 2100 | } else { |
| 2101 | availRight = mRestrictedScreenLeft + mRestrictedScreenWidth; |
| 2102 | availBottom = mRestrictedScreenTop + mRestrictedScreenHeight; |
| 2103 | } |
| 2104 | if ((attrs.systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2105 | contentInset.set(mStableLeft, mStableTop, |
| 2106 | availRight - mStableRight, availBottom - mStableBottom); |
| 2107 | } else if ((attrs.systemUiVisibility & (View.SYSTEM_UI_FLAG_FULLSCREEN |
| 2108 | | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)) == 0) { |
| 2109 | contentInset.set(mCurLeft, mCurTop, |
| 2110 | availRight - mCurRight, availBottom - mCurBottom); |
| 2111 | } else { |
| 2112 | contentInset.set(mCurLeft, mCurTop, |
| 2113 | availRight - mCurRight, availBottom - mCurBottom); |
| 2114 | } |
| 2115 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2116 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2117 | contentInset.setEmpty(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2118 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2119 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2120 | /** {@inheritDoc} */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 2121 | public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotation) { |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2122 | mUnrestrictedScreenLeft = mUnrestrictedScreenTop = 0; |
| 2123 | mUnrestrictedScreenWidth = displayWidth; |
| 2124 | mUnrestrictedScreenHeight = displayHeight; |
| 2125 | mRestrictedScreenLeft = mRestrictedScreenTop = 0; |
| 2126 | mRestrictedScreenWidth = displayWidth; |
| 2127 | mRestrictedScreenHeight = displayHeight; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2128 | mDockLeft = mContentLeft = mStableLeft = mCurLeft = 0; |
| 2129 | mDockTop = mContentTop = mStableTop = mCurTop = 0; |
| 2130 | mDockRight = mContentRight = mStableRight = mCurRight = displayWidth; |
| 2131 | mDockBottom = mContentBottom = mStableBottom = mCurBottom = displayHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2132 | mDockLayer = 0x10000000; |
| 2133 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2134 | // start with the current dock rect, which will be (0,0,displayWidth,displayHeight) |
| 2135 | final Rect pf = mTmpParentFrame; |
| 2136 | final Rect df = mTmpDisplayFrame; |
| 2137 | final Rect vf = mTmpVisibleFrame; |
| 2138 | pf.left = df.left = vf.left = mDockLeft; |
| 2139 | pf.top = df.top = vf.top = mDockTop; |
| 2140 | pf.right = df.right = vf.right = mDockRight; |
| 2141 | pf.bottom = df.bottom = vf.bottom = mDockBottom; |
| 2142 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2143 | // For purposes of putting out fake window up to steal focus, we will |
| 2144 | // drive nav being hidden only by whether it is requested. |
| 2145 | boolean navVisible = (mLastSystemUiFlags&View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0; |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2146 | |
| 2147 | // When the navigation bar isn't visible, we put up a fake |
| 2148 | // input window to catch all touch events. This way we can |
| 2149 | // detect when the user presses anywhere to bring back the nav |
| 2150 | // bar and ensure the application doesn't see the event. |
| 2151 | if (navVisible) { |
| 2152 | if (mHideNavFakeWindow != null) { |
| 2153 | mHideNavFakeWindow.dismiss(); |
| 2154 | mHideNavFakeWindow = null; |
| 2155 | } |
| 2156 | } else if (mHideNavFakeWindow == null) { |
| 2157 | mHideNavFakeWindow = mWindowManagerFuncs.addFakeWindow( |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 2158 | mHandler.getLooper(), mHideNavInputEventReceiverFactory, |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 2159 | "hidden nav", WindowManager.LayoutParams.TYPE_HIDDEN_NAV_CONSUMER, |
| 2160 | 0, false, false, true); |
| 2161 | } |
| 2162 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2163 | // For purposes of positioning and showing the nav bar, if we have |
| 2164 | // decided that it can't be hidden (because of the screen aspect ratio), |
| 2165 | // then take that into account. |
| 2166 | navVisible |= !mCanHideNavigationBar; |
| 2167 | |
| 2168 | if (mNavigationBar != null) { |
| 2169 | // Force the navigation bar to its appropriate place and |
| 2170 | // size. We need to do this directly, instead of relying on |
| 2171 | // it to bubble up from the nav bar, because this needs to |
| 2172 | // change atomically with screen rotations. |
| 2173 | mNavigationBarOnBottom = !mHasNavigationBar || displayWidth < displayHeight; |
| 2174 | if (mNavigationBarOnBottom) { |
| 2175 | // It's a system nav bar or a portrait screen; nav bar goes on bottom. |
| 2176 | int top = displayHeight - mNavigationBarHeight; |
| 2177 | if (mHdmiPlugged) { |
| 2178 | if (top > mExternalDisplayHeight) { |
| 2179 | top = mExternalDisplayHeight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2180 | } |
| 2181 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2182 | mTmpNavigationFrame.set(0, top, displayWidth, displayHeight); |
| 2183 | mStableBottom = mTmpNavigationFrame.top; |
| 2184 | if (navVisible) { |
| 2185 | mNavigationBar.showLw(true); |
| 2186 | mDockBottom = mTmpNavigationFrame.top; |
| 2187 | mRestrictedScreenHeight = mDockBottom - mDockTop; |
| 2188 | } else { |
| 2189 | // We currently want to hide the navigation UI. |
| 2190 | mNavigationBar.hideLw(true); |
| 2191 | } |
| 2192 | } else { |
| 2193 | // Landscape screen; nav bar goes to the right. |
| 2194 | int left = displayWidth - mNavigationBarWidth; |
| 2195 | if (mHdmiPlugged) { |
| 2196 | if (left > mExternalDisplayWidth) { |
| 2197 | left = mExternalDisplayWidth; |
| 2198 | } |
| 2199 | } |
| 2200 | mTmpNavigationFrame.set(left, 0, displayWidth, displayHeight); |
| 2201 | mStableRight = mTmpNavigationFrame.left; |
| 2202 | if (navVisible) { |
| 2203 | mNavigationBar.showLw(true); |
| 2204 | mDockRight = mTmpNavigationFrame.left; |
| 2205 | mRestrictedScreenWidth = mDockRight - mDockLeft; |
| 2206 | } else { |
| 2207 | // We currently want to hide the navigation UI. |
| 2208 | mNavigationBar.hideLw(true); |
| 2209 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2210 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2211 | // Make sure the content and current rectangles are updated to |
| 2212 | // account for the restrictions from the navigation bar. |
| 2213 | mContentTop = mCurTop = mDockTop; |
| 2214 | mContentBottom = mCurBottom = mDockBottom; |
| 2215 | mContentLeft = mCurLeft = mDockLeft; |
| 2216 | mContentRight = mCurRight = mDockRight; |
| 2217 | // And compute the final frame. |
| 2218 | mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame, |
| 2219 | mTmpNavigationFrame, mTmpNavigationFrame); |
| 2220 | if (DEBUG_LAYOUT) Log.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame); |
| 2221 | } |
| 2222 | if (DEBUG_LAYOUT) Log.i(TAG, String.format("mDock rect: (%d,%d - %d,%d)", |
| 2223 | mDockLeft, mDockTop, mDockRight, mDockBottom)); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2224 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2225 | // decide where the status bar goes ahead of time |
| 2226 | if (mStatusBar != null) { |
| 2227 | // apply any navigation bar insets |
Dianne Hackborn | 9801435 | 2012-04-05 18:31:41 -0700 | [diff] [blame] | 2228 | pf.left = df.left = mUnrestrictedScreenLeft; |
| 2229 | pf.top = df.top = mUnrestrictedScreenTop; |
| 2230 | pf.right = df.right = mUnrestrictedScreenWidth - mUnrestrictedScreenLeft; |
| 2231 | pf.bottom = df.bottom = mUnrestrictedScreenHeight - mUnrestrictedScreenTop; |
| 2232 | vf.left = mStableLeft; |
| 2233 | vf.top = mStableTop; |
| 2234 | vf.right = mStableRight; |
| 2235 | vf.bottom = mStableBottom; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2236 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2237 | mStatusBar.computeFrameLw(pf, df, vf, vf); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2238 | final Rect r = mStatusBar.getFrameLw(); |
| 2239 | |
| 2240 | // Compute the stable dimensions whether or not the status bar is hidden. |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2241 | if (mDockTop == r.top) mStableTop = r.bottom; |
| 2242 | else if (mDockBottom == r.bottom) mStableBottom = r.top; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2243 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2244 | // If the status bar is hidden, we don't want to cause |
| 2245 | // windows behind it to scroll. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2246 | if (mStatusBar.isVisibleLw()) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2247 | // Status bar may go away, so the screen area it occupies |
| 2248 | // is available to apps but just covering them when the |
| 2249 | // status bar is visible. |
| 2250 | if (mDockTop == r.top) mDockTop = r.bottom; |
| 2251 | else if (mDockBottom == r.bottom) mDockBottom = r.top; |
| 2252 | |
| 2253 | mContentTop = mCurTop = mDockTop; |
| 2254 | mContentBottom = mCurBottom = mDockBottom; |
| 2255 | mContentLeft = mCurLeft = mDockLeft; |
| 2256 | mContentRight = mCurRight = mDockRight; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2257 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2258 | if (DEBUG_LAYOUT) Log.v(TAG, "Status bar: " + |
| 2259 | String.format( |
| 2260 | "dock=[%d,%d][%d,%d] content=[%d,%d][%d,%d] cur=[%d,%d][%d,%d]", |
| 2261 | mDockLeft, mDockTop, mDockRight, mDockBottom, |
| 2262 | mContentLeft, mContentTop, mContentRight, mContentBottom, |
| 2263 | mCurLeft, mCurTop, mCurRight, mCurBottom)); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2264 | } |
| 2265 | } |
| 2266 | } |
| 2267 | |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2268 | void setAttachedWindowFrames(WindowState win, int fl, int adjust, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2269 | WindowState attached, boolean insetDecors, Rect pf, Rect df, Rect cf, Rect vf) { |
| 2270 | if (win.getSurfaceLayer() > mDockLayer && attached.getSurfaceLayer() < mDockLayer) { |
| 2271 | // Here's a special case: if this attached window is a panel that is |
| 2272 | // above the dock window, and the window it is attached to is below |
| 2273 | // the dock window, then the frames we computed for the window it is |
| 2274 | // attached to can not be used because the dock is effectively part |
| 2275 | // of the underlying window and the attached window is floating on top |
| 2276 | // of the whole thing. So, we ignore the attached window and explicitly |
| 2277 | // compute the frames that would be appropriate without the dock. |
| 2278 | df.left = cf.left = vf.left = mDockLeft; |
| 2279 | df.top = cf.top = vf.top = mDockTop; |
| 2280 | df.right = cf.right = vf.right = mDockRight; |
| 2281 | df.bottom = cf.bottom = vf.bottom = mDockBottom; |
| 2282 | } else { |
| 2283 | // The effective display frame of the attached window depends on |
| 2284 | // whether it is taking care of insetting its content. If not, |
| 2285 | // we need to use the parent's content frame so that the entire |
| 2286 | // window is positioned within that content. Otherwise we can use |
| 2287 | // the display frame and let the attached window take care of |
| 2288 | // positioning its content appropriately. |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2289 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2290 | cf.set(attached.getDisplayFrameLw()); |
| 2291 | } else { |
| 2292 | // If the window is resizing, then we want to base the content |
| 2293 | // frame on our attached content frame to resize... however, |
| 2294 | // things can be tricky if the attached window is NOT in resize |
| 2295 | // mode, in which case its content frame will be larger. |
| 2296 | // Ungh. So to deal with that, make sure the content frame |
| 2297 | // we end up using is not covering the IM dock. |
| 2298 | cf.set(attached.getContentFrameLw()); |
| 2299 | if (attached.getSurfaceLayer() < mDockLayer) { |
| 2300 | if (cf.left < mContentLeft) cf.left = mContentLeft; |
| 2301 | if (cf.top < mContentTop) cf.top = mContentTop; |
| 2302 | if (cf.right > mContentRight) cf.right = mContentRight; |
| 2303 | if (cf.bottom > mContentBottom) cf.bottom = mContentBottom; |
| 2304 | } |
| 2305 | } |
| 2306 | df.set(insetDecors ? attached.getDisplayFrameLw() : cf); |
| 2307 | vf.set(attached.getVisibleFrameLw()); |
| 2308 | } |
| 2309 | // The LAYOUT_IN_SCREEN flag is used to determine whether the attached |
| 2310 | // window should be positioned relative to its parent or the entire |
| 2311 | // screen. |
| 2312 | pf.set((fl & FLAG_LAYOUT_IN_SCREEN) == 0 |
| 2313 | ? attached.getFrameLw() : df); |
| 2314 | } |
| 2315 | |
| 2316 | /** {@inheritDoc} */ |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 2317 | public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs, |
| 2318 | WindowState attached) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2319 | // we've already done the status bar |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 2320 | if (win == mStatusBar || win == mNavigationBar) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2321 | return; |
| 2322 | } |
| 2323 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2324 | final int fl = attrs.flags; |
| 2325 | final int sim = attrs.softInputMode; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2326 | final int sysUiFl = win.getSystemUiVisibility(); |
| 2327 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2328 | final Rect pf = mTmpParentFrame; |
| 2329 | final Rect df = mTmpDisplayFrame; |
| 2330 | final Rect cf = mTmpContentFrame; |
| 2331 | final Rect vf = mTmpVisibleFrame; |
| 2332 | |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 2333 | final boolean hasNavBar = (mHasNavigationBar |
| 2334 | && mNavigationBar != null && mNavigationBar.isVisibleLw()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2335 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2336 | if (attrs.type == TYPE_INPUT_METHOD) { |
| 2337 | pf.left = df.left = cf.left = vf.left = mDockLeft; |
| 2338 | pf.top = df.top = cf.top = vf.top = mDockTop; |
| 2339 | pf.right = df.right = cf.right = vf.right = mDockRight; |
| 2340 | pf.bottom = df.bottom = cf.bottom = vf.bottom = mDockBottom; |
| 2341 | // IM dock windows always go to the bottom of the screen. |
| 2342 | attrs.gravity = Gravity.BOTTOM; |
| 2343 | mDockLayer = win.getSurfaceLayer(); |
| 2344 | } else { |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2345 | final int adjust = sim & SOFT_INPUT_MASK_ADJUST; |
| 2346 | |
Dianne Hackborn | 82de1ae | 2010-10-28 11:28:39 -0700 | [diff] [blame] | 2347 | if ((fl & (FLAG_LAYOUT_IN_SCREEN | FLAG_FULLSCREEN | FLAG_LAYOUT_INSET_DECOR)) |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2348 | == (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR) |
| 2349 | && (sysUiFl & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2350 | if (DEBUG_LAYOUT) |
| 2351 | Log.v(TAG, "layoutWindowLw(" + attrs.getTitle() |
| 2352 | + "): IN_SCREEN, INSET_DECOR, !FULLSCREEN"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2353 | // This is the case for a normal activity window: we want it |
| 2354 | // to cover all of the screen space, and it can take care of |
| 2355 | // moving its contents to account for screen decorations that |
| 2356 | // intrude into that space. |
| 2357 | if (attached != null) { |
| 2358 | // If this window is attached to another, our display |
| 2359 | // frame is the same as the one we are attached to. |
| 2360 | setAttachedWindowFrames(win, fl, sim, attached, true, pf, df, cf, vf); |
| 2361 | } else { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2362 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 2363 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2364 | // Status bar panels are the only windows who can go on top of |
| 2365 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 2366 | // permission, so they have the same privileges as the status |
| 2367 | // bar itself. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2368 | // |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 2369 | // However, they should still dodge the navigation bar if it exists. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2370 | |
| 2371 | pf.left = df.left = hasNavBar ? mDockLeft : mUnrestrictedScreenLeft; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2372 | pf.top = df.top = mUnrestrictedScreenTop; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2373 | pf.right = df.right = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 2374 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2375 | : mUnrestrictedScreenLeft+mUnrestrictedScreenWidth; |
| 2376 | pf.bottom = df.bottom = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 2377 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2378 | : mUnrestrictedScreenTop+mUnrestrictedScreenHeight; |
| 2379 | |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 2380 | if (DEBUG_LAYOUT) { |
| 2381 | Log.v(TAG, String.format( |
| 2382 | "Laying out status bar window: (%d,%d - %d,%d)", |
| 2383 | pf.left, pf.top, pf.right, pf.bottom)); |
| 2384 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2385 | } else if (mCanHideNavigationBar |
| 2386 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2387 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 2388 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 2389 | // Asking for layout as if the nav bar is hidden, lets the |
| 2390 | // application extend into the unrestricted screen area. We |
| 2391 | // only do this for application windows to ensure no window that |
| 2392 | // can be above the nav bar can do this. |
| 2393 | pf.left = df.left = mUnrestrictedScreenLeft; |
| 2394 | pf.top = df.top = mUnrestrictedScreenTop; |
| 2395 | pf.right = df.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth; |
| 2396 | pf.bottom = df.bottom = mUnrestrictedScreenTop+mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2397 | } else { |
| 2398 | pf.left = df.left = mRestrictedScreenLeft; |
| 2399 | pf.top = df.top = mRestrictedScreenTop; |
| 2400 | pf.right = df.right = mRestrictedScreenLeft+mRestrictedScreenWidth; |
| 2401 | pf.bottom = df.bottom = mRestrictedScreenTop+mRestrictedScreenHeight; |
| 2402 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2403 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2404 | cf.left = mDockLeft; |
| 2405 | cf.top = mDockTop; |
| 2406 | cf.right = mDockRight; |
| 2407 | cf.bottom = mDockBottom; |
| 2408 | } else { |
| 2409 | cf.left = mContentLeft; |
| 2410 | cf.top = mContentTop; |
| 2411 | cf.right = mContentRight; |
| 2412 | cf.bottom = mContentBottom; |
| 2413 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2414 | if ((sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2415 | // If app is requesting a stable layout, don't let the |
| 2416 | // content insets go below the stable values. |
| 2417 | if (cf.left < mStableLeft) cf.left = mStableLeft; |
| 2418 | if (cf.top < mStableTop) cf.top = mStableTop; |
| 2419 | if (cf.right > mStableRight) cf.right = mStableRight; |
| 2420 | if (cf.bottom > mStableBottom) cf.bottom = mStableBottom; |
| 2421 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2422 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 2423 | vf.left = mCurLeft; |
| 2424 | vf.top = mCurTop; |
| 2425 | vf.right = mCurRight; |
| 2426 | vf.bottom = mCurBottom; |
| 2427 | } else { |
| 2428 | vf.set(cf); |
| 2429 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2430 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2431 | } else if ((fl & FLAG_LAYOUT_IN_SCREEN) != 0 || (sysUiFl |
| 2432 | & (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
| 2433 | | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)) != 0) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2434 | if (DEBUG_LAYOUT) |
| 2435 | Log.v(TAG, "layoutWindowLw(" + attrs.getTitle() + "): IN_SCREEN"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2436 | // A window that has requested to fill the entire screen just |
| 2437 | // gets everything, period. |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2438 | if (attrs.type == TYPE_STATUS_BAR_PANEL |
| 2439 | || attrs.type == TYPE_STATUS_BAR_SUB_PANEL) { |
| 2440 | pf.left = df.left = cf.left = hasNavBar ? mDockLeft : mUnrestrictedScreenLeft; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2441 | pf.top = df.top = cf.top = mUnrestrictedScreenTop; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2442 | pf.right = df.right = cf.right = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 2443 | ? mRestrictedScreenLeft+mRestrictedScreenWidth |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2444 | : mUnrestrictedScreenLeft+mUnrestrictedScreenWidth; |
| 2445 | pf.bottom = df.bottom = cf.bottom = hasNavBar |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 2446 | ? mRestrictedScreenTop+mRestrictedScreenHeight |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2447 | : mUnrestrictedScreenTop+mUnrestrictedScreenHeight; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 2448 | if (DEBUG_LAYOUT) { |
| 2449 | Log.v(TAG, String.format( |
| 2450 | "Laying out IN_SCREEN status bar window: (%d,%d - %d,%d)", |
| 2451 | pf.left, pf.top, pf.right, pf.bottom)); |
| 2452 | } |
Daniel Sandler | 8e8b415 | 2011-07-21 01:16:43 -0400 | [diff] [blame] | 2453 | } else if (attrs.type == TYPE_NAVIGATION_BAR) { |
| 2454 | // The navigation bar has Real Ultimate Power. |
| 2455 | pf.left = df.left = mUnrestrictedScreenLeft; |
| 2456 | pf.top = df.top = mUnrestrictedScreenTop; |
| 2457 | pf.right = df.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth; |
| 2458 | pf.bottom = df.bottom = mUnrestrictedScreenTop+mUnrestrictedScreenHeight; |
| 2459 | if (DEBUG_LAYOUT) { |
| 2460 | Log.v(TAG, String.format( |
| 2461 | "Laying out navigation bar window: (%d,%d - %d,%d)", |
| 2462 | pf.left, pf.top, pf.right, pf.bottom)); |
| 2463 | } |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 2464 | } else if ((attrs.type == TYPE_SECURE_SYSTEM_OVERLAY |
| 2465 | || attrs.type == TYPE_BOOT_PROGRESS) |
Jeff Brown | bfcb60a | 2011-09-08 18:51:14 -0700 | [diff] [blame] | 2466 | && ((fl & FLAG_FULLSCREEN) != 0)) { |
| 2467 | // Fullscreen secure system overlays get what they ask for. |
| 2468 | pf.left = df.left = mUnrestrictedScreenLeft; |
| 2469 | pf.top = df.top = mUnrestrictedScreenTop; |
| 2470 | pf.right = df.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth; |
| 2471 | pf.bottom = df.bottom = mUnrestrictedScreenTop+mUnrestrictedScreenHeight; |
Dianne Hackborn | 01011c3 | 2012-02-21 13:54:21 -0800 | [diff] [blame] | 2472 | } else if (attrs.type == TYPE_BOOT_PROGRESS) { |
| 2473 | // Boot progress screen always covers entire display. |
| 2474 | pf.left = df.left = cf.left = mUnrestrictedScreenLeft; |
| 2475 | pf.top = df.top = cf.top = mUnrestrictedScreenTop; |
| 2476 | pf.right = df.right = cf.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth; |
| 2477 | pf.bottom = df.bottom = cf.bottom |
| 2478 | = mUnrestrictedScreenTop+mUnrestrictedScreenHeight; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2479 | } else if (mCanHideNavigationBar |
| 2480 | && (sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) != 0 |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2481 | && attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW |
| 2482 | && attrs.type <= WindowManager.LayoutParams.LAST_SUB_WINDOW) { |
| 2483 | // Asking for layout as if the nav bar is hidden, lets the |
| 2484 | // application extend into the unrestricted screen area. We |
| 2485 | // only do this for application windows to ensure no window that |
| 2486 | // can be above the nav bar can do this. |
| 2487 | // XXX This assumes that an app asking for this will also |
| 2488 | // ask for layout in only content. We can't currently figure out |
| 2489 | // what the screen would be if only laying out to hide the nav bar. |
| 2490 | pf.left = df.left = cf.left = mUnrestrictedScreenLeft; |
| 2491 | pf.top = df.top = cf.top = mUnrestrictedScreenTop; |
| 2492 | pf.right = df.right = cf.right = mUnrestrictedScreenLeft+mUnrestrictedScreenWidth; |
| 2493 | pf.bottom = df.bottom = cf.bottom |
| 2494 | = mUnrestrictedScreenTop+mUnrestrictedScreenHeight; |
Joe Onorato | 29fc2c9 | 2010-11-24 10:26:50 -0800 | [diff] [blame] | 2495 | } else { |
| 2496 | pf.left = df.left = cf.left = mRestrictedScreenLeft; |
| 2497 | pf.top = df.top = cf.top = mRestrictedScreenTop; |
| 2498 | pf.right = df.right = cf.right = mRestrictedScreenLeft+mRestrictedScreenWidth; |
| 2499 | pf.bottom = df.bottom = cf.bottom |
| 2500 | = mRestrictedScreenTop+mRestrictedScreenHeight; |
| 2501 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2502 | if ((sysUiFl & View.SYSTEM_UI_FLAG_LAYOUT_STABLE) != 0) { |
| 2503 | // If app is requesting a stable layout, don't let the |
| 2504 | // content insets go below the stable values. |
| 2505 | if (cf.left < mStableLeft) cf.left = mStableLeft; |
| 2506 | if (cf.top < mStableTop) cf.top = mStableTop; |
| 2507 | if (cf.right > mStableRight) cf.right = mStableRight; |
| 2508 | if (cf.bottom > mStableBottom) cf.bottom = mStableBottom; |
| 2509 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2510 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 2511 | vf.left = mCurLeft; |
| 2512 | vf.top = mCurTop; |
| 2513 | vf.right = mCurRight; |
| 2514 | vf.bottom = mCurBottom; |
| 2515 | } else { |
| 2516 | vf.set(cf); |
| 2517 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2518 | } else if (attached != null) { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2519 | if (DEBUG_LAYOUT) |
| 2520 | Log.v(TAG, "layoutWindowLw(" + attrs.getTitle() + "): attached to " + attached); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2521 | // A child window should be placed inside of the same visible |
| 2522 | // frame that its parent had. |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2523 | setAttachedWindowFrames(win, fl, adjust, attached, false, pf, df, cf, vf); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2524 | } else { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2525 | if (DEBUG_LAYOUT) |
| 2526 | Log.v(TAG, "layoutWindowLw(" + attrs.getTitle() + "): normal window"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2527 | // Otherwise, a normal window must be placed inside the content |
| 2528 | // of all screen decorations. |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 2529 | if (attrs.type == TYPE_STATUS_BAR_PANEL) { |
| 2530 | // Status bar panels are the only windows who can go on top of |
| 2531 | // the status bar. They are protected by the STATUS_BAR_SERVICE |
| 2532 | // permission, so they have the same privileges as the status |
| 2533 | // bar itself. |
Dianne Hackborn | 7d04932 | 2011-06-14 15:00:32 -0700 | [diff] [blame] | 2534 | pf.left = df.left = cf.left = mRestrictedScreenLeft; |
| 2535 | pf.top = df.top = cf.top = mRestrictedScreenTop; |
| 2536 | pf.right = df.right = cf.right = mRestrictedScreenLeft+mRestrictedScreenWidth; |
| 2537 | pf.bottom = df.bottom = cf.bottom |
| 2538 | = mRestrictedScreenTop+mRestrictedScreenHeight; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2539 | } else { |
Dianne Hackborn | a239c84 | 2011-06-01 12:28:20 -0700 | [diff] [blame] | 2540 | pf.left = mContentLeft; |
| 2541 | pf.top = mContentTop; |
| 2542 | pf.right = mContentRight; |
| 2543 | pf.bottom = mContentBottom; |
| 2544 | if (adjust != SOFT_INPUT_ADJUST_RESIZE) { |
| 2545 | df.left = cf.left = mDockLeft; |
| 2546 | df.top = cf.top = mDockTop; |
| 2547 | df.right = cf.right = mDockRight; |
| 2548 | df.bottom = cf.bottom = mDockBottom; |
| 2549 | } else { |
| 2550 | df.left = cf.left = mContentLeft; |
| 2551 | df.top = cf.top = mContentTop; |
| 2552 | df.right = cf.right = mContentRight; |
| 2553 | df.bottom = cf.bottom = mContentBottom; |
| 2554 | } |
| 2555 | if (adjust != SOFT_INPUT_ADJUST_NOTHING) { |
| 2556 | vf.left = mCurLeft; |
| 2557 | vf.top = mCurTop; |
| 2558 | vf.right = mCurRight; |
| 2559 | vf.bottom = mCurBottom; |
| 2560 | } else { |
| 2561 | vf.set(cf); |
| 2562 | } |
Dianne Hackborn | dea3ef7 | 2010-10-28 14:24:22 -0700 | [diff] [blame] | 2563 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2564 | } |
| 2565 | } |
| 2566 | |
| 2567 | if ((fl & FLAG_LAYOUT_NO_LIMITS) != 0) { |
| 2568 | df.left = df.top = cf.left = cf.top = vf.left = vf.top = -10000; |
| 2569 | df.right = df.bottom = cf.right = cf.bottom = vf.right = vf.bottom = 10000; |
| 2570 | } |
| 2571 | |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 2572 | if (DEBUG_LAYOUT) Log.v(TAG, "Compute frame " + attrs.getTitle() |
| 2573 | + ": sim=#" + Integer.toHexString(sim) |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 2574 | + " attach=" + attached + " type=" + attrs.type |
| 2575 | + String.format(" flags=0x%08x", fl) |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 2576 | + " pf=" + pf.toShortString() + " df=" + df.toShortString() |
| 2577 | + " cf=" + cf.toShortString() + " vf=" + vf.toShortString()); |
| 2578 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2579 | win.computeFrameLw(pf, df, cf, vf); |
| 2580 | |
| 2581 | // Dock windows carve out the bottom of the screen, so normal windows |
| 2582 | // can't appear underneath them. |
| 2583 | if (attrs.type == TYPE_INPUT_METHOD && !win.getGivenInsetsPendingLw()) { |
| 2584 | int top = win.getContentFrameLw().top; |
| 2585 | top += win.getGivenContentInsetsLw().top; |
| 2586 | if (mContentBottom > top) { |
| 2587 | mContentBottom = top; |
| 2588 | } |
| 2589 | top = win.getVisibleFrameLw().top; |
| 2590 | top += win.getGivenVisibleInsetsLw().top; |
| 2591 | if (mCurBottom > top) { |
| 2592 | mCurBottom = top; |
| 2593 | } |
The Android Open Source Project | 1126766 | 2009-03-18 17:39:47 -0700 | [diff] [blame] | 2594 | if (DEBUG_LAYOUT) Log.v(TAG, "Input method: mDockBottom=" |
| 2595 | + mDockBottom + " mContentBottom=" |
| 2596 | + mContentBottom + " mCurBottom=" + mCurBottom); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2597 | } |
| 2598 | } |
| 2599 | |
| 2600 | /** {@inheritDoc} */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 2601 | @Override |
| 2602 | public void finishLayoutLw() { |
| 2603 | return; |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 2604 | } |
| 2605 | |
| 2606 | /** {@inheritDoc} */ |
| 2607 | public void beginAnimationLw(int displayWidth, int displayHeight) { |
| 2608 | mTopFullscreenOpaqueWindowState = null; |
| 2609 | mForceStatusBar = false; |
| 2610 | |
| 2611 | mHideLockScreen = false; |
| 2612 | mAllowLockscreenWhenOn = false; |
| 2613 | mDismissKeyguard = false; |
| 2614 | } |
| 2615 | |
| 2616 | /** {@inheritDoc} */ |
| 2617 | public void animatingWindowLw(WindowState win, |
| 2618 | WindowManager.LayoutParams attrs) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 2619 | if (DEBUG_LAYOUT) Slog.i(TAG, "Win " + win + ": isVisibleOrBehindKeyguardLw=" |
| 2620 | + win.isVisibleOrBehindKeyguardLw()); |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 2621 | if (mTopFullscreenOpaqueWindowState == null && |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 2622 | win.isVisibleOrBehindKeyguardLw() && !win.isGoneForLayoutLw()) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 2623 | if ((attrs.flags & FLAG_FORCE_NOT_FULLSCREEN) != 0) { |
| 2624 | mForceStatusBar = true; |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 2625 | } |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 2626 | if (attrs.type >= FIRST_APPLICATION_WINDOW |
| 2627 | && attrs.type <= LAST_APPLICATION_WINDOW |
Dianne Hackborn | 6493e64 | 2010-10-01 13:06:30 -0700 | [diff] [blame] | 2628 | && attrs.x == 0 && attrs.y == 0 |
| 2629 | && attrs.width == WindowManager.LayoutParams.MATCH_PARENT |
| 2630 | && attrs.height == WindowManager.LayoutParams.MATCH_PARENT) { |
Dianne Hackborn | 5f3063e | 2010-03-10 16:01:58 -0800 | [diff] [blame] | 2631 | if (DEBUG_LAYOUT) Log.v(TAG, "Fullscreen window: " + win); |
| 2632 | mTopFullscreenOpaqueWindowState = win; |
| 2633 | if ((attrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0) { |
| 2634 | if (localLOGV) Log.v(TAG, "Setting mHideLockScreen to true by win " + win); |
| 2635 | mHideLockScreen = true; |
| 2636 | } |
| 2637 | if ((attrs.flags & FLAG_DISMISS_KEYGUARD) != 0) { |
| 2638 | if (localLOGV) Log.v(TAG, "Setting mDismissKeyguard to true by win " + win); |
| 2639 | mDismissKeyguard = true; |
| 2640 | } |
| 2641 | if ((attrs.flags & FLAG_ALLOW_LOCK_WHILE_SCREEN_ON) != 0) { |
| 2642 | mAllowLockscreenWhenOn = true; |
| 2643 | } |
| 2644 | } |
| 2645 | } |
| 2646 | } |
| 2647 | |
| 2648 | /** {@inheritDoc} */ |
| 2649 | public int finishAnimationLw() { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2650 | int changes = 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 2651 | boolean topIsFullscreen = false; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 2652 | |
| 2653 | final WindowManager.LayoutParams lp = (mTopFullscreenOpaqueWindowState != null) |
| 2654 | ? mTopFullscreenOpaqueWindowState.getAttrs() |
| 2655 | : null; |
| 2656 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2657 | if (mStatusBar != null) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 2658 | if (DEBUG_LAYOUT) Log.i(TAG, "force=" + mForceStatusBar |
Dianne Hackborn | d70bc2f | 2009-10-06 23:25:51 -0700 | [diff] [blame] | 2659 | + " top=" + mTopFullscreenOpaqueWindowState); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2660 | if (mForceStatusBar) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 2661 | if (DEBUG_LAYOUT) Log.v(TAG, "Showing status bar: forced"); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2662 | if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2663 | } else if (mTopFullscreenOpaqueWindowState != null) { |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 2664 | if (localLOGV) { |
| 2665 | Log.d(TAG, "frame: " + mTopFullscreenOpaqueWindowState.getFrameLw() |
| 2666 | + " shown frame: " + mTopFullscreenOpaqueWindowState.getShownFrameLw()); |
| 2667 | Log.d(TAG, "attr: " + mTopFullscreenOpaqueWindowState.getAttrs() |
| 2668 | + " lp.flags=0x" + Integer.toHexString(lp.flags)); |
| 2669 | } |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2670 | topIsFullscreen = (lp.flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0 |
| 2671 | || (mLastSystemUiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 2672 | // The subtle difference between the window for mTopFullscreenOpaqueWindowState |
| 2673 | // and mTopIsFullscreen is that that mTopIsFullscreen is set only if the window |
| 2674 | // has the FLAG_FULLSCREEN set. Not sure if there is another way that to be the |
| 2675 | // case though. |
| 2676 | if (topIsFullscreen) { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2677 | if (DEBUG_LAYOUT) Log.v(TAG, "** HIDING status bar"); |
| 2678 | if (mStatusBar.hideLw(true)) { |
| 2679 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
Daniel Sandler | 9c00d5b | 2011-09-13 14:04:26 -0400 | [diff] [blame] | 2680 | |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2681 | mHandler.post(new Runnable() { public void run() { |
| 2682 | if (mStatusBarService != null) { |
| 2683 | try { |
| 2684 | mStatusBarService.collapse(); |
| 2685 | } catch (RemoteException ex) {} |
| 2686 | } |
| 2687 | }}); |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 2688 | } else if (DEBUG_LAYOUT) { |
Daniel Sandler | 4042744 | 2010-07-16 11:44:52 -0400 | [diff] [blame] | 2689 | Log.v(TAG, "Preventing status bar from hiding by policy"); |
| 2690 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2691 | } else { |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 2692 | if (DEBUG_LAYOUT) Log.v(TAG, "** SHOWING status bar: top is not fullscreen"); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2693 | if (mStatusBar.showLw(true)) changes |= FINISH_LAYOUT_REDO_LAYOUT; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2694 | } |
| 2695 | } |
| 2696 | } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 2697 | |
Joe Onorato | 644f9c3 | 2011-01-25 12:06:23 -0800 | [diff] [blame] | 2698 | mTopIsFullscreen = topIsFullscreen; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 2699 | |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 2700 | // Hide the key guard if a visible window explicitly specifies that it wants to be displayed |
| 2701 | // when the screen is locked |
| 2702 | if (mKeyguard != null) { |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 2703 | if (localLOGV) Log.v(TAG, "finishAnimationLw::mHideKeyguard="+mHideLockScreen); |
Dianne Hackborn | 0572658 | 2009-09-22 17:28:24 -0700 | [diff] [blame] | 2704 | if (mDismissKeyguard && !mKeyguardMediator.isSecure()) { |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 2705 | if (mKeyguard.hideLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2706 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 2707 | | FINISH_LAYOUT_REDO_CONFIG |
| 2708 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 2709 | } |
Dianne Hackborn | 0572658 | 2009-09-22 17:28:24 -0700 | [diff] [blame] | 2710 | if (mKeyguardMediator.isShowing()) { |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 2711 | mHandler.post(new Runnable() { |
| 2712 | public void run() { |
Dianne Hackborn | 0572658 | 2009-09-22 17:28:24 -0700 | [diff] [blame] | 2713 | mKeyguardMediator.keyguardDone(false, false); |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 2714 | } |
| 2715 | }); |
| 2716 | } |
Dianne Hackborn | 0572658 | 2009-09-22 17:28:24 -0700 | [diff] [blame] | 2717 | } else if (mHideLockScreen) { |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 2718 | if (mKeyguard.hideLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2719 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 2720 | | FINISH_LAYOUT_REDO_CONFIG |
| 2721 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 2722 | } |
Mike Lockwood | f3bfed5 | 2010-01-21 16:38:44 -0500 | [diff] [blame] | 2723 | mKeyguardMediator.setHidden(true); |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 2724 | } else { |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 2725 | if (mKeyguard.showLw(true)) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2726 | changes |= FINISH_LAYOUT_REDO_LAYOUT |
| 2727 | | FINISH_LAYOUT_REDO_CONFIG |
| 2728 | | FINISH_LAYOUT_REDO_WALLPAPER; |
| 2729 | } |
Mike Lockwood | f3bfed5 | 2010-01-21 16:38:44 -0500 | [diff] [blame] | 2730 | mKeyguardMediator.setHidden(false); |
Suchi Amalapurapu | 9cdc903 | 2009-05-14 18:01:07 -0700 | [diff] [blame] | 2731 | } |
| 2732 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 2733 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2734 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2735 | // If the navigation bar has been hidden or shown, we need to do another |
| 2736 | // layout pass to update that window. |
| 2737 | changes |= FINISH_LAYOUT_REDO_LAYOUT; |
| 2738 | } |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 2739 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 2740 | // update since mAllowLockscreenWhenOn might have changed |
| 2741 | updateLockScreenTimeout(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 2742 | return changes; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2743 | } |
| 2744 | |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 2745 | public boolean allowAppAnimationsLw() { |
| 2746 | if (mKeyguard != null && mKeyguard.isVisibleLw()) { |
| 2747 | // If keyguard is currently visible, no reason to animate |
| 2748 | // behind it. |
| 2749 | return false; |
| 2750 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2751 | if (mStatusBar != null && mStatusBar.isVisibleLw()) { |
| 2752 | RectF rect = new RectF(mStatusBar.getShownFrameLw()); |
| 2753 | for (int i=mStatusBarPanels.size()-1; i>=0; i--) { |
| 2754 | WindowState w = mStatusBarPanels.get(i); |
| 2755 | if (w.isVisibleLw()) { |
| 2756 | rect.union(w.getShownFrameLw()); |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 2757 | } |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2758 | } |
| 2759 | final int insetw = mRestrictedScreenWidth/10; |
| 2760 | final int inseth = mRestrictedScreenHeight/10; |
| 2761 | if (rect.contains(insetw, inseth, mRestrictedScreenWidth-insetw, |
| 2762 | mRestrictedScreenHeight-inseth)) { |
| 2763 | // All of the status bar windows put together cover the |
| 2764 | // screen, so the app can't be seen. (Note this test doesn't |
| 2765 | // work if the rects of these windows are at odd offsets or |
| 2766 | // sizes, causing gaps in the rect union we have computed.) |
| 2767 | return false; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 2768 | } |
| 2769 | } |
| 2770 | return true; |
| 2771 | } |
| 2772 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2773 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus) { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 2774 | mFocusedWindow = newFocus; |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 2775 | if ((updateSystemUiVisibilityLw()&SYSTEM_UI_CHANGING_LAYOUT) != 0) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 2776 | // If the navigation bar has been hidden or shown, we need to do another |
| 2777 | // layout pass to update that window. |
| 2778 | return FINISH_LAYOUT_REDO_LAYOUT; |
| 2779 | } |
| 2780 | return 0; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 2781 | } |
| 2782 | |
Dianne Hackborn | 0ecadf7 | 2009-03-31 18:00:37 -0700 | [diff] [blame] | 2783 | /** {@inheritDoc} */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 2784 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 2785 | // do nothing if headless |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 2786 | if (mHeadless) return; |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 2787 | |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 2788 | // lid changed state |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 2789 | mLidOpen = lidOpen ? LID_OPEN : LID_CLOSED; |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 2790 | updateKeyboardVisibility(); |
| 2791 | |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 2792 | boolean awakeNow = mKeyguardMediator.doLidChangeTq(lidOpen); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 2793 | updateRotation(true); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 2794 | if (awakeNow) { |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 2795 | // If the lid is opening and we don't have to keep the |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 2796 | // keyguard up, then we can turn on the screen |
| 2797 | // immediately. |
| 2798 | mKeyguardMediator.pokeWakelock(); |
| 2799 | } else if (keyguardIsShowingTq()) { |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 2800 | if (lidOpen) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 2801 | // If we are opening the lid and not hiding the |
| 2802 | // keyguard, then we need to have it turn on the |
| 2803 | // screen once it is shown. |
| 2804 | mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq( |
Jeff Brown | 43150bf | 2011-11-08 20:22:03 -0800 | [diff] [blame] | 2805 | KeyEvent.KEYCODE_POWER, mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED); |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 2806 | } |
| 2807 | } else { |
| 2808 | // Light up the keyboard if we are sliding up. |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 2809 | if (lidOpen) { |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 2810 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false, |
| 2811 | LocalPowerManager.BUTTON_EVENT); |
| 2812 | } else { |
| 2813 | mPowerManager.userActivity(SystemClock.uptimeMillis(), false, |
| 2814 | LocalPowerManager.OTHER_EVENT); |
| 2815 | } |
| 2816 | } |
| 2817 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2818 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 2819 | void setHdmiPlugged(boolean plugged) { |
| 2820 | if (mHdmiPlugged != plugged) { |
| 2821 | mHdmiPlugged = plugged; |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 2822 | if (plugged && mDisplay != null) { |
| 2823 | mExternalDisplayWidth = mDisplay.getRawExternalWidth(); |
| 2824 | mExternalDisplayHeight = mDisplay.getRawExternalHeight(); |
| 2825 | } |
| 2826 | updateRotation(true, true); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 2827 | Intent intent = new Intent(ACTION_HDMI_PLUGGED); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 2828 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 2829 | intent.putExtra(EXTRA_HDMI_PLUGGED_STATE, plugged); |
| 2830 | mContext.sendStickyBroadcast(intent); |
| 2831 | } |
| 2832 | } |
| 2833 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 2834 | void initializeHdmiState() { |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 2835 | boolean plugged = false; |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 2836 | // watch for HDMI plug messages if the hdmi switch exists |
| 2837 | if (new File("/sys/devices/virtual/switch/hdmi/state").exists()) { |
| 2838 | mHDMIObserver.startObserving("DEVPATH=/devices/virtual/switch/hdmi"); |
| 2839 | |
Joe Onorato | ea495d4 | 2011-04-06 11:41:11 -0700 | [diff] [blame] | 2840 | final String filename = "/sys/class/switch/hdmi/state"; |
| 2841 | FileReader reader = null; |
| 2842 | try { |
| 2843 | reader = new FileReader(filename); |
| 2844 | char[] buf = new char[15]; |
| 2845 | int n = reader.read(buf); |
| 2846 | if (n > 1) { |
| 2847 | plugged = 0 != Integer.parseInt(new String(buf, 0, n-1)); |
| 2848 | } |
| 2849 | } catch (IOException ex) { |
| 2850 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 2851 | } catch (NumberFormatException ex) { |
| 2852 | Slog.w(TAG, "Couldn't read hdmi state from " + filename + ": " + ex); |
| 2853 | } finally { |
| 2854 | if (reader != null) { |
| 2855 | try { |
| 2856 | reader.close(); |
| 2857 | } catch (IOException ex) { |
| 2858 | } |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 2859 | } |
| 2860 | } |
| 2861 | } |
Joe Onorato | 7ba631f | 2011-05-04 15:28:00 -0700 | [diff] [blame] | 2862 | // This dance forces the code in setHdmiPlugged to run. |
| 2863 | // Always do this so the sticky intent is stuck (to false) if there is no hdmi. |
| 2864 | mHdmiPlugged = !plugged; |
| 2865 | setHdmiPlugged(!mHdmiPlugged); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 2866 | } |
| 2867 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2868 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2869 | * @return Whether music is being played right now. |
| 2870 | */ |
| 2871 | boolean isMusicActive() { |
Eric Laurent | 413cb9d | 2009-07-17 11:52:43 -0700 | [diff] [blame] | 2872 | final AudioManager am = (AudioManager)mContext.getSystemService(Context.AUDIO_SERVICE); |
| 2873 | if (am == null) { |
| 2874 | Log.w(TAG, "isMusicActive: couldn't get AudioManager reference"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2875 | return false; |
| 2876 | } |
Eric Laurent | 413cb9d | 2009-07-17 11:52:43 -0700 | [diff] [blame] | 2877 | return am.isMusicActive(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2878 | } |
| 2879 | |
| 2880 | /** |
| 2881 | * Tell the audio service to adjust the volume appropriate to the event. |
| 2882 | * @param keycode |
| 2883 | */ |
Mike Lockwood | a53e381 | 2009-09-25 10:51:39 -0400 | [diff] [blame] | 2884 | void handleVolumeKey(int stream, int keycode) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 2885 | IAudioService audioService = getAudioService(); |
| 2886 | if (audioService == null) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2887 | return; |
| 2888 | } |
| 2889 | try { |
| 2890 | // since audio is playing, we shouldn't have to hold a wake lock |
| 2891 | // during the call, but we do it as a precaution for the rare possibility |
| 2892 | // that the music stops right before we call this |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 2893 | // TODO: Actually handle MUTE. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2894 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 2895 | audioService.adjustStreamVolume(stream, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2896 | keycode == KeyEvent.KEYCODE_VOLUME_UP |
| 2897 | ? AudioManager.ADJUST_RAISE |
| 2898 | : AudioManager.ADJUST_LOWER, |
| 2899 | 0); |
| 2900 | } catch (RemoteException e) { |
| 2901 | Log.w(TAG, "IAudioService.adjustStreamVolume() threw RemoteException " + e); |
| 2902 | } finally { |
| 2903 | mBroadcastWakeLock.release(); |
| 2904 | } |
| 2905 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 2906 | |
Dianne Hackborn | c0e3f24 | 2011-08-19 14:19:10 -0700 | [diff] [blame] | 2907 | final Object mScreenshotLock = new Object(); |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 2908 | ServiceConnection mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 2909 | |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2910 | final Runnable mScreenshotTimeout = new Runnable() { |
| 2911 | @Override public void run() { |
| 2912 | synchronized (mScreenshotLock) { |
| 2913 | if (mScreenshotConnection != null) { |
| 2914 | mContext.unbindService(mScreenshotConnection); |
| 2915 | mScreenshotConnection = null; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 2916 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 2917 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2918 | } |
| 2919 | }; |
| 2920 | |
| 2921 | // Assume this is called from the Handler thread. |
| 2922 | private void takeScreenshot() { |
| 2923 | synchronized (mScreenshotLock) { |
| 2924 | if (mScreenshotConnection != null) { |
| 2925 | return; |
| 2926 | } |
| 2927 | ComponentName cn = new ComponentName("com.android.systemui", |
| 2928 | "com.android.systemui.screenshot.TakeScreenshotService"); |
| 2929 | Intent intent = new Intent(); |
| 2930 | intent.setComponent(cn); |
| 2931 | ServiceConnection conn = new ServiceConnection() { |
| 2932 | @Override |
| 2933 | public void onServiceConnected(ComponentName name, IBinder service) { |
| 2934 | synchronized (mScreenshotLock) { |
| 2935 | if (mScreenshotConnection != this) { |
| 2936 | return; |
| 2937 | } |
| 2938 | Messenger messenger = new Messenger(service); |
| 2939 | Message msg = Message.obtain(null, 1); |
| 2940 | final ServiceConnection myConn = this; |
| 2941 | Handler h = new Handler(mHandler.getLooper()) { |
| 2942 | @Override |
| 2943 | public void handleMessage(Message msg) { |
| 2944 | synchronized (mScreenshotLock) { |
| 2945 | if (mScreenshotConnection == myConn) { |
| 2946 | mContext.unbindService(mScreenshotConnection); |
| 2947 | mScreenshotConnection = null; |
| 2948 | mHandler.removeCallbacks(mScreenshotTimeout); |
| 2949 | } |
| 2950 | } |
| 2951 | } |
| 2952 | }; |
| 2953 | msg.replyTo = new Messenger(h); |
Winson Chung | a63bb84 | 2011-10-17 10:26:28 -0700 | [diff] [blame] | 2954 | msg.arg1 = msg.arg2 = 0; |
| 2955 | if (mStatusBar != null && mStatusBar.isVisibleLw()) |
| 2956 | msg.arg1 = 1; |
| 2957 | if (mNavigationBar != null && mNavigationBar.isVisibleLw()) |
| 2958 | msg.arg2 = 1; |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 2959 | try { |
| 2960 | messenger.send(msg); |
| 2961 | } catch (RemoteException e) { |
| 2962 | } |
| 2963 | } |
| 2964 | } |
| 2965 | @Override |
| 2966 | public void onServiceDisconnected(ComponentName name) {} |
| 2967 | }; |
| 2968 | if (mContext.bindService(intent, conn, Context.BIND_AUTO_CREATE)) { |
| 2969 | mScreenshotConnection = conn; |
| 2970 | mHandler.postDelayed(mScreenshotTimeout, 10000); |
| 2971 | } |
| 2972 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 2973 | } |
| 2974 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2975 | /** {@inheritDoc} */ |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2976 | @Override |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 2977 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn) { |
| 2978 | final boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 2979 | final boolean canceled = event.isCanceled(); |
| 2980 | final int keyCode = event.getKeyCode(); |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 2981 | |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 2982 | final boolean isInjected = (policyFlags & WindowManagerPolicy.FLAG_INJECTED) != 0; |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 2983 | |
Mike Lockwood | c72b15f | 2009-11-28 20:58:22 -0500 | [diff] [blame] | 2984 | // If screen is off then we treat the case where the keyguard is open but hidden |
| 2985 | // the same as if it were open and in front. |
| 2986 | // This will prevent any keys other than the power button from waking the screen |
| 2987 | // when the keyguard is hidden by another activity. |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 2988 | final boolean keyguardActive = (mKeyguardMediator == null ? false : |
| 2989 | (isScreenOn ? |
| 2990 | mKeyguardMediator.isShowingAndNotHidden() : |
| 2991 | mKeyguardMediator.isShowing())); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2992 | |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 2993 | if (!mSystemBooted) { |
| 2994 | // If we have not yet booted, don't let key events do anything. |
| 2995 | return 0; |
| 2996 | } |
| 2997 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 2998 | if (false) { |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 2999 | Log.d(TAG, "interceptKeyTq keycode=" + keyCode |
| 3000 | + " screenIsOn=" + isScreenOn + " keyguardActive=" + keyguardActive); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3001 | } |
| 3002 | |
Jeff Brown | 98392ef | 2011-09-12 18:24:59 -0700 | [diff] [blame] | 3003 | if (down && (policyFlags & WindowManagerPolicy.FLAG_VIRTUAL) != 0 |
| 3004 | && event.getRepeatCount() == 0) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3005 | performHapticFeedbackLw(null, HapticFeedbackConstants.VIRTUAL_KEY, false); |
| 3006 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3007 | |
Jeff Brown | bc072da | 2011-11-15 12:56:55 -0800 | [diff] [blame] | 3008 | if (keyCode == KeyEvent.KEYCODE_POWER) { |
| 3009 | policyFlags |= WindowManagerPolicy.FLAG_WAKE; |
| 3010 | } |
| 3011 | final boolean isWakeKey = (policyFlags & (WindowManagerPolicy.FLAG_WAKE |
| 3012 | | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; |
| 3013 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3014 | // Basic policy based on screen state and keyguard. |
| 3015 | // FIXME: This policy isn't quite correct. We shouldn't care whether the screen |
| 3016 | // is on or off, really. We should care about whether the device is in an |
| 3017 | // interactive state or is in suspend pretending to be "off". |
| 3018 | // The primary screen might be turned off due to proximity sensor or |
| 3019 | // because we are presenting media on an auxiliary screen or remotely controlling |
| 3020 | // the device some other way (which is why we have an exemption here for injected |
| 3021 | // events). |
| 3022 | int result; |
Mike Lockwood | d747dc8 | 2011-09-13 16:28:22 -0400 | [diff] [blame] | 3023 | if ((isScreenOn && !mHeadless) || (isInjected && !isWakeKey)) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3024 | // When the screen is on or if the key is injected pass the key to the application. |
| 3025 | result = ACTION_PASS_TO_USER; |
| 3026 | } else { |
| 3027 | // When the screen is off and the key is not injected, determine whether |
| 3028 | // to wake the device but don't pass the key to the application. |
| 3029 | result = 0; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3030 | if (down && isWakeKey) { |
| 3031 | if (keyguardActive) { |
| 3032 | // If the keyguard is showing, let it decide what to do with the wake key. |
Jeff Brown | 43150bf | 2011-11-08 20:22:03 -0800 | [diff] [blame] | 3033 | mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(keyCode, |
| 3034 | mDockMode != Intent.EXTRA_DOCK_STATE_UNDOCKED); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3035 | } else { |
| 3036 | // Otherwise, wake the device ourselves. |
| 3037 | result |= ACTION_POKE_USER_ACTIVITY; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3038 | } |
| 3039 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3040 | } |
| 3041 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3042 | // Handle special keys. |
| 3043 | switch (keyCode) { |
| 3044 | case KeyEvent.KEYCODE_VOLUME_DOWN: |
Jeff Brown | b0418da | 2010-11-01 15:24:01 -0700 | [diff] [blame] | 3045 | case KeyEvent.KEYCODE_VOLUME_UP: |
| 3046 | case KeyEvent.KEYCODE_VOLUME_MUTE: { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3047 | if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { |
| 3048 | if (down) { |
| 3049 | if (isScreenOn && !mVolumeDownKeyTriggered |
| 3050 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 3051 | mVolumeDownKeyTriggered = true; |
| 3052 | mVolumeDownKeyTime = event.getDownTime(); |
| 3053 | mVolumeDownKeyConsumedByScreenshotChord = false; |
| 3054 | cancelPendingPowerKeyAction(); |
| 3055 | interceptScreenshotChord(); |
| 3056 | } |
| 3057 | } else { |
| 3058 | mVolumeDownKeyTriggered = false; |
| 3059 | cancelPendingScreenshotChordAction(); |
| 3060 | } |
| 3061 | } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) { |
| 3062 | if (down) { |
| 3063 | if (isScreenOn && !mVolumeUpKeyTriggered |
| 3064 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 3065 | mVolumeUpKeyTriggered = true; |
| 3066 | cancelPendingPowerKeyAction(); |
| 3067 | cancelPendingScreenshotChordAction(); |
| 3068 | } |
| 3069 | } else { |
| 3070 | mVolumeUpKeyTriggered = false; |
| 3071 | cancelPendingScreenshotChordAction(); |
| 3072 | } |
| 3073 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3074 | if (down) { |
| 3075 | ITelephony telephonyService = getTelephonyService(); |
| 3076 | if (telephonyService != null) { |
| 3077 | try { |
| 3078 | if (telephonyService.isRinging()) { |
| 3079 | // If an incoming call is ringing, either VOLUME key means |
| 3080 | // "silence ringer". We handle these keys here, rather than |
| 3081 | // in the InCallScreen, to make sure we'll respond to them |
| 3082 | // even if the InCallScreen hasn't come to the foreground yet. |
| 3083 | // Look for the DOWN event here, to agree with the "fallback" |
| 3084 | // behavior in the InCallScreen. |
| 3085 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 3086 | + " VOLUME key-down while ringing: Silence ringer!"); |
| 3087 | |
| 3088 | // Silence the ringer. (It's safe to call this |
| 3089 | // even if the ringer has already been silenced.) |
| 3090 | telephonyService.silenceRinger(); |
| 3091 | |
| 3092 | // And *don't* pass this key thru to the current activity |
| 3093 | // (which is probably the InCallScreen.) |
| 3094 | result &= ~ACTION_PASS_TO_USER; |
| 3095 | break; |
| 3096 | } |
| 3097 | if (telephonyService.isOffhook() |
| 3098 | && (result & ACTION_PASS_TO_USER) == 0) { |
| 3099 | // If we are in call but we decided not to pass the key to |
| 3100 | // the application, handle the volume change here. |
| 3101 | handleVolumeKey(AudioManager.STREAM_VOICE_CALL, keyCode); |
| 3102 | break; |
| 3103 | } |
| 3104 | } catch (RemoteException ex) { |
| 3105 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
| 3106 | } |
| 3107 | } |
| 3108 | |
| 3109 | if (isMusicActive() && (result & ACTION_PASS_TO_USER) == 0) { |
| 3110 | // If music is playing but we decided not to pass the key to the |
| 3111 | // application, handle the volume change here. |
| 3112 | handleVolumeKey(AudioManager.STREAM_MUSIC, keyCode); |
| 3113 | break; |
| 3114 | } |
| 3115 | } |
| 3116 | break; |
| 3117 | } |
| 3118 | |
| 3119 | case KeyEvent.KEYCODE_ENDCALL: { |
| 3120 | result &= ~ACTION_PASS_TO_USER; |
| 3121 | if (down) { |
| 3122 | ITelephony telephonyService = getTelephonyService(); |
| 3123 | boolean hungUp = false; |
| 3124 | if (telephonyService != null) { |
| 3125 | try { |
| 3126 | hungUp = telephonyService.endCall(); |
| 3127 | } catch (RemoteException ex) { |
| 3128 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
| 3129 | } |
| 3130 | } |
| 3131 | interceptPowerKeyDown(!isScreenOn || hungUp); |
| 3132 | } else { |
| 3133 | if (interceptPowerKeyUp(canceled)) { |
| 3134 | if ((mEndcallBehavior |
| 3135 | & Settings.System.END_BUTTON_BEHAVIOR_HOME) != 0) { |
| 3136 | if (goHome()) { |
| 3137 | break; |
Dianne Hackborn | 0041e97 | 2009-07-24 17:14:43 -0700 | [diff] [blame] | 3138 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3139 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3140 | if ((mEndcallBehavior |
| 3141 | & Settings.System.END_BUTTON_BEHAVIOR_SLEEP) != 0) { |
| 3142 | result = (result & ~ACTION_POKE_USER_ACTIVITY) | ACTION_GO_TO_SLEEP; |
| 3143 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3144 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3145 | } |
| 3146 | break; |
| 3147 | } |
| 3148 | |
| 3149 | case KeyEvent.KEYCODE_POWER: { |
| 3150 | result &= ~ACTION_PASS_TO_USER; |
| 3151 | if (down) { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3152 | if (isScreenOn && !mPowerKeyTriggered |
| 3153 | && (event.getFlags() & KeyEvent.FLAG_FALLBACK) == 0) { |
| 3154 | mPowerKeyTriggered = true; |
| 3155 | mPowerKeyTime = event.getDownTime(); |
| 3156 | interceptScreenshotChord(); |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3157 | } |
Winson Chung | 9112ec3 | 2011-06-27 13:15:32 -0700 | [diff] [blame] | 3158 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3159 | ITelephony telephonyService = getTelephonyService(); |
| 3160 | boolean hungUp = false; |
| 3161 | if (telephonyService != null) { |
| 3162 | try { |
| 3163 | if (telephonyService.isRinging()) { |
| 3164 | // Pressing Power while there's a ringing incoming |
| 3165 | // call should silence the ringer. |
| 3166 | telephonyService.silenceRinger(); |
| 3167 | } else if ((mIncallPowerBehavior |
| 3168 | & Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP) != 0 |
| 3169 | && telephonyService.isOffhook()) { |
| 3170 | // Otherwise, if "Power button ends call" is enabled, |
| 3171 | // the Power button will hang up any current active call. |
| 3172 | hungUp = telephonyService.endCall(); |
| 3173 | } |
| 3174 | } catch (RemoteException ex) { |
| 3175 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
| 3176 | } |
| 3177 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3178 | interceptPowerKeyDown(!isScreenOn || hungUp |
| 3179 | || mVolumeDownKeyTriggered || mVolumeUpKeyTriggered); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3180 | } else { |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3181 | mPowerKeyTriggered = false; |
| 3182 | cancelPendingScreenshotChordAction(); |
| 3183 | if (interceptPowerKeyUp(canceled || mPendingPowerKeyUpCanceled)) { |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3184 | result = (result & ~ACTION_POKE_USER_ACTIVITY) | ACTION_GO_TO_SLEEP; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3185 | } |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 3186 | mPendingPowerKeyUpCanceled = false; |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3187 | } |
| 3188 | break; |
| 3189 | } |
| 3190 | |
| 3191 | case KeyEvent.KEYCODE_MEDIA_PLAY: |
| 3192 | case KeyEvent.KEYCODE_MEDIA_PAUSE: |
| 3193 | case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: |
| 3194 | if (down) { |
| 3195 | ITelephony telephonyService = getTelephonyService(); |
| 3196 | if (telephonyService != null) { |
| 3197 | try { |
| 3198 | if (!telephonyService.isIdle()) { |
| 3199 | // Suppress PLAY/PAUSE toggle when phone is ringing or in-call |
| 3200 | // to avoid music playback. |
| 3201 | break; |
| 3202 | } |
| 3203 | } catch (RemoteException ex) { |
| 3204 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
Jeff Brown | 3122e44 | 2010-10-11 23:32:49 -0700 | [diff] [blame] | 3205 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3206 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3207 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3208 | case KeyEvent.KEYCODE_HEADSETHOOK: |
| 3209 | case KeyEvent.KEYCODE_MUTE: |
| 3210 | case KeyEvent.KEYCODE_MEDIA_STOP: |
| 3211 | case KeyEvent.KEYCODE_MEDIA_NEXT: |
| 3212 | case KeyEvent.KEYCODE_MEDIA_PREVIOUS: |
| 3213 | case KeyEvent.KEYCODE_MEDIA_REWIND: |
| 3214 | case KeyEvent.KEYCODE_MEDIA_RECORD: |
| 3215 | case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: { |
| 3216 | if ((result & ACTION_PASS_TO_USER) == 0) { |
| 3217 | // Only do this if we would otherwise not pass it to the user. In that |
| 3218 | // case, the PhoneWindow class will do the same thing, except it will |
| 3219 | // only do it if the showing app doesn't process the key on its own. |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3220 | mBroadcastWakeLock.acquire(); |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 3221 | mHandler.post(new PassHeadsetKey(new KeyEvent(event))); |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3222 | } |
| 3223 | break; |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3224 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3225 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3226 | case KeyEvent.KEYCODE_CALL: { |
| 3227 | if (down) { |
| 3228 | ITelephony telephonyService = getTelephonyService(); |
| 3229 | if (telephonyService != null) { |
| 3230 | try { |
| 3231 | if (telephonyService.isRinging()) { |
| 3232 | Log.i(TAG, "interceptKeyBeforeQueueing:" |
| 3233 | + " CALL key-down while ringing: Answer the call!"); |
| 3234 | telephonyService.answerRingingCall(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3235 | |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3236 | // And *don't* pass this key thru to the current activity |
| 3237 | // (which is presumably the InCallScreen.) |
| 3238 | result &= ~ACTION_PASS_TO_USER; |
| 3239 | } |
| 3240 | } catch (RemoteException ex) { |
| 3241 | Log.w(TAG, "ITelephony threw RemoteException", ex); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3242 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3243 | } |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 3244 | } |
Jeff Brown | 4d39605 | 2010-10-29 21:50:21 -0700 | [diff] [blame] | 3245 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3246 | } |
| 3247 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3248 | return result; |
| 3249 | } |
| 3250 | |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 3251 | /** {@inheritDoc} */ |
| 3252 | @Override |
| 3253 | public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags) { |
| 3254 | int result = 0; |
| 3255 | |
| 3256 | final boolean isWakeMotion = (policyFlags |
| 3257 | & (WindowManagerPolicy.FLAG_WAKE | WindowManagerPolicy.FLAG_WAKE_DROPPED)) != 0; |
| 3258 | if (isWakeMotion) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3259 | if (mKeyguardMediator != null && mKeyguardMediator.isShowing()) { |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 3260 | // If the keyguard is showing, let it decide what to do with the wake motion. |
| 3261 | mKeyguardMediator.onWakeMotionWhenKeyguardShowingTq(); |
| 3262 | } else { |
| 3263 | // Otherwise, wake the device ourselves. |
| 3264 | result |= ACTION_POKE_USER_ACTIVITY; |
| 3265 | } |
| 3266 | } |
| 3267 | return result; |
| 3268 | } |
| 3269 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3270 | class PassHeadsetKey implements Runnable { |
| 3271 | KeyEvent mKeyEvent; |
| 3272 | |
| 3273 | PassHeadsetKey(KeyEvent keyEvent) { |
| 3274 | mKeyEvent = keyEvent; |
| 3275 | } |
| 3276 | |
| 3277 | public void run() { |
| 3278 | if (ActivityManagerNative.isSystemReady()) { |
| 3279 | Intent intent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); |
| 3280 | intent.putExtra(Intent.EXTRA_KEY_EVENT, mKeyEvent); |
| 3281 | mContext.sendOrderedBroadcast(intent, null, mBroadcastDone, |
| 3282 | mHandler, Activity.RESULT_OK, null, null); |
| 3283 | } |
| 3284 | } |
| 3285 | } |
| 3286 | |
| 3287 | BroadcastReceiver mBroadcastDone = new BroadcastReceiver() { |
| 3288 | public void onReceive(Context context, Intent intent) { |
| 3289 | mBroadcastWakeLock.release(); |
| 3290 | } |
| 3291 | }; |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 3292 | |
| 3293 | BroadcastReceiver mDockReceiver = new BroadcastReceiver() { |
| 3294 | public void onReceive(Context context, Intent intent) { |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 3295 | if (Intent.ACTION_DOCK_EVENT.equals(intent.getAction())) { |
| 3296 | mDockMode = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, |
| 3297 | Intent.EXTRA_DOCK_STATE_UNDOCKED); |
| 3298 | } else { |
| 3299 | try { |
| 3300 | IUiModeManager uiModeService = IUiModeManager.Stub.asInterface( |
| 3301 | ServiceManager.getService(Context.UI_MODE_SERVICE)); |
| 3302 | mUiMode = uiModeService.getCurrentModeType(); |
| 3303 | } catch (RemoteException e) { |
| 3304 | } |
Dianne Hackborn | 80fa166 | 2009-10-07 14:02:10 -0700 | [diff] [blame] | 3305 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3306 | updateRotation(true); |
Mike Lockwood | e9867d2 | 2009-09-20 01:59:02 -0400 | [diff] [blame] | 3307 | updateOrientationListenerLp(); |
Mike Lockwood | 1753f7f | 2009-08-24 14:49:07 -0700 | [diff] [blame] | 3308 | } |
| 3309 | }; |
| 3310 | |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 3311 | BroadcastReceiver mPowerReceiver = new BroadcastReceiver() { |
| 3312 | public void onReceive(Context context, Intent intent) { |
| 3313 | if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) { |
| 3314 | mPluggedIn = (0 != intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0)); |
| 3315 | if (localLOGV) Log.v(TAG, "BATTERY_CHANGED: " + intent + " plugged=" + mPluggedIn); |
| 3316 | } |
| 3317 | } |
| 3318 | }; |
| 3319 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3320 | /** {@inheritDoc} */ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3321 | public void screenTurnedOff(int why) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 3322 | EventLog.writeEvent(70000, 0); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 3323 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3324 | mScreenOnEarly = false; |
| 3325 | mScreenOnFully = false; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 3326 | } |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3327 | if (mKeyguardMediator != null) { |
| 3328 | mKeyguardMediator.onScreenTurnedOff(why); |
| 3329 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 3330 | synchronized (mLock) { |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 3331 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3332 | updateLockScreenTimeout(); |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 3333 | updateScreenSaverTimeoutLocked(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 3334 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3335 | } |
| 3336 | |
| 3337 | /** {@inheritDoc} */ |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 3338 | public void screenTurningOn(final ScreenOnListener screenOnListener) { |
Dianne Hackborn | 7448901 | 2009-03-24 20:50:09 -0700 | [diff] [blame] | 3339 | EventLog.writeEvent(70000, 1); |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 3340 | if (false) { |
| 3341 | RuntimeException here = new RuntimeException("here"); |
| 3342 | here.fillInStackTrace(); |
| 3343 | Slog.i(TAG, "Screen turning on...", here); |
| 3344 | } |
| 3345 | if (screenOnListener != null) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3346 | if (mKeyguardMediator != null) { |
| 3347 | mKeyguardMediator.onScreenTurnedOn(new KeyguardViewManager.ShowListener() { |
| 3348 | @Override public void onShown(IBinder windowToken) { |
| 3349 | if (windowToken != null) { |
| 3350 | try { |
| 3351 | mWindowManager.waitForWindowDrawn(windowToken, |
| 3352 | new IRemoteCallback.Stub() { |
| 3353 | @Override public void sendResult(Bundle data) { |
| 3354 | Slog.i(TAG, "Lock screen displayed!"); |
| 3355 | screenOnListener.onScreenOn(); |
| 3356 | synchronized (mLock) { |
| 3357 | mScreenOnFully = true; |
| 3358 | } |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 3359 | } |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3360 | }); |
| 3361 | } catch (RemoteException e) { |
| 3362 | } |
| 3363 | } else { |
| 3364 | Slog.i(TAG, "No lock screen!"); |
| 3365 | screenOnListener.onScreenOn(); |
| 3366 | synchronized (mLock) { |
| 3367 | mScreenOnFully = true; |
| 3368 | } |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 3369 | } |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3370 | } |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3371 | }); |
| 3372 | } |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 3373 | } else { |
| 3374 | synchronized (mLock) { |
| 3375 | mScreenOnFully = true; |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 3376 | } |
Dianne Hackborn | 4001109 | 2011-09-22 13:37:48 -0700 | [diff] [blame] | 3377 | } |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 3378 | synchronized (mLock) { |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3379 | mScreenOnEarly = true; |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 3380 | updateOrientationListenerLp(); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3381 | updateLockScreenTimeout(); |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 3382 | updateScreenSaverTimeoutLocked(); |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 3383 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3384 | } |
| 3385 | |
| 3386 | /** {@inheritDoc} */ |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 3387 | public boolean isScreenOnEarly() { |
| 3388 | return mScreenOnEarly; |
| 3389 | } |
| 3390 | |
| 3391 | /** {@inheritDoc} */ |
| 3392 | public boolean isScreenOnFully() { |
| 3393 | return mScreenOnFully; |
Dianne Hackborn | 0874372 | 2009-12-21 12:16:51 -0800 | [diff] [blame] | 3394 | } |
| 3395 | |
| 3396 | /** {@inheritDoc} */ |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3397 | public void enableKeyguard(boolean enabled) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3398 | if (mKeyguardMediator != null) { |
| 3399 | mKeyguardMediator.setKeyguardEnabled(enabled); |
| 3400 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3401 | } |
| 3402 | |
| 3403 | /** {@inheritDoc} */ |
| 3404 | public void exitKeyguardSecurely(OnKeyguardExitResult callback) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3405 | if (mKeyguardMediator != null) { |
| 3406 | mKeyguardMediator.verifyUnlock(callback); |
| 3407 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3408 | } |
| 3409 | |
Mike Lockwood | f791330 | 2009-11-28 22:27:10 -0500 | [diff] [blame] | 3410 | private boolean keyguardIsShowingTq() { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3411 | if (mKeyguardMediator == null) return false; |
Dianne Hackborn | 9dc06cc | 2009-11-17 18:19:23 -0800 | [diff] [blame] | 3412 | return mKeyguardMediator.isShowingAndNotHidden(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3413 | } |
| 3414 | |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 3415 | |
| 3416 | /** {@inheritDoc} */ |
| 3417 | public boolean isKeyguardLocked() { |
| 3418 | return keyguardOn(); |
| 3419 | } |
| 3420 | |
| 3421 | /** {@inheritDoc} */ |
| 3422 | public boolean isKeyguardSecure() { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3423 | if (mKeyguardMediator == null) return false; |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 3424 | return mKeyguardMediator.isSecure(); |
| 3425 | } |
| 3426 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3427 | /** {@inheritDoc} */ |
| 3428 | public boolean inKeyguardRestrictedKeyInputMode() { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3429 | if (mKeyguardMediator == null) return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3430 | return mKeyguardMediator.isInputRestricted(); |
| 3431 | } |
| 3432 | |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 3433 | public void dismissKeyguardLw() { |
| 3434 | if (!mKeyguardMediator.isSecure()) { |
| 3435 | if (mKeyguardMediator.isShowing()) { |
| 3436 | mHandler.post(new Runnable() { |
| 3437 | public void run() { |
| 3438 | mKeyguardMediator.keyguardDone(false, true); |
| 3439 | } |
| 3440 | }); |
| 3441 | } |
| 3442 | } |
| 3443 | } |
| 3444 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3445 | void sendCloseSystemWindows() { |
| 3446 | sendCloseSystemWindows(mContext, null); |
| 3447 | } |
| 3448 | |
| 3449 | void sendCloseSystemWindows(String reason) { |
| 3450 | sendCloseSystemWindows(mContext, reason); |
| 3451 | } |
| 3452 | |
| 3453 | static void sendCloseSystemWindows(Context context, String reason) { |
| 3454 | if (ActivityManagerNative.isSystemReady()) { |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 3455 | try { |
| 3456 | ActivityManagerNative.getDefault().closeSystemDialogs(reason); |
| 3457 | } catch (RemoteException e) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3458 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3459 | } |
| 3460 | } |
Mitsuru Oshima | 831d0d9 | 2009-06-16 18:27:18 -0700 | [diff] [blame] | 3461 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3462 | @Override |
| 3463 | public int rotationForOrientationLw(int orientation, int lastRotation) { |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 3464 | if (false) { |
| 3465 | Slog.v(TAG, "rotationForOrientationLw(orient=" |
| 3466 | + orientation + ", last=" + lastRotation |
| 3467 | + "); user=" + mUserRotation + " " |
| 3468 | + ((mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) |
| 3469 | ? "USER_ROTATION_LOCKED" : "") |
| 3470 | ); |
| 3471 | } |
| 3472 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 3473 | synchronized (mLock) { |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 3474 | int sensorRotation = mOrientationListener.getProposedRotation(); // may be -1 |
| 3475 | if (sensorRotation < 0) { |
| 3476 | sensorRotation = lastRotation; |
| 3477 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3478 | |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 3479 | final int preferredRotation; |
Jeff Brown | eb3e4b9 | 2011-12-06 19:54:24 -0800 | [diff] [blame] | 3480 | if (mLidOpen == LID_OPEN && mLidOpenRotation >= 0) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3481 | // Ignore sensor when lid switch is open and rotation is forced. |
| 3482 | preferredRotation = mLidOpenRotation; |
| 3483 | } else if (mDockMode == Intent.EXTRA_DOCK_STATE_CAR |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 3484 | && (mCarDockEnablesAccelerometer || mCarDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3485 | // Ignore sensor when in car dock unless explicitly enabled. |
| 3486 | // This case can override the behavior of NOSENSOR, and can also |
| 3487 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 3488 | preferredRotation = mCarDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3489 | ? sensorRotation : mCarDockRotation; |
Jeff Brown | 1a69318 | 2011-11-08 14:44:16 -0800 | [diff] [blame] | 3490 | } else if ((mDockMode == Intent.EXTRA_DOCK_STATE_DESK |
| 3491 | || mDockMode == Intent.EXTRA_DOCK_STATE_LE_DESK |
| 3492 | || mDockMode == Intent.EXTRA_DOCK_STATE_HE_DESK) |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 3493 | && (mDeskDockEnablesAccelerometer || mDeskDockRotation >= 0)) { |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3494 | // Ignore sensor when in desk dock unless explicitly enabled. |
| 3495 | // This case can override the behavior of NOSENSOR, and can also |
| 3496 | // enable 180 degree rotation while docked. |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 3497 | preferredRotation = mDeskDockEnablesAccelerometer |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3498 | ? sensorRotation : mDeskDockRotation; |
Jeff Brown | eb3e4b9 | 2011-12-06 19:54:24 -0800 | [diff] [blame] | 3499 | } else if (mHdmiPlugged) { |
| 3500 | // Ignore sensor when plugged into HDMI. |
| 3501 | // Note that the dock orientation overrides the HDMI orientation. |
| 3502 | preferredRotation = mHdmiRotation; |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 3503 | } else if ((mAccelerometerDefault != 0 /* implies not rotation locked */ |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3504 | && (orientation == ActivityInfo.SCREEN_ORIENTATION_USER |
| 3505 | || orientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)) |
| 3506 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR |
| 3507 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR |
| 3508 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE |
| 3509 | || orientation == ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) { |
| 3510 | // Otherwise, use sensor only if requested by the application or enabled |
| 3511 | // by default for USER or UNSPECIFIED modes. Does not apply to NOSENSOR. |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 3512 | if (mAllowAllRotations < 0) { |
| 3513 | // Can't read this during init() because the context doesn't |
| 3514 | // have display metrics at that time so we cannot determine |
| 3515 | // tablet vs. phone then. |
| 3516 | mAllowAllRotations = mContext.getResources().getBoolean( |
| 3517 | com.android.internal.R.bool.config_allowAllRotations) ? 1 : 0; |
| 3518 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3519 | if (sensorRotation != Surface.ROTATION_180 |
Jeff Brown | d3187e3 | 2011-09-21 19:26:44 -0700 | [diff] [blame] | 3520 | || mAllowAllRotations == 1 |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3521 | || orientation == ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR) { |
| 3522 | preferredRotation = sensorRotation; |
| 3523 | } else { |
| 3524 | preferredRotation = lastRotation; |
| 3525 | } |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 3526 | } else if (mUserRotationMode == WindowManagerPolicy.USER_ROTATION_LOCKED) { |
| 3527 | // Apply rotation lock. |
| 3528 | preferredRotation = mUserRotation; |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 3529 | } else { |
| 3530 | // No overriding preference. |
| 3531 | // We will do exactly what the application asked us to do. |
| 3532 | preferredRotation = -1; |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3533 | } |
| 3534 | |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 3535 | switch (orientation) { |
| 3536 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 3537 | // Return portrait unless overridden. |
| 3538 | if (isAnyPortrait(preferredRotation)) { |
| 3539 | return preferredRotation; |
| 3540 | } |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 3541 | return mPortraitRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 3542 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3543 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 3544 | // Return landscape unless overridden. |
| 3545 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 3546 | return preferredRotation; |
| 3547 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3548 | return mLandscapeRotation; |
| 3549 | |
| 3550 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 3551 | // Return reverse portrait unless overridden. |
| 3552 | if (isAnyPortrait(preferredRotation)) { |
| 3553 | return preferredRotation; |
| 3554 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3555 | return mUpsideDownRotation; |
| 3556 | |
| 3557 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
Jeff Brown | dec6cf4 | 2011-11-15 14:08:20 -0800 | [diff] [blame] | 3558 | // Return seascape unless overridden. |
| 3559 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 3560 | return preferredRotation; |
| 3561 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3562 | return mSeascapeRotation; |
| 3563 | |
| 3564 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
| 3565 | // Return either landscape rotation. |
| 3566 | if (isLandscapeOrSeascape(preferredRotation)) { |
| 3567 | return preferredRotation; |
| 3568 | } |
| 3569 | if (isLandscapeOrSeascape(lastRotation)) { |
Jeff Brown | 4519f07 | 2011-01-23 13:16:01 -0800 | [diff] [blame] | 3570 | return lastRotation; |
| 3571 | } |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3572 | return mLandscapeRotation; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3573 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3574 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
| 3575 | // Return either portrait rotation. |
| 3576 | if (isAnyPortrait(preferredRotation)) { |
| 3577 | return preferredRotation; |
| 3578 | } |
| 3579 | if (isAnyPortrait(lastRotation)) { |
| 3580 | return lastRotation; |
| 3581 | } |
| 3582 | return mPortraitRotation; |
| 3583 | |
| 3584 | default: |
Jeff Brown | 4dfce20 | 2011-10-05 12:00:10 -0700 | [diff] [blame] | 3585 | // For USER, UNSPECIFIED, NOSENSOR, SENSOR and FULL_SENSOR, |
| 3586 | // just return the preferred orientation we already calculated. |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3587 | if (preferredRotation >= 0) { |
| 3588 | return preferredRotation; |
| 3589 | } |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 3590 | return Surface.ROTATION_0; |
Daniel Sandler | e7e5ac2 | 2011-02-22 16:10:21 -0500 | [diff] [blame] | 3591 | } |
| 3592 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 3593 | } |
| 3594 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3595 | @Override |
| 3596 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation) { |
| 3597 | switch (orientation) { |
| 3598 | case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT: |
| 3599 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT: |
| 3600 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT: |
| 3601 | return isAnyPortrait(rotation); |
| 3602 | |
| 3603 | case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE: |
| 3604 | case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE: |
| 3605 | case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE: |
| 3606 | return isLandscapeOrSeascape(rotation); |
| 3607 | |
| 3608 | default: |
| 3609 | return true; |
| 3610 | } |
Steve Howard | a7bfe6a | 2010-09-23 16:47:49 -0700 | [diff] [blame] | 3611 | } |
| 3612 | |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 3613 | @Override |
| 3614 | public void setRotationLw(int rotation) { |
| 3615 | mOrientationListener.setCurrentRotation(rotation); |
| 3616 | } |
| 3617 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3618 | private boolean isLandscapeOrSeascape(int rotation) { |
| 3619 | return rotation == mLandscapeRotation || rotation == mSeascapeRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 3620 | } |
| 3621 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3622 | private boolean isAnyPortrait(int rotation) { |
| 3623 | return rotation == mPortraitRotation || rotation == mUpsideDownRotation; |
Dianne Hackborn | e5439f2 | 2010-10-02 16:53:50 -0700 | [diff] [blame] | 3624 | } |
| 3625 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 3626 | |
| 3627 | // User rotation: to be used when all else fails in assigning an orientation to the device |
| 3628 | public void setUserRotationMode(int mode, int rot) { |
| 3629 | ContentResolver res = mContext.getContentResolver(); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 3630 | |
| 3631 | // mUserRotationMode and mUserRotation will be assigned by the content observer |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 3632 | if (mode == WindowManagerPolicy.USER_ROTATION_LOCKED) { |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 3633 | Settings.System.putInt(res, |
| 3634 | Settings.System.USER_ROTATION, |
| 3635 | rot); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 3636 | Settings.System.putInt(res, |
| 3637 | Settings.System.ACCELEROMETER_ROTATION, |
| 3638 | 0); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 3639 | } else { |
| 3640 | Settings.System.putInt(res, |
| 3641 | Settings.System.ACCELEROMETER_ROTATION, |
| 3642 | 1); |
| 3643 | } |
| 3644 | } |
| 3645 | |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 3646 | public void setSafeMode(boolean safeMode) { |
| 3647 | mSafeMode = safeMode; |
| 3648 | performHapticFeedbackLw(null, safeMode |
| 3649 | ? HapticFeedbackConstants.SAFE_MODE_ENABLED |
| 3650 | : HapticFeedbackConstants.SAFE_MODE_DISABLED, true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3651 | } |
| 3652 | |
Dianne Hackborn | 181ceb5 | 2009-08-27 22:16:40 -0700 | [diff] [blame] | 3653 | static long[] getLongIntArray(Resources r, int resid) { |
| 3654 | int[] ar = r.getIntArray(resid); |
| 3655 | if (ar == null) { |
| 3656 | return null; |
| 3657 | } |
| 3658 | long[] out = new long[ar.length]; |
| 3659 | for (int i=0; i<ar.length; i++) { |
| 3660 | out[i] = ar[i]; |
| 3661 | } |
| 3662 | return out; |
| 3663 | } |
| 3664 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3665 | /** {@inheritDoc} */ |
| 3666 | public void systemReady() { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3667 | if (mKeyguardMediator != null) { |
| 3668 | // tell the keyguard |
| 3669 | mKeyguardMediator.onSystemReady(); |
| 3670 | } |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 3671 | synchronized (mLock) { |
| 3672 | updateOrientationListenerLp(); |
Dianne Hackborn | c777e07 | 2010-02-12 13:07:59 -0800 | [diff] [blame] | 3673 | mSystemReady = true; |
| 3674 | mHandler.post(new Runnable() { |
| 3675 | public void run() { |
| 3676 | updateSettings(); |
| 3677 | } |
| 3678 | }); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3679 | } |
| 3680 | } |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 3681 | |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 3682 | /** {@inheritDoc} */ |
| 3683 | public void systemBooted() { |
| 3684 | synchronized (mLock) { |
| 3685 | mSystemBooted = true; |
| 3686 | } |
| 3687 | } |
| 3688 | |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 3689 | ProgressDialog mBootMsgDialog = null; |
| 3690 | |
| 3691 | /** {@inheritDoc} */ |
| 3692 | public void showBootMessage(final CharSequence msg, final boolean always) { |
Mike Lockwood | aa5bf14 | 2011-09-21 13:03:40 -0400 | [diff] [blame] | 3693 | if (mHeadless) return; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 3694 | mHandler.post(new Runnable() { |
| 3695 | @Override public void run() { |
| 3696 | if (mBootMsgDialog == null) { |
Dianne Hackborn | 295e3c2 | 2011-08-25 13:19:08 -0700 | [diff] [blame] | 3697 | mBootMsgDialog = new ProgressDialog(mContext) { |
| 3698 | // This dialog will consume all events coming in to |
| 3699 | // it, to avoid it trying to do things too early in boot. |
| 3700 | @Override public boolean dispatchKeyEvent(KeyEvent event) { |
| 3701 | return true; |
| 3702 | } |
| 3703 | @Override public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 3704 | return true; |
| 3705 | } |
| 3706 | @Override public boolean dispatchTouchEvent(MotionEvent ev) { |
| 3707 | return true; |
| 3708 | } |
| 3709 | @Override public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 3710 | return true; |
| 3711 | } |
| 3712 | @Override public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 3713 | return true; |
| 3714 | } |
| 3715 | @Override public boolean dispatchPopulateAccessibilityEvent( |
| 3716 | AccessibilityEvent event) { |
| 3717 | return true; |
| 3718 | } |
| 3719 | }; |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 3720 | mBootMsgDialog.setTitle(R.string.android_upgrading_title); |
| 3721 | mBootMsgDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); |
| 3722 | mBootMsgDialog.setIndeterminate(true); |
| 3723 | mBootMsgDialog.getWindow().setType( |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 3724 | WindowManager.LayoutParams.TYPE_BOOT_PROGRESS); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 3725 | mBootMsgDialog.getWindow().addFlags( |
| 3726 | WindowManager.LayoutParams.FLAG_DIM_BEHIND |
| 3727 | | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); |
| 3728 | mBootMsgDialog.getWindow().setDimAmount(1); |
Dianne Hackborn | d9efb95 | 2011-12-07 14:56:51 -0800 | [diff] [blame] | 3729 | WindowManager.LayoutParams lp = mBootMsgDialog.getWindow().getAttributes(); |
| 3730 | lp.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR; |
| 3731 | mBootMsgDialog.getWindow().setAttributes(lp); |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 3732 | mBootMsgDialog.setCancelable(false); |
| 3733 | mBootMsgDialog.show(); |
| 3734 | } |
| 3735 | mBootMsgDialog.setMessage(msg); |
| 3736 | } |
| 3737 | }); |
| 3738 | } |
| 3739 | |
| 3740 | /** {@inheritDoc} */ |
| 3741 | public void hideBootMessages() { |
| 3742 | mHandler.post(new Runnable() { |
| 3743 | @Override public void run() { |
| 3744 | if (mBootMsgDialog != null) { |
| 3745 | mBootMsgDialog.dismiss(); |
| 3746 | mBootMsgDialog = null; |
| 3747 | } |
| 3748 | } |
| 3749 | }); |
| 3750 | } |
| 3751 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3752 | /** {@inheritDoc} */ |
| 3753 | public void userActivity() { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 3754 | // *************************************** |
| 3755 | // NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE |
| 3756 | // *************************************** |
| 3757 | // THIS IS CALLED FROM DEEP IN THE POWER MANAGER |
| 3758 | // WITH ITS LOCKS HELD. |
| 3759 | // |
| 3760 | // This code must be VERY careful about the locks |
| 3761 | // it acquires. |
| 3762 | // In fact, the current code acquires way too many, |
| 3763 | // and probably has lurking deadlocks. |
| 3764 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3765 | synchronized (mScreenLockTimeout) { |
| 3766 | if (mLockScreenTimerActive) { |
| 3767 | // reset the timer |
| 3768 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 3769 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 3770 | } |
| 3771 | } |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 3772 | |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3773 | synchronized (mLock) { |
| 3774 | // Only posts messages; holds no additional locks. |
| 3775 | updateScreenSaverTimeoutLocked(); |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 3776 | } |
| 3777 | } |
| 3778 | |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3779 | Runnable mScreenSaverActivator = new Runnable() { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 3780 | public void run() { |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 3781 | if (!(mScreenSaverMayRun && mScreenOnEarly)) { |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3782 | Log.w(TAG, "mScreenSaverActivator ran, but the screensaver should not be showing. Who's driving this thing?"); |
| 3783 | return; |
| 3784 | } |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 3785 | if (!mPluggedIn) { |
| 3786 | if (localLOGV) Log.v(TAG, "mScreenSaverActivator: not running screen saver when not plugged in"); |
| 3787 | return; |
| 3788 | } |
Daniel Sandler | 7d46c61 | 2011-11-23 09:03:51 -0500 | [diff] [blame] | 3789 | // Quick fix for automation tests. |
| 3790 | // The correct fix is to move this triggering logic to PowerManager, where more complete |
| 3791 | // information about wakelocks (including StayOnWhilePluggedIn) is available. |
| 3792 | if (Settings.System.getInt(mContext.getContentResolver(), |
| 3793 | Settings.System.STAY_ON_WHILE_PLUGGED_IN, |
| 3794 | BatteryManager.BATTERY_PLUGGED_AC) != 0) { |
| 3795 | Log.v(TAG, "mScreenSaverActivator: not running screen saver when STAY_ON_WHILE_PLUGGED_IN"); |
| 3796 | return; |
| 3797 | } |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 3798 | |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3799 | if (localLOGV) Log.v(TAG, "mScreenSaverActivator entering dreamland"); |
Daniel Sandler | 7e37df5 | 2011-11-16 22:08:23 -0800 | [diff] [blame] | 3800 | |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3801 | try { |
| 3802 | String component = Settings.Secure.getString( |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 3803 | mContext.getContentResolver(), Settings.Secure.SCREENSAVER_COMPONENT); |
Daniel Sandler | c224f76 | 2011-11-15 22:55:03 -0800 | [diff] [blame] | 3804 | if (component == null) { |
| 3805 | component = mContext.getResources().getString(R.string.config_defaultDreamComponent); |
| 3806 | } |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3807 | if (component != null) { |
Daniel Sandler | 5207d9c | 2011-11-18 09:30:08 -0800 | [diff] [blame] | 3808 | // dismiss the notification shade, recents, etc. |
Dianne Hackborn | 672342c | 2011-11-29 11:29:02 -0800 | [diff] [blame] | 3809 | mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS) |
| 3810 | .addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT)); |
Daniel Sandler | 5207d9c | 2011-11-18 09:30:08 -0800 | [diff] [blame] | 3811 | |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3812 | ComponentName cn = ComponentName.unflattenFromString(component); |
| 3813 | Intent intent = new Intent(Intent.ACTION_MAIN) |
| 3814 | .setComponent(cn) |
| 3815 | .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 3816 | | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS |
| 3817 | | Intent.FLAG_ACTIVITY_NO_USER_ACTION |
Daniel Sandler | 5207d9c | 2011-11-18 09:30:08 -0800 | [diff] [blame] | 3818 | | Intent.FLAG_FROM_BACKGROUND |
| 3819 | | Intent.FLAG_ACTIVITY_NO_HISTORY |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3820 | ); |
| 3821 | mContext.startActivity(intent); |
| 3822 | } else { |
| 3823 | Log.e(TAG, "Couldn't start screen saver: none selected"); |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 3824 | } |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3825 | } catch (android.content.ActivityNotFoundException exc) { |
| 3826 | // no screensaver? give up |
| 3827 | Log.e(TAG, "Couldn't start screen saver: none installed"); |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 3828 | } |
| 3829 | } |
| 3830 | }; |
| 3831 | |
| 3832 | // Must call while holding mLock |
| 3833 | private void updateScreenSaverTimeoutLocked() { |
Daniel Sandler | ee91d94 | 2011-08-03 14:13:36 -0400 | [diff] [blame] | 3834 | if (mScreenSaverActivator == null) return; |
| 3835 | |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3836 | mHandler.removeCallbacks(mScreenSaverActivator); |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 3837 | if (mScreenSaverEnabledByUser && mScreenSaverMayRun && mScreenOnEarly && mScreenSaverTimeout > 0) { |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3838 | if (localLOGV) |
| 3839 | Log.v(TAG, "scheduling screensaver for " + mScreenSaverTimeout + "ms from now"); |
| 3840 | mHandler.postDelayed(mScreenSaverActivator, mScreenSaverTimeout); |
| 3841 | } else { |
| 3842 | if (localLOGV) { |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 3843 | if (!mScreenSaverEnabledByUser || mScreenSaverTimeout == 0) |
Daniel Sandler | e5f2cfe | 2011-11-02 23:30:58 -0400 | [diff] [blame] | 3844 | Log.v(TAG, "screen saver disabled by user"); |
| 3845 | else if (!mScreenOnEarly) |
| 3846 | Log.v(TAG, "screen saver disabled while screen off"); |
| 3847 | else |
| 3848 | Log.v(TAG, "screen saver disabled by wakelock"); |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 3849 | } |
| 3850 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3851 | } |
| 3852 | |
| 3853 | Runnable mScreenLockTimeout = new Runnable() { |
| 3854 | public void run() { |
| 3855 | synchronized (this) { |
| 3856 | if (localLOGV) Log.v(TAG, "mScreenLockTimeout activating keyguard"); |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3857 | if (mKeyguardMediator != null) { |
| 3858 | mKeyguardMediator.doKeyguardTimeout(); |
| 3859 | } |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3860 | mLockScreenTimerActive = false; |
| 3861 | } |
| 3862 | } |
| 3863 | }; |
| 3864 | |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 3865 | public void lockNow() { |
| 3866 | mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null); |
| 3867 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 3868 | mHandler.post(mScreenLockTimeout); |
| 3869 | } |
| 3870 | |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3871 | private void updateLockScreenTimeout() { |
| 3872 | synchronized (mScreenLockTimeout) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 3873 | boolean enable = (mAllowLockscreenWhenOn && mScreenOnEarly && |
| 3874 | mKeyguardMediator != null && mKeyguardMediator.isSecure()); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 3875 | if (mLockScreenTimerActive != enable) { |
| 3876 | if (enable) { |
| 3877 | if (localLOGV) Log.v(TAG, "setting lockscreen timer"); |
| 3878 | mHandler.postDelayed(mScreenLockTimeout, mLockScreenTimeout); |
| 3879 | } else { |
| 3880 | if (localLOGV) Log.v(TAG, "clearing lockscreen timer"); |
| 3881 | mHandler.removeCallbacks(mScreenLockTimeout); |
| 3882 | } |
| 3883 | mLockScreenTimerActive = enable; |
| 3884 | } |
| 3885 | } |
| 3886 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3887 | |
| 3888 | /** {@inheritDoc} */ |
| 3889 | public void enableScreenAfterBoot() { |
| 3890 | readLidState(); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3891 | updateKeyboardVisibility(); |
| 3892 | |
| 3893 | updateRotation(true); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3894 | } |
Dianne Hackborn | f54c8f9 | 2009-09-19 14:03:57 -0700 | [diff] [blame] | 3895 | |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3896 | private void updateKeyboardVisibility() { |
Jeff Brown | 4aed78b | 2011-01-14 17:36:55 -0800 | [diff] [blame] | 3897 | mPowerManager.setKeyboardVisibility(mLidOpen == LID_OPEN); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 3898 | } |
| 3899 | |
| 3900 | void updateRotation(boolean alwaysSendConfiguration) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3901 | try { |
| 3902 | //set orientation on WindowManager |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 3903 | mWindowManager.updateRotation(alwaysSendConfiguration, false); |
| 3904 | } catch (RemoteException e) { |
| 3905 | // Ignore |
| 3906 | } |
| 3907 | } |
| 3908 | |
| 3909 | void updateRotation(boolean alwaysSendConfiguration, boolean forceRelayout) { |
| 3910 | try { |
| 3911 | //set orientation on WindowManager |
| 3912 | mWindowManager.updateRotation(alwaysSendConfiguration, forceRelayout); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3913 | } catch (RemoteException e) { |
| 3914 | // Ignore |
| 3915 | } |
| 3916 | } |
| 3917 | |
| 3918 | /** |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 3919 | * Return an Intent to launch the currently active dock app as home. Returns |
| 3920 | * null if the standard home should be launched, which is the case if any of the following is |
| 3921 | * true: |
| 3922 | * <ul> |
| 3923 | * <li>The device is not in either car mode or desk mode |
| 3924 | * <li>The device is in car mode but ENABLE_CAR_DOCK_HOME_CAPTURE is false |
| 3925 | * <li>The device is in desk mode but ENABLE_DESK_DOCK_HOME_CAPTURE is false |
| 3926 | * <li>The device is in car mode but there's no CAR_DOCK app with METADATA_DOCK_HOME |
| 3927 | * <li>The device is in desk mode but there's no DESK_DOCK app with METADATA_DOCK_HOME |
| 3928 | * </ul> |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3929 | * @return |
| 3930 | */ |
| 3931 | Intent createHomeDockIntent() { |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 3932 | Intent intent = null; |
Dianne Hackborn | 867ab647 | 2010-04-29 13:28:56 -0700 | [diff] [blame] | 3933 | |
| 3934 | // What home does is based on the mode, not the dock state. That |
| 3935 | // is, when in car mode you should be taken to car home regardless |
| 3936 | // of whether we are actually in a car dock. |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 3937 | if (mUiMode == Configuration.UI_MODE_TYPE_CAR) { |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 3938 | if (ENABLE_CAR_DOCK_HOME_CAPTURE) { |
| 3939 | intent = mCarDockIntent; |
| 3940 | } |
Dianne Hackborn | 7896839 | 2010-03-04 20:47:56 -0800 | [diff] [blame] | 3941 | } else if (mUiMode == Configuration.UI_MODE_TYPE_DESK) { |
Daniel Sandler | 11ddf53 | 2011-11-16 11:10:03 -0800 | [diff] [blame] | 3942 | if (ENABLE_DESK_DOCK_HOME_CAPTURE) { |
| 3943 | intent = mDeskDockIntent; |
| 3944 | } |
| 3945 | } |
| 3946 | |
| 3947 | if (intent == null) { |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3948 | return null; |
| 3949 | } |
| 3950 | |
| 3951 | ActivityInfo ai = intent.resolveActivityInfo( |
| 3952 | mContext.getPackageManager(), PackageManager.GET_META_DATA); |
| 3953 | if (ai == null) { |
| 3954 | return null; |
| 3955 | } |
| 3956 | |
| 3957 | if (ai.metaData != null && ai.metaData.getBoolean(Intent.METADATA_DOCK_HOME)) { |
| 3958 | intent = new Intent(intent); |
| 3959 | intent.setClassName(ai.packageName, ai.name); |
| 3960 | return intent; |
| 3961 | } |
| 3962 | |
| 3963 | return null; |
| 3964 | } |
| 3965 | |
| 3966 | void startDockOrHome() { |
| 3967 | Intent dock = createHomeDockIntent(); |
| 3968 | if (dock != null) { |
| 3969 | try { |
| 3970 | mContext.startActivity(dock); |
| 3971 | return; |
| 3972 | } catch (ActivityNotFoundException e) { |
| 3973 | } |
| 3974 | } |
| 3975 | mContext.startActivity(mHomeIntent); |
| 3976 | } |
| 3977 | |
| 3978 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3979 | * goes to the home screen |
| 3980 | * @return whether it did anything |
| 3981 | */ |
| 3982 | boolean goHome() { |
| 3983 | if (false) { |
| 3984 | // This code always brings home to the front. |
Dianne Hackborn | 256dd3b | 2009-05-19 18:51:21 -0700 | [diff] [blame] | 3985 | try { |
| 3986 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 3987 | } catch (RemoteException e) { |
| 3988 | } |
Dianne Hackborn | 94a679d | 2009-07-28 17:51:07 -0700 | [diff] [blame] | 3989 | sendCloseSystemWindows(); |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 3990 | startDockOrHome(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3991 | } else { |
| 3992 | // This code brings home to the front or, if it is already |
| 3993 | // at the front, puts the device to sleep. |
| 3994 | try { |
Wink Saville | d2e6a33 | 2010-02-12 12:12:06 -0800 | [diff] [blame] | 3995 | if (SystemProperties.getInt("persist.sys.uts-test-mode", 0) == 1) { |
| 3996 | /// Roll back EndcallBehavior as the cupcake design to pass P1 lab entry. |
| 3997 | Log.d(TAG, "UTS-TEST-MODE"); |
| 3998 | } else { |
| 3999 | ActivityManagerNative.getDefault().stopAppSwitches(); |
| 4000 | sendCloseSystemWindows(); |
| 4001 | Intent dock = createHomeDockIntent(); |
| 4002 | if (dock != null) { |
| 4003 | int result = ActivityManagerNative.getDefault() |
| 4004 | .startActivity(null, dock, |
| 4005 | dock.resolveTypeIfNeeded(mContext.getContentResolver()), |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 4006 | null, null, 0, |
| 4007 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
| 4008 | null, null, null); |
| 4009 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
Wink Saville | d2e6a33 | 2010-02-12 12:12:06 -0800 | [diff] [blame] | 4010 | return false; |
| 4011 | } |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 4012 | } |
| 4013 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4014 | int result = ActivityManagerNative.getDefault() |
| 4015 | .startActivity(null, mHomeIntent, |
| 4016 | mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()), |
Dianne Hackborn | a4972e9 | 2012-03-14 10:38:05 -0700 | [diff] [blame] | 4017 | null, null, 0, |
| 4018 | ActivityManager.START_FLAG_ONLY_IF_NEEDED, |
| 4019 | null, null, null); |
| 4020 | if (result == ActivityManager.START_RETURN_INTENT_TO_CALLER) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4021 | return false; |
| 4022 | } |
| 4023 | } catch (RemoteException ex) { |
| 4024 | // bummer, the activity manager, which is in this process, is dead |
| 4025 | } |
| 4026 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4027 | return true; |
| 4028 | } |
| 4029 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4030 | public void setCurrentOrientationLw(int newOrientation) { |
| 4031 | synchronized (mLock) { |
| 4032 | if (newOrientation != mCurrentAppOrientation) { |
| 4033 | mCurrentAppOrientation = newOrientation; |
| 4034 | updateOrientationListenerLp(); |
| 4035 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4036 | } |
| 4037 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4038 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4039 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always) { |
Jim Miller | 89b1722 | 2009-10-27 14:54:09 -0700 | [diff] [blame] | 4040 | final boolean hapticsDisabled = Settings.System.getInt(mContext.getContentResolver(), |
| 4041 | Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) == 0; |
Dianne Hackborn | 9dc06cc | 2009-11-17 18:19:23 -0800 | [diff] [blame] | 4042 | if (!always && (hapticsDisabled || mKeyguardMediator.isShowingAndNotHidden())) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4043 | return false; |
| 4044 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4045 | long[] pattern = null; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4046 | switch (effectId) { |
| 4047 | case HapticFeedbackConstants.LONG_PRESS: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4048 | pattern = mLongPressVibePattern; |
| 4049 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 4050 | case HapticFeedbackConstants.VIRTUAL_KEY: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4051 | pattern = mVirtualKeyVibePattern; |
| 4052 | break; |
| 4053 | case HapticFeedbackConstants.KEYBOARD_TAP: |
| 4054 | pattern = mKeyboardTapVibePattern; |
| 4055 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 4056 | case HapticFeedbackConstants.SAFE_MODE_DISABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4057 | pattern = mSafeModeDisabledVibePattern; |
| 4058 | break; |
Dianne Hackborn | b1a7980 | 2009-09-29 15:18:31 -0700 | [diff] [blame] | 4059 | case HapticFeedbackConstants.SAFE_MODE_ENABLED: |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4060 | pattern = mSafeModeEnabledVibePattern; |
| 4061 | break; |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4062 | default: |
| 4063 | return false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4064 | } |
Amith Yamasani | c33cb71 | 2010-02-10 15:21:49 -0800 | [diff] [blame] | 4065 | if (pattern.length == 1) { |
| 4066 | // One-shot vibration |
| 4067 | mVibrator.vibrate(pattern[0]); |
| 4068 | } else { |
| 4069 | // Pattern vibration |
| 4070 | mVibrator.vibrate(pattern, -1); |
| 4071 | } |
| 4072 | return true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4073 | } |
| 4074 | |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 4075 | public void screenOnStartedLw() { |
| 4076 | // The window manager has just grabbed a wake lock. This is our cue to disable the screen |
| 4077 | // saver. |
| 4078 | synchronized (mLock) { |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 4079 | mScreenSaverMayRun = false; |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 4080 | } |
| 4081 | } |
| 4082 | |
The Android Open Source Project | 0727d22 | 2009-03-11 12:11:58 -0700 | [diff] [blame] | 4083 | public void screenOnStoppedLw() { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 4084 | if (mPowerManager.isScreenOn()) { |
Mike Lockwood | 3a74bd3 | 2011-08-12 13:55:22 -0700 | [diff] [blame] | 4085 | if (mKeyguardMediator != null && !mKeyguardMediator.isShowingAndNotHidden()) { |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 4086 | long curTime = SystemClock.uptimeMillis(); |
| 4087 | mPowerManager.userActivity(curTime, false, LocalPowerManager.OTHER_EVENT); |
| 4088 | } |
| 4089 | |
| 4090 | synchronized (mLock) { |
| 4091 | // even if the keyguard is up, now that all the wakelocks have been released, we |
| 4092 | // should re-enable the screen saver |
Daniel Sandler | 2d54536 | 2011-11-17 10:38:37 -0800 | [diff] [blame] | 4093 | mScreenSaverMayRun = true; |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 4094 | updateScreenSaverTimeoutLocked(); |
| 4095 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4096 | } |
| 4097 | } |
Mike Lockwood | fcb3924 | 2009-10-21 23:01:07 -0400 | [diff] [blame] | 4098 | |
| 4099 | public boolean allowKeyRepeat() { |
| 4100 | // disable key repeat when screen is off |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4101 | return mScreenOnEarly; |
Mike Lockwood | fcb3924 | 2009-10-21 23:01:07 -0400 | [diff] [blame] | 4102 | } |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 4103 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4104 | private int updateSystemUiVisibilityLw() { |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4105 | // If there is no window focused, there will be nobody to handle the events |
| 4106 | // anyway, so just hang on in whatever state we're in until things settle down. |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4107 | if (mFocusedWindow == null) { |
| 4108 | return 0; |
| 4109 | } |
| 4110 | final int visibility = mFocusedWindow.getSystemUiVisibility() |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 4111 | & ~mResettingSystemUiFlags |
| 4112 | & ~mForceClearedSystemUiFlags; |
| 4113 | int diff = visibility ^ mLastSystemUiFlags; |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 4114 | final boolean needsMenu = mFocusedWindow.getNeedsMenuLw(mTopFullscreenOpaqueWindowState); |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 4115 | if (diff == 0 && mLastFocusNeedsMenu == needsMenu |
| 4116 | && mFocusedApp == mFocusedWindow.getAppToken()) { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4117 | return 0; |
| 4118 | } |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 4119 | mLastSystemUiFlags = visibility; |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 4120 | mLastFocusNeedsMenu = needsMenu; |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 4121 | mFocusedApp = mFocusedWindow.getAppToken(); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4122 | mHandler.post(new Runnable() { |
| 4123 | public void run() { |
| 4124 | if (mStatusBarService == null) { |
| 4125 | mStatusBarService = IStatusBarService.Stub.asInterface( |
| 4126 | ServiceManager.getService("statusbar")); |
| 4127 | } |
| 4128 | if (mStatusBarService != null) { |
| 4129 | try { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4130 | mStatusBarService.setSystemUiVisibility(visibility, 0xffffffff); |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 4131 | mStatusBarService.topAppWindowChanged(needsMenu); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4132 | } catch (RemoteException e) { |
| 4133 | // not much to be done |
| 4134 | mStatusBarService = null; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4135 | } |
| 4136 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4137 | } |
| 4138 | }); |
| 4139 | return diff; |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 4140 | } |
| 4141 | |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 4142 | // Use this instead of checking config_showNavigationBar so that it can be consistently |
| 4143 | // overridden by qemu.hw.mainkeys in the emulator. |
| 4144 | public boolean hasNavigationBar() { |
| 4145 | return mHasNavigationBar; |
| 4146 | } |
| 4147 | |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 4148 | public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args) { |
| 4149 | pw.print(prefix); pw.print("mSafeMode="); pw.print(mSafeMode); |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 4150 | pw.print(" mSystemReady="); pw.print(mSystemReady); |
| 4151 | pw.print(" mSystemBooted="); pw.println(mSystemBooted); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 4152 | pw.print(prefix); pw.print("mLidOpen="); pw.print(mLidOpen); |
| 4153 | pw.print(" mLidOpenRotation="); pw.print(mLidOpenRotation); |
| 4154 | pw.print(" mHdmiPlugged="); pw.println(mHdmiPlugged); |
Dianne Hackborn | e26ab70 | 2011-10-16 13:21:33 -0700 | [diff] [blame] | 4155 | if (mLastSystemUiFlags != 0 || mResettingSystemUiFlags != 0 |
| 4156 | || mForceClearedSystemUiFlags != 0) { |
| 4157 | pw.print(prefix); pw.print("mLastSystemUiFlags=0x"); |
| 4158 | pw.print(Integer.toHexString(mLastSystemUiFlags)); |
| 4159 | pw.print(" mResettingSystemUiFlags=0x"); |
| 4160 | pw.print(Integer.toHexString(mResettingSystemUiFlags)); |
| 4161 | pw.print(" mForceClearedSystemUiFlags=0x"); |
| 4162 | pw.println(Integer.toHexString(mForceClearedSystemUiFlags)); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 4163 | } |
Dianne Hackborn | 4eff8d3 | 2011-11-10 19:38:40 -0800 | [diff] [blame] | 4164 | if (mLastFocusNeedsMenu) { |
| 4165 | pw.print(prefix); pw.print("mLastFocusNeedsMenu="); |
| 4166 | pw.println(mLastFocusNeedsMenu); |
| 4167 | } |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 4168 | pw.print(prefix); pw.print("mUiMode="); pw.print(mUiMode); |
| 4169 | pw.print(" mDockMode="); pw.print(mDockMode); |
| 4170 | pw.print(" mCarDockRotation="); pw.print(mCarDockRotation); |
| 4171 | pw.print(" mDeskDockRotation="); pw.println(mDeskDockRotation); |
| 4172 | pw.print(prefix); pw.print("mUserRotationMode="); pw.print(mUserRotationMode); |
| 4173 | pw.print(" mUserRotation="); pw.print(mUserRotation); |
Daniel Sandler | 2ed6ad6 | 2011-02-22 14:54:17 -0500 | [diff] [blame] | 4174 | pw.print(" mAllowAllRotations="); pw.println(mAllowAllRotations); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 4175 | pw.print(prefix); pw.print("mAccelerometerDefault="); pw.print(mAccelerometerDefault); |
| 4176 | pw.print(" mCurrentAppOrientation="); pw.println(mCurrentAppOrientation); |
| 4177 | pw.print(prefix); pw.print("mCarDockEnablesAccelerometer="); |
| 4178 | pw.print(mCarDockEnablesAccelerometer); |
| 4179 | pw.print(" mDeskDockEnablesAccelerometer="); |
| 4180 | pw.println(mDeskDockEnablesAccelerometer); |
| 4181 | pw.print(prefix); pw.print("mLidKeyboardAccessibility="); |
| 4182 | pw.print(mLidKeyboardAccessibility); |
| 4183 | pw.print(" mLidNavigationAccessibility="); pw.print(mLidNavigationAccessibility); |
| 4184 | pw.print(" mLongPressOnPowerBehavior="); pw.println(mLongPressOnPowerBehavior); |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 4185 | pw.print(prefix); pw.print("mScreenOnEarly="); pw.print(mScreenOnEarly); |
| 4186 | pw.print(" mScreenOnFully="); pw.print(mScreenOnFully); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 4187 | pw.print(" mOrientationSensorEnabled="); pw.print(mOrientationSensorEnabled); |
| 4188 | pw.print(" mHasSoftInput="); pw.println(mHasSoftInput); |
| 4189 | pw.print(prefix); pw.print("mUnrestrictedScreen=("); pw.print(mUnrestrictedScreenLeft); |
| 4190 | pw.print(","); pw.print(mUnrestrictedScreenTop); |
| 4191 | pw.print(") "); pw.print(mUnrestrictedScreenWidth); |
| 4192 | pw.print("x"); pw.println(mUnrestrictedScreenHeight); |
| 4193 | pw.print(prefix); pw.print("mRestrictedScreen=("); pw.print(mRestrictedScreenLeft); |
| 4194 | pw.print(","); pw.print(mRestrictedScreenTop); |
| 4195 | pw.print(") "); pw.print(mRestrictedScreenWidth); |
| 4196 | pw.print("x"); pw.println(mRestrictedScreenHeight); |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 4197 | pw.print(prefix); pw.print("mStable=("); pw.print(mStableLeft); |
| 4198 | pw.print(","); pw.print(mStableTop); |
| 4199 | pw.print(")-("); pw.print(mStableRight); |
| 4200 | pw.print(","); pw.print(mStableBottom); pw.println(")"); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 4201 | pw.print(prefix); pw.print("mCur=("); pw.print(mCurLeft); |
| 4202 | pw.print(","); pw.print(mCurTop); |
| 4203 | pw.print(")-("); pw.print(mCurRight); |
| 4204 | pw.print(","); pw.print(mCurBottom); pw.println(")"); |
| 4205 | pw.print(prefix); pw.print("mContent=("); pw.print(mContentLeft); |
| 4206 | pw.print(","); pw.print(mContentTop); |
| 4207 | pw.print(")-("); pw.print(mContentRight); |
| 4208 | pw.print(","); pw.print(mContentBottom); pw.println(")"); |
| 4209 | pw.print(prefix); pw.print("mDock=("); pw.print(mDockLeft); |
| 4210 | pw.print(","); pw.print(mDockTop); |
| 4211 | pw.print(")-("); pw.print(mDockRight); |
| 4212 | pw.print(","); pw.print(mDockBottom); pw.println(")"); |
| 4213 | pw.print(prefix); pw.print("mDockLayer="); pw.println(mDockLayer); |
| 4214 | pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState="); |
| 4215 | pw.println(mTopFullscreenOpaqueWindowState); |
| 4216 | pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen); |
| 4217 | pw.print(" mForceStatusBar="); pw.print(mForceStatusBar); |
| 4218 | pw.print(" mHideLockScreen="); pw.println(mHideLockScreen); |
| 4219 | pw.print(prefix); pw.print("mDismissKeyguard="); pw.print(mDismissKeyguard); |
| 4220 | pw.print(" mHomePressed="); pw.println(mHomePressed); |
| 4221 | pw.print(prefix); pw.print("mAllowLockscreenWhenOn="); pw.print(mAllowLockscreenWhenOn); |
| 4222 | pw.print(" mLockScreenTimeout="); pw.print(mLockScreenTimeout); |
| 4223 | pw.print(" mLockScreenTimerActive="); pw.println(mLockScreenTimerActive); |
| 4224 | pw.print(prefix); pw.print("mEndcallBehavior="); pw.print(mEndcallBehavior); |
| 4225 | pw.print(" mIncallPowerBehavior="); pw.print(mIncallPowerBehavior); |
| 4226 | pw.print(" mLongPressOnHomeBehavior="); pw.println(mLongPressOnHomeBehavior); |
| 4227 | pw.print(prefix); pw.print("mLandscapeRotation="); pw.print(mLandscapeRotation); |
| 4228 | pw.print(" mSeascapeRotation="); pw.println(mSeascapeRotation); |
| 4229 | pw.print(prefix); pw.print("mPortraitRotation="); pw.print(mPortraitRotation); |
| 4230 | pw.print(" mUpsideDownRotation="); pw.println(mUpsideDownRotation); |
| 4231 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 4232 | } |