summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorKevin Chyn <kchyn@google.com>2019-02-09 00:37:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-02-09 00:37:44 +0000
commiteb8c06d65d9fa5f55c383e09e246c6c839a1526e (patch)
treef7720fda9e324ee45f2bb1566ca0876bd7960e3f /core/java
parent2fb540e01f5a88c33ea9edbf3accd0eb78349b5f (diff)
parent45d1f9d311dec6dc0f5e748e8b7bfb704caf4e28 (diff)
Merge "Rename setEnableFallback to setAllowDeviceCredential"
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/KeyguardManager.java2
-rw-r--r--core/java/android/hardware/biometrics/BiometricConstants.java8
-rw-r--r--core/java/android/hardware/biometrics/BiometricFaceConstants.java8
-rw-r--r--core/java/android/hardware/biometrics/BiometricFingerprintConstants.java9
-rw-r--r--core/java/android/hardware/biometrics/BiometricPrompt.java23
-rw-r--r--core/java/android/hardware/biometrics/IBiometricService.aidl2
6 files changed, 41 insertions, 11 deletions
diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java
index f522d71afd08..17f645dfbf23 100644
--- a/core/java/android/app/KeyguardManager.java
+++ b/core/java/android/app/KeyguardManager.java
@@ -125,7 +125,7 @@ public class KeyguardManager {
public static final int RESULT_ALTERNATE = 1;
/**
- * @deprecated see {@link BiometricPrompt.Builder#setEnableFallback(boolean)}
+ * @deprecated see {@link BiometricPrompt.Builder#setAllowDeviceCredential(boolean)}
*
* Get an intent to prompt the user to confirm credentials (pin, pattern, password or biometrics
* if enrolled) for the current user of the device. The caller is expected to launch this
diff --git a/core/java/android/hardware/biometrics/BiometricConstants.java b/core/java/android/hardware/biometrics/BiometricConstants.java
index c814b7c67817..1cb7eb0d1256 100644
--- a/core/java/android/hardware/biometrics/BiometricConstants.java
+++ b/core/java/android/hardware/biometrics/BiometricConstants.java
@@ -17,6 +17,7 @@
package android.hardware.biometrics;
import android.annotation.UnsupportedAppUsage;
+import android.app.KeyguardManager;
/**
@@ -126,6 +127,13 @@ public interface BiometricConstants {
int BIOMETRIC_ERROR_NEGATIVE_BUTTON = 13;
/**
+ * The device does not have pin, pattern, or password set up. See
+ * {@link BiometricPrompt.Builder#setAllowDeviceCredential(boolean)} and
+ * {@link KeyguardManager#isDeviceSecure()}
+ */
+ int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;
+
+ /**
* @hide
*/
@UnsupportedAppUsage
diff --git a/core/java/android/hardware/biometrics/BiometricFaceConstants.java b/core/java/android/hardware/biometrics/BiometricFaceConstants.java
index b708ef12b210..459ec62d4135 100644
--- a/core/java/android/hardware/biometrics/BiometricFaceConstants.java
+++ b/core/java/android/hardware/biometrics/BiometricFaceConstants.java
@@ -16,6 +16,7 @@
package android.hardware.biometrics;
+import android.app.KeyguardManager;
import android.hardware.face.FaceManager;
/**
@@ -134,6 +135,13 @@ public interface BiometricFaceConstants {
public static final int FACE_ERROR_NEGATIVE_BUTTON = 13;
/**
+ * The device does not have pin, pattern, or password set up. See
+ * {@link BiometricPrompt.Builder#setAllowDeviceCredential(boolean)} and
+ * {@link KeyguardManager#isDeviceSecure()}
+ */
+ public static final int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;
+
+ /**
* @hide
*/
public static final int FACE_ERROR_VENDOR_BASE = 1000;
diff --git a/core/java/android/hardware/biometrics/BiometricFingerprintConstants.java b/core/java/android/hardware/biometrics/BiometricFingerprintConstants.java
index 041b2e673b96..6cbab471ce23 100644
--- a/core/java/android/hardware/biometrics/BiometricFingerprintConstants.java
+++ b/core/java/android/hardware/biometrics/BiometricFingerprintConstants.java
@@ -17,6 +17,7 @@
package android.hardware.biometrics;
import android.annotation.UnsupportedAppUsage;
+import android.app.KeyguardManager;
import android.hardware.fingerprint.FingerprintManager;
/**
@@ -119,6 +120,14 @@ public interface BiometricFingerprintConstants {
public static final int FINGERPRINT_ERROR_NEGATIVE_BUTTON = 13;
/**
+ * The device does not have pin, pattern, or password set up. See
+ * {@link BiometricPrompt.Builder#setAllowDeviceCredential(boolean)} and
+ * {@link KeyguardManager#isDeviceSecure()}
+ * @hide
+ */
+ public static final int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14;
+
+ /**
* @hide
*/
@UnsupportedAppUsage
diff --git a/core/java/android/hardware/biometrics/BiometricPrompt.java b/core/java/android/hardware/biometrics/BiometricPrompt.java
index d569a7800c37..baf972b26573 100644
--- a/core/java/android/hardware/biometrics/BiometricPrompt.java
+++ b/core/java/android/hardware/biometrics/BiometricPrompt.java
@@ -23,6 +23,7 @@ import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
+import android.app.KeyguardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Binder;
@@ -80,7 +81,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
/**
* @hide
*/
- public static final String KEY_ENABLE_FALLBACK = "enable_fallback";
+ public static final String KEY_ALLOW_DEVICE_CREDENTIAL = "allow_device_credential";
/**
* Error/help message will show for this amount of time.
@@ -203,7 +204,8 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
* "Cancel" button, but may be also used to show an alternative method for authentication,
* such as screen that asks for a backup password.
*
- * Note that this should not be set if {@link #setEnableFallback(boolean)} is set to true.
+ * Note that this should not be set if {@link #setAllowDeviceCredential(boolean)
+ * is set to true.
*
* @param text
* @return
@@ -250,7 +252,10 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
/**
* The user will first be prompted to authenticate with biometrics, but also given the
- * option to authenticate with their device PIN, pattern, or password.
+ * option to authenticate with their device PIN, pattern, or password. Developers should
+ * first check {@link KeyguardManager#isDeviceSecure()} before enabling this. If the device
+ * is not secure, {@link BiometricPrompt#BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL} will be
+ * returned in {@link AuthenticationCallback#onAuthenticationError(int, CharSequence)}}
*
* Note that {@link #setNegativeButton(CharSequence, Executor,
* DialogInterface.OnClickListener)} should not be set if this is set to true.
@@ -259,8 +264,8 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
* credentials (PIN, pattern, or password).
* @return
*/
- public Builder setEnableFallback(boolean enable) {
- mBundle.putBoolean(KEY_ENABLE_FALLBACK, enable);
+ public Builder setAllowDeviceCredential(boolean enable) {
+ mBundle.putBoolean(KEY_ALLOW_DEVICE_CREDENTIAL, enable);
return this;
}
@@ -273,7 +278,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
final CharSequence title = mBundle.getCharSequence(KEY_TITLE);
final CharSequence negative = mBundle.getCharSequence(KEY_NEGATIVE_TEXT);
final boolean useDefaultTitle = mBundle.getBoolean(KEY_USE_DEFAULT_TITLE);
- final boolean enableFallback = mBundle.getBoolean(KEY_ENABLE_FALLBACK);
+ final boolean enableFallback = mBundle.getBoolean(KEY_ALLOW_DEVICE_CREDENTIAL);
if (TextUtils.isEmpty(title) && !useDefaultTitle) {
throw new IllegalArgumentException("Title must be set and non-empty");
@@ -281,7 +286,7 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
throw new IllegalArgumentException("Negative text must be set and non-empty");
} else if (!TextUtils.isEmpty(negative) && enableFallback) {
throw new IllegalArgumentException("Can't have both negative button behavior"
- + " and fallback enabled");
+ + " and device credential enabled");
}
return new BiometricPrompt(mContext, mBundle, mPositiveButtonInfo, mNegativeButtonInfo);
}
@@ -541,8 +546,8 @@ public class BiometricPrompt implements BiometricAuthenticator, BiometricConstan
if (callback == null) {
throw new IllegalArgumentException("Must supply a callback");
}
- if (mBundle.getBoolean(KEY_ENABLE_FALLBACK)) {
- throw new IllegalArgumentException("Fallback not supported with crypto");
+ if (mBundle.getBoolean(KEY_ALLOW_DEVICE_CREDENTIAL)) {
+ throw new IllegalArgumentException("Device credential not supported with crypto");
}
authenticateInternal(crypto, cancel, executor, callback, mContext.getUserId());
}
diff --git a/core/java/android/hardware/biometrics/IBiometricService.aidl b/core/java/android/hardware/biometrics/IBiometricService.aidl
index e4336d171ab6..a20e2bf3d067 100644
--- a/core/java/android/hardware/biometrics/IBiometricService.aidl
+++ b/core/java/android/hardware/biometrics/IBiometricService.aidl
@@ -54,7 +54,7 @@ interface IBiometricService {
// TODO(b/123378871): Remove when moved.
// CDCA needs to send results to BiometricService if it was invoked using BiometricPrompt's
- // setEnableFallback method, since there's no way for us to intercept onActivityResult.
+ // setAllowDeviceCredential method, since there's no way for us to intercept onActivityResult.
// CDCA is launched from BiometricService (startActivityAsUser) instead of *ForResult.
void onConfirmDeviceCredentialSuccess();
// TODO(b/123378871): Remove when moved.