rebind if the connection drops

Change-Id: I9d91e9080b99690ff1e50dc28b01df0dcda4e97a
Fixes: 36566927
Test: Manual; stop gms:persistent process using "kill -9"
Test: Manual; stop process using "adb shell am force-stop com.google.android.gms"
Test: Manual; stop process using "adb install -r PrebuiltGmsCore.apk"
This commit is contained in:
Todd Kennedy
2017-04-03 12:03:35 -07:00
parent 2ac9698271
commit 16c3a3e7e8

View File

@@ -27,6 +27,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.IBinder.DeathRecipient;
import android.os.IRemoteCallback;
import android.os.RemoteException;
import android.os.SystemClock;
@@ -47,7 +48,7 @@ import java.util.concurrent.TimeoutException;
* service and handling all interactions in a timely manner.
* @hide
*/
final class EphemeralResolverConnection {
final class EphemeralResolverConnection implements DeathRecipient {
// This is running in a critical section and the timeout must be sufficiently low
private static final long BIND_SERVICE_TIMEOUT_MS =
("eng".equals(Build.TYPE)) ? 300 : 200;
@@ -171,6 +172,15 @@ final class EphemeralResolverConnection {
}
}
@Override
public void binderDied() {
if (mRemoteInstance != null) {
mRemoteInstance.asBinder().unlinkToDeath(this, 0 /*flags*/);
}
mRemoteInstance = null;
mBindRequested = false;
}
/**
* Asynchronous callback when results come back from ephemeral resolution phase two.
*/
@@ -183,7 +193,11 @@ final class EphemeralResolverConnection {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
synchronized (mLock) {
mRemoteInstance = IInstantAppResolver.Stub.asInterface(service);
try {
service.linkToDeath(EphemeralResolverConnection.this, 0 /*flags*/);
mRemoteInstance = IInstantAppResolver.Stub.asInterface(service);
} catch (RemoteException e) {
}
mLock.notifyAll();
}
}