/** @return Whether the keyguard is showing */
 public synchronized boolean isShowing() {
   return (mKeyguardHost != null && mKeyguardHost.getVisibility() == View.VISIBLE);
 }
  public synchronized void onScreenTurnedOn(final IKeyguardShowCallback callback) {
    if (DEBUG) Log.d(TAG, "onScreenTurnedOn()");
    mScreenOn = true;

    // If keyguard is not showing, we need to inform PhoneWindowManager with a null
    // token so it doesn't wait for us to draw...
    final IBinder token = isShowing() ? mKeyguardHost.getWindowToken() : null;

    if (DEBUG && token == null)
      Slog.v(
          TAG, "send wm null token: " + (mKeyguardHost == null ? "host was null" : "not showing"));

    if (mKeyguardView != null) {
      mKeyguardView.onScreenTurnedOn();

      if (mCreateOrientation != mContext.getResources().getConfiguration().orientation) {
        if (DEBUG)
          Log.d(
              TAG,
              "onScreenTurnedOn orientation is different, recreate it. mCreateOrientation="
                  + mCreateOrientation
                  + ", newConfig="
                  + mContext.getResources().getConfiguration().orientation);
        maybeCreateKeyguardLocked(KeyguardUtils.shouldEnableScreenRotation(mContext), true, null);
      }
      // Caller should wait for this window to be shown before turning
      // on the screen.
      if (callback != null) {
        if (mKeyguardHost.getVisibility() == View.VISIBLE) {
          // Keyguard may be in the process of being shown, but not yet
          // updated with the window manager...  give it a chance to do so.
          if (DEBUG) Log.d(TAG, "onScreenTurnedOn mKeyguardView visible, post runnable");
          mKeyguardHost.post(
              new Runnable() {
                @Override
                public void run() {
                  try {
                    if (DEBUG)
                      Log.d(
                          TAG,
                          "onScreenTurnedOn before callback.onShown() mKeyguardHost is Visible");
                    callback.onShown(token);
                  } catch (RemoteException e) {
                    Slog.w(TAG, "Exception calling onShown():", e);
                  }
                }
              });
        } else {
          try {
            if (DEBUG)
              Log.d(TAG, "onScreenTurnedOn before callback.onShown() mKeyguardHost is NOT Visible");
            callback.onShown(token);
          } catch (RemoteException e) {
            Slog.w(TAG, "Exception calling onShown():", e);
          }
        }
      }
    } else if (callback != null) {
      try {
        if (DEBUG) Log.d(TAG, "onScreenTurnedOn before callback.onShown() mKeyguardView is null");
        callback.onShown(token);
      } catch (RemoteException e) {
        Slog.w(TAG, "Exception calling onShown():", e);
      }
    }
  }