From c96b611d14090bc299d6af6b8b6436d154b92c4c Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Thu, 24 Feb 2022 15:36:06 +0000 Subject: KeyChain: always unbind service Context.unbindService() should always be called even if the previous bindService() call returns false. Otherwise the service might be left dangling. Bug: 211582968 Test: None Change-Id: Ic1705096254afa12993d8992303432896bfecd57 --- keystore/java/android/security/KeyChain.java | 1 + 1 file changed, 1 insertion(+) diff --git a/keystore/java/android/security/KeyChain.java b/keystore/java/android/security/KeyChain.java index 02cdeef77bec..4b367e0e5b4b 100644 --- a/keystore/java/android/security/KeyChain.java +++ b/keystore/java/android/security/KeyChain.java @@ -1117,6 +1117,7 @@ public final class KeyChain { intent, keyChainServiceConnection, Context.BIND_AUTO_CREATE, user); } if (!bindSucceed) { + context.unbindService(keyChainServiceConnection); throw new AssertionError("could not bind to KeyChainService"); } countDownLatch.await(); -- cgit v1.2.3-59-g8ed1b