From 91aa2dd5079780464d2a3c8d1c8e2bf4e128732f Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Fri, 31 Jan 2020 11:37:51 -0500 Subject: Make IdentityCredentialStore.getInstance() return null if credstore is not installed. Having this method return null is the expected and documented behavior when either the IC HAL or credstore isn't available. Test: atest android.security.identity.cts (with credstore not running) Bug: 148495024 Change-Id: Ifa17c58a84057499b1aeb8404959d5c0badfe52a --- .../android/security/identity/CredstoreIdentityCredentialStore.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'identity/java/android') diff --git a/identity/java/android/security/identity/CredstoreIdentityCredentialStore.java b/identity/java/android/security/identity/CredstoreIdentityCredentialStore.java index dcc6b95aec02..129063361b35 100644 --- a/identity/java/android/security/identity/CredstoreIdentityCredentialStore.java +++ b/identity/java/android/security/identity/CredstoreIdentityCredentialStore.java @@ -38,6 +38,10 @@ class CredstoreIdentityCredentialStore extends IdentityCredentialStore { ICredentialStoreFactory storeFactory = ICredentialStoreFactory.Stub.asInterface( ServiceManager.getService("android.security.identity")); + if (storeFactory == null) { + // This can happen if credstore is not running or not installed. + return null; + } ICredentialStore credStore = null; try { -- cgit v1.2.3-59-g8ed1b