The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1 | /* |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 2 | * Copyright (C) 2014 The Android Open Source Project |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 14 | * limitations under the License |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 15 | */ |
| 16 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 17 | package com.android.systemui.keyguard; |
Jim Miller | bc4603b | 2010-08-30 21:21:34 -0700 | [diff] [blame] | 18 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 19 | import android.app.Activity; |
Dianne Hackborn | 4994c66 | 2009-09-23 22:21:23 -0700 | [diff] [blame] | 20 | import android.app.ActivityManagerNative; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 21 | import android.app.AlarmManager; |
| 22 | import android.app.PendingIntent; |
John Spurlock | 43d8451 | 2012-11-09 10:27:33 -0500 | [diff] [blame] | 23 | import android.app.SearchManager; |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 24 | import android.app.StatusBarManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 25 | import android.content.BroadcastReceiver; |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 26 | import android.content.ContentResolver; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 27 | import android.content.Context; |
| 28 | import android.content.Intent; |
| 29 | import android.content.IntentFilter; |
Daniel Sandler | aec967a | 2010-02-20 01:05:22 -0500 | [diff] [blame] | 30 | import android.media.AudioManager; |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 31 | import android.media.SoundPool; |
Adrian Roos | 58b58fe | 2014-01-31 16:00:39 -0800 | [diff] [blame] | 32 | import android.os.Build; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 33 | import android.os.Bundle; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 34 | import android.os.Handler; |
Jeff Brown | 109025d | 2012-08-14 20:41:30 -0700 | [diff] [blame] | 35 | import android.os.Looper; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 36 | import android.os.Message; |
| 37 | import android.os.PowerManager; |
Dianne Hackborn | 4994c66 | 2009-09-23 22:21:23 -0700 | [diff] [blame] | 38 | import android.os.RemoteException; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 39 | import android.os.SystemClock; |
Jim Miller | 1b15202 | 2009-10-28 16:08:15 -0700 | [diff] [blame] | 40 | import android.os.SystemProperties; |
Jeff Sharkey | 6a25cbd | 2012-08-23 12:14:26 -0700 | [diff] [blame] | 41 | import android.os.UserHandle; |
Amith Yamasani | b70ff9a | 2012-09-07 18:28:11 -0700 | [diff] [blame] | 42 | import android.os.UserManager; |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 43 | import android.provider.Settings; |
Karl Rosaen | ab10008 | 2009-03-24 22:35:17 -0700 | [diff] [blame] | 44 | import android.telephony.TelephonyManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 45 | import android.util.EventLog; |
Karl Rosaen | ab10008 | 2009-03-24 22:35:17 -0700 | [diff] [blame] | 46 | import android.util.Log; |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 47 | import android.util.Slog; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 48 | import android.view.ViewGroup; |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 49 | import android.view.IWindowManager; |
| 50 | import android.view.WindowManagerGlobal; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 51 | import android.view.WindowManagerPolicy; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 52 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 53 | import com.android.internal.policy.IKeyguardExitCallback; |
| 54 | import com.android.internal.policy.IKeyguardShowCallback; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 55 | import com.android.internal.telephony.IccCardConstants; |
| 56 | import com.android.internal.widget.LockPatternUtils; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 57 | import com.android.keyguard.KeyguardDisplayManager; |
| 58 | import com.android.keyguard.KeyguardUpdateMonitor; |
| 59 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
| 60 | import com.android.keyguard.MultiUserAvatarCache; |
| 61 | import com.android.keyguard.ViewMediatorCallback; |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 62 | import com.android.systemui.SystemUI; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 63 | import com.android.systemui.statusbar.phone.PhoneStatusBar; |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 64 | import com.android.systemui.statusbar.phone.ScrimController; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 65 | import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; |
| 66 | import com.android.systemui.statusbar.phone.StatusBarWindowManager; |
Adrian Roos | 58b58fe | 2014-01-31 16:00:39 -0800 | [diff] [blame] | 67 | |
| 68 | import java.io.File; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 69 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 70 | import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 71 | |
Wink Saville | 37c124c | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 72 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 73 | /** |
| 74 | * Mediates requests related to the keyguard. This includes queries about the |
| 75 | * state of the keyguard, power management events that effect whether the keyguard |
| 76 | * should be shown or reset, callbacks to the phone window manager to notify |
| 77 | * it of when the keyguard is showing, and events from the keyguard view itself |
| 78 | * stating that the keyguard was succesfully unlocked. |
| 79 | * |
| 80 | * Note that the keyguard view is shown when the screen is off (as appropriate) |
| 81 | * so that once the screen comes on, it will be ready immediately. |
| 82 | * |
| 83 | * Example queries about the keyguard: |
| 84 | * - is {movement, key} one that should wake the keygaurd? |
| 85 | * - is the keyguard showing? |
| 86 | * - are input events restricted due to the state of the keyguard? |
| 87 | * |
| 88 | * Callbacks to the phone window manager: |
| 89 | * - the keyguard is showing |
| 90 | * |
| 91 | * Example external events that translate to keyguard view changes: |
| 92 | * - screen turned off -> reset the keyguard, and show it so it will be ready |
| 93 | * next time the screen turns on |
| 94 | * - keyboard is slid open -> if the keyguard is not secure, hide it |
| 95 | * |
| 96 | * Events from the keyguard view: |
| 97 | * - user succesfully unlocked keyguard -> hide keyguard view, and no longer |
| 98 | * restrict input events. |
| 99 | * |
| 100 | * Note: in addition to normal power managment events that effect the state of |
| 101 | * whether the keyguard should be showing, external apps and services may request |
| 102 | * that the keyguard be disabled via {@link #setKeyguardEnabled(boolean)}. When |
| 103 | * false, this will override all other conditions for turning on the keyguard. |
| 104 | * |
| 105 | * Threading and synchronization: |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 106 | * This class is created by the initialization routine of the {@link android.view.WindowManagerPolicy}, |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 107 | * and runs on its thread. The keyguard UI is created from that thread in the |
| 108 | * constructor of this class. The apis may be called from other threads, including the |
Jeff Brown | 4532e61 | 2012-04-05 14:27:12 -0700 | [diff] [blame] | 109 | * {@link com.android.server.input.InputManagerService}'s and {@link android.view.WindowManager}'s. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 110 | * Therefore, methods on this class are synchronized, and any action that is pointed |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 111 | * directly to the keyguard UI is posted to a {@link android.os.Handler} to ensure it is taken on the UI |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 112 | * thread of the keyguard. |
| 113 | */ |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 114 | public class KeyguardViewMediator extends SystemUI { |
Jim Miller | bc4603b | 2010-08-30 21:21:34 -0700 | [diff] [blame] | 115 | private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000; |
Jim Miller | 9b1db68 | 2012-10-25 19:31:19 -0700 | [diff] [blame] | 116 | final static boolean DEBUG = false; |
Joe Onorato | 431bb22 | 2010-10-18 19:13:23 -0400 | [diff] [blame] | 117 | private final static boolean DBG_WAKE = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 118 | |
| 119 | private final static String TAG = "KeyguardViewMediator"; |
| 120 | |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 121 | private static final String DELAYED_KEYGUARD_ACTION = |
Wink Saville | 37c124c | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 122 | "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD"; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 123 | |
| 124 | // used for handler messages |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 125 | private static final int SHOW = 2; |
| 126 | private static final int HIDE = 3; |
| 127 | private static final int RESET = 4; |
| 128 | private static final int VERIFY_UNLOCK = 5; |
| 129 | private static final int NOTIFY_SCREEN_OFF = 6; |
| 130 | private static final int NOTIFY_SCREEN_ON = 7; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 131 | private static final int KEYGUARD_DONE = 9; |
| 132 | private static final int KEYGUARD_DONE_DRAWING = 10; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 133 | private static final int KEYGUARD_DONE_AUTHENTICATING = 11; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 134 | private static final int SET_OCCLUDED = 12; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 135 | private static final int KEYGUARD_TIMEOUT = 13; |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 136 | private static final int DISMISS = 17; |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 137 | private static final int START_KEYGUARD_EXIT_ANIM = 18; |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 138 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 139 | /** |
| 140 | * The default amount of time we stay awake (used for all key input) |
| 141 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 142 | public static final int AWAKE_INTERVAL_DEFAULT_MS = 10000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 143 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 144 | /** |
| 145 | * How long to wait after the screen turns off due to timeout before |
| 146 | * turning on the keyguard (i.e, the user has this much time to turn |
| 147 | * the screen back on without having to face the keyguard). |
| 148 | */ |
Jim Miller | bc4603b | 2010-08-30 21:21:34 -0700 | [diff] [blame] | 149 | private static final int KEYGUARD_LOCK_AFTER_DELAY_DEFAULT = 5000; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 150 | |
| 151 | /** |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 152 | * How long we'll wait for the {@link ViewMediatorCallback#keyguardDoneDrawing()} |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 153 | * callback before unblocking a call to {@link #setKeyguardEnabled(boolean)} |
| 154 | * that is reenabling the keyguard. |
| 155 | */ |
| 156 | private static final int KEYGUARD_DONE_DRAWING_TIMEOUT_MS = 2000; |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 157 | |
Daniel Sandler | 74d188c | 2011-08-10 00:00:31 -0400 | [diff] [blame] | 158 | /** |
Adrian Roos | 58b58fe | 2014-01-31 16:00:39 -0800 | [diff] [blame] | 159 | * Secure setting whether analytics are collected on the keyguard. |
| 160 | */ |
| 161 | private static final String KEYGUARD_ANALYTICS_SETTING = "keyguard_analytics"; |
| 162 | |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 163 | /** The stream type that the lock sounds are tied to. */ |
Eric Laurent | 6d51766 | 2012-04-23 18:42:39 -0700 | [diff] [blame] | 164 | private int mMasterStreamType; |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 165 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 166 | private AlarmManager mAlarmManager; |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 167 | private AudioManager mAudioManager; |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 168 | private StatusBarManager mStatusBarManager; |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 169 | private boolean mSwitchingUser; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 170 | |
| 171 | private boolean mSystemReady; |
Daniel Sandler | 0060a9b | 2010-03-15 23:09:57 -0400 | [diff] [blame] | 172 | |
| 173 | // Whether the next call to playSounds() should be skipped. Defaults to |
| 174 | // true because the first lock (on boot) should be silent. |
| 175 | private boolean mSuppressNextLockSound = true; |
| 176 | |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 177 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 178 | /** High level access to the power manager for WakeLocks */ |
| 179 | private PowerManager mPM; |
| 180 | |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 181 | /** High level access to the window manager for dismissing keyguard animation */ |
| 182 | private IWindowManager mWM; |
| 183 | |
Amith Yamasani | b70ff9a | 2012-09-07 18:28:11 -0700 | [diff] [blame] | 184 | /** UserManager for querying number of users */ |
| 185 | private UserManager mUserManager; |
| 186 | |
John Spurlock | 43d8451 | 2012-11-09 10:27:33 -0500 | [diff] [blame] | 187 | /** SearchManager for determining whether or not search assistant is available */ |
| 188 | private SearchManager mSearchManager; |
| 189 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 190 | /** |
Mike Lockwood | 674d3e4 | 2009-10-06 09:28:54 -0400 | [diff] [blame] | 191 | * Used to keep the device awake while to ensure the keyguard finishes opening before |
| 192 | * we sleep. |
| 193 | */ |
| 194 | private PowerManager.WakeLock mShowKeyguardWakeLock; |
| 195 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 196 | private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 197 | |
| 198 | // these are protected by synchronized (this) |
| 199 | |
| 200 | /** |
Mike Lockwood | 5d258b6 | 2009-12-02 13:50:45 -0500 | [diff] [blame] | 201 | * External apps (like the phone app) can tell us to disable the keygaurd. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 202 | */ |
| 203 | private boolean mExternallyEnabled = true; |
| 204 | |
| 205 | /** |
| 206 | * Remember if an external call to {@link #setKeyguardEnabled} with value |
| 207 | * false caused us to hide the keyguard, so that we need to reshow it once |
| 208 | * the keygaurd is reenabled with another call with value true. |
| 209 | */ |
| 210 | private boolean mNeedToReshowWhenReenabled = false; |
| 211 | |
| 212 | // cached value of whether we are showing (need to know this to quickly |
| 213 | // answer whether the input should be restricted) |
Jim Miller | e5f17ab | 2013-11-13 15:40:48 -0800 | [diff] [blame] | 214 | private boolean mShowing; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 215 | |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 216 | // true if the keyguard is hidden by another window |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 217 | private boolean mOccluded = false; |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 218 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 219 | /** |
| 220 | * Helps remember whether the screen has turned on since the last time |
| 221 | * it turned off due to timeout. see {@link #onScreenTurnedOff(int)} |
| 222 | */ |
| 223 | private int mDelayedShowingSequence; |
| 224 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 225 | /** |
| 226 | * If the user has disabled the keyguard, then requests to exit, this is |
| 227 | * how we'll ultimately let them know whether it was successful. We use this |
| 228 | * var being non-null as an indicator that there is an in progress request. |
| 229 | */ |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 230 | private IKeyguardExitCallback mExitSecureCallback; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 231 | |
| 232 | // the properties of the keyguard |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 233 | |
| 234 | private KeyguardUpdateMonitor mUpdateMonitor; |
| 235 | |
Daniel Hansson | 4b71686 | 2012-03-29 11:02:05 +0200 | [diff] [blame] | 236 | private boolean mScreenOn; |
Karl Rosaen | ab10008 | 2009-03-24 22:35:17 -0700 | [diff] [blame] | 237 | |
Daniel Sandler | f2d8e74 | 2010-02-22 13:09:48 -0500 | [diff] [blame] | 238 | // last known state of the cellular connection |
| 239 | private String mPhoneState = TelephonyManager.EXTRA_STATE_IDLE; |
| 240 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 241 | /** |
The Android Open Source Project | c84bf28 | 2009-03-09 11:52:14 -0700 | [diff] [blame] | 242 | * we send this intent when the keyguard is dismissed. |
| 243 | */ |
Jim Miller | 17f509a | 2013-02-28 18:36:12 -0800 | [diff] [blame] | 244 | private static final Intent USER_PRESENT_INTENT = new Intent(Intent.ACTION_USER_PRESENT) |
| 245 | .addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING |
| 246 | | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
The Android Open Source Project | c84bf28 | 2009-03-09 11:52:14 -0700 | [diff] [blame] | 247 | |
| 248 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 249 | * {@link #setKeyguardEnabled} waits on this condition when it reenables |
| 250 | * the keyguard. |
| 251 | */ |
| 252 | private boolean mWaitingUntilKeyguardVisible = false; |
Jim Miller | bc4603b | 2010-08-30 21:21:34 -0700 | [diff] [blame] | 253 | private LockPatternUtils mLockPatternUtils; |
John Spurlock | 34c4fe5 | 2012-11-07 10:12:29 -0500 | [diff] [blame] | 254 | private boolean mKeyguardDonePending = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 255 | |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 256 | private SoundPool mLockSounds; |
| 257 | private int mLockSoundId; |
| 258 | private int mUnlockSoundId; |
| 259 | private int mLockSoundStreamId; |
Jean-Michel Trivi | c55b393 | 2012-06-05 11:57:59 -0700 | [diff] [blame] | 260 | |
| 261 | /** |
| 262 | * The volume applied to the lock/unlock sounds. |
| 263 | */ |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 264 | private float mLockSoundVolume; |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 265 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 266 | /** |
Jim Miller | 3192148 | 2013-11-06 20:43:55 -0800 | [diff] [blame] | 267 | * For managing external displays |
| 268 | */ |
| 269 | private KeyguardDisplayManager mKeyguardDisplayManager; |
| 270 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 271 | KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { |
| 272 | |
| 273 | @Override |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 274 | public void onUserSwitching(int userId) { |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 275 | // Note that the mLockPatternUtils user has already been updated from setCurrentUser. |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 276 | // We need to force a reset of the views, since lockNow (called by |
| 277 | // ActivityManagerService) will not reconstruct the keyguard if it is already showing. |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 278 | synchronized (KeyguardViewMediator.this) { |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 279 | mSwitchingUser = true; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 280 | resetStateLocked(); |
John Spurlock | 4e6922d | 2012-10-04 14:51:51 -0400 | [diff] [blame] | 281 | adjustStatusBarLocked(); |
Brian Colonna | a523989 | 2013-04-15 11:45:40 -0400 | [diff] [blame] | 282 | // When we switch users we want to bring the new user to the biometric unlock even |
| 283 | // if the current user has gone to the backup. |
| 284 | KeyguardUpdateMonitor.getInstance(mContext).setAlternateUnlockEnabled(true); |
Dianne Hackborn | 5dc5a00 | 2012-09-15 19:33:48 -0700 | [diff] [blame] | 285 | } |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | @Override |
Chris Wren | f41c61b | 2012-11-29 15:19:54 -0500 | [diff] [blame] | 289 | public void onUserSwitchComplete(int userId) { |
| 290 | mSwitchingUser = false; |
| 291 | } |
| 292 | |
| 293 | @Override |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 294 | public void onUserRemoved(int userId) { |
| 295 | mLockPatternUtils.removeUser(userId); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 296 | MultiUserAvatarCache.getInstance().clear(userId); |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public void onUserInfoChanged(int userId) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 301 | MultiUserAvatarCache.getInstance().clear(userId); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | @Override |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 305 | public void onPhoneStateChanged(int phoneState) { |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 306 | synchronized (KeyguardViewMediator.this) { |
| 307 | if (TelephonyManager.CALL_STATE_IDLE == phoneState // call ending |
| 308 | && !mScreenOn // screen off |
| 309 | && mExternallyEnabled) { // not disabled by any app |
| 310 | |
| 311 | // note: this is a way to gracefully reenable the keyguard when the call |
| 312 | // ends and the screen is off without always reenabling the keyguard |
| 313 | // each time the screen turns off while in call (and having an occasional ugly |
| 314 | // flicker while turning back on the screen and disabling the keyguard again). |
| 315 | if (DEBUG) Log.d(TAG, "screen is off and call ended, let's make sure the " |
| 316 | + "keyguard is showing"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 317 | doKeyguardLocked(null); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 318 | } |
| 319 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 320 | } |
Jim Miller | b030476 | 2012-03-13 20:01:25 -0700 | [diff] [blame] | 321 | |
| 322 | @Override |
| 323 | public void onClockVisibilityChanged() { |
| 324 | adjustStatusBarLocked(); |
| 325 | } |
| 326 | |
| 327 | @Override |
| 328 | public void onDeviceProvisioned() { |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 329 | sendUserPresentBroadcast(); |
Jim Miller | b030476 | 2012-03-13 20:01:25 -0700 | [diff] [blame] | 330 | } |
| 331 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 332 | @Override |
| 333 | public void onSimStateChanged(IccCardConstants.State simState) { |
| 334 | if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState); |
| 335 | |
| 336 | switch (simState) { |
| 337 | case NOT_READY: |
| 338 | case ABSENT: |
| 339 | // only force lock screen in case of missing sim if user hasn't |
| 340 | // gone through setup wizard |
| 341 | synchronized (this) { |
| 342 | if (!mUpdateMonitor.isDeviceProvisioned()) { |
| 343 | if (!isShowing()) { |
| 344 | if (DEBUG) Log.d(TAG, "ICC_ABSENT isn't showing," |
| 345 | + " we need to show the keyguard since the " |
| 346 | + "device isn't provisioned yet."); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 347 | doKeyguardLocked(null); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 348 | } else { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 349 | resetStateLocked(); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 350 | } |
| 351 | } |
| 352 | } |
| 353 | break; |
| 354 | case PIN_REQUIRED: |
| 355 | case PUK_REQUIRED: |
| 356 | synchronized (this) { |
| 357 | if (!isShowing()) { |
| 358 | if (DEBUG) Log.d(TAG, "INTENT_VALUE_ICC_LOCKED and keygaurd isn't " |
| 359 | + "showing; need to show keyguard so user can enter sim pin"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 360 | doKeyguardLocked(null); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 361 | } else { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 362 | resetStateLocked(); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 363 | } |
| 364 | } |
| 365 | break; |
| 366 | case PERM_DISABLED: |
| 367 | synchronized (this) { |
| 368 | if (!isShowing()) { |
| 369 | if (DEBUG) Log.d(TAG, "PERM_DISABLED and " |
| 370 | + "keygaurd isn't showing."); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 371 | doKeyguardLocked(null); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 372 | } else { |
| 373 | if (DEBUG) Log.d(TAG, "PERM_DISABLED, resetStateLocked to" |
| 374 | + "show permanently disabled message in lockscreen."); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 375 | resetStateLocked(); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 376 | } |
| 377 | } |
| 378 | break; |
| 379 | case READY: |
| 380 | synchronized (this) { |
| 381 | if (isShowing()) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 382 | resetStateLocked(); |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 383 | } |
| 384 | } |
| 385 | break; |
| 386 | } |
| 387 | } |
| 388 | |
Jim Miller | b030476 | 2012-03-13 20:01:25 -0700 | [diff] [blame] | 389 | }; |
| 390 | |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 391 | ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 392 | |
Jeff Brown | c7505bc | 2012-10-05 21:58:15 -0700 | [diff] [blame] | 393 | public void userActivity() { |
| 394 | KeyguardViewMediator.this.userActivity(); |
| 395 | } |
| 396 | |
Jeff Brown | 3dc524b | 2012-09-30 19:49:11 -0700 | [diff] [blame] | 397 | public void userActivity(long holdMs) { |
| 398 | KeyguardViewMediator.this.userActivity(holdMs); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | public void keyguardDone(boolean authenticated) { |
| 402 | KeyguardViewMediator.this.keyguardDone(authenticated, true); |
| 403 | } |
| 404 | |
| 405 | public void keyguardDoneDrawing() { |
| 406 | mHandler.sendEmptyMessage(KEYGUARD_DONE_DRAWING); |
| 407 | } |
| 408 | |
| 409 | @Override |
| 410 | public void setNeedsInput(boolean needsInput) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 411 | mStatusBarKeyguardViewManager.setNeedsInput(needsInput); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 412 | } |
Jeff Brown | c7505bc | 2012-10-05 21:58:15 -0700 | [diff] [blame] | 413 | |
| 414 | @Override |
| 415 | public void onUserActivityTimeoutChanged() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 416 | mStatusBarKeyguardViewManager.updateUserActivityTimeout(); |
Jeff Brown | c7505bc | 2012-10-05 21:58:15 -0700 | [diff] [blame] | 417 | } |
John Spurlock | 34c4fe5 | 2012-11-07 10:12:29 -0500 | [diff] [blame] | 418 | |
| 419 | @Override |
| 420 | public void keyguardDonePending() { |
| 421 | mKeyguardDonePending = true; |
| 422 | } |
Jim Miller | 0b9d8ac | 2013-11-07 19:15:49 -0800 | [diff] [blame] | 423 | |
| 424 | @Override |
| 425 | public void keyguardGone() { |
| 426 | mKeyguardDisplayManager.hide(); |
| 427 | } |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 428 | }; |
| 429 | |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 430 | private void userActivity() { |
Jeff Brown | 3dc524b | 2012-09-30 19:49:11 -0700 | [diff] [blame] | 431 | userActivity(AWAKE_INTERVAL_DEFAULT_MS); |
| 432 | } |
| 433 | |
| 434 | public void userActivity(long holdMs) { |
| 435 | // We ignore the hold time. Eventually we should remove it. |
| 436 | // Instead, the keyguard window has an explicit user activity timeout set on it. |
| 437 | mPM.userActivity(SystemClock.uptimeMillis(), false); |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 440 | private void setup() { |
| 441 | mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 442 | mWM = WindowManagerGlobal.getWindowManagerService(); |
Amith Yamasani | b70ff9a | 2012-09-07 18:28:11 -0700 | [diff] [blame] | 443 | mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); |
Mike Lockwood | 674d3e4 | 2009-10-06 09:28:54 -0400 | [diff] [blame] | 444 | mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard"); |
| 445 | mShowKeyguardWakeLock.setReferenceCounted(false); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 446 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 447 | mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_KEYGUARD_ACTION)); |
| 448 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 449 | mKeyguardDisplayManager = new KeyguardDisplayManager(mContext); |
Jim Miller | 3192148 | 2013-11-06 20:43:55 -0800 | [diff] [blame] | 450 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 451 | mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 452 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 453 | mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 454 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 455 | mLockPatternUtils = new LockPatternUtils(mContext); |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 456 | mLockPatternUtils.setCurrentUser(UserHandle.USER_OWNER); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 457 | |
Jim Miller | e5f17ab | 2013-11-13 15:40:48 -0800 | [diff] [blame] | 458 | // Assume keyguard is showing (unless it's disabled) until we know for sure... |
Jim Miller | 299422b | 2013-11-14 14:15:02 -0800 | [diff] [blame] | 459 | mShowing = (mUpdateMonitor.isDeviceProvisioned() || mLockPatternUtils.isSecure()) |
| 460 | && !mLockPatternUtils.isLockScreenDisabled(); |
Jim Miller | e5f17ab | 2013-11-13 15:40:48 -0800 | [diff] [blame] | 461 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 462 | mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(mContext, |
| 463 | mViewMediatorCallback, mLockPatternUtils); |
Daniel Sandler | 687a327 | 2010-03-13 15:44:47 -0500 | [diff] [blame] | 464 | final ContentResolver cr = mContext.getContentResolver(); |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 465 | |
Daniel Hansson | 4b71686 | 2012-03-29 11:02:05 +0200 | [diff] [blame] | 466 | mScreenOn = mPM.isScreenOn(); |
| 467 | |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 468 | mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0); |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 469 | String soundPath = Settings.Global.getString(cr, Settings.Global.LOCK_SOUND); |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 470 | if (soundPath != null) { |
| 471 | mLockSoundId = mLockSounds.load(soundPath, 1); |
| 472 | } |
| 473 | if (soundPath == null || mLockSoundId == 0) { |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 474 | Log.w(TAG, "failed to load lock sound from " + soundPath); |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 475 | } |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 476 | soundPath = Settings.Global.getString(cr, Settings.Global.UNLOCK_SOUND); |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 477 | if (soundPath != null) { |
| 478 | mUnlockSoundId = mLockSounds.load(soundPath, 1); |
| 479 | } |
| 480 | if (soundPath == null || mUnlockSoundId == 0) { |
Jim Miller | b14288d | 2012-09-30 18:25:05 -0700 | [diff] [blame] | 481 | Log.w(TAG, "failed to load unlock sound from " + soundPath); |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 482 | } |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 483 | int lockSoundDefaultAttenuation = mContext.getResources().getInteger( |
Jean-Michel Trivi | c55b393 | 2012-06-05 11:57:59 -0700 | [diff] [blame] | 484 | com.android.internal.R.integer.config_lockSoundVolumeDb); |
Jean-Michel Trivi | f2b0c11 | 2012-07-09 11:59:11 -0700 | [diff] [blame] | 485 | mLockSoundVolume = (float)Math.pow(10, (float)lockSoundDefaultAttenuation/20); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 486 | } |
| 487 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 488 | @Override |
| 489 | public void start() { |
| 490 | setup(); |
| 491 | putComponent(KeyguardViewMediator.class, this); |
| 492 | } |
| 493 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 494 | /** |
| 495 | * Let us know that the system is ready after startup. |
| 496 | */ |
| 497 | public void onSystemReady() { |
John Spurlock | 43d8451 | 2012-11-09 10:27:33 -0500 | [diff] [blame] | 498 | mSearchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 499 | synchronized (this) { |
| 500 | if (DEBUG) Log.d(TAG, "onSystemReady"); |
| 501 | mSystemReady = true; |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 502 | mUpdateMonitor.registerCallback(mUpdateCallback); |
Jim Miller | 0869770 | 2012-10-22 16:49:52 -0700 | [diff] [blame] | 503 | |
Brian Colonna | d4a3e5d | 2012-11-01 16:20:24 -0400 | [diff] [blame] | 504 | // Suppress biometric unlock right after boot until things have settled if it is the |
| 505 | // selected security method, otherwise unsuppress it. It must be unsuppressed if it is |
| 506 | // not the selected security method for the following reason: if the user starts |
| 507 | // without a screen lock selected, the biometric unlock would be suppressed the first |
| 508 | // time they try to use it. |
| 509 | // |
| 510 | // Note that the biometric unlock will still not show if it is not the selected method. |
| 511 | // Calling setAlternateUnlockEnabled(true) simply says don't suppress it if it is the |
| 512 | // selected method. |
| 513 | if (mLockPatternUtils.usingBiometricWeak() |
| 514 | && mLockPatternUtils.isBiometricWeakInstalled()) { |
| 515 | if (DEBUG) Log.d(TAG, "suppressing biometric unlock during boot"); |
| 516 | mUpdateMonitor.setAlternateUnlockEnabled(false); |
| 517 | } else { |
| 518 | mUpdateMonitor.setAlternateUnlockEnabled(true); |
| 519 | } |
Jim Miller | 0869770 | 2012-10-22 16:49:52 -0700 | [diff] [blame] | 520 | |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 521 | doKeyguardLocked(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 522 | } |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 523 | // Most services aren't available until the system reaches the ready state, so we |
| 524 | // send it here when the device first boots. |
| 525 | maybeSendUserPresentBroadcast(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | /** |
| 529 | * Called to let us know the screen was turned off. |
Jeff Brown | fb0448a | 2014-05-01 18:19:31 -0700 | [diff] [blame] | 530 | * @param why either {@link android.view.WindowManagerPolicy#OFF_BECAUSE_OF_USER} or |
| 531 | * {@link android.view.WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 532 | */ |
| 533 | public void onScreenTurnedOff(int why) { |
| 534 | synchronized (this) { |
Karl Rosaen | ab10008 | 2009-03-24 22:35:17 -0700 | [diff] [blame] | 535 | mScreenOn = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 536 | if (DEBUG) Log.d(TAG, "onScreenTurnedOff(" + why + ")"); |
| 537 | |
John Spurlock | 14adfe4 | 2012-11-08 10:29:26 -0500 | [diff] [blame] | 538 | mKeyguardDonePending = false; |
| 539 | |
Jim Miller | a4edd15 | 2012-01-06 18:24:04 -0800 | [diff] [blame] | 540 | // Lock immediately based on setting if secure (user has a pin/pattern/password). |
| 541 | // This also "locks" the device when not secure to provide easy access to the |
| 542 | // camera while preventing unwanted input. |
| 543 | final boolean lockImmediately = |
| 544 | mLockPatternUtils.getPowerButtonInstantlyLocks() || !mLockPatternUtils.isSecure(); |
| 545 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 546 | if (mExitSecureCallback != null) { |
| 547 | if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 548 | try { |
| 549 | mExitSecureCallback.onKeyguardExitResult(false); |
| 550 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 551 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 552 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 553 | mExitSecureCallback = null; |
| 554 | if (!mExternallyEnabled) { |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 555 | hideLocked(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 556 | } |
| 557 | } else if (mShowing) { |
| 558 | notifyScreenOffLocked(); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 559 | resetStateLocked(); |
Jim Miller | a4edd15 | 2012-01-06 18:24:04 -0800 | [diff] [blame] | 560 | } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT |
| 561 | || (why == WindowManagerPolicy.OFF_BECAUSE_OF_USER && !lockImmediately)) { |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 562 | doKeyguardLaterLocked(); |
Mike Lockwood | 016e397 | 2009-09-17 11:45:06 -0400 | [diff] [blame] | 563 | } else { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 564 | doKeyguardLocked(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 565 | } |
| 566 | } |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 567 | KeyguardUpdateMonitor.getInstance(mContext).dispatchScreenTurndOff(why); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 568 | } |
| 569 | |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 570 | private void doKeyguardLaterLocked() { |
| 571 | // if the screen turned off because of timeout or the user hit the power button |
| 572 | // and we don't need to lock immediately, set an alarm |
| 573 | // to enable it a little bit later (i.e, give the user a chance |
| 574 | // to turn the screen back on within a certain window without |
| 575 | // having to unlock the screen) |
| 576 | final ContentResolver cr = mContext.getContentResolver(); |
| 577 | |
| 578 | // From DisplaySettings |
| 579 | long displayTimeout = Settings.System.getInt(cr, SCREEN_OFF_TIMEOUT, |
| 580 | KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT); |
| 581 | |
| 582 | // From SecuritySettings |
| 583 | final long lockAfterTimeout = Settings.Secure.getInt(cr, |
| 584 | Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, |
| 585 | KEYGUARD_LOCK_AFTER_DELAY_DEFAULT); |
| 586 | |
| 587 | // From DevicePolicyAdmin |
| 588 | final long policyTimeout = mLockPatternUtils.getDevicePolicyManager() |
| 589 | .getMaximumTimeToLock(null, mLockPatternUtils.getCurrentUser()); |
| 590 | |
| 591 | long timeout; |
| 592 | if (policyTimeout > 0) { |
| 593 | // policy in effect. Make sure we don't go beyond policy limit. |
| 594 | displayTimeout = Math.max(displayTimeout, 0); // ignore negative values |
| 595 | timeout = Math.min(policyTimeout - displayTimeout, lockAfterTimeout); |
| 596 | } else { |
| 597 | timeout = lockAfterTimeout; |
| 598 | } |
| 599 | |
| 600 | if (timeout <= 0) { |
| 601 | // Lock now |
| 602 | mSuppressNextLockSound = true; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 603 | doKeyguardLocked(null); |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 604 | } else { |
| 605 | // Lock in the future |
| 606 | long when = SystemClock.elapsedRealtime() + timeout; |
| 607 | Intent intent = new Intent(DELAYED_KEYGUARD_ACTION); |
| 608 | intent.putExtra("seq", mDelayedShowingSequence); |
| 609 | PendingIntent sender = PendingIntent.getBroadcast(mContext, |
| 610 | 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); |
| 611 | mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender); |
| 612 | if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " |
| 613 | + mDelayedShowingSequence); |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | private void cancelDoKeyguardLaterLocked() { |
| 618 | mDelayedShowingSequence++; |
| 619 | } |
| 620 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 621 | /** |
| 622 | * Let's us know the screen was turned on. |
| 623 | */ |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 624 | public void onScreenTurnedOn(IKeyguardShowCallback callback) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 625 | synchronized (this) { |
Karl Rosaen | ab10008 | 2009-03-24 22:35:17 -0700 | [diff] [blame] | 626 | mScreenOn = true; |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 627 | cancelDoKeyguardLaterLocked(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 628 | if (DEBUG) Log.d(TAG, "onScreenTurnedOn, seq = " + mDelayedShowingSequence); |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 629 | if (callback != null) { |
| 630 | notifyScreenOnLocked(callback); |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 631 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 632 | } |
Jim Miller | 20daffd | 2013-10-07 14:59:53 -0700 | [diff] [blame] | 633 | KeyguardUpdateMonitor.getInstance(mContext).dispatchScreenTurnedOn(); |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 634 | maybeSendUserPresentBroadcast(); |
| 635 | } |
| 636 | |
| 637 | private void maybeSendUserPresentBroadcast() { |
| 638 | if (mSystemReady && mLockPatternUtils.isLockScreenDisabled() |
Kenny Guy | 1a44753 | 2014-02-20 21:55:32 +0000 | [diff] [blame] | 639 | && !mUserManager.isUserSwitcherEnabled()) { |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 640 | // Lock screen is disabled because the user has set the preference to "None". |
| 641 | // In this case, send out ACTION_USER_PRESENT here instead of in |
| 642 | // handleKeyguardDone() |
| 643 | sendUserPresentBroadcast(); |
| 644 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | /** |
Jeff Brown | 6aaf295 | 2012-10-05 16:01:08 -0700 | [diff] [blame] | 648 | * A dream started. We should lock after the usual screen-off lock timeout but only |
| 649 | * if there is a secure lock pattern. |
| 650 | */ |
| 651 | public void onDreamingStarted() { |
| 652 | synchronized (this) { |
| 653 | if (mScreenOn && mLockPatternUtils.isSecure()) { |
| 654 | doKeyguardLaterLocked(); |
| 655 | } |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | /** |
| 660 | * A dream stopped. |
| 661 | */ |
| 662 | public void onDreamingStopped() { |
| 663 | synchronized (this) { |
| 664 | if (mScreenOn) { |
| 665 | cancelDoKeyguardLaterLocked(); |
| 666 | } |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 671 | * Same semantics as {@link android.view.WindowManagerPolicy#enableKeyguard}; provide |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 672 | * a way for external stuff to override normal keyguard behavior. For instance |
| 673 | * the phone app disables the keyguard when it receives incoming calls. |
| 674 | */ |
| 675 | public void setKeyguardEnabled(boolean enabled) { |
| 676 | synchronized (this) { |
| 677 | if (DEBUG) Log.d(TAG, "setKeyguardEnabled(" + enabled + ")"); |
| 678 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 679 | mExternallyEnabled = enabled; |
| 680 | |
| 681 | if (!enabled && mShowing) { |
| 682 | if (mExitSecureCallback != null) { |
| 683 | if (DEBUG) Log.d(TAG, "in process of verifyUnlock request, ignoring"); |
| 684 | // we're in the process of handling a request to verify the user |
| 685 | // can get past the keyguard. ignore extraneous requests to disable / reenable |
| 686 | return; |
| 687 | } |
| 688 | |
| 689 | // hiding keyguard that is showing, remember to reshow later |
| 690 | if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, " |
| 691 | + "disabling status bar expansion"); |
| 692 | mNeedToReshowWhenReenabled = true; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 693 | hideLocked(); |
| 694 | } else if (enabled && mNeedToReshowWhenReenabled) { |
| 695 | // reenabled after previously hidden, reshow |
| 696 | if (DEBUG) Log.d(TAG, "previously hidden, reshowing, reenabling " |
| 697 | + "status bar expansion"); |
| 698 | mNeedToReshowWhenReenabled = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 699 | |
| 700 | if (mExitSecureCallback != null) { |
| 701 | if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 702 | try { |
| 703 | mExitSecureCallback.onKeyguardExitResult(false); |
| 704 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 705 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 706 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 707 | mExitSecureCallback = null; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 708 | resetStateLocked(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 709 | } else { |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 710 | showLocked(null); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 711 | |
| 712 | // block until we know the keygaurd is done drawing (and post a message |
| 713 | // to unblock us after a timeout so we don't risk blocking too long |
| 714 | // and causing an ANR). |
| 715 | mWaitingUntilKeyguardVisible = true; |
| 716 | mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_DRAWING, KEYGUARD_DONE_DRAWING_TIMEOUT_MS); |
| 717 | if (DEBUG) Log.d(TAG, "waiting until mWaitingUntilKeyguardVisible is false"); |
| 718 | while (mWaitingUntilKeyguardVisible) { |
| 719 | try { |
| 720 | wait(); |
| 721 | } catch (InterruptedException e) { |
| 722 | Thread.currentThread().interrupt(); |
| 723 | } |
| 724 | } |
| 725 | if (DEBUG) Log.d(TAG, "done waiting for mWaitingUntilKeyguardVisible"); |
| 726 | } |
| 727 | } |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | /** |
| 732 | * @see android.app.KeyguardManager#exitKeyguardSecurely |
| 733 | */ |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 734 | public void verifyUnlock(IKeyguardExitCallback callback) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 735 | synchronized (this) { |
| 736 | if (DEBUG) Log.d(TAG, "verifyUnlock"); |
| 737 | if (!mUpdateMonitor.isDeviceProvisioned()) { |
| 738 | // don't allow this api when the device isn't provisioned |
| 739 | if (DEBUG) Log.d(TAG, "ignoring because device isn't provisioned"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 740 | try { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 741 | callback.onKeyguardExitResult(false); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 742 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 743 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 744 | } |
Mike Lockwood | 5d258b6 | 2009-12-02 13:50:45 -0500 | [diff] [blame] | 745 | } else if (mExternallyEnabled) { |
| 746 | // this only applies when the user has externally disabled the |
| 747 | // keyguard. this is unexpected and means the user is not |
| 748 | // using the api properly. |
| 749 | Log.w(TAG, "verifyUnlock called when not externally disabled"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 750 | try { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 751 | callback.onKeyguardExitResult(false); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 752 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 753 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 754 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 755 | } else if (mExitSecureCallback != null) { |
| 756 | // already in progress with someone else |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 757 | try { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 758 | callback.onKeyguardExitResult(false); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 759 | } catch (RemoteException e) { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 760 | Slog.w(TAG, "Failed to call onKeyguardExitResult(false)", e); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 761 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 762 | } else { |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 763 | mExitSecureCallback = callback; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 764 | verifyUnlockLocked(); |
| 765 | } |
| 766 | } |
| 767 | } |
| 768 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 769 | /** |
| 770 | * Is the keyguard currently showing? |
| 771 | */ |
| 772 | public boolean isShowing() { |
| 773 | return mShowing; |
| 774 | } |
| 775 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 776 | public boolean isOccluded() { |
| 777 | return mOccluded; |
Dianne Hackborn | 9dc06cc | 2009-11-17 18:19:23 -0800 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 781 | * Is the keyguard currently showing and not being force hidden? |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 782 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 783 | public boolean isShowingAndNotOccluded() { |
| 784 | return mShowing && !mOccluded; |
| 785 | } |
| 786 | |
| 787 | /** |
| 788 | * Notify us when the keyguard is occluded by another window |
| 789 | */ |
| 790 | public void setOccluded(boolean isOccluded) { |
| 791 | if (DEBUG) Log.d(TAG, "setOccluded " + isOccluded); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 792 | mHandler.removeMessages(SET_OCCLUDED); |
| 793 | Message msg = mHandler.obtainMessage(SET_OCCLUDED, (isOccluded ? 1 : 0), 0); |
Mike Lockwood | 9200a39 | 2009-11-17 20:25:58 -0500 | [diff] [blame] | 794 | mHandler.sendMessage(msg); |
| 795 | } |
| 796 | |
| 797 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 798 | * Handles SET_OCCLUDED message sent by setOccluded() |
Mike Lockwood | 9200a39 | 2009-11-17 20:25:58 -0500 | [diff] [blame] | 799 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 800 | private void handleSetOccluded(boolean isOccluded) { |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 801 | synchronized (KeyguardViewMediator.this) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 802 | if (mOccluded != isOccluded) { |
| 803 | mOccluded = isOccluded; |
| 804 | mStatusBarKeyguardViewManager.setOccluded(isOccluded); |
Dianne Hackborn | ff5b158 | 2012-04-12 17:24:07 -0700 | [diff] [blame] | 805 | updateActivityLockScreenState(); |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 806 | adjustStatusBarLocked(); |
Mike Lockwood | 9200a39 | 2009-11-17 20:25:58 -0500 | [diff] [blame] | 807 | } |
Mike Lockwood | 09a4040 | 2009-11-08 00:33:23 -0500 | [diff] [blame] | 808 | } |
| 809 | } |
| 810 | |
| 811 | /** |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 812 | * Used by PhoneWindowManager to enable the keyguard due to a user activity timeout. |
| 813 | * This must be safe to call from any thread and with any window manager locks held. |
| 814 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 815 | public void doKeyguardTimeout(Bundle options) { |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 816 | mHandler.removeMessages(KEYGUARD_TIMEOUT); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 817 | Message msg = mHandler.obtainMessage(KEYGUARD_TIMEOUT, options); |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 818 | mHandler.sendMessage(msg); |
| 819 | } |
| 820 | |
| 821 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 822 | * Given the state of the keyguard, is the input restricted? |
| 823 | * Input is restricted when the keyguard is showing, or when the keyguard |
| 824 | * was suppressed by an app that disabled the keyguard or we haven't been provisioned yet. |
| 825 | */ |
| 826 | public boolean isInputRestricted() { |
| 827 | return mShowing || mNeedToReshowWhenReenabled || !mUpdateMonitor.isDeviceProvisioned(); |
| 828 | } |
| 829 | |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 830 | /** |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 831 | * Enable the keyguard if the settings are appropriate. |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 832 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 833 | private void doKeyguardLocked(Bundle options) { |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 834 | // if another app is disabling us, don't show |
| 835 | if (!mExternallyEnabled) { |
| 836 | if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled"); |
Karl Rosaen | ab10008 | 2009-03-24 22:35:17 -0700 | [diff] [blame] | 837 | |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 838 | // note: we *should* set mNeedToReshowWhenReenabled=true here, but that makes |
| 839 | // for an occasional ugly flicker in this situation: |
| 840 | // 1) receive a call with the screen on (no keyguard) or make a call |
| 841 | // 2) screen times out |
| 842 | // 3) user hits key to turn screen back on |
| 843 | // instead, we reenable the keyguard when we know the screen is off and the call |
| 844 | // ends (see the broadcast receiver below) |
| 845 | // TODO: clean this up when we have better support at the window manager level |
| 846 | // for apps that wish to be on top of the keyguard |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 847 | return; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 848 | } |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 849 | |
| 850 | // if the keyguard is already showing, don't bother |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 851 | if (mStatusBarKeyguardViewManager.isShowing()) { |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 852 | if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing"); |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 853 | return; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | // if the setup wizard hasn't run yet, don't show |
| 857 | final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim", |
| 858 | false); |
| 859 | final boolean provisioned = mUpdateMonitor.isDeviceProvisioned(); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 860 | final IccCardConstants.State state = mUpdateMonitor.getSimState(); |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 861 | final boolean lockedOrMissing = state.isPinLocked() |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 862 | || ((state == IccCardConstants.State.ABSENT |
| 863 | || state == IccCardConstants.State.PERM_DISABLED) |
Jim Miller | 9fa1ada | 2011-10-31 18:21:49 -0700 | [diff] [blame] | 864 | && requireSim); |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 865 | |
| 866 | if (!lockedOrMissing && !provisioned) { |
| 867 | if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned" |
| 868 | + " and the sim is not locked or missing"); |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 869 | return; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 870 | } |
| 871 | |
Kenny Guy | 1a44753 | 2014-02-20 21:55:32 +0000 | [diff] [blame] | 872 | if (!mUserManager.isUserSwitcherEnabled() |
Amith Yamasani | b70ff9a | 2012-09-07 18:28:11 -0700 | [diff] [blame] | 873 | && mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) { |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 874 | if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off"); |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 875 | return; |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 876 | } |
| 877 | |
Paul Lawrence | 945490c | 2014-03-27 16:37:28 +0000 | [diff] [blame] | 878 | if (mLockPatternUtils.checkVoldPassword()) { |
| 879 | if (DEBUG) Log.d(TAG, "Not showing lock screen since just decrypted"); |
| 880 | // Without this, settings is not enabled until the lock screen first appears |
Jorim Jaggi | b9d6079 | 2014-06-03 22:34:22 +0200 | [diff] [blame] | 881 | mShowing = false; |
Paul Lawrence | 945490c | 2014-03-27 16:37:28 +0000 | [diff] [blame] | 882 | hideLocked(); |
| 883 | return; |
| 884 | } |
| 885 | |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 886 | if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen"); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 887 | showLocked(options); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | /** |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 891 | * Dismiss the keyguard through the security layers. |
| 892 | */ |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 893 | public void handleDismiss() { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 894 | if (mShowing && !mOccluded) { |
| 895 | mStatusBarKeyguardViewManager.dismiss(); |
Jim Miller | 87d0366 | 2012-11-05 20:28:09 -0800 | [diff] [blame] | 896 | } |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 897 | } |
| 898 | |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 899 | public void dismiss() { |
| 900 | mHandler.sendEmptyMessage(DISMISS); |
| 901 | } |
| 902 | |
Craig Mautner | ad09bcc | 2012-10-08 13:33:11 -0700 | [diff] [blame] | 903 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 904 | * Send message to keyguard telling it to reset its state. |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 905 | * @see #handleReset |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 906 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 907 | private void resetStateLocked() { |
Jim Miller | 4894a01 | 2013-04-03 15:23:55 -0700 | [diff] [blame] | 908 | if (DEBUG) Log.e(TAG, "resetStateLocked"); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 909 | Message msg = mHandler.obtainMessage(RESET); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 910 | mHandler.sendMessage(msg); |
| 911 | } |
| 912 | |
| 913 | /** |
| 914 | * Send message to keyguard telling it to verify unlock |
| 915 | * @see #handleVerifyUnlock() |
| 916 | */ |
| 917 | private void verifyUnlockLocked() { |
| 918 | if (DEBUG) Log.d(TAG, "verifyUnlockLocked"); |
| 919 | mHandler.sendEmptyMessage(VERIFY_UNLOCK); |
| 920 | } |
| 921 | |
| 922 | |
| 923 | /** |
| 924 | * Send a message to keyguard telling it the screen just turned on. |
| 925 | * @see #onScreenTurnedOff(int) |
| 926 | * @see #handleNotifyScreenOff |
| 927 | */ |
| 928 | private void notifyScreenOffLocked() { |
| 929 | if (DEBUG) Log.d(TAG, "notifyScreenOffLocked"); |
| 930 | mHandler.sendEmptyMessage(NOTIFY_SCREEN_OFF); |
| 931 | } |
| 932 | |
| 933 | /** |
| 934 | * Send a message to keyguard telling it the screen just turned on. |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 935 | * @see #onScreenTurnedOn |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 936 | * @see #handleNotifyScreenOn |
| 937 | */ |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 938 | private void notifyScreenOnLocked(IKeyguardShowCallback result) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 939 | if (DEBUG) Log.d(TAG, "notifyScreenOnLocked"); |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 940 | Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_ON, result); |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 941 | mHandler.sendMessage(msg); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 945 | * Send message to keyguard telling it to show itself |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 946 | * @see #handleShow |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 947 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 948 | private void showLocked(Bundle options) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 949 | if (DEBUG) Log.d(TAG, "showLocked"); |
Mike Lockwood | 674d3e4 | 2009-10-06 09:28:54 -0400 | [diff] [blame] | 950 | // ensure we stay awake until we are finished displaying the keyguard |
| 951 | mShowKeyguardWakeLock.acquire(); |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 952 | Message msg = mHandler.obtainMessage(SHOW, options); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 953 | mHandler.sendMessage(msg); |
| 954 | } |
| 955 | |
| 956 | /** |
| 957 | * Send message to keyguard telling it to hide itself |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 958 | * @see #handleHide() |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 959 | */ |
| 960 | private void hideLocked() { |
| 961 | if (DEBUG) Log.d(TAG, "hideLocked"); |
| 962 | Message msg = mHandler.obtainMessage(HIDE); |
| 963 | mHandler.sendMessage(msg); |
| 964 | } |
| 965 | |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 966 | public boolean isSecure() { |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 967 | return mLockPatternUtils.isSecure() |
| 968 | || KeyguardUpdateMonitor.getInstance(mContext).isSimPinSecure(); |
Dianne Hackborn | b446e97 | 2009-09-20 15:23:25 -0700 | [diff] [blame] | 969 | } |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 970 | |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 971 | /** |
| 972 | * Update the newUserId. Call while holding WindowManagerService lock. |
Jim Miller | ee82f8f | 2012-10-01 16:26:18 -0700 | [diff] [blame] | 973 | * NOTE: Should only be called by KeyguardViewMediator in response to the user id changing. |
| 974 | * |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 975 | * @param newUserId The id of the incoming user. |
| 976 | */ |
| 977 | public void setCurrentUser(int newUserId) { |
| 978 | mLockPatternUtils.setCurrentUser(newUserId); |
| 979 | } |
| 980 | |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 981 | private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
Amith Yamasani | 52c489c | 2012-03-28 11:42:42 -0700 | [diff] [blame] | 982 | @Override |
| 983 | public void onReceive(Context context, Intent intent) { |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 984 | if (DELAYED_KEYGUARD_ACTION.equals(intent.getAction())) { |
| 985 | final int sequence = intent.getIntExtra("seq", 0); |
Jim Miller | f344735 | 2011-08-07 14:00:09 -0700 | [diff] [blame] | 986 | if (DEBUG) Log.d(TAG, "received DELAYED_KEYGUARD_ACTION with seq = " |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 987 | + sequence + ", mDelayedShowingSequence = " + mDelayedShowingSequence); |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 988 | synchronized (KeyguardViewMediator.this) { |
| 989 | if (mDelayedShowingSequence == sequence) { |
Jim Miller | bbf1a74 | 2012-07-17 18:30:30 -0700 | [diff] [blame] | 990 | // Don't play lockscreen SFX if the screen went off due to timeout. |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 991 | mSuppressNextLockSound = true; |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 992 | doKeyguardLocked(null); |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 993 | } |
Daniel Sandler | f2d8e74 | 2010-02-22 13:09:48 -0500 | [diff] [blame] | 994 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 995 | } |
| 996 | } |
| 997 | }; |
| 998 | |
Dianne Hackborn | 0572658 | 2009-09-22 17:28:24 -0700 | [diff] [blame] | 999 | public void keyguardDone(boolean authenticated, boolean wakeup) { |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1000 | if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated + ")"); |
| 1001 | EventLog.writeEvent(70000, 2); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1002 | synchronized (this) { |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1003 | mKeyguardDonePending = false; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1004 | } |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1005 | Message msg = mHandler.obtainMessage(KEYGUARD_DONE, authenticated ? 1 : 0, wakeup ? 1 : 0); |
| 1006 | mHandler.sendMessage(msg); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | /** |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1010 | * This handler will be associated with the policy thread, which will also |
| 1011 | * be the UI thread of the keyguard. Since the apis of the policy, and therefore |
| 1012 | * this class, can be called by other threads, any action that directly |
| 1013 | * interacts with the keyguard ui should be posted to this handler, rather |
| 1014 | * than called directly. |
| 1015 | */ |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 1016 | private Handler mHandler = new Handler(Looper.myLooper(), null, true /*async*/) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1017 | @Override |
Wink Saville | 37c124c | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 1018 | public void handleMessage(Message msg) { |
| 1019 | switch (msg.what) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1020 | case SHOW: |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1021 | handleShow((Bundle) msg.obj); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1022 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1023 | case HIDE: |
| 1024 | handleHide(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1025 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1026 | case RESET: |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1027 | handleReset(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1028 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1029 | case VERIFY_UNLOCK: |
| 1030 | handleVerifyUnlock(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1031 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1032 | case NOTIFY_SCREEN_OFF: |
| 1033 | handleNotifyScreenOff(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1034 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1035 | case NOTIFY_SCREEN_ON: |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1036 | handleNotifyScreenOn((IKeyguardShowCallback) msg.obj); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1037 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1038 | case KEYGUARD_DONE: |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 1039 | handleKeyguardDone(msg.arg1 != 0, msg.arg2 != 0); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1040 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1041 | case KEYGUARD_DONE_DRAWING: |
| 1042 | handleKeyguardDoneDrawing(); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1043 | break; |
Dianne Hackborn | 39c2d71 | 2009-09-22 11:41:31 -0700 | [diff] [blame] | 1044 | case KEYGUARD_DONE_AUTHENTICATING: |
Jim Miller | dcb3d84 | 2012-08-23 19:18:12 -0700 | [diff] [blame] | 1045 | keyguardDone(true, true); |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1046 | break; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1047 | case SET_OCCLUDED: |
| 1048 | handleSetOccluded(msg.arg1 != 0); |
Mike Lockwood | 9200a39 | 2009-11-17 20:25:58 -0500 | [diff] [blame] | 1049 | break; |
Mike Lockwood | 2856930 | 2010-01-28 11:54:40 -0500 | [diff] [blame] | 1050 | case KEYGUARD_TIMEOUT: |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1051 | synchronized (KeyguardViewMediator.this) { |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1052 | doKeyguardLocked((Bundle) msg.obj); |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1053 | } |
| 1054 | break; |
Jim Miller | 6001379 | 2013-10-03 18:31:34 -0700 | [diff] [blame] | 1055 | case DISMISS: |
| 1056 | handleDismiss(); |
| 1057 | break; |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1058 | case START_KEYGUARD_EXIT_ANIM: |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1059 | StartKeyguardExitAnimParams params = (StartKeyguardExitAnimParams) msg.obj; |
| 1060 | handleStartKeyguardExitAnimation(params.startTime, params.fadeoutDuration); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1061 | break; |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1062 | } |
| 1063 | } |
| 1064 | }; |
| 1065 | |
| 1066 | /** |
| 1067 | * @see #keyguardDone |
| 1068 | * @see #KEYGUARD_DONE |
| 1069 | */ |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 1070 | private void handleKeyguardDone(boolean authenticated, boolean wakeup) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1071 | if (DEBUG) Log.d(TAG, "handleKeyguardDone"); |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 1072 | |
| 1073 | if (authenticated) { |
| 1074 | mUpdateMonitor.clearFailedUnlockAttempts(); |
Dianne Hackborn | 0572658 | 2009-09-22 17:28:24 -0700 | [diff] [blame] | 1075 | } |
Jeff Sharkey | 6a25cbd | 2012-08-23 12:14:26 -0700 | [diff] [blame] | 1076 | |
Jim Miller | e51cf7ae | 2013-06-25 18:31:56 -0700 | [diff] [blame] | 1077 | if (mExitSecureCallback != null) { |
| 1078 | try { |
| 1079 | mExitSecureCallback.onKeyguardExitResult(authenticated); |
| 1080 | } catch (RemoteException e) { |
| 1081 | Slog.w(TAG, "Failed to call onKeyguardExitResult(" + authenticated + ")", e); |
| 1082 | } |
| 1083 | |
| 1084 | mExitSecureCallback = null; |
| 1085 | |
| 1086 | if (authenticated) { |
| 1087 | // after succesfully exiting securely, no need to reshow |
| 1088 | // the keyguard when they've released the lock |
| 1089 | mExternallyEnabled = true; |
| 1090 | mNeedToReshowWhenReenabled = false; |
| 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | handleHide(); |
Jim Miller | 3fd47af | 2012-09-21 19:55:27 -0700 | [diff] [blame] | 1095 | sendUserPresentBroadcast(); |
| 1096 | } |
| 1097 | |
| 1098 | private void sendUserPresentBroadcast() { |
Jim Miller | 17f509a | 2013-02-28 18:36:12 -0800 | [diff] [blame] | 1099 | final UserHandle currentUser = new UserHandle(mLockPatternUtils.getCurrentUser()); |
| 1100 | mContext.sendBroadcastAsUser(USER_PRESENT_INTENT, currentUser); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1104 | * @see #keyguardDone |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1105 | * @see #KEYGUARD_DONE_DRAWING |
| 1106 | */ |
| 1107 | private void handleKeyguardDoneDrawing() { |
| 1108 | synchronized(this) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1109 | if (DEBUG) Log.d(TAG, "handleKeyguardDoneDrawing"); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1110 | if (mWaitingUntilKeyguardVisible) { |
| 1111 | if (DEBUG) Log.d(TAG, "handleKeyguardDoneDrawing: notifying mWaitingUntilKeyguardVisible"); |
| 1112 | mWaitingUntilKeyguardVisible = false; |
| 1113 | notifyAll(); |
| 1114 | |
| 1115 | // there will usually be two of these sent, one as a timeout, and one |
| 1116 | // as a result of the callback, so remove any remaining messages from |
| 1117 | // the queue |
| 1118 | mHandler.removeMessages(KEYGUARD_DONE_DRAWING); |
| 1119 | } |
| 1120 | } |
| 1121 | } |
| 1122 | |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 1123 | private void playSounds(boolean locked) { |
| 1124 | // User feedback for keyguard. |
Daniel Sandler | 0060a9b | 2010-03-15 23:09:57 -0400 | [diff] [blame] | 1125 | |
| 1126 | if (mSuppressNextLockSound) { |
| 1127 | mSuppressNextLockSound = false; |
| 1128 | return; |
| 1129 | } |
| 1130 | |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 1131 | final ContentResolver cr = mContext.getContentResolver(); |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 1132 | if (Settings.System.getInt(cr, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) == 1) { |
Marco Nelissen | d5545bd | 2011-09-29 12:49:17 -0700 | [diff] [blame] | 1133 | final int whichSound = locked |
| 1134 | ? mLockSoundId |
| 1135 | : mUnlockSoundId; |
| 1136 | mLockSounds.stop(mLockSoundStreamId); |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 1137 | // Init mAudioManager |
| 1138 | if (mAudioManager == null) { |
| 1139 | mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); |
| 1140 | if (mAudioManager == null) return; |
Eric Laurent | 6d51766 | 2012-04-23 18:42:39 -0700 | [diff] [blame] | 1141 | mMasterStreamType = mAudioManager.getMasterStreamType(); |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 1142 | } |
| 1143 | // If the stream is muted, don't play the sound |
Eric Laurent | 6d51766 | 2012-04-23 18:42:39 -0700 | [diff] [blame] | 1144 | if (mAudioManager.isStreamMute(mMasterStreamType)) return; |
Amith Yamasani | 8cb751b | 2011-09-30 15:39:41 -0700 | [diff] [blame] | 1145 | |
Jean-Michel Trivi | c55b393 | 2012-06-05 11:57:59 -0700 | [diff] [blame] | 1146 | mLockSoundStreamId = mLockSounds.play(whichSound, |
| 1147 | mLockSoundVolume, mLockSoundVolume, 1/*priortiy*/, 0/*loop*/, 1.0f/*rate*/); |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 1148 | } |
Jim Miller | 2a98a4c | 2010-11-19 18:49:26 -0800 | [diff] [blame] | 1149 | } |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 1150 | |
Dianne Hackborn | ff5b158 | 2012-04-12 17:24:07 -0700 | [diff] [blame] | 1151 | private void updateActivityLockScreenState() { |
| 1152 | try { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1153 | ActivityManagerNative.getDefault().setLockScreenShown(mShowing && !mOccluded); |
Dianne Hackborn | ff5b158 | 2012-04-12 17:24:07 -0700 | [diff] [blame] | 1154 | } catch (RemoteException e) { |
| 1155 | } |
| 1156 | } |
| 1157 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1158 | /** |
| 1159 | * Handle message sent by {@link #showLocked}. |
| 1160 | * @see #SHOW |
| 1161 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1162 | private void handleShow(Bundle options) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1163 | synchronized (KeyguardViewMediator.this) { |
Jim Miller | 5ecd811 | 2013-01-09 18:50:26 -0800 | [diff] [blame] | 1164 | if (!mSystemReady) { |
| 1165 | if (DEBUG) Log.d(TAG, "ignoring handleShow because system is not ready."); |
| 1166 | return; |
| 1167 | } else { |
| 1168 | if (DEBUG) Log.d(TAG, "handleShow"); |
| 1169 | } |
Jim Miller | 9c20d0e | 2010-01-20 15:00:23 -0800 | [diff] [blame] | 1170 | |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1171 | mStatusBarKeyguardViewManager.show(options); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1172 | mShowing = true; |
John Spurlock | 14adfe4 | 2012-11-08 10:29:26 -0500 | [diff] [blame] | 1173 | mKeyguardDonePending = false; |
Dianne Hackborn | ff5b158 | 2012-04-12 17:24:07 -0700 | [diff] [blame] | 1174 | updateActivityLockScreenState(); |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1175 | adjustStatusBarLocked(); |
Jeff Brown | 3dc524b | 2012-09-30 19:49:11 -0700 | [diff] [blame] | 1176 | userActivity(); |
Dianne Hackborn | 29aae6f | 2011-08-18 18:30:09 -0700 | [diff] [blame] | 1177 | |
| 1178 | // Do this at the end to not slow down display of the keyguard. |
| 1179 | playSounds(true); |
| 1180 | |
Mike Lockwood | 674d3e4 | 2009-10-06 09:28:54 -0400 | [diff] [blame] | 1181 | mShowKeyguardWakeLock.release(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1182 | } |
Jim Miller | 3192148 | 2013-11-06 20:43:55 -0800 | [diff] [blame] | 1183 | mKeyguardDisplayManager.show(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1184 | } |
| 1185 | |
| 1186 | /** |
| 1187 | * Handle message sent by {@link #hideLocked()} |
| 1188 | * @see #HIDE |
| 1189 | */ |
| 1190 | private void handleHide() { |
| 1191 | synchronized (KeyguardViewMediator.this) { |
| 1192 | if (DEBUG) Log.d(TAG, "handleHide"); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1193 | try { |
| 1194 | |
Jorim Jaggi | b9d6079 | 2014-06-03 22:34:22 +0200 | [diff] [blame] | 1195 | if (mShowing) { |
| 1196 | |
| 1197 | // Don't actually hide the Keyguard at the moment, wait for window manager until |
| 1198 | // it tells us it's safe to do so with startKeyguardExitAnimation. |
| 1199 | mWM.keyguardGoingAway(); |
| 1200 | } else { |
| 1201 | |
| 1202 | // Don't try to rely on WindowManager - if Keyguard wasn't showing, window |
| 1203 | // manager won't start the exit animation. |
| 1204 | handleStartKeyguardExitAnimation(0, 0); |
| 1205 | } |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1206 | } catch (RemoteException e) { |
| 1207 | Log.e(TAG, "Error while calling WindowManager", e); |
| 1208 | } |
| 1209 | } |
| 1210 | } |
| 1211 | |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1212 | private void handleStartKeyguardExitAnimation(long startTime, long fadeoutDuration) { |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1213 | synchronized (KeyguardViewMediator.this) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1214 | |
Daniel Sandler | f2d8e74 | 2010-02-22 13:09:48 -0500 | [diff] [blame] | 1215 | // only play "unlock" noises if not on a call (since the incall UI |
| 1216 | // disables the keyguard) |
| 1217 | if (TelephonyManager.EXTRA_STATE_IDLE.equals(mPhoneState)) { |
| 1218 | playSounds(false); |
| 1219 | } |
Daniel Sandler | db783bd | 2010-02-11 15:27:37 -0500 | [diff] [blame] | 1220 | |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1221 | mStatusBarKeyguardViewManager.hide(startTime, fadeoutDuration); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1222 | mShowing = false; |
John Spurlock | 14adfe4 | 2012-11-08 10:29:26 -0500 | [diff] [blame] | 1223 | mKeyguardDonePending = false; |
Dianne Hackborn | ff5b158 | 2012-04-12 17:24:07 -0700 | [diff] [blame] | 1224 | updateActivityLockScreenState(); |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1225 | adjustStatusBarLocked(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1226 | } |
| 1227 | } |
| 1228 | |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1229 | private void adjustStatusBarLocked() { |
| 1230 | if (mStatusBarManager == null) { |
| 1231 | mStatusBarManager = (StatusBarManager) |
| 1232 | mContext.getSystemService(Context.STATUS_BAR_SERVICE); |
| 1233 | } |
| 1234 | if (mStatusBarManager == null) { |
| 1235 | Log.w(TAG, "Could not get status bar manager"); |
| 1236 | } else { |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 1237 | // Disable aspects of the system/status/navigation bars that must not be re-enabled by |
| 1238 | // windows that appear on top, ever |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 1239 | int flags = StatusBarManager.DISABLE_NONE; |
Mike Lockwood | e3646dd | 2011-09-01 12:46:28 -0400 | [diff] [blame] | 1240 | if (mShowing) { |
Jim Miller | e23ab8b | 2012-09-16 15:45:44 -0700 | [diff] [blame] | 1241 | // Permanently disable components not available when keyguard is enabled |
| 1242 | // (like recents). Temporary enable/disable (e.g. the "back" button) are |
| 1243 | // done in KeyguardHostView. |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 1244 | flags |= StatusBarManager.DISABLE_RECENT; |
John Spurlock | 43d8451 | 2012-11-09 10:27:33 -0500 | [diff] [blame] | 1245 | if (!isAssistantAvailable()) { |
| 1246 | flags |= StatusBarManager.DISABLE_SEARCH; |
| 1247 | } |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 1248 | } |
Jorim Jaggi | a005f1b | 2014-04-16 19:06:10 +0200 | [diff] [blame] | 1249 | if (isShowingAndNotOccluded()) { |
| 1250 | flags |= StatusBarManager.DISABLE_HOME; |
| 1251 | } |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 1252 | |
| 1253 | if (DEBUG) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1254 | Log.d(TAG, "adjustStatusBarLocked: mShowing=" + mShowing + " mOccluded=" + mOccluded |
Jeff Sharkey | 4519a02 | 2011-09-07 23:24:53 -0700 | [diff] [blame] | 1255 | + " isSecure=" + isSecure() + " --> flags=0x" + Integer.toHexString(flags)); |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 1256 | } |
| 1257 | |
Jim Miller | d6523da | 2012-10-21 16:47:02 -0700 | [diff] [blame] | 1258 | if (!(mContext instanceof Activity)) { |
| 1259 | mStatusBarManager.disable(flags); |
| 1260 | } |
Mike Lockwood | 5f892c1 | 2009-11-19 23:39:13 -0500 | [diff] [blame] | 1261 | } |
| 1262 | } |
| 1263 | |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1264 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1265 | * Handle message sent by {@link #resetStateLocked} |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1266 | * @see #RESET |
| 1267 | */ |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1268 | private void handleReset() { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1269 | synchronized (KeyguardViewMediator.this) { |
| 1270 | if (DEBUG) Log.d(TAG, "handleReset"); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1271 | mStatusBarKeyguardViewManager.reset(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1272 | } |
| 1273 | } |
| 1274 | |
| 1275 | /** |
| 1276 | * Handle message sent by {@link #verifyUnlock} |
Craig Mautner | 904732c | 2012-10-17 15:20:24 -0700 | [diff] [blame] | 1277 | * @see #VERIFY_UNLOCK |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1278 | */ |
| 1279 | private void handleVerifyUnlock() { |
| 1280 | synchronized (KeyguardViewMediator.this) { |
| 1281 | if (DEBUG) Log.d(TAG, "handleVerifyUnlock"); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1282 | mStatusBarKeyguardViewManager.verifyUnlock(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1283 | mShowing = true; |
Dianne Hackborn | ff5b158 | 2012-04-12 17:24:07 -0700 | [diff] [blame] | 1284 | updateActivityLockScreenState(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | /** |
| 1289 | * Handle message sent by {@link #notifyScreenOffLocked()} |
| 1290 | * @see #NOTIFY_SCREEN_OFF |
| 1291 | */ |
| 1292 | private void handleNotifyScreenOff() { |
| 1293 | synchronized (KeyguardViewMediator.this) { |
| 1294 | if (DEBUG) Log.d(TAG, "handleNotifyScreenOff"); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1295 | mStatusBarKeyguardViewManager.onScreenTurnedOff(); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1296 | } |
| 1297 | } |
| 1298 | |
| 1299 | /** |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1300 | * Handle message sent by {@link #notifyScreenOnLocked} |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1301 | * @see #NOTIFY_SCREEN_ON |
| 1302 | */ |
Jim Miller | 2519057 | 2013-02-28 17:36:24 -0800 | [diff] [blame] | 1303 | private void handleNotifyScreenOn(IKeyguardShowCallback callback) { |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1304 | synchronized (KeyguardViewMediator.this) { |
| 1305 | if (DEBUG) Log.d(TAG, "handleNotifyScreenOn"); |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1306 | mStatusBarKeyguardViewManager.onScreenTurnedOn(callback); |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1307 | } |
| 1308 | } |
Jeff Sharkey | 054340d | 2011-09-01 22:28:03 -0700 | [diff] [blame] | 1309 | |
John Spurlock | 34c4fe5 | 2012-11-07 10:12:29 -0500 | [diff] [blame] | 1310 | public boolean isDismissable() { |
| 1311 | return mKeyguardDonePending || !isSecure(); |
| 1312 | } |
| 1313 | |
John Spurlock | 43d8451 | 2012-11-09 10:27:33 -0500 | [diff] [blame] | 1314 | private boolean isAssistantAvailable() { |
| 1315 | return mSearchManager != null |
Dianne Hackborn | f9c5e0f | 2013-01-23 14:39:13 -0800 | [diff] [blame] | 1316 | && mSearchManager.getAssistIntent(mContext, false, UserHandle.USER_CURRENT) != null; |
John Spurlock | 43d8451 | 2012-11-09 10:27:33 -0500 | [diff] [blame] | 1317 | } |
Amith Yamasani | 6fc1d4e | 2013-05-08 16:43:58 -0700 | [diff] [blame] | 1318 | |
Jim Miller | e5f910a | 2013-10-16 18:15:46 -0700 | [diff] [blame] | 1319 | public void onBootCompleted() { |
| 1320 | mUpdateMonitor.dispatchBootCompleted(); |
| 1321 | } |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1322 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1323 | public StatusBarKeyguardViewManager registerStatusBar(PhoneStatusBar phoneStatusBar, |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 1324 | ViewGroup container, StatusBarWindowManager statusBarWindowManager, |
| 1325 | ScrimController scrimController) { |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1326 | mStatusBarKeyguardViewManager.registerStatusBar(phoneStatusBar, container, |
Jorim Jaggi | ecc798e | 2014-05-26 18:14:37 +0200 | [diff] [blame] | 1327 | statusBarWindowManager, scrimController); |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1328 | return mStatusBarKeyguardViewManager; |
| 1329 | } |
| 1330 | |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1331 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) { |
| 1332 | Message msg = mHandler.obtainMessage(START_KEYGUARD_EXIT_ANIM, |
| 1333 | new StartKeyguardExitAnimParams(startTime, fadeoutDuration)); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1334 | mHandler.sendMessage(msg); |
| 1335 | } |
| 1336 | |
Jorim Jaggi | 03c701e | 2014-04-02 12:39:51 +0200 | [diff] [blame] | 1337 | public ViewMediatorCallback getViewMediatorCallback() { |
| 1338 | return mViewMediatorCallback; |
Jorim Jaggi | 5cf1787 | 2014-03-26 18:31:48 +0100 | [diff] [blame] | 1339 | } |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1340 | |
| 1341 | private static class StartKeyguardExitAnimParams { |
| 1342 | |
| 1343 | long startTime; |
| 1344 | long fadeoutDuration; |
| 1345 | |
| 1346 | private StartKeyguardExitAnimParams(long startTime, long fadeoutDuration) { |
| 1347 | this.startTime = startTime; |
| 1348 | this.fadeoutDuration = fadeoutDuration; |
| 1349 | } |
| 1350 | } |
The Android Open Source Project | 1f838aa | 2009-03-03 19:32:13 -0800 | [diff] [blame] | 1351 | } |