KeyChain: return null instead of throw

The API documentation says it will return null if the key isn't found.
We get null back from the keystore daemon when it can't retrieve the
data, so just return null back to the API caller.

Change-Id: I42248bd50cbc5f76864bd762aae3faab1c50529d
This commit is contained in:
Kenny Root
2013-02-13 15:22:50 -08:00
parent c5748148c5
commit 0150e48200

View File

@ -336,7 +336,12 @@ public final class KeyChain {
KeyChainConnection keyChainConnection = bind(context);
try {
IKeyChainService keyChainService = keyChainConnection.getService();
byte[] certificateBytes = keyChainService.getCertificate(alias);
final byte[] certificateBytes = keyChainService.getCertificate(alias);
if (certificateBytes == null) {
return null;
}
TrustedCertificateStore store = new TrustedCertificateStore();
List<X509Certificate> chain = store
.getCertificateChain(toCertificate(certificateBytes));