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

Commit 82893681 authored by Adrian Roos's avatar Adrian Roos
Browse files

Add KeyguardManager.isDeviceSecure

Bug: 19823211
Change-Id: I92a1d2542274bf1dc2d5757511ce495264f90733
parent 855fa30b
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -4596,6 +4596,7 @@ package android.app {
    method public deprecated void exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult);
    method public deprecated void exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult);
    method public boolean inKeyguardRestrictedInputMode();
    method public boolean inKeyguardRestrictedInputMode();
    method public boolean isDeviceLocked();
    method public boolean isDeviceLocked();
    method public boolean isDeviceSecure();
    method public boolean isKeyguardLocked();
    method public boolean isKeyguardLocked();
    method public boolean isKeyguardSecure();
    method public boolean isKeyguardSecure();
    method public deprecated android.app.KeyguardManager.KeyguardLock newKeyguardLock(java.lang.String);
    method public deprecated android.app.KeyguardManager.KeyguardLock newKeyguardLock(java.lang.String);
+1 −0
Original line number Original line Diff line number Diff line
@@ -4687,6 +4687,7 @@ package android.app {
    method public deprecated void exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult);
    method public deprecated void exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult);
    method public boolean inKeyguardRestrictedInputMode();
    method public boolean inKeyguardRestrictedInputMode();
    method public boolean isDeviceLocked();
    method public boolean isDeviceLocked();
    method public boolean isDeviceSecure();
    method public boolean isKeyguardLocked();
    method public boolean isKeyguardLocked();
    method public boolean isKeyguardSecure();
    method public boolean isKeyguardSecure();
    method public deprecated android.app.KeyguardManager.KeyguardLock newKeyguardLock(java.lang.String);
    method public deprecated android.app.KeyguardManager.KeyguardLock newKeyguardLock(java.lang.String);
+26 −0
Original line number Original line 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}
     * @deprecated Use {@link android.view.WindowManager.LayoutParams#FLAG_DISMISS_KEYGUARD}
     * and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED}
     * and/or {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WHEN_LOCKED}
+1 −0
Original line number Original line Diff line number Diff line
@@ -31,4 +31,5 @@ interface ITrustManager {
    void unregisterTrustListener(in ITrustListener trustListener);
    void unregisterTrustListener(in ITrustListener trustListener);
    void reportKeyguardShowingChanged();
    void reportKeyguardShowingChanged();
    boolean isDeviceLocked(int userId);
    boolean isDeviceLocked(int userId);
    boolean isDeviceSecure(int userId);
}
}
+14 −0
Original line number Original line Diff line number Diff line
@@ -691,6 +691,20 @@ public class TrustManagerService extends SystemService {
            return isDeviceLockedInner(userId);
            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() {
        private void enforceReportPermission() {
            mContext.enforceCallingOrSelfPermission(
            mContext.enforceCallingOrSelfPermission(
                    Manifest.permission.ACCESS_KEYGUARD_SECURE_STORAGE, "reporting trust events");
                    Manifest.permission.ACCESS_KEYGUARD_SECURE_STORAGE, "reporting trust events");