@Override
 public void onServiceConnected(ComponentName name, IBinder service) {
   if (DEBUG) Log.v(TAG, "*** Keyguard connected (yay!)");
   mKeyguardService = new KeyguardServiceWrapper(IKeyguardService.Stub.asInterface(service));
   if (mKeyguardState.systemIsReady) {
     // If the system is ready, it means keyguard crashed and restarted.
     mKeyguardService.onSystemReady();
     // This is used to hide the scrim once keyguard displays.
     mKeyguardService.onScreenTurnedOn(new KeyguardShowDelegate(null));
   }
   if (mKeyguardState.bootCompleted) {
     mKeyguardService.onBootCompleted();
   }
 }
 public void onBootCompleted() {
   if (mKeyguardService != null) {
     mKeyguardService.onBootCompleted();
     sendStateChangeBroadcast(true);
   }
   mKeyguardState.bootCompleted = true;
 }
 public void onScreenTurnedOff(int why) {
   if (mKeyguardService != null) {
     mKeyguardService.onScreenTurnedOff(why);
   }
   mKeyguardState.offReason = why;
   mKeyguardState.screenIsOn = false;
 }
 public void onSystemReady() {
   if (mKeyguardService != null) {
     mKeyguardService.onSystemReady();
   } else {
     mKeyguardState.systemIsReady = true;
   }
 }
 public int setOccluded(boolean isOccluded) {
   int result = 0;
   if (mKeyguardService != null) {
     result = mKeyguardService.setOccluded(isOccluded);
   }
   mKeyguardState.occluded = isOccluded;
   return result;
 }
 public void onSystemReady() {
   if (mKeyguardService != null) {
     mKeyguardService.onSystemReady();
   } else {
     if (DEBUG) Log.v(TAG, "onSystemReady() called before keyguard service was ready");
     mKeyguardState.systemIsReady = true;
   }
 }
 public void onScreenTurnedOn(final ShowListener showListener) {
   if (mKeyguardService != null) {
     if (DEBUG) Log.v(TAG, "onScreenTurnedOn(showListener = " + showListener + ")");
     mKeyguardService.onScreenTurnedOn(new KeyguardShowDelegate(showListener));
   } else {
     // try again when we establish a connection
     Slog.w(TAG, "onScreenTurnedOn(): no keyguard service!");
     // This shouldn't happen, but if it does, invoke the listener immediately
     // to avoid a dark screen...
     showListener.onShown(null);
   }
   mKeyguardState.screenIsOn = true;
 }
 public void onScreenTurnedOn(final ShowListener showListener) {
   if (mKeyguardService != null) {
     if (DEBUG) Log.v(TAG, "onScreenTurnedOn(showListener = " + showListener + ")");
     mKeyguardService.onScreenTurnedOn(new KeyguardShowDelegate(showListener));
   } else {
     // try again when we establish a connection
     Slog.w(TAG, "onScreenTurnedOn(): no keyguard service!");
     // This shouldn't happen, but if it does, show the scrim immediately and
     // invoke the listener's callback after the service actually connects.
     mShowListenerWhenConnect = showListener;
     showScrim();
   }
   mKeyguardState.screenIsOn = true;
 }
 public boolean isShowingAndNotHidden() {
   if (mKeyguardService != null) {
     mKeyguardState.showingAndNotHidden = mKeyguardService.isShowingAndNotHidden();
   }
   return mKeyguardState.showingAndNotHidden;
 }
 public void onDreamingStopped() {
   if (mKeyguardService != null) {
     mKeyguardService.onDreamingStopped();
   }
   mKeyguardState.dreaming = false;
 }
 public void onDreamingStarted() {
   if (mKeyguardService != null) {
     mKeyguardService.onDreamingStarted();
   }
   mKeyguardState.dreaming = true;
 }
 public boolean isSecure() {
   if (mKeyguardService != null) {
     mKeyguardState.secure = mKeyguardService.isSecure();
   }
   return mKeyguardState.secure;
 }
 public void dismiss() {
   if (mKeyguardService != null) {
     mKeyguardService.dismiss();
   }
 }
 public void setCurrentUser(int newUserId) {
   if (mKeyguardService != null) {
     mKeyguardService.setCurrentUser(newUserId);
   }
   mKeyguardState.currentUser = newUserId;
 }
 public void doKeyguardTimeout(Bundle options) {
   if (mKeyguardService != null) {
     mKeyguardService.doKeyguardTimeout(options);
   }
 }
 public boolean isDismissable() {
   if (mKeyguardService != null) {
     mKeyguardState.dismissable = mKeyguardService.isDismissable();
   }
   return mKeyguardState.dismissable;
 }
 public void startKeyguardExitAnimation(long startTime, long fadeoutDuration) {
   if (mKeyguardService != null) {
     mKeyguardService.startKeyguardExitAnimation(startTime, fadeoutDuration);
   }
 }
 public boolean isShowing() {
   if (mKeyguardService != null) {
     mKeyguardState.showing = mKeyguardService.isShowing();
   }
   return mKeyguardState.showing;
 }
 public void onActivityDrawn() {
   if (mKeyguardService != null) {
     mKeyguardService.onActivityDrawn();
   }
 }
 public void setKeyguardEnabled(boolean enabled) {
   if (mKeyguardService != null) {
     mKeyguardService.setKeyguardEnabled(enabled);
   }
   mKeyguardState.enabled = enabled;
 }
 public boolean isInputRestricted() {
   if (mKeyguardService != null) {
     mKeyguardState.inputRestricted = mKeyguardService.isInputRestricted();
   }
   return mKeyguardState.inputRestricted;
 }
 public void verifyUnlock(final OnKeyguardExitResult onKeyguardExitResult) {
   if (mKeyguardService != null) {
     mKeyguardService.verifyUnlock(new KeyguardExitDelegate(onKeyguardExitResult));
   }
 }
 public void keyguardDone(boolean authenticated, boolean wakeup) {
   if (mKeyguardService != null) {
     mKeyguardService.keyguardDone(authenticated, wakeup);
   }
 }
 public void showAssistant() {
   if (mKeyguardService != null) {
     mKeyguardService.showAssistant();
   }
 }
 public void setHidden(boolean isHidden) {
   if (mKeyguardService != null) {
     mKeyguardService.setHidden(isHidden);
   }
   mKeyguardState.hidden = isHidden;
 }
 public void onBootCompleted() {
   if (mKeyguardService != null) {
     mKeyguardService.onBootCompleted();
   }
   mKeyguardState.bootCompleted = true;
 }
 public boolean isShowingAndNotOccluded() {
   if (mKeyguardService != null) {
     mKeyguardState.showingAndNotOccluded = mKeyguardService.isShowingAndNotOccluded();
   }
   return mKeyguardState.showingAndNotOccluded;
 }