Only bind to RESOLVE_EPHEMERAL_PACKAGE once.

We never unbind, so we only ever need one bind request; creating more
bind requests just wastes resources.

Test: builds
Bug: 32446301
Change-Id: I7d6c4a93b8f5bb8d9aed7a5041b193e19a2d65fc
This commit is contained in:
Jeff Sharkey
2016-10-26 16:58:49 -06:00
committed by Jeff Sharkey
parent e9db00e39f
commit 7765d7320d

View File

@@ -56,6 +56,7 @@ final class EphemeralResolverConnection {
/** Intent used to bind to the service */
private final Intent mIntent;
private volatile boolean mBindRequested;
private IEphemeralResolver mRemoteInstance;
public EphemeralResolverConnection(Context context, ComponentName componentName) {
@@ -111,8 +112,11 @@ final class EphemeralResolverConnection {
return;
}
mContext.bindServiceAsUser(mIntent, mServiceConnection,
Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE, UserHandle.SYSTEM);
if (!mBindRequested) {
mBindRequested = true;
mContext.bindServiceAsUser(mIntent, mServiceConnection,
Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE, UserHandle.SYSTEM);
}
final long startMillis = SystemClock.uptimeMillis();
while (true) {