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

Commit 33c9dde9 authored by Alex Klyubin's avatar Alex Klyubin Committed by Android (Google) Code Review
Browse files

Merge "Add KeyPermanentlyInvalidatedException." into mnc-dev

parents 490d23bf 708fc940
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -28616,6 +28616,12 @@ package android.security {
    method public android.security.KeyPairGeneratorSpec.Builder setUserAuthenticationValidityDurationSeconds(int);
  }
  public class KeyPermanentlyInvalidatedException extends java.security.InvalidKeyException {
    ctor public KeyPermanentlyInvalidatedException();
    ctor public KeyPermanentlyInvalidatedException(java.lang.String);
    ctor public KeyPermanentlyInvalidatedException(java.lang.String, java.lang.Throwable);
  }
  public abstract class KeyStoreKeyProperties {
  }
@@ -28696,11 +28702,6 @@ package android.security {
    method public boolean isCleartextTrafficPermitted();
  }
  public class NewFingerprintEnrolledException extends java.security.InvalidKeyException {
    ctor public NewFingerprintEnrolledException();
    ctor public NewFingerprintEnrolledException(java.lang.String);
  }
  public class UserNotAuthenticatedException extends java.security.InvalidKeyException {
    ctor public UserNotAuthenticatedException();
    ctor public UserNotAuthenticatedException(java.lang.String);
+6 −5
Original line number Diff line number Diff line
@@ -30629,6 +30629,12 @@ package android.security {
    method public android.security.KeyPairGeneratorSpec.Builder setUserAuthenticationValidityDurationSeconds(int);
  }
  public class KeyPermanentlyInvalidatedException extends java.security.InvalidKeyException {
    ctor public KeyPermanentlyInvalidatedException();
    ctor public KeyPermanentlyInvalidatedException(java.lang.String);
    ctor public KeyPermanentlyInvalidatedException(java.lang.String, java.lang.Throwable);
  }
  public abstract class KeyStoreKeyProperties {
  }
@@ -30709,11 +30715,6 @@ package android.security {
    method public boolean isCleartextTrafficPermitted();
  }
  public class NewFingerprintEnrolledException extends java.security.InvalidKeyException {
    ctor public NewFingerprintEnrolledException();
    ctor public NewFingerprintEnrolledException(java.lang.String);
  }
  public class UserNotAuthenticatedException extends java.security.InvalidKeyException {
    ctor public UserNotAuthenticatedException();
    ctor public UserNotAuthenticatedException(java.lang.String);
+22 −0
Original line number Diff line number Diff line
@@ -87,6 +87,28 @@ public class KeyCharacteristics implements Parcelable {
        return result;
    }

    public Long getLong(int tag) {
        if (hwEnforced.containsTag(tag)) {
            return hwEnforced.getLong(tag, -1);
        } else if (swEnforced.containsTag(tag)) {
            return swEnforced.getLong(tag, -1);
        } else {
            return null;
        }
    }

    public long getLong(int tag, long defaultValue) {
        Long result = getLong(tag);
        return (result != null) ? result : defaultValue;
    }

    public List<Long> getLongs(int tag) {
        List<Long> result = new ArrayList<Long>();
        result.addAll(hwEnforced.getLongs(tag));
        result.addAll(swEnforced.getLongs(tag));
        return result;
    }

    public Date getDate(int tag) {
        Date result = hwEnforced.getDate(tag, null);
        if (result == null) {
+6 −2
Original line number Diff line number Diff line
@@ -15,13 +15,17 @@ public abstract class GateKeeper {
    private GateKeeper() {}

    public static IGateKeeperService getService() {
        return IGateKeeperService.Stub.asInterface(
        IGateKeeperService service = IGateKeeperService.Stub.asInterface(
                ServiceManager.getService("android.service.gatekeeper.IGateKeeperService"));
        if (service == null) {
            throw new IllegalStateException("Gatekeeper service not available");
        }
        return service;
    }

    public static long getSecureUserId() throws IllegalStateException {
        try {
            return GateKeeper.getService().getSecureUserId(UserHandle.myUserId());
            return getService().getSecureUserId(UserHandle.myUserId());
        } catch (RemoteException e) {
            throw new IllegalStateException(
                    "Failed to obtain secure user ID from gatekeeper", e);
+55 −0
Original line number Diff line number Diff line
@@ -19,23 +19,37 @@ package android.security;
import java.security.InvalidKeyException;

/**
 * Indicates that a cryptographic operation could not be performed because the key used by the
 * operation is permanently invalid because a new fingerprint was enrolled.
 * Indicates that the key can no longer be used because it has been permanently invalidated.
 *
 * <p>This can currently occur only for keys that require user authentication. Such keys are
 * permanently invalidated once the secure lock screen is disabled (i.e., reconfigured to None,
 * Swipe or other mode which does not authenticate the user) or when the secure lock screen is
 * forcibly reset (e.g., by Device Admin). Additionally, keys configured to require user
 * authentication for every use of the key are also permanently invalidated once a new fingerprint
 * is enrolled or once no more fingerprints are enrolled.
 */
public class NewFingerprintEnrolledException extends InvalidKeyException {
public class KeyPermanentlyInvalidatedException extends InvalidKeyException {

    /**
     * Constructs a new {@code NewFingerprintEnrolledException} without detail message and cause.
     * Constructs a new {@code KeyPermanentlyInvalidatedException} without detail message and cause.
     */
    public NewFingerprintEnrolledException() {
        super("Invalid key: new fingerprint enrolled");
    public KeyPermanentlyInvalidatedException() {
        super("Key permanently invalidated");
    }

    /**
     * Constructs a new {@code NewFingerprintEnrolledException} with the provided detail message and
     * no cause.
     * Constructs a new {@code KeyPermanentlyInvalidatedException} with the provided detail message
     * and no cause.
     */
    public NewFingerprintEnrolledException(String message) {
    public KeyPermanentlyInvalidatedException(String message) {
        super(message);
    }

    /**
     * Constructs a new {@code KeyPermanentlyInvalidatedException} with the provided detail message
     * and cause.
     */
    public KeyPermanentlyInvalidatedException(String message, Throwable cause) {
        super(message, cause);
    }
}
Loading