Fix: CTS Verifier app crashes Fingerprint Bound keys Test

The CTS Verifier app crashes due to using a non static
member class as fragment. It is impossible to recover the
state of the fragment upon configuration change. This was
never a problem for the Fingerprint Bound Keys Test because
it handles configuration changes and is not recreated.
However, as of SDK version N_MR1 a check was introduced
that checks the condition before it leads to problems
causing this crash.

This patch makes the FingerprintAuthDialogFragment a static
member class to fix the issue.

Bug: 63066872
Test: Install and run CtsVerifier then perform the
      "Fingerprint Bound Keys Test"

Change-Id: I530978b8bb9790ae404c342317284c4766082bbd
(cherry picked from commit b15813d813c95c87e04956badf81d3b02de60d15)
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java b/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java
index eb0fc59..764ecb3 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/security/FingerprintBoundKeysTest.java
@@ -219,6 +219,7 @@
 
     private void showAuthenticationScreen() {
         mFingerprintDialog = new FingerprintAuthDialogFragment();
+        mFingerprintDialog.setActivity(this);
         mFingerprintDialog.show(getFragmentManager(), "fingerprint_dialog");
     }
 
@@ -227,9 +228,11 @@
             .show();
     }
 
-    public class FingerprintAuthDialogFragment extends DialogFragment {
+    public static class FingerprintAuthDialogFragment extends DialogFragment {
 
+        private FingerprintBoundKeysTest mActivity;
         private CancellationSignal mCancellationSignal;
+        private FingerprintManager mFingerprintManager;
         private FingerprintManagerCallback mFingerprintManagerCallback;
         private boolean mSelfCancelled;
 
@@ -262,9 +265,9 @@
                 if (DEBUG) {
                     Log.i(TAG,"onAuthenticationSucceeded");
                 }
-                if (tryEncrypt()) {
+                if (mActivity.tryEncrypt()) {
                     showToast("Test passed.");
-                    getPassButton().setEnabled(true);
+                    mActivity.getPassButton().setEnabled(true);
                     FingerprintAuthDialogFragment.this.dismiss();
                 } else {
                     showToast("Test failed. Key not accessible after auth");
@@ -278,12 +281,24 @@
             mSelfCancelled = true;
         }
 
+        private void setActivity(FingerprintBoundKeysTest 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(mCipher),
+            mFingerprintManager.authenticate(
+                    new FingerprintManager.CryptoObject(mActivity.mCipher),
                     mCancellationSignal, 0, mFingerprintManagerCallback, null);
             AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
             builder.setMessage(R.string.sec_fp_dialog_message);