Log metric when generateKeyPair throws exception

Bug: 181758899
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
      atest android.devicepolicy.cts.CredentialManagementAppTest
Change-Id: Ib6f73ed1fcb1d7364281b5bd13523eafec30c729
This commit is contained in:
Alex Johnston
2021-03-08 15:24:47 +00:00
parent 02abb5b924
commit d104aeefb2

View File

@@ -5684,6 +5684,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
if (generationResult != KeyChain.KEY_GEN_SUCCESS) {
Log.e(LOG_TAG, String.format(
"KeyChain failed to generate a keypair, error %d.", generationResult));
logGenerateKeyPairFailure(caller, isCredentialManagementApp);
switch (generationResult) {
case KeyChain.KEY_GEN_STRONGBOX_UNAVAILABLE:
throw new ServiceSpecificException(
@@ -5693,7 +5694,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
throw new UnsupportedOperationException(
"Device does not support Device ID attestation.");
default:
logGenerateKeyPairFailure(caller, isCredentialManagementApp);
return false;
}
}