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

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

Merge "Add KeyguardManager.isDeviceSecure"

parents 1dc22fa9 82893681
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4596,6 +4596,7 @@ package android.app {
    method public deprecated void exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult);
    method public boolean inKeyguardRestrictedInputMode();
    method public boolean isDeviceLocked();
    method public boolean isDeviceSecure();
    method public boolean isKeyguardLocked();
    method public boolean isKeyguardSecure();
    method public deprecated android.app.KeyguardManager.KeyguardLock newKeyguardLock(java.lang.String);
+1 −0
Original line number Diff line number Diff line
@@ -4687,6 +4687,7 @@ package android.app {
    method public deprecated void exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult);
    method public boolean inKeyguardRestrictedInputMode();
    method public boolean isDeviceLocked();
    method public boolean isDeviceSecure();
    method public boolean isKeyguardLocked();
    method public boolean isKeyguardSecure();
    method public deprecated android.app.KeyguardManager.KeyguardLock newKeyguardLock(java.lang.String);
+26 −0
Original line number Diff line number Diff line
@@ -252,6 +252,32 @@ public class KeyguardManager {
        }
    }

    /**
     * Returns whether the device is secured with a PIN, pattern or
     * password.
     *
     * @return true if a PIN, pattern or password was set.
     */
    public boolean isDeviceSecure() {
        return isDeviceSecure(UserHandle.getCallingUserId());
    }

    /**
     * Returns whether the device is secured with a PIN, pattern or
     * password.
     *
     * @param userId the user for which the secure state should be reported.
     * @return true if a PIN, pattern or password was set.
     * @hide
     */
    public boolean isDeviceSecure(int userId) {
        try {
            return mTrustManager.isDeviceSecure(userId);
        } catch (RemoteException e) {
            return false;
        }
    }

    /**
     * @deprecated Use {@link android.view.WindowManager.LayoutParams#FLAG_DISMISS_KEYGUARD}
     * and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED}
+1 −0
Original line number Diff line number Diff line
@@ -31,4 +31,5 @@ interface ITrustManager {
    void unregisterTrustListener(in ITrustListener trustListener);
    void reportKeyguardShowingChanged();
    boolean isDeviceLocked(int userId);
    boolean isDeviceSecure(int userId);
}
+14 −0
Original line number Diff line number Diff line
@@ -691,6 +691,20 @@ public class TrustManagerService extends SystemService {
            return isDeviceLockedInner(userId);
        }

        @Override
        public boolean isDeviceSecure(int userId) throws RemoteException {
            userId = ActivityManager.handleIncomingUser(getCallingPid(), getCallingUid(), userId,
                    false /* allowAll */, true /* requireFull */, "isDeviceSecure", null);
            userId = resolveProfileParent(userId);

            long token = Binder.clearCallingIdentity();
            try {
                return new LockPatternUtils(mContext).isSecure(userId);
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        private void enforceReportPermission() {
            mContext.enforceCallingOrSelfPermission(
                    Manifest.permission.ACCESS_KEYGUARD_SECURE_STORAGE, "reporting trust events");