Merge "Merge "Merge "Fix fingerprint-bound key test in work profile" into nougat-cts-dev am: 4a9240df07" into nougat-mr1-cts-dev am: 95ec2b7644"
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 66aaa98..07fac7a 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1585,7 +1585,7 @@
     <string name="provisioning_byod_capture_media_error">Error while capturing media from managed profile.</string>
     <string name="provisioning_byod_capture_image_error">Error while capturing image from managed profile.</string>
 
-    <string name="provisioning_byod_auth_bound_key">Autentication-boud keys</string>
+    <string name="provisioning_byod_auth_bound_key">Authentication-bound keys</string>
     <string name="provisioning_byod_auth_bound_key_info">
         This test verifies keystore cryptographic keys can be bound to device credentials.
         These keys should only be available if there was a recent enough authentication.
@@ -1594,7 +1594,7 @@
         This test verifies keystore cryptographic keys can be bound to device lockscreen challenge or fingerprints (if available).
         These keys should only be available if there was a recent enough authentication. \n
 
-        1. Press "Set up" to open Security settings. Create a lockscreen password and if available, enroll a fingerprint.\n
+        1. Press "Set up" to open Security settings. Create a lockscreen password and if available, enroll a fingerprint under "Work profile security".\n
         2. Go through the list of tests.\n
         3. Mark the overall test pass or fail.\n
         4. Once the set of tests are completed, remove the lockscreen challenge.
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 073412d..7b6c696 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/AuthenticationBoundKeyTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/AuthenticationBoundKeyTestActivity.java
@@ -208,6 +208,8 @@
      */
     private void createKey(int testType) {
         try {
+            KeyStore keyStore = KeyStore.getInstance(KEYSTORE_NAME);
+            keyStore.load(null);
             // Set the alias of the entry in Android KeyStore where the key will appear
             // and the constrains (purposes) in the constructor of the Builder
             KeyGenParameterSpec.Builder builder;
@@ -226,7 +228,8 @@
             keyGenerator.init(builder.build());
             keyGenerator.generateKey();
         } catch (NoSuchAlgorithmException | NoSuchProviderException
-                | InvalidAlgorithmParameterException e) {
+                | InvalidAlgorithmParameterException | KeyStoreException
+                | CertificateException | IOException e) {
             throw new RuntimeException("Failed to create a symmetric key", e);
         }
     }