Merge "Make RemoteService propagate Context#bindService failure to PendingRequests" into qt-dev

am: 7fdbe22475

Change-Id: I73c0053bc0f6a48881c3ff19b36663cc467c740d
This commit is contained in:
Eugene Susla
2019-04-18 16:19:49 -07:00
committed by android-build-merger
4 changed files with 41 additions and 0 deletions

View File

@@ -275,6 +275,11 @@ public class RoleControllerManager {
Log.e(LOG_TAG, "Error calling grantDefaultRoles()", e);
}
}
@Override
protected void onFailed() {
mRemoteCallback.sendResult(null);
}
}
/**

View File

@@ -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
public void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
super.dump(prefix, pw);

View File

@@ -405,6 +405,11 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
abstract void handlePendingRequestWhileUnBound(
@NonNull BasePendingRequest<S, I> pendingRequest);
/**
* Called if {@link Context#bindServiceAsUser} returns {@code false}.
*/
abstract void handleBindFailure();
private boolean handleIsBound() {
return mService != null;
}
@@ -426,6 +431,8 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
mBinding = false;
if (!mServiceDied) {
// TODO(b/126266412): merge these 2 calls?
handleBindFailure();
handleBinderDied();
}
}
@@ -561,6 +568,12 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
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.
*/

View File

@@ -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
public void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
super.dump(prefix, pw);