summaryrefslogtreecommitdiff
path: root/keystore/java/android/security/KeyChain.java
diff options
context:
space:
mode:
authorRobin Lee <rgl@google.com>2016-02-29 18:55:35 +0000
committerRobin Lee <rgl@google.com>2016-03-03 18:57:32 +0000
commit21bcbc54dd6b1f029f4973bef27c20e55d057432 (patch)
treec72ebd2bd73bd8f895604d010e4f3ddd254bd4d6 /keystore/java/android/security/KeyChain.java
parent42d8b7d7abe4ecab049e020c3836dae97660dd4d (diff)
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
Diffstat (limited to 'keystore/java/android/security/KeyChain.java')
-rw-r--r--keystore/java/android/security/KeyChain.java7
1 files changed, 2 insertions, 5 deletions
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());