Merge "Make RemoteService propagate Context#bindService failure to PendingRequests" into qt-dev
am: 7fdbe22475
Change-Id: I73c0053bc0f6a48881c3ff19b36663cc467c740d
This commit is contained in:
@@ -275,6 +275,11 @@ public class RoleControllerManager {
|
|||||||
Log.e(LOG_TAG, "Error calling grantDefaultRoles()", e);
|
Log.e(LOG_TAG, "Error calling grantDefaultRoles()", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onFailed() {
|
||||||
|
mRemoteCallback.sendResult(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -74,6 +74,20 @@ public abstract class AbstractMultiplePendingRequestsRemoteService<S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override // from AbstractRemoteService
|
||||||
|
final void handleBindFailure() {
|
||||||
|
if (mPendingRequests != null) {
|
||||||
|
final int size = mPendingRequests.size();
|
||||||
|
if (mVerbose) Slog.v(mTag, "Sending failure to " + size + " pending requests");
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
final BasePendingRequest<S, I> request = mPendingRequests.get(i);
|
||||||
|
request.onFailed();
|
||||||
|
request.finish();
|
||||||
|
}
|
||||||
|
mPendingRequests = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override // from AbstractRemoteService
|
@Override // from AbstractRemoteService
|
||||||
public void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
|
public void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
|
||||||
super.dump(prefix, pw);
|
super.dump(prefix, pw);
|
||||||
|
|||||||
@@ -405,6 +405,11 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
|
|||||||
abstract void handlePendingRequestWhileUnBound(
|
abstract void handlePendingRequestWhileUnBound(
|
||||||
@NonNull BasePendingRequest<S, I> pendingRequest);
|
@NonNull BasePendingRequest<S, I> pendingRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called if {@link Context#bindServiceAsUser} returns {@code false}.
|
||||||
|
*/
|
||||||
|
abstract void handleBindFailure();
|
||||||
|
|
||||||
private boolean handleIsBound() {
|
private boolean handleIsBound() {
|
||||||
return mService != null;
|
return mService != null;
|
||||||
}
|
}
|
||||||
@@ -426,6 +431,8 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
|
|||||||
mBinding = false;
|
mBinding = false;
|
||||||
|
|
||||||
if (!mServiceDied) {
|
if (!mServiceDied) {
|
||||||
|
// TODO(b/126266412): merge these 2 calls?
|
||||||
|
handleBindFailure();
|
||||||
handleBinderDied();
|
handleBinderDied();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -561,6 +568,12 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
|
|||||||
|
|
||||||
void onFinished() { }
|
void onFinished() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when request fails due to reasons internal to {@link AbstractRemoteService},
|
||||||
|
* e.g. failure to bind to service.
|
||||||
|
*/
|
||||||
|
protected void onFailed() { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether this request was cancelled.
|
* Checks whether this request was cancelled.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -66,6 +66,15 @@ public abstract class AbstractSinglePendingRequestRemoteService<S
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override // from AbstractRemoteService
|
||||||
|
void handleBindFailure() {
|
||||||
|
if (mPendingRequest != null) {
|
||||||
|
if (mVerbose) Slog.v(mTag, "Sending failure to " + mPendingRequest);
|
||||||
|
mPendingRequest.onFailed();
|
||||||
|
mPendingRequest = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override // from AbstractRemoteService
|
@Override // from AbstractRemoteService
|
||||||
public void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
|
public void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
|
||||||
super.dump(prefix, pw);
|
super.dump(prefix, pw);
|
||||||
|
|||||||
Reference in New Issue
Block a user