Merge "Expose pending request to subclasses and ensure clean up"

This commit is contained in:
Treehugger Robot
2023-03-04 00:41:27 +00:00
committed by Gerrit Code Review
2 changed files with 7 additions and 2 deletions

View File

@@ -61,7 +61,7 @@ public abstract class AbstractMultiplePendingRequestsRemoteService<S
final int size = mPendingRequests.size(); final int size = mPendingRequests.size();
if (mVerbose) Slog.v(mTag, "Sending " + size + " pending requests"); if (mVerbose) Slog.v(mTag, "Sending " + size + " pending requests");
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
mPendingRequests.get(i).run(); handlePendingRequest(mPendingRequests.get(i));
} }
mPendingRequests.clear(); mPendingRequests.clear();
} }

View File

@@ -98,7 +98,7 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
private long mNextUnbind; private long mNextUnbind;
/** Requests that have been scheduled, but that are not finished yet */ /** Requests that have been scheduled, but that are not finished yet */
private final ArrayList<BasePendingRequest<S, I>> mUnfinishedRequests = new ArrayList<>(); protected final ArrayList<BasePendingRequest<S, I>> mUnfinishedRequests = new ArrayList<>();
/** /**
* Callback called when the service dies. * Callback called when the service dies.
@@ -622,6 +622,11 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
mCancelled = true; mCancelled = true;
} }
S service = mWeakService.get();
if (service != null) {
service.finishRequest(this);
}
onCancel(); onCancel();
return true; return true;
} }