Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c49dfaf4 authored by Adrian Roos's avatar Adrian Roos Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'smooth_unlock' into nyc-mr1-dev

* changes:
  Keyguard: Improve trusted unlock while occluded
  Keyguard: Refactoring for improving trusted unlock while occluded
parents b3690ccf ddcdecc9
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -135,6 +135,12 @@ public interface WindowManagerPolicy {
    void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)
            throws RemoteException;

    /**
     * @return true if windows with FLAG_DISMISS_KEYGUARD should be allowed to show even if
     *         the keyguard is locked.
     */
    boolean canShowDismissingWindowWhileLockedLw();

    /**
     * Interface to the Window Manager state associated with a particular
     * window.  You can hold on to an instance of this interface from the call
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ oneway interface IKeyguardService {
    void addStateMonitorCallback(IKeyguardStateCallback callback);
    void verifyUnlock(IKeyguardExitCallback callback);
    void keyguardDone(boolean authenticated, boolean wakeup);
    void dismiss();
    void dismiss(boolean allowWhileOccluded);
    void onDreamingStarted();
    void onDreamingStopped();

+1 −0
Original line number Diff line number Diff line
@@ -19,4 +19,5 @@ interface IKeyguardStateCallback {
    void onShowingStateChanged(boolean showing);
    void onSimSecureStateChanged(boolean simSecure);
    void onInputRestrictedStateChanged(boolean inputRestricted);
    void onTrustedChanged(boolean trusted);
}
 No newline at end of file
+2 −2
Original line number Diff line number Diff line
@@ -98,9 +98,9 @@ public class KeyguardService extends Service {
        }

        @Override // Binder interface
        public void dismiss() {
        public void dismiss(boolean allowWhileOccluded) {
            checkPermission();
            mKeyguardViewMediator.dismiss();
            mKeyguardViewMediator.dismiss(allowWhileOccluded);
        }

        @Override // Binder interface
+38 −7
Original line number Diff line number Diff line
@@ -363,7 +363,7 @@ public class KeyguardViewMediator extends SystemUI {
                UserInfo info = UserManager.get(mContext).getUserInfo(userId);
                if (info != null && (info.isGuest() || info.isDemo())) {
                    // If we just switched to a guest, try to dismiss keyguard.
                    dismiss();
                    dismiss(false /* allowWhileOccluded */);
                }
            }
        }
@@ -500,6 +500,17 @@ public class KeyguardViewMediator extends SystemUI {
                        userId);
            }
        }

        @Override
        public void onTrustChanged(int userId) {
            if (userId == KeyguardUpdateMonitor.getCurrentUser()) {
                synchronized (KeyguardViewMediator.this) {
                    notifyTrustedChangedLocked(mUpdateMonitor.getUserHasTrust(userId));
                }
            }
        }


    };

    ViewMediatorCallback mViewMediatorCallback = new ViewMediatorCallback() {
@@ -1253,15 +1264,16 @@ public class KeyguardViewMediator extends SystemUI {

    /**
     * Dismiss the keyguard through the security layers.
     * @param allowWhileOccluded if true, dismiss the keyguard even if it's currently occluded.
     */
    public void handleDismiss() {
        if (mShowing && !mOccluded) {
    public void handleDismiss(boolean allowWhileOccluded) {
        if (mShowing && (allowWhileOccluded || !mOccluded)) {
            mStatusBarKeyguardViewManager.dismiss();
        }
    }

    public void dismiss() {
        mHandler.sendEmptyMessage(DISMISS);
    public void dismiss(boolean allowWhileOccluded) {
        mHandler.obtainMessage(DISMISS, allowWhileOccluded ? 1 : 0, 0).sendToTarget();
    }

    /**
@@ -1355,6 +1367,9 @@ public class KeyguardViewMediator extends SystemUI {
     */
    public void setCurrentUser(int newUserId) {
        KeyguardUpdateMonitor.setCurrentUser(newUserId);
        synchronized (this) {
            notifyTrustedChangedLocked(mUpdateMonitor.getUserHasTrust(newUserId));
        }
    }

    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@@ -1463,7 +1478,7 @@ public class KeyguardViewMediator extends SystemUI {
                    }
                    break;
                case DISMISS:
                    handleDismiss();
                    handleDismiss(msg.arg1 == 1 ? true : false /* allowWhileOccluded */);
                    break;
                case START_KEYGUARD_EXIT_ANIM:
                    Trace.beginSection("KeyguardViewMediator#handleMessage START_KEYGUARD_EXIT_ANIM");
@@ -1989,6 +2004,20 @@ public class KeyguardViewMediator extends SystemUI {
        }
    }

    private void notifyTrustedChangedLocked(boolean trusted) {
        int size = mKeyguardStateCallbacks.size();
        for (int i = size - 1; i >= 0; i--) {
            try {
                mKeyguardStateCallbacks.get(i).onTrustedChanged(trusted);
            } catch (RemoteException e) {
                Slog.w(TAG, "Failed to call notifyTrustedChangedLocked", e);
                if (e instanceof DeadObjectException) {
                    mKeyguardStateCallbacks.remove(i);
                }
            }
        }
    }

    public void addStateMonitorCallback(IKeyguardStateCallback callback) {
        synchronized (this) {
            mKeyguardStateCallbacks.add(callback);
@@ -1996,8 +2025,10 @@ public class KeyguardViewMediator extends SystemUI {
                callback.onSimSecureStateChanged(mUpdateMonitor.isSimPinSecure());
                callback.onShowingStateChanged(mShowing);
                callback.onInputRestrictedStateChanged(mInputRestricted);
                callback.onTrustedChanged(mUpdateMonitor.getUserHasTrust(
                        KeyguardUpdateMonitor.getCurrentUser()));
            } catch (RemoteException e) {
                Slog.w(TAG, "Failed to call onShowingStateChanged or onSimSecureStateChanged or onInputRestrictedStateChanged", e);
                Slog.w(TAG, "Failed to call to IKeyguardStateCallback", e);
            }
        }
    }
Loading