Merge "Added more logging around failures in overview connecting to launcher" into pi-dev

This commit is contained in:
android-build-team Robot
2018-05-03 21:45:47 +00:00
committed by Android (Google) Code Review

View File

@@ -66,6 +66,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
public static final String TAG_OPS = "OverviewProxyService";
public static final boolean DEBUG_OVERVIEW_PROXY = false;
private static final long BACKOFF_MILLIS = 5000;
private static final long DEFERRED_CALLBACK_MILLIS = 5000;
private final Context mContext;
private final Handler mHandler;
@@ -162,6 +163,12 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
}
};
private final Runnable mDeferredConnectionCallback = () -> {
Log.w(TAG_OPS, "Binder supposed established connection but actual connection to service "
+ "timed out, trying again");
internalConnectToCurrentUser();
};
private final BroadcastReceiver mLauncherStateChangedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -181,22 +188,33 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
private final ServiceConnection mOverviewServiceConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
if (service != null) {
mConnectionBackoffAttempts = 0;
mOverviewProxy = IOverviewProxy.Stub.asInterface(service);
// Listen for launcher's death
try {
service.linkToDeath(mOverviewServiceDeathRcpt, 0);
} catch (RemoteException e) {
Log.e(TAG_OPS, "Lost connection to launcher service", e);
}
try {
mOverviewProxy.onBind(mSysUiProxy);
} catch (RemoteException e) {
Log.e(TAG_OPS, "Failed to call onBind()", e);
}
notifyConnectionChanged();
mHandler.removeCallbacks(mDeferredConnectionCallback);
mConnectionBackoffAttempts = 0;
mOverviewProxy = IOverviewProxy.Stub.asInterface(service);
// Listen for launcher's death
try {
service.linkToDeath(mOverviewServiceDeathRcpt, 0);
} catch (RemoteException e) {
Log.e(TAG_OPS, "Lost connection to launcher service", e);
}
try {
mOverviewProxy.onBind(mSysUiProxy);
} catch (RemoteException e) {
Log.e(TAG_OPS, "Failed to call onBind()", e);
}
notifyConnectionChanged();
}
@Override
public void onNullBinding(ComponentName name) {
Log.w(TAG_OPS, "Null binding of '" + name + "', try reconnecting");
internalConnectToCurrentUser();
}
@Override
public void onBindingDied(ComponentName name) {
Log.w(TAG_OPS, "Binding died of '" + name + "', try reconnecting");
internalConnectToCurrentUser();
}
@Override
@@ -262,6 +280,9 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
// If user has not setup yet or already connected, do not try to connect
if (!mDeviceProvisionedController.isCurrentUserSetup() || !isEnabled()) {
Log.v(TAG_OPS, "Cannot attempt connection, is setup "
+ mDeviceProvisionedController.isCurrentUserSetup() + ", is enabled "
+ isEnabled());
return;
}
mHandler.removeCallbacks(mConnectionRunnable);
@@ -275,11 +296,16 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
} catch (SecurityException e) {
Log.e(TAG_OPS, "Unable to bind because of security error", e);
}
if (!bound) {
if (bound) {
// Ensure that connection has been established even if it thinks it is bound
mHandler.postDelayed(mDeferredConnectionCallback, DEFERRED_CALLBACK_MILLIS);
} else {
// Retry after exponential backoff timeout
final long timeoutMs = (long) Math.scalb(BACKOFF_MILLIS, mConnectionBackoffAttempts);
mHandler.postDelayed(mConnectionRunnable, timeoutMs);
mConnectionBackoffAttempts++;
Log.w(TAG_OPS, "Failed to connect on attempt " + mConnectionBackoffAttempts
+ " will try again in " + timeoutMs + "ms");
}
}
@@ -351,6 +377,10 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
pw.print(" isCurrentUserSetup="); pw.println(mDeviceProvisionedController
.isCurrentUserSetup());
pw.print(" isConnected="); pw.println(mOverviewProxy != null);
pw.print(" mRecentsComponentName="); pw.println(mRecentsComponentName);
pw.print(" mIsEnabled="); pw.println(isEnabled());
pw.print(" mInteractionFlags="); pw.println(mInteractionFlags);
pw.print(" mQuickStepIntent="); pw.println(mQuickStepIntent);
}
public interface OverviewProxyListener {