Merge "Fix unbind crash in AbstractRemoteService." into tm-dev
This commit is contained in:
@@ -88,6 +88,7 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
|
|||||||
private final int mBindingFlags;
|
private final int mBindingFlags;
|
||||||
protected I mService;
|
protected I mService;
|
||||||
|
|
||||||
|
private boolean mBound;
|
||||||
private boolean mConnecting;
|
private boolean mConnecting;
|
||||||
private boolean mDestroyed;
|
private boolean mDestroyed;
|
||||||
private boolean mServiceDied;
|
private boolean mServiceDied;
|
||||||
@@ -255,8 +256,10 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
|
|||||||
.append(String.valueOf(mDestroyed)).println();
|
.append(String.valueOf(mDestroyed)).println();
|
||||||
pw.append(prefix).append(tab).append("numUnfinishedRequests=")
|
pw.append(prefix).append(tab).append("numUnfinishedRequests=")
|
||||||
.append(String.valueOf(mUnfinishedRequests.size())).println();
|
.append(String.valueOf(mUnfinishedRequests.size())).println();
|
||||||
final boolean bound = handleIsBound();
|
|
||||||
pw.append(prefix).append(tab).append("bound=")
|
pw.append(prefix).append(tab).append("bound=")
|
||||||
|
.append(String.valueOf(mBound));
|
||||||
|
final boolean bound = handleIsBound();
|
||||||
|
pw.append(prefix).append(tab).append("connected=")
|
||||||
.append(String.valueOf(bound));
|
.append(String.valueOf(bound));
|
||||||
final long idleTimeout = getTimeoutIdleBindMillis();
|
final long idleTimeout = getTimeoutIdleBindMillis();
|
||||||
if (bound) {
|
if (bound) {
|
||||||
@@ -430,6 +433,8 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
|
|||||||
*/
|
*/
|
||||||
abstract void handleBindFailure();
|
abstract void handleBindFailure();
|
||||||
|
|
||||||
|
// This is actually checking isConnected. TODO: rename this and other related methods (or just
|
||||||
|
// stop using this class..)
|
||||||
private boolean handleIsBound() {
|
private boolean handleIsBound() {
|
||||||
return mService != null;
|
return mService != null;
|
||||||
}
|
}
|
||||||
@@ -445,6 +450,7 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
|
|||||||
|
|
||||||
final boolean willBind = mContext.bindServiceAsUser(mIntent, mServiceConnection, flags,
|
final boolean willBind = mContext.bindServiceAsUser(mIntent, mServiceConnection, flags,
|
||||||
mHandler, new UserHandle(mUserId));
|
mHandler, new UserHandle(mUserId));
|
||||||
|
mBound = true;
|
||||||
|
|
||||||
if (!willBind) {
|
if (!willBind) {
|
||||||
Slog.w(mTag, "could not bind to " + mIntent + " using flags " + flags);
|
Slog.w(mTag, "could not bind to " + mIntent + " using flags " + flags);
|
||||||
@@ -469,7 +475,10 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mNextUnbind = 0;
|
mNextUnbind = 0;
|
||||||
mContext.unbindService(mServiceConnection);
|
if (mBound) {
|
||||||
|
mContext.unbindService(mServiceConnection);
|
||||||
|
mBound = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RemoteServiceConnection implements ServiceConnection {
|
private class RemoteServiceConnection implements ServiceConnection {
|
||||||
|
|||||||
Reference in New Issue
Block a user