1/* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.internal.policy.impl.keyguard_obsolete; 18 19import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; 20 21import com.android.internal.policy.impl.PhoneWindowManager; 22import com.android.internal.telephony.IccCardConstants; 23import com.android.internal.widget.LockPatternUtils; 24 25import android.app.ActivityManagerNative; 26import android.app.AlarmManager; 27import android.app.PendingIntent; 28import android.app.StatusBarManager; 29import android.content.BroadcastReceiver; 30import android.content.ContentResolver; 31import android.content.Context; 32import android.content.Intent; 33import android.content.IntentFilter; 34import android.media.AudioManager; 35import android.media.SoundPool; 36import android.os.Handler; 37import android.os.Looper; 38import android.os.Message; 39import android.os.PowerManager; 40import android.os.RemoteException; 41import android.os.SystemClock; 42import android.os.SystemProperties; 43import android.os.UserHandle; 44import android.provider.Settings; 45import android.telephony.TelephonyManager; 46import android.util.EventLog; 47import android.util.Log; 48import android.view.KeyEvent; 49import android.view.WindowManager; 50import android.view.WindowManagerPolicy; 51 52 53/** 54 * Mediates requests related to the keyguard. This includes queries about the 55 * state of the keyguard, power management events that effect whether the keyguard 56 * should be shown or reset, callbacks to the phone window manager to notify 57 * it of when the keyguard is showing, and events from the keyguard view itself 58 * stating that the keyguard was succesfully unlocked. 59 * 60 * Note that the keyguard view is shown when the screen is off (as appropriate) 61 * so that once the screen comes on, it will be ready immediately. 62 * 63 * Example queries about the keyguard: 64 * - is {movement, key} one that should wake the keygaurd? 65 * - is the keyguard showing? 66 * - are input events restricted due to the state of the keyguard? 67 * 68 * Callbacks to the phone window manager: 69 * - the keyguard is showing 70 * 71 * Example external events that translate to keyguard view changes: 72 * - screen turned off -> reset the keyguard, and show it so it will be ready 73 * next time the screen turns on 74 * - keyboard is slid open -> if the keyguard is not secure, hide it 75 * 76 * Events from the keyguard view: 77 * - user succesfully unlocked keyguard -> hide keyguard view, and no longer 78 * restrict input events. 79 * 80 * Note: in addition to normal power managment events that effect the state of 81 * whether the keyguard should be showing, external apps and services may request 82 * that the keyguard be disabled via {@link #setKeyguardEnabled(boolean)}. When 83 * false, this will override all other conditions for turning on the keyguard. 84 * 85 * Threading and synchronization: 86 * This class is created by the initialization routine of the {@link WindowManagerPolicy}, 87 * and runs on its thread. The keyguard UI is created from that thread in the 88 * constructor of this class. The apis may be called from other threads, including the 89 * {@link com.android.server.input.InputManagerService}'s and {@link android.view.WindowManager}'s. 90 * Therefore, methods on this class are synchronized, and any action that is pointed 91 * directly to the keyguard UI is posted to a {@link Handler} to ensure it is taken on the UI 92 * thread of the keyguard. 93 */ 94public class KeyguardViewMediator implements KeyguardViewCallback { 95 private static final int KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT = 30000; 96 private final static boolean DEBUG = false; 97 private final static boolean DBG_WAKE = false; 98 99 private final static String TAG = "KeyguardViewMediator"; 100 101 private static final String DELAYED_KEYGUARD_ACTION = 102 "com.android.internal.policy.impl.PhoneWindowManager.DELAYED_KEYGUARD"; 103 104 // used for handler messages 105 private static final int TIMEOUT = 1; 106 private static final int SHOW = 2; 107 private static final int HIDE = 3; 108 private static final int RESET = 4; 109 private static final int VERIFY_UNLOCK = 5; 110 private static final int NOTIFY_SCREEN_OFF = 6; 111 private static final int NOTIFY_SCREEN_ON = 7; 112 private static final int WAKE_WHEN_READY = 8; 113 private static final int KEYGUARD_DONE = 9; 114 private static final int KEYGUARD_DONE_DRAWING = 10; 115 private static final int KEYGUARD_DONE_AUTHENTICATING = 11; 116 private static final int SET_HIDDEN = 12; 117 private static final int KEYGUARD_TIMEOUT = 13; 118 119 /** 120 * The default amount of time we stay awake (used for all key input) 121 */ 122 protected static final int AWAKE_INTERVAL_DEFAULT_MS = 10000; 123 124 /** 125 * How long to wait after the screen turns off due to timeout before 126 * turning on the keyguard (i.e, the user has this much time to turn 127 * the screen back on without having to face the keyguard). 128 */ 129 private static final int KEYGUARD_LOCK_AFTER_DELAY_DEFAULT = 5000; 130 131 /** 132 * How long we'll wait for the {@link KeyguardViewCallback#keyguardDoneDrawing()} 133 * callback before unblocking a call to {@link #setKeyguardEnabled(boolean)} 134 * that is reenabling the keyguard. 135 */ 136 private static final int KEYGUARD_DONE_DRAWING_TIMEOUT_MS = 2000; 137 138 /** 139 * Allow the user to expand the status bar when the keyguard is engaged 140 * (without a pattern or password). 141 */ 142 private static final boolean ENABLE_INSECURE_STATUS_BAR_EXPAND = true; 143 144 /** The stream type that the lock sounds are tied to. */ 145 private int mMasterStreamType; 146 147 private Context mContext; 148 private AlarmManager mAlarmManager; 149 private AudioManager mAudioManager; 150 private StatusBarManager mStatusBarManager; 151 private boolean mShowLockIcon; 152 private boolean mShowingLockIcon; 153 154 private boolean mSystemReady; 155 156 // Whether the next call to playSounds() should be skipped. Defaults to 157 // true because the first lock (on boot) should be silent. 158 private boolean mSuppressNextLockSound = true; 159 160 161 /** High level access to the power manager for WakeLocks */ 162 private PowerManager mPM; 163 164 /** 165 * Used to keep the device awake while the keyguard is showing, i.e for 166 * calls to {@link #pokeWakelock()} 167 */ 168 private PowerManager.WakeLock mWakeLock; 169 170 /** 171 * Used to keep the device awake while to ensure the keyguard finishes opening before 172 * we sleep. 173 */ 174 private PowerManager.WakeLock mShowKeyguardWakeLock; 175 176 /** 177 * Does not turn on screen, held while a call to {@link KeyguardViewManager#wakeWhenReadyTq(int)} 178 * is called to make sure the device doesn't sleep before it has a chance to poke 179 * the wake lock. 180 * @see #wakeWhenReadyLocked(int) 181 */ 182 private PowerManager.WakeLock mWakeAndHandOff; 183 184 private KeyguardViewManager mKeyguardViewManager; 185 186 // these are protected by synchronized (this) 187 188 /** 189 * External apps (like the phone app) can tell us to disable the keygaurd. 190 */ 191 private boolean mExternallyEnabled = true; 192 193 /** 194 * Remember if an external call to {@link #setKeyguardEnabled} with value 195 * false caused us to hide the keyguard, so that we need to reshow it once 196 * the keygaurd is reenabled with another call with value true. 197 */ 198 private boolean mNeedToReshowWhenReenabled = false; 199 200 // cached value of whether we are showing (need to know this to quickly 201 // answer whether the input should be restricted) 202 private boolean mShowing = false; 203 204 // true if the keyguard is hidden by another window 205 private boolean mHidden = false; 206 207 /** 208 * Helps remember whether the screen has turned on since the last time 209 * it turned off due to timeout. see {@link #onScreenTurnedOff(int)} 210 */ 211 private int mDelayedShowingSequence; 212 213 private int mWakelockSequence; 214 215 private PhoneWindowManager mCallback; 216 217 /** 218 * If the user has disabled the keyguard, then requests to exit, this is 219 * how we'll ultimately let them know whether it was successful. We use this 220 * var being non-null as an indicator that there is an in progress request. 221 */ 222 private WindowManagerPolicy.OnKeyguardExitResult mExitSecureCallback; 223 224 // the properties of the keyguard 225 private KeyguardViewProperties mKeyguardViewProperties; 226 227 private KeyguardUpdateMonitor mUpdateMonitor; 228 229 private boolean mScreenOn; 230 231 // last known state of the cellular connection 232 private String mPhoneState = TelephonyManager.EXTRA_STATE_IDLE; 233 234 /** 235 * we send this intent when the keyguard is dismissed. 236 */ 237 private Intent mUserPresentIntent; 238 239 /** 240 * {@link #setKeyguardEnabled} waits on this condition when it reenables 241 * the keyguard. 242 */ 243 private boolean mWaitingUntilKeyguardVisible = false; 244 private LockPatternUtils mLockPatternUtils; 245 246 private SoundPool mLockSounds; 247 private int mLockSoundId; 248 private int mUnlockSoundId; 249 private int mLockSoundStreamId; 250 251 /** 252 * The volume applied to the lock/unlock sounds. 253 */ 254 private final float mLockSoundVolume; 255 256 KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() { 257 258 @Override 259 public void onUserSwitched(int userId) { 260 mLockPatternUtils.setCurrentUser(userId); 261 synchronized (KeyguardViewMediator.this) { 262 resetStateLocked(); 263 } 264 } 265 266 @Override 267 public void onUserRemoved(int userId) { 268 mLockPatternUtils.removeUser(userId); 269 } 270 271 @Override 272 void onPhoneStateChanged(int phoneState) { 273 synchronized (KeyguardViewMediator.this) { 274 if (TelephonyManager.CALL_STATE_IDLE == phoneState // call ending 275 && !mScreenOn // screen off 276 && mExternallyEnabled) { // not disabled by any app 277 278 // note: this is a way to gracefully reenable the keyguard when the call 279 // ends and the screen is off without always reenabling the keyguard 280 // each time the screen turns off while in call (and having an occasional ugly 281 // flicker while turning back on the screen and disabling the keyguard again). 282 if (DEBUG) Log.d(TAG, "screen is off and call ended, let's make sure the " 283 + "keyguard is showing"); 284 doKeyguardLocked(); 285 } 286 } 287 }; 288 289 @Override 290 public void onClockVisibilityChanged() { 291 adjustStatusBarLocked(); 292 } 293 294 @Override 295 public void onDeviceProvisioned() { 296 mContext.sendBroadcastAsUser(mUserPresentIntent, UserHandle.ALL); 297 } 298 299 @Override 300 public void onSimStateChanged(IccCardConstants.State simState) { 301 if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState); 302 303 switch (simState) { 304 case NOT_READY: 305 case ABSENT: 306 // only force lock screen in case of missing sim if user hasn't 307 // gone through setup wizard 308 synchronized (this) { 309 if (!mUpdateMonitor.isDeviceProvisioned()) { 310 if (!isShowing()) { 311 if (DEBUG) Log.d(TAG, "ICC_ABSENT isn't showing," 312 + " we need to show the keyguard since the " 313 + "device isn't provisioned yet."); 314 doKeyguardLocked(); 315 } else { 316 resetStateLocked(); 317 } 318 } 319 } 320 break; 321 case PIN_REQUIRED: 322 case PUK_REQUIRED: 323 synchronized (this) { 324 if (!isShowing()) { 325 if (DEBUG) Log.d(TAG, "INTENT_VALUE_ICC_LOCKED and keygaurd isn't " 326 + "showing; need to show keyguard so user can enter sim pin"); 327 doKeyguardLocked(); 328 } else { 329 resetStateLocked(); 330 } 331 } 332 break; 333 case PERM_DISABLED: 334 synchronized (this) { 335 if (!isShowing()) { 336 if (DEBUG) Log.d(TAG, "PERM_DISABLED and " 337 + "keygaurd isn't showing."); 338 doKeyguardLocked(); 339 } else { 340 if (DEBUG) Log.d(TAG, "PERM_DISABLED, resetStateLocked to" 341 + "show permanently disabled message in lockscreen."); 342 resetStateLocked(); 343 } 344 } 345 break; 346 case READY: 347 synchronized (this) { 348 if (isShowing()) { 349 resetStateLocked(); 350 } 351 } 352 break; 353 } 354 } 355 356 }; 357 358 public KeyguardViewMediator(Context context, PhoneWindowManager callback) { 359 mContext = context; 360 mCallback = callback; 361 mPM = (PowerManager) context.getSystemService(Context.POWER_SERVICE); 362 mWakeLock = mPM.newWakeLock( 363 PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "keyguard"); 364 mWakeLock.setReferenceCounted(false); 365 mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard"); 366 mShowKeyguardWakeLock.setReferenceCounted(false); 367 368 mWakeAndHandOff = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "keyguardWakeAndHandOff"); 369 mWakeAndHandOff.setReferenceCounted(false); 370 371 mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_KEYGUARD_ACTION)); 372 373 mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); 374 375 mUpdateMonitor = new KeyguardUpdateMonitor(context); 376 377 mLockPatternUtils = new LockPatternUtils(mContext); 378 mKeyguardViewProperties 379 = new LockPatternKeyguardViewProperties(mLockPatternUtils, mUpdateMonitor); 380 381 WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE); 382 mKeyguardViewManager = new KeyguardViewManager( 383 context, wm, this, mKeyguardViewProperties, mUpdateMonitor); 384 385 mUserPresentIntent = new Intent(Intent.ACTION_USER_PRESENT); 386 mUserPresentIntent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING 387 | Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); 388 389 final ContentResolver cr = mContext.getContentResolver(); 390 mShowLockIcon = (Settings.System.getInt(cr, "show_status_bar_lock", 0) == 1); 391 392 mScreenOn = mPM.isScreenOn(); 393 394 mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0); 395 String soundPath = Settings.Global.getString(cr, Settings.Global.LOCK_SOUND); 396 if (soundPath != null) { 397 mLockSoundId = mLockSounds.load(soundPath, 1); 398 } 399 if (soundPath == null || mLockSoundId == 0) { 400 if (DEBUG) Log.d(TAG, "failed to load sound from " + soundPath); 401 } 402 soundPath = Settings.Global.getString(cr, Settings.Global.UNLOCK_SOUND); 403 if (soundPath != null) { 404 mUnlockSoundId = mLockSounds.load(soundPath, 1); 405 } 406 if (soundPath == null || mUnlockSoundId == 0) { 407 if (DEBUG) Log.d(TAG, "failed to load sound from " + soundPath); 408 } 409 int lockSoundDefaultAttenuation = context.getResources().getInteger( 410 com.android.internal.R.integer.config_lockSoundVolumeDb); 411 mLockSoundVolume = (float)Math.pow(10, (float)lockSoundDefaultAttenuation/20); 412 } 413 414 /** 415 * Let us know that the system is ready after startup. 416 */ 417 public void onSystemReady() { 418 synchronized (this) { 419 if (DEBUG) Log.d(TAG, "onSystemReady"); 420 mSystemReady = true; 421 mUpdateMonitor.registerCallback(mUpdateCallback); 422 doKeyguardLocked(); 423 } 424 } 425 426 /** 427 * Called to let us know the screen was turned off. 428 * @param why either {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER}, 429 * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT} or 430 * {@link WindowManagerPolicy#OFF_BECAUSE_OF_PROX_SENSOR}. 431 */ 432 public void onScreenTurnedOff(int why) { 433 synchronized (this) { 434 mScreenOn = false; 435 if (DEBUG) Log.d(TAG, "onScreenTurnedOff(" + why + ")"); 436 437 // Lock immediately based on setting if secure (user has a pin/pattern/password). 438 // This also "locks" the device when not secure to provide easy access to the 439 // camera while preventing unwanted input. 440 final boolean lockImmediately = 441 mLockPatternUtils.getPowerButtonInstantlyLocks() || !mLockPatternUtils.isSecure(); 442 443 if (mExitSecureCallback != null) { 444 if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled"); 445 mExitSecureCallback.onKeyguardExitResult(false); 446 mExitSecureCallback = null; 447 if (!mExternallyEnabled) { 448 hideLocked(); 449 } 450 } else if (mShowing) { 451 notifyScreenOffLocked(); 452 resetStateLocked(); 453 } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT 454 || (why == WindowManagerPolicy.OFF_BECAUSE_OF_USER && !lockImmediately)) { 455 // if the screen turned off because of timeout or the user hit the power button 456 // and we don't need to lock immediately, set an alarm 457 // to enable it a little bit later (i.e, give the user a chance 458 // to turn the screen back on within a certain window without 459 // having to unlock the screen) 460 final ContentResolver cr = mContext.getContentResolver(); 461 462 // From DisplaySettings 463 long displayTimeout = Settings.System.getInt(cr, SCREEN_OFF_TIMEOUT, 464 KEYGUARD_DISPLAY_TIMEOUT_DELAY_DEFAULT); 465 466 // From SecuritySettings 467 final long lockAfterTimeout = Settings.Secure.getInt(cr, 468 Settings.Secure.LOCK_SCREEN_LOCK_AFTER_TIMEOUT, 469 KEYGUARD_LOCK_AFTER_DELAY_DEFAULT); 470 471 // From DevicePolicyAdmin 472 final long policyTimeout = mLockPatternUtils.getDevicePolicyManager() 473 .getMaximumTimeToLock(null); 474 475 long timeout; 476 if (policyTimeout > 0) { 477 // policy in effect. Make sure we don't go beyond policy limit. 478 displayTimeout = Math.max(displayTimeout, 0); // ignore negative values 479 timeout = Math.min(policyTimeout - displayTimeout, lockAfterTimeout); 480 } else { 481 timeout = lockAfterTimeout; 482 } 483 484 if (timeout <= 0) { 485 // Lock now 486 mSuppressNextLockSound = true; 487 doKeyguardLocked(); 488 } else { 489 // Lock in the future 490 long when = SystemClock.elapsedRealtime() + timeout; 491 Intent intent = new Intent(DELAYED_KEYGUARD_ACTION); 492 intent.putExtra("seq", mDelayedShowingSequence); 493 PendingIntent sender = PendingIntent.getBroadcast(mContext, 494 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); 495 mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, when, sender); 496 if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " 497 + mDelayedShowingSequence); 498 } 499 } else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR) { 500 // Do not enable the keyguard if the prox sensor forced the screen off. 501 } else { 502 doKeyguardLocked(); 503 } 504 } 505 } 506 507 /** 508 * Let's us know the screen was turned on. 509 */ 510 public void onScreenTurnedOn(KeyguardViewManager.ShowListener showListener) { 511 synchronized (this) { 512 mScreenOn = true; 513 mDelayedShowingSequence++; 514 if (DEBUG) Log.d(TAG, "onScreenTurnedOn, seq = " + mDelayedShowingSequence); 515 if (showListener != null) { 516 notifyScreenOnLocked(showListener); 517 } 518 } 519 } 520 521 /** 522 * Same semantics as {@link WindowManagerPolicy#enableKeyguard}; provide 523 * a way for external stuff to override normal keyguard behavior. For instance 524 * the phone app disables the keyguard when it receives incoming calls. 525 */ 526 public void setKeyguardEnabled(boolean enabled) { 527 synchronized (this) { 528 if (DEBUG) Log.d(TAG, "setKeyguardEnabled(" + enabled + ")"); 529 530 531 mExternallyEnabled = enabled; 532 533 if (!enabled && mShowing) { 534 if (mExitSecureCallback != null) { 535 if (DEBUG) Log.d(TAG, "in process of verifyUnlock request, ignoring"); 536 // we're in the process of handling a request to verify the user 537 // can get past the keyguard. ignore extraneous requests to disable / reenable 538 return; 539 } 540 541 // hiding keyguard that is showing, remember to reshow later 542 if (DEBUG) Log.d(TAG, "remembering to reshow, hiding keyguard, " 543 + "disabling status bar expansion"); 544 mNeedToReshowWhenReenabled = true; 545 hideLocked(); 546 } else if (enabled && mNeedToReshowWhenReenabled) { 547 // reenabled after previously hidden, reshow 548 if (DEBUG) Log.d(TAG, "previously hidden, reshowing, reenabling " 549 + "status bar expansion"); 550 mNeedToReshowWhenReenabled = false; 551 552 if (mExitSecureCallback != null) { 553 if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting"); 554 mExitSecureCallback.onKeyguardExitResult(false); 555 mExitSecureCallback = null; 556 resetStateLocked(); 557 } else { 558 showLocked(); 559 560 // block until we know the keygaurd is done drawing (and post a message 561 // to unblock us after a timeout so we don't risk blocking too long 562 // and causing an ANR). 563 mWaitingUntilKeyguardVisible = true; 564 mHandler.sendEmptyMessageDelayed(KEYGUARD_DONE_DRAWING, KEYGUARD_DONE_DRAWING_TIMEOUT_MS); 565 if (DEBUG) Log.d(TAG, "waiting until mWaitingUntilKeyguardVisible is false"); 566 while (mWaitingUntilKeyguardVisible) { 567 try { 568 wait(); 569 } catch (InterruptedException e) { 570 Thread.currentThread().interrupt(); 571 } 572 } 573 if (DEBUG) Log.d(TAG, "done waiting for mWaitingUntilKeyguardVisible"); 574 } 575 } 576 } 577 } 578 579 /** 580 * @see android.app.KeyguardManager#exitKeyguardSecurely 581 */ 582 public void verifyUnlock(WindowManagerPolicy.OnKeyguardExitResult callback) { 583 synchronized (this) { 584 if (DEBUG) Log.d(TAG, "verifyUnlock"); 585 if (!mUpdateMonitor.isDeviceProvisioned()) { 586 // don't allow this api when the device isn't provisioned 587 if (DEBUG) Log.d(TAG, "ignoring because device isn't provisioned"); 588 callback.onKeyguardExitResult(false); 589 } else if (mExternallyEnabled) { 590 // this only applies when the user has externally disabled the 591 // keyguard. this is unexpected and means the user is not 592 // using the api properly. 593 Log.w(TAG, "verifyUnlock called when not externally disabled"); 594 callback.onKeyguardExitResult(false); 595 } else if (mExitSecureCallback != null) { 596 // already in progress with someone else 597 callback.onKeyguardExitResult(false); 598 } else { 599 mExitSecureCallback = callback; 600 verifyUnlockLocked(); 601 } 602 } 603 } 604 605 /** 606 * Is the keyguard currently showing? 607 */ 608 public boolean isShowing() { 609 return mShowing; 610 } 611 612 /** 613 * Is the keyguard currently showing and not being force hidden? 614 */ 615 public boolean isShowingAndNotHidden() { 616 return mShowing && !mHidden; 617 } 618 619 /** 620 * Notify us when the keyguard is hidden by another window 621 */ 622 public void setHidden(boolean isHidden) { 623 if (DEBUG) Log.d(TAG, "setHidden " + isHidden); 624 mHandler.removeMessages(SET_HIDDEN); 625 Message msg = mHandler.obtainMessage(SET_HIDDEN, (isHidden ? 1 : 0), 0); 626 mHandler.sendMessage(msg); 627 } 628 629 /** 630 * Handles SET_HIDDEN message sent by setHidden() 631 */ 632 private void handleSetHidden(boolean isHidden) { 633 synchronized (KeyguardViewMediator.this) { 634 if (mHidden != isHidden) { 635 mHidden = isHidden; 636 updateActivityLockScreenState(); 637 adjustUserActivityLocked(); 638 adjustStatusBarLocked(); 639 } 640 } 641 } 642 643 /** 644 * Used by PhoneWindowManager to enable the keyguard due to a user activity timeout. 645 * This must be safe to call from any thread and with any window manager locks held. 646 */ 647 public void doKeyguardTimeout() { 648 mHandler.removeMessages(KEYGUARD_TIMEOUT); 649 Message msg = mHandler.obtainMessage(KEYGUARD_TIMEOUT); 650 mHandler.sendMessage(msg); 651 } 652 653 /** 654 * Given the state of the keyguard, is the input restricted? 655 * Input is restricted when the keyguard is showing, or when the keyguard 656 * was suppressed by an app that disabled the keyguard or we haven't been provisioned yet. 657 */ 658 public boolean isInputRestricted() { 659 return mShowing || mNeedToReshowWhenReenabled || !mUpdateMonitor.isDeviceProvisioned(); 660 } 661 662 /** 663 * Enable the keyguard if the settings are appropriate. Return true if all 664 * work that will happen is done; returns false if the caller can wait for 665 * the keyguard to be shown. 666 */ 667 private void doKeyguardLocked() { 668 // if another app is disabling us, don't show 669 if (!mExternallyEnabled) { 670 if (DEBUG) Log.d(TAG, "doKeyguard: not showing because externally disabled"); 671 672 // note: we *should* set mNeedToReshowWhenReenabled=true here, but that makes 673 // for an occasional ugly flicker in this situation: 674 // 1) receive a call with the screen on (no keyguard) or make a call 675 // 2) screen times out 676 // 3) user hits key to turn screen back on 677 // instead, we reenable the keyguard when we know the screen is off and the call 678 // ends (see the broadcast receiver below) 679 // TODO: clean this up when we have better support at the window manager level 680 // for apps that wish to be on top of the keyguard 681 return; 682 } 683 684 // if the keyguard is already showing, don't bother 685 if (mKeyguardViewManager.isShowing()) { 686 if (DEBUG) Log.d(TAG, "doKeyguard: not showing because it is already showing"); 687 return; 688 } 689 690 // if the setup wizard hasn't run yet, don't show 691 final boolean requireSim = !SystemProperties.getBoolean("keyguard.no_require_sim", 692 false); 693 final boolean provisioned = mUpdateMonitor.isDeviceProvisioned(); 694 final IccCardConstants.State state = mUpdateMonitor.getSimState(); 695 final boolean lockedOrMissing = state.isPinLocked() 696 || ((state == IccCardConstants.State.ABSENT 697 || state == IccCardConstants.State.PERM_DISABLED) 698 && requireSim); 699 700 if (!lockedOrMissing && !provisioned) { 701 if (DEBUG) Log.d(TAG, "doKeyguard: not showing because device isn't provisioned" 702 + " and the sim is not locked or missing"); 703 return; 704 } 705 706 if (mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) { 707 if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off"); 708 return; 709 } 710 711 if (DEBUG) Log.d(TAG, "doKeyguard: showing the lock screen"); 712 showLocked(); 713 } 714 715 /** 716 * Send message to keyguard telling it to reset its state. 717 * @see #handleReset() 718 */ 719 private void resetStateLocked() { 720 if (DEBUG) Log.d(TAG, "resetStateLocked"); 721 Message msg = mHandler.obtainMessage(RESET); 722 mHandler.sendMessage(msg); 723 } 724 725 /** 726 * Send message to keyguard telling it to verify unlock 727 * @see #handleVerifyUnlock() 728 */ 729 private void verifyUnlockLocked() { 730 if (DEBUG) Log.d(TAG, "verifyUnlockLocked"); 731 mHandler.sendEmptyMessage(VERIFY_UNLOCK); 732 } 733 734 735 /** 736 * Send a message to keyguard telling it the screen just turned on. 737 * @see #onScreenTurnedOff(int) 738 * @see #handleNotifyScreenOff 739 */ 740 private void notifyScreenOffLocked() { 741 if (DEBUG) Log.d(TAG, "notifyScreenOffLocked"); 742 mHandler.sendEmptyMessage(NOTIFY_SCREEN_OFF); 743 } 744 745 /** 746 * Send a message to keyguard telling it the screen just turned on. 747 * @see #onScreenTurnedOn() 748 * @see #handleNotifyScreenOn 749 */ 750 private void notifyScreenOnLocked(KeyguardViewManager.ShowListener showListener) { 751 if (DEBUG) Log.d(TAG, "notifyScreenOnLocked"); 752 Message msg = mHandler.obtainMessage(NOTIFY_SCREEN_ON, showListener); 753 mHandler.sendMessage(msg); 754 } 755 756 /** 757 * Send message to keyguard telling it about a wake key so it can adjust 758 * its state accordingly and then poke the wake lock when it is ready. 759 * @param keyCode The wake key. 760 * @see #handleWakeWhenReady 761 * @see #onWakeKeyWhenKeyguardShowingTq(int) 762 */ 763 private void wakeWhenReadyLocked(int keyCode) { 764 if (DBG_WAKE) Log.d(TAG, "wakeWhenReadyLocked(" + keyCode + ")"); 765 766 /** 767 * acquire the handoff lock that will keep the cpu running. this will 768 * be released once the keyguard has set itself up and poked the other wakelock 769 * in {@link #handleWakeWhenReady(int)} 770 */ 771 mWakeAndHandOff.acquire(); 772 773 Message msg = mHandler.obtainMessage(WAKE_WHEN_READY, keyCode, 0); 774 mHandler.sendMessage(msg); 775 } 776 777 /** 778 * Send message to keyguard telling it to show itself 779 * @see #handleShow() 780 */ 781 private void showLocked() { 782 if (DEBUG) Log.d(TAG, "showLocked"); 783 // ensure we stay awake until we are finished displaying the keyguard 784 mShowKeyguardWakeLock.acquire(); 785 Message msg = mHandler.obtainMessage(SHOW); 786 mHandler.sendMessage(msg); 787 } 788 789 /** 790 * Send message to keyguard telling it to hide itself 791 * @see #handleHide() 792 */ 793 private void hideLocked() { 794 if (DEBUG) Log.d(TAG, "hideLocked"); 795 Message msg = mHandler.obtainMessage(HIDE); 796 mHandler.sendMessage(msg); 797 } 798 799 public boolean isSecure() { 800 return mKeyguardViewProperties.isSecure(); 801 } 802 803 private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { 804 @Override 805 public void onReceive(Context context, Intent intent) { 806 if (DELAYED_KEYGUARD_ACTION.equals(intent.getAction())) { 807 final int sequence = intent.getIntExtra("seq", 0); 808 if (DEBUG) Log.d(TAG, "received DELAYED_KEYGUARD_ACTION with seq = " 809 + sequence + ", mDelayedShowingSequence = " + mDelayedShowingSequence); 810 synchronized (KeyguardViewMediator.this) { 811 if (mDelayedShowingSequence == sequence) { 812 // Don't play lockscreen SFX if the screen went off due to timeout. 813 mSuppressNextLockSound = true; 814 doKeyguardLocked(); 815 } 816 } 817 } 818 } 819 }; 820 821 /** 822 * When a key is received when the screen is off and the keyguard is showing, 823 * we need to decide whether to actually turn on the screen, and if so, tell 824 * the keyguard to prepare itself and poke the wake lock when it is ready. 825 * 826 * The 'Tq' suffix is per the documentation in {@link WindowManagerPolicy}. 827 * Be sure not to take any action that takes a long time; any significant 828 * action should be posted to a handler. 829 * 830 * @param keyCode The keycode of the key that woke the device 831 * @param isDocked True if the device is in the dock 832 * @return Whether we poked the wake lock (and turned the screen on) 833 */ 834 public boolean onWakeKeyWhenKeyguardShowingTq(int keyCode, boolean isDocked) { 835 if (DEBUG) Log.d(TAG, "onWakeKeyWhenKeyguardShowing(" + keyCode + ")"); 836 837 if (isWakeKeyWhenKeyguardShowing(keyCode, isDocked)) { 838 // give the keyguard view manager a chance to adjust the state of the 839 // keyguard based on the key that woke the device before poking 840 // the wake lock 841 wakeWhenReadyLocked(keyCode); 842 return true; 843 } else { 844 return false; 845 } 846 } 847 848 /** 849 * When the keyguard is showing we ignore some keys that might otherwise typically 850 * be considered wake keys. We filter them out here. 851 * 852 * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it 853 * is always considered a wake key. 854 */ 855 private boolean isWakeKeyWhenKeyguardShowing(int keyCode, boolean isDocked) { 856 switch (keyCode) { 857 // ignore volume keys unless docked 858 case KeyEvent.KEYCODE_VOLUME_UP: 859 case KeyEvent.KEYCODE_VOLUME_DOWN: 860 case KeyEvent.KEYCODE_VOLUME_MUTE: 861 return isDocked; 862 863 // ignore media and camera keys 864 case KeyEvent.KEYCODE_MUTE: 865 case KeyEvent.KEYCODE_HEADSETHOOK: 866 case KeyEvent.KEYCODE_MEDIA_PLAY: 867 case KeyEvent.KEYCODE_MEDIA_PAUSE: 868 case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: 869 case KeyEvent.KEYCODE_MEDIA_STOP: 870 case KeyEvent.KEYCODE_MEDIA_NEXT: 871 case KeyEvent.KEYCODE_MEDIA_PREVIOUS: 872 case KeyEvent.KEYCODE_MEDIA_REWIND: 873 case KeyEvent.KEYCODE_MEDIA_RECORD: 874 case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: 875 case KeyEvent.KEYCODE_CAMERA: 876 return false; 877 } 878 return true; 879 } 880 881 /** 882 * When a wake motion such as an external mouse movement is received when the screen 883 * is off and the keyguard is showing, we need to decide whether to actually turn 884 * on the screen, and if so, tell the keyguard to prepare itself and poke the wake 885 * lock when it is ready. 886 * 887 * The 'Tq' suffix is per the documentation in {@link WindowManagerPolicy}. 888 * Be sure not to take any action that takes a long time; any significant 889 * action should be posted to a handler. 890 * 891 * @return Whether we poked the wake lock (and turned the screen on) 892 */ 893 public boolean onWakeMotionWhenKeyguardShowingTq() { 894 if (DEBUG) Log.d(TAG, "onWakeMotionWhenKeyguardShowing()"); 895 896 // give the keyguard view manager a chance to adjust the state of the 897 // keyguard based on the key that woke the device before poking 898 // the wake lock 899 wakeWhenReadyLocked(KeyEvent.KEYCODE_UNKNOWN); 900 return true; 901 } 902 903 /** 904 * Callbacks from {@link KeyguardViewManager}. 905 */ 906 907 /** {@inheritDoc} */ 908 public void pokeWakelock() { 909 pokeWakelock(AWAKE_INTERVAL_DEFAULT_MS); 910 } 911 912 /** {@inheritDoc} */ 913 public void pokeWakelock(int holdMs) { 914 synchronized (this) { 915 if (DBG_WAKE) Log.d(TAG, "pokeWakelock(" + holdMs + ")"); 916 mWakeLock.acquire(); 917 mHandler.removeMessages(TIMEOUT); 918 mWakelockSequence++; 919 Message msg = mHandler.obtainMessage(TIMEOUT, mWakelockSequence, 0); 920 mHandler.sendMessageDelayed(msg, holdMs); 921 } 922 } 923 924 /** 925 * {@inheritDoc} 926 * 927 * @see #handleKeyguardDone 928 */ 929 public void keyguardDone(boolean authenticated) { 930 keyguardDone(authenticated, true); 931 } 932 933 public void keyguardDone(boolean authenticated, boolean wakeup) { 934 synchronized (this) { 935 EventLog.writeEvent(70000, 2); 936 if (DEBUG) Log.d(TAG, "keyguardDone(" + authenticated + ")"); 937 Message msg = mHandler.obtainMessage(KEYGUARD_DONE); 938 msg.arg1 = wakeup ? 1 : 0; 939 mHandler.sendMessage(msg); 940 941 if (authenticated) { 942 mUpdateMonitor.clearFailedAttempts(); 943 } 944 945 if (mExitSecureCallback != null) { 946 mExitSecureCallback.onKeyguardExitResult(authenticated); 947 mExitSecureCallback = null; 948 949 if (authenticated) { 950 // after succesfully exiting securely, no need to reshow 951 // the keyguard when they've released the lock 952 mExternallyEnabled = true; 953 mNeedToReshowWhenReenabled = false; 954 } 955 } 956 } 957 } 958 959 /** 960 * {@inheritDoc} 961 * 962 * @see #handleKeyguardDoneDrawing 963 */ 964 public void keyguardDoneDrawing() { 965 mHandler.sendEmptyMessage(KEYGUARD_DONE_DRAWING); 966 } 967 968 /** 969 * This handler will be associated with the policy thread, which will also 970 * be the UI thread of the keyguard. Since the apis of the policy, and therefore 971 * this class, can be called by other threads, any action that directly 972 * interacts with the keyguard ui should be posted to this handler, rather 973 * than called directly. 974 */ 975 private Handler mHandler = new Handler(true /*async*/) { 976 @Override 977 public void handleMessage(Message msg) { 978 switch (msg.what) { 979 case TIMEOUT: 980 handleTimeout(msg.arg1); 981 return ; 982 case SHOW: 983 handleShow(); 984 return ; 985 case HIDE: 986 handleHide(); 987 return ; 988 case RESET: 989 handleReset(); 990 return ; 991 case VERIFY_UNLOCK: 992 handleVerifyUnlock(); 993 return; 994 case NOTIFY_SCREEN_OFF: 995 handleNotifyScreenOff(); 996 return; 997 case NOTIFY_SCREEN_ON: 998 handleNotifyScreenOn((KeyguardViewManager.ShowListener)msg.obj); 999 return; 1000 case WAKE_WHEN_READY: 1001 handleWakeWhenReady(msg.arg1); 1002 return; 1003 case KEYGUARD_DONE: 1004 handleKeyguardDone(msg.arg1 != 0); 1005 return; 1006 case KEYGUARD_DONE_DRAWING: 1007 handleKeyguardDoneDrawing(); 1008 return; 1009 case KEYGUARD_DONE_AUTHENTICATING: 1010 keyguardDone(true); 1011 return; 1012 case SET_HIDDEN: 1013 handleSetHidden(msg.arg1 != 0); 1014 break; 1015 case KEYGUARD_TIMEOUT: 1016 synchronized (KeyguardViewMediator.this) { 1017 doKeyguardLocked(); 1018 } 1019 break; 1020 } 1021 } 1022 }; 1023 1024 /** 1025 * @see #keyguardDone 1026 * @see #KEYGUARD_DONE 1027 */ 1028 private void handleKeyguardDone(boolean wakeup) { 1029 if (DEBUG) Log.d(TAG, "handleKeyguardDone"); 1030 handleHide(); 1031 if (wakeup) { 1032 mPM.wakeUp(SystemClock.uptimeMillis()); 1033 } 1034 mWakeLock.release(); 1035 1036 final UserHandle currentUser = new UserHandle(mLockPatternUtils.getCurrentUser()); 1037 mContext.sendBroadcastAsUser(mUserPresentIntent, currentUser); 1038 } 1039 1040 /** 1041 * @see #keyguardDoneDrawing 1042 * @see #KEYGUARD_DONE_DRAWING 1043 */ 1044 private void handleKeyguardDoneDrawing() { 1045 synchronized(this) { 1046 if (false) Log.d(TAG, "handleKeyguardDoneDrawing"); 1047 if (mWaitingUntilKeyguardVisible) { 1048 if (DEBUG) Log.d(TAG, "handleKeyguardDoneDrawing: notifying mWaitingUntilKeyguardVisible"); 1049 mWaitingUntilKeyguardVisible = false; 1050 notifyAll(); 1051 1052 // there will usually be two of these sent, one as a timeout, and one 1053 // as a result of the callback, so remove any remaining messages from 1054 // the queue 1055 mHandler.removeMessages(KEYGUARD_DONE_DRAWING); 1056 } 1057 } 1058 } 1059 1060 /** 1061 * Handles the message sent by {@link #pokeWakelock} 1062 * @param seq used to determine if anything has changed since the message 1063 * was sent. 1064 * @see #TIMEOUT 1065 */ 1066 private void handleTimeout(int seq) { 1067 synchronized (KeyguardViewMediator.this) { 1068 if (DEBUG) Log.d(TAG, "handleTimeout"); 1069 if (seq == mWakelockSequence) { 1070 mWakeLock.release(); 1071 } 1072 } 1073 } 1074 1075 private void playSounds(boolean locked) { 1076 // User feedback for keyguard. 1077 1078 if (mSuppressNextLockSound) { 1079 mSuppressNextLockSound = false; 1080 return; 1081 } 1082 1083 final ContentResolver cr = mContext.getContentResolver(); 1084 if (Settings.System.getInt(cr, Settings.System.LOCKSCREEN_SOUNDS_ENABLED, 1) == 1) { 1085 final int whichSound = locked 1086 ? mLockSoundId 1087 : mUnlockSoundId; 1088 mLockSounds.stop(mLockSoundStreamId); 1089 // Init mAudioManager 1090 if (mAudioManager == null) { 1091 mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); 1092 if (mAudioManager == null) return; 1093 mMasterStreamType = mAudioManager.getMasterStreamType(); 1094 } 1095 // If the stream is muted, don't play the sound 1096 if (mAudioManager.isStreamMute(mMasterStreamType)) return; 1097 1098 mLockSoundStreamId = mLockSounds.play(whichSound, 1099 mLockSoundVolume, mLockSoundVolume, 1/*priortiy*/, 0/*loop*/, 1.0f/*rate*/); 1100 } 1101 } 1102 1103 private void updateActivityLockScreenState() { 1104 try { 1105 ActivityManagerNative.getDefault().setLockScreenShown( 1106 mShowing && !mHidden); 1107 } catch (RemoteException e) { 1108 } 1109 } 1110 1111 /** 1112 * Handle message sent by {@link #showLocked}. 1113 * @see #SHOW 1114 */ 1115 private void handleShow() { 1116 synchronized (KeyguardViewMediator.this) { 1117 if (DEBUG) Log.d(TAG, "handleShow"); 1118 if (!mSystemReady) return; 1119 1120 mKeyguardViewManager.show(); 1121 mShowing = true; 1122 updateActivityLockScreenState(); 1123 adjustUserActivityLocked(); 1124 adjustStatusBarLocked(); 1125 try { 1126 ActivityManagerNative.getDefault().closeSystemDialogs("lock"); 1127 } catch (RemoteException e) { 1128 } 1129 1130 // Do this at the end to not slow down display of the keyguard. 1131 playSounds(true); 1132 1133 mShowKeyguardWakeLock.release(); 1134 } 1135 } 1136 1137 /** 1138 * Handle message sent by {@link #hideLocked()} 1139 * @see #HIDE 1140 */ 1141 private void handleHide() { 1142 synchronized (KeyguardViewMediator.this) { 1143 if (DEBUG) Log.d(TAG, "handleHide"); 1144 if (mWakeAndHandOff.isHeld()) { 1145 Log.w(TAG, "attempt to hide the keyguard while waking, ignored"); 1146 return; 1147 } 1148 1149 // only play "unlock" noises if not on a call (since the incall UI 1150 // disables the keyguard) 1151 if (TelephonyManager.EXTRA_STATE_IDLE.equals(mPhoneState)) { 1152 playSounds(false); 1153 } 1154 1155 mKeyguardViewManager.hide(); 1156 mShowing = false; 1157 updateActivityLockScreenState(); 1158 adjustUserActivityLocked(); 1159 adjustStatusBarLocked(); 1160 } 1161 } 1162 1163 private void adjustUserActivityLocked() { 1164 // disable user activity if we are shown and not hidden 1165 if (DEBUG) Log.d(TAG, "adjustUserActivityLocked mShowing: " + mShowing + " mHidden: " + mHidden); 1166 boolean enabled = !mShowing || mHidden; 1167 // FIXME: Replace this with a new timeout control mechanism. 1168 //mRealPowerManager.enableUserActivity(enabled); 1169 if (!enabled && mScreenOn) { 1170 // reinstate our short screen timeout policy 1171 pokeWakelock(); 1172 } 1173 } 1174 1175 private void adjustStatusBarLocked() { 1176 if (mStatusBarManager == null) { 1177 mStatusBarManager = (StatusBarManager) 1178 mContext.getSystemService(Context.STATUS_BAR_SERVICE); 1179 } 1180 if (mStatusBarManager == null) { 1181 Log.w(TAG, "Could not get status bar manager"); 1182 } else { 1183 if (mShowLockIcon) { 1184 // Give feedback to user when secure keyguard is active and engaged 1185 if (mShowing && isSecure()) { 1186 if (!mShowingLockIcon) { 1187 String contentDescription = mContext.getString( 1188 com.android.internal.R.string.status_bar_device_locked); 1189 mStatusBarManager.setIcon("secure", 1190 com.android.internal.R.drawable.stat_sys_secure, 0, 1191 contentDescription); 1192 mShowingLockIcon = true; 1193 } 1194 } else { 1195 if (mShowingLockIcon) { 1196 mStatusBarManager.removeIcon("secure"); 1197 mShowingLockIcon = false; 1198 } 1199 } 1200 } 1201 1202 // Disable aspects of the system/status/navigation bars that must not be re-enabled by 1203 // windows that appear on top, ever 1204 int flags = StatusBarManager.DISABLE_NONE; 1205 if (mShowing) { 1206 // disable navigation status bar components (home, recents) if lock screen is up 1207 flags |= StatusBarManager.DISABLE_RECENT; 1208 if (isSecure() || !ENABLE_INSECURE_STATUS_BAR_EXPAND) { 1209 // showing secure lockscreen; disable expanding. 1210 flags |= StatusBarManager.DISABLE_EXPAND; 1211 } 1212 if (isSecure()) { 1213 // showing secure lockscreen; disable ticker. 1214 flags |= StatusBarManager.DISABLE_NOTIFICATION_TICKER; 1215 } 1216 } 1217 1218 if (DEBUG) { 1219 Log.d(TAG, "adjustStatusBarLocked: mShowing=" + mShowing + " mHidden=" + mHidden 1220 + " isSecure=" + isSecure() + " --> flags=0x" + Integer.toHexString(flags)); 1221 } 1222 1223 mStatusBarManager.disable(flags); 1224 } 1225 } 1226 1227 /** 1228 * Handle message sent by {@link #wakeWhenReadyLocked(int)} 1229 * @param keyCode The key that woke the device. 1230 * @see #WAKE_WHEN_READY 1231 */ 1232 private void handleWakeWhenReady(int keyCode) { 1233 synchronized (KeyguardViewMediator.this) { 1234 if (DBG_WAKE) Log.d(TAG, "handleWakeWhenReady(" + keyCode + ")"); 1235 1236 // this should result in a call to 'poke wakelock' which will set a timeout 1237 // on releasing the wakelock 1238 if (!mKeyguardViewManager.wakeWhenReadyTq(keyCode)) { 1239 // poke wakelock ourselves if keyguard is no longer active 1240 Log.w(TAG, "mKeyguardViewManager.wakeWhenReadyTq did not poke wake lock, so poke it ourselves"); 1241 pokeWakelock(); 1242 } 1243 1244 /** 1245 * Now that the keyguard is ready and has poked the wake lock, we can 1246 * release the handoff wakelock 1247 */ 1248 mWakeAndHandOff.release(); 1249 1250 if (!mWakeLock.isHeld()) { 1251 Log.w(TAG, "mWakeLock not held in mKeyguardViewManager.wakeWhenReadyTq"); 1252 } 1253 } 1254 } 1255 1256 /** 1257 * Handle message sent by {@link #resetStateLocked()} 1258 * @see #RESET 1259 */ 1260 private void handleReset() { 1261 synchronized (KeyguardViewMediator.this) { 1262 if (DEBUG) Log.d(TAG, "handleReset"); 1263 mKeyguardViewManager.reset(); 1264 } 1265 } 1266 1267 /** 1268 * Handle message sent by {@link #verifyUnlock} 1269 * @see #RESET 1270 */ 1271 private void handleVerifyUnlock() { 1272 synchronized (KeyguardViewMediator.this) { 1273 if (DEBUG) Log.d(TAG, "handleVerifyUnlock"); 1274 mKeyguardViewManager.verifyUnlock(); 1275 mShowing = true; 1276 updateActivityLockScreenState(); 1277 } 1278 } 1279 1280 /** 1281 * Handle message sent by {@link #notifyScreenOffLocked()} 1282 * @see #NOTIFY_SCREEN_OFF 1283 */ 1284 private void handleNotifyScreenOff() { 1285 synchronized (KeyguardViewMediator.this) { 1286 if (DEBUG) Log.d(TAG, "handleNotifyScreenOff"); 1287 mKeyguardViewManager.onScreenTurnedOff(); 1288 } 1289 } 1290 1291 /** 1292 * Handle message sent by {@link #notifyScreenOnLocked()} 1293 * @see #NOTIFY_SCREEN_ON 1294 */ 1295 private void handleNotifyScreenOn(KeyguardViewManager.ShowListener showListener) { 1296 synchronized (KeyguardViewMediator.this) { 1297 if (DEBUG) Log.d(TAG, "handleNotifyScreenOn"); 1298 mKeyguardViewManager.onScreenTurnedOn(showListener); 1299 } 1300 } 1301 1302} 1303