From 21bcbc54dd6b1f029f4973bef27c20e55d057432 Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Mon, 29 Feb 2016 18:55:35 +0000 Subject: Guard against null component when binding KeyChain If keychain is removed from a device, there will be no sensible resolution and client apps will bind to whatever is available. Doesn't affect system apps which are forcibly prevented from wildcard binding. Bug: 27475655 Change-Id: Ide1aab3778e12f0b9a96662deb297a76d2f4997f --- keystore/java/android/security/KeyChain.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'keystore/java/android/security/KeyChain.java') diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java index 7adad8a4b86e..0886487f70cf 100644 --- a/keystore/java/android/security/KeyChain.java +++ b/keystore/java/android/security/KeyChain.java @@ -547,11 +547,8 @@ public final class KeyChain { Intent intent = new Intent(IKeyChainService.class.getName()); ComponentName comp = intent.resolveSystemService(context.getPackageManager(), 0); intent.setComponent(comp); - boolean isBound = context.bindServiceAsUser(intent, - keyChainServiceConnection, - Context.BIND_AUTO_CREATE, - user); - if (!isBound) { + if (comp == null || !context.bindServiceAsUser( + intent, keyChainServiceConnection, Context.BIND_AUTO_CREATE, user)) { throw new AssertionError("could not bind to KeyChainService"); } return new KeyChainConnection(context, keyChainServiceConnection, q.take()); -- cgit v1.2.3