Merge "QS API: Handle return value from bindServiceAsUser" into nyc-dev am: 7e10e630b4

am: 08305d711d

* commit '08305d711d626ebe58661b2c5c4dbda593b27cf7':
  QS API: Handle return value from bindServiceAsUser

Change-Id: I21d3343f11940b29a2cf81801514956110b50667
This commit is contained in:
Jason Monk
2016-05-25 17:30:56 +00:00
committed by android-build-merger

View File

@@ -81,6 +81,8 @@ public class TileLifecycleManager extends BroadcastReceiver implements
private IQSService mService;
private boolean mUnbindImmediate;
private TileChangeListener mChangeListener;
// Return value from bindServiceAsUser, determines whether safe to call unbind.
private boolean mIsBound;
public TileLifecycleManager(Handler handler, Context context, Intent intent, UserHandle user) {
mContext = context;
@@ -132,7 +134,7 @@ public class TileLifecycleManager extends BroadcastReceiver implements
}
if (DEBUG) Log.d(TAG, "Binding service " + mIntent + " " + mUser);
mBindTryCount++;
mContext.bindServiceAsUser(mIntent, this,
mIsBound = mContext.bindServiceAsUser(mIntent, this,
Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
mUser);
} else {
@@ -140,7 +142,10 @@ public class TileLifecycleManager extends BroadcastReceiver implements
// Give it another chance next time it needs to be bound, out of kindness.
mBindTryCount = 0;
mWrapper = null;
mContext.unbindService(this);
if (mIsBound) {
mContext.unbindService(this);
mIsBound = false;
}
}
}