Fix: CTS Verifier app crashes Fingerprint Bound keys Test
am: 3907a3eb84
Change-Id: I260c2a26ba8d0577a72fe28891250291a58cbf4d
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index f7ab4dc..b965644 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -2409,7 +2409,8 @@
</intent-filter>
</service>
- <activity android:name=".managedprovisioning.AuthenticationBoundKeyTestActivity">
+ <activity android:name=".managedprovisioning.AuthenticationBoundKeyTestActivity"
+ android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="com.android.cts.verifier.managedprovisioning.action.AUTH_BOUND_KEY_TEST" />
<category android:name="android.intent.category.DEFAULT" />
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/AuthenticationBoundKeyTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/AuthenticationBoundKeyTestActivity.java
index 7b6c696..f404d2f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/AuthenticationBoundKeyTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/AuthenticationBoundKeyTestActivity.java
@@ -6,6 +6,7 @@
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.KeyguardManager;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.hardware.fingerprint.FingerprintManager;
@@ -162,8 +163,8 @@
}
};
adapter.add(mLockScreenBoundKeyTest);
-
if (mFingerprintSupported) {
+ AuthenticationBoundKeyTestActivity that = this;
mFingerprintBoundKeyTest = new DialogTestListItem(this,
R.string.provisioning_byod_fingerprint_bound_key,
"BYOD_FingerprintBoundKeyTest") {
@@ -177,8 +178,10 @@
showToast("Test failed. Key accessible without auth.");
setTestResult(mFingerprintBoundKeyTest, TestResult.TEST_RESULT_FAILED);
} else {
- new FingerprintAuthDialogFragment().show(getFragmentManager(),
- "fingerprint_dialog");
+ FingerprintAuthDialogFragment fadf =
+ new FingerprintAuthDialogFragment();
+ fadf.setActivity(that);
+ fadf.show(getFragmentManager(),"fingerprint_dialog");
}
}
}
@@ -324,9 +327,11 @@
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
}
- public class FingerprintAuthDialogFragment extends DialogFragment {
+ static public class FingerprintAuthDialogFragment extends DialogFragment {
+ private AuthenticationBoundKeyTestActivity mActivity;
private CancellationSignal mCancellationSignal;
+ private FingerprintManager mFingerprintManager;
private FingerprintManagerCallback mFingerprintManagerCallback;
private boolean mSelfCancelled;
@@ -350,12 +355,14 @@
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
- if (tryEncryptWithFingerprintKey(mFingerprintCipher)) {
+ if (mActivity.tryEncryptWithFingerprintKey(mActivity.mFingerprintCipher)) {
showToast("Test passed.");
- setTestResult(mFingerprintBoundKeyTest, TestResult.TEST_RESULT_PASSED);
+ mActivity.setTestResult(mActivity.mFingerprintBoundKeyTest,
+ TestResult.TEST_RESULT_PASSED);
} else {
showToast("Test failed. Key not accessible after auth");
- setTestResult(mFingerprintBoundKeyTest, TestResult.TEST_RESULT_FAILED);
+ mActivity.setTestResult(mActivity.mFingerprintBoundKeyTest,
+ TestResult.TEST_RESULT_FAILED);
}
FingerprintAuthDialogFragment.this.dismiss();
}
@@ -367,12 +374,25 @@
mSelfCancelled = true;
}
+ private void setActivity(AuthenticationBoundKeyTestActivity activity) {
+ mActivity = activity;
+ }
+
+ private void showToast(String message) {
+ Toast.makeText(getContext(), message, Toast.LENGTH_LONG)
+ .show();
+ }
+
+
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mCancellationSignal = new CancellationSignal();
mSelfCancelled = false;
+ mFingerprintManager =
+ (FingerprintManager) getContext().getSystemService(Context.FINGERPRINT_SERVICE);
mFingerprintManagerCallback = new FingerprintManagerCallback();
- mFingerprintManager.authenticate(new FingerprintManager.CryptoObject(mFingerprintCipher),
+ mFingerprintManager.authenticate(
+ new FingerprintManager.CryptoObject(mActivity.mFingerprintCipher),
mCancellationSignal, 0, mFingerprintManagerCallback, null);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.sec_fp_dialog_message);