summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrerna Kalla <quic_prernak@quicinc.com>2023-02-20 13:36:05 +0530
committerPrerna Kalla <quic_prernak@quicinc.com>2023-03-13 15:38:12 +0530
commit7874fe020ef4d320ce52ec7f168a3f80c0bb148a (patch)
treefe3ebdceff8ce81dff669cc8f47b2c76f35816ff
parent9c2cfd90483797fef5b2396b65c96948038568d9 (diff)
Add 100ms delay in GenerateRkp service
The communication between GenerateRkpKey and GenerateRkpKeyService is not established while running "TestFallback" RemoteProvisioner test. The GenerateRkpKeyService is not up when GenerateRkpKey is trying to call it via bindAndSendCommand API. A delay of 100ms is added to give some time for the service to start. Tests: RemoteProvisioner Unit tests passed. CRs-Fixed: 3372309 Change-Id: I306a05ce672f48a20795cf33c3db07a4b8d74cbe
-rw-r--r--keystore/java/android/security/GenerateRkpKey.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/keystore/java/android/security/GenerateRkpKey.java b/keystore/java/android/security/GenerateRkpKey.java
index 2e54e63a5b7a..833e4f7d4efe 100644
--- a/keystore/java/android/security/GenerateRkpKey.java
+++ b/keystore/java/android/security/GenerateRkpKey.java
@@ -52,6 +52,7 @@ public class GenerateRkpKey {
private static final int NOTIFY_EMPTY = 0;
private static final int NOTIFY_KEY_GENERATED = 1;
private static final int TIMEOUT_MS = 1000;
+ private static final int DELAY_MS = 100;
private IGenerateRkpKeyService mBinder;
private Context mContext;
@@ -82,14 +83,20 @@ public class GenerateRkpKey {
}
private void bindAndSendCommand(int command, int securityLevel) throws RemoteException {
+ mCountDownLatch = new CountDownLatch(1);
Intent intent = new Intent(IGenerateRkpKeyService.class.getName());
+ try {
+ //Add 100ms delay to allow GenerateKeyService to come up
+ mCountDownLatch.await(DELAY_MS, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException e) {
+ Log.e(TAG, "Interrupted: ", e);
+ }
ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0);
if (comp == null) {
// On a system that does not use RKP, the RemoteProvisioner app won't be installed.
return;
}
intent.setComponent(comp);
- mCountDownLatch = new CountDownLatch(1);
Executor executor = Executors.newCachedThreadPool();
if (!mContext.bindService(intent, Context.BIND_AUTO_CREATE, executor, mConnection)) {
throw new RemoteException("Failed to bind to GenerateRkpKeyService");