package com.android.server.pm;
+import android.annotation.AnyThread;
+import android.annotation.WorkerThread;
import android.app.IInstantAppResolver;
import android.app.InstantAppResolverService;
import android.content.ComponentName;
import android.util.TimedRemoteCaller;
import com.android.internal.annotations.GuardedBy;
+import com.android.internal.os.BackgroundThread;
import java.util.ArrayList;
import java.util.List;
private static final int STATE_IDLE = 0; // no bind operation is ongoing
private static final int STATE_BINDING = 1; // someone is binding and waiting
private static final int STATE_PENDING = 2; // a bind is pending, but the caller is not waiting
+ private final Handler mBgHandler;
@GuardedBy("mLock")
private int mBindState = STATE_IDLE;
Context context, ComponentName componentName, String action) {
mContext = context;
mIntent = new Intent(action).setComponent(componentName);
+ mBgHandler = BackgroundThread.getHandler();
}
public final List<InstantAppResolveInfo> getInstantAppResolveInfoList(Intent sanitizedIntent,
}
}
+ @WorkerThread
private IInstantAppResolver getRemoteInstanceLazy(String token)
throws ConnectionException, TimeoutException, InterruptedException {
long binderToken = Binder.clearCallingIdentity();
}
}
+ @WorkerThread
private IInstantAppResolver bind(String token)
throws ConnectionException, TimeoutException, InterruptedException {
boolean doUnbind = false;
}
}
+ @AnyThread
+ void optimisticBind() {
+ mBgHandler.post(() -> {
+ try {
+ if (bind("Optimistic Bind") != null && DEBUG_INSTANT) {
+ Slog.i(TAG, "Optimistic bind succeeded.");
+ }
+ } catch (ConnectionException | TimeoutException | InterruptedException e) {
+ Slog.e(TAG, "Optimistic bind failed.", e);
+ }
+ });
+ }
+
@Override
public void binderDied() {
if (DEBUG_INSTANT) {
synchronized (mLock) {
handleBinderDiedLocked();
}
+ optimisticBind();
}
@GuardedBy("mLock")
reconcileApps(StorageManager.UUID_PRIVATE_INTERNAL);
mPermissionManager.systemReady();
+
+ if (mInstantAppResolverConnection != null) {
+ mContext.registerReceiver(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ mInstantAppResolverConnection.optimisticBind();
+ mContext.unregisterReceiver(this);
+ }
+ }, new IntentFilter(Intent.ACTION_BOOT_COMPLETED));
+ }
}
public void waitForAppDataPrepared() {