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

Commit 0f8d67ee authored by Rubin Xu's avatar Rubin Xu Committed by Automerger Merge Worker
Browse files

Merge "Set timeout for binding service to avoid thread blocking" into main am:...

Merge "Set timeout for binding service to avoid thread blocking" into main am: cce61395 am: 50c2d1c0

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3170019



Change-Id: I2b429bd7d572aca5a3a63d6df3424ca481ef1e24
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 8cbd1f48 50c2d1c0
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import javax.security.auth.x500.X500Principal;
@@ -376,6 +377,8 @@ public final class KeyChain {
     */
    public static final int KEY_ATTESTATION_FAILURE = 4;

    private static final int BIND_KEY_CHAIN_SERVICE_TIMEOUT_MS = 30 * 1000;

    /**
     * Used by DPC or delegated app in
     * {@link android.app.admin.DeviceAdminReceiver#onChoosePrivateKeyAlias} or
@@ -1120,7 +1123,10 @@ public final class KeyChain {
            context.unbindService(keyChainServiceConnection);
            throw new AssertionError("could not bind to KeyChainService");
        }
        countDownLatch.await();
        if (!countDownLatch.await(BIND_KEY_CHAIN_SERVICE_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
            context.unbindService(keyChainServiceConnection);
            throw new AssertionError("binding to KeyChainService timeout");
        }
        IKeyChainService service = keyChainService.get();
        if (service != null) {
            return new KeyChainConnection(context, keyChainServiceConnection, service);