Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21bcbc54 authored by Robin Lee's avatar Robin Lee
Browse files

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
parent 42d8b7d7
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -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());