Expose pending request to subclasses and ensure clean up

Pending requests were not exposed to subclasses interested in
operating on them and also the pending requests were not cleaned
up after being handled leaving them in memory and potentially
preventing us from unbinding from the remote service upon timeout.

Test: Perform the following steps on a Meta Quest 2:
1. Launch 2D app in shell
2. Launch 2D app in shell from non activity context
3. Launch 2D app in shell and request permission in 2D
4. Request permission from 3D app in 2D overlay
5. Request permission from 3D app in 2D (via VrUi)
6. Subclasses can access pending jobs which are cleaned upon completion

Change-Id: I29e7146619913dd3457fa2a228cece2d245ff02d
This commit is contained in:
Stephen Trier
2022-09-19 10:26:22 -07:00
parent c12a383385
commit 58d3f87f33
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();
if (mVerbose) Slog.v(mTag, "Sending " + size + " pending requests");
for (int i = 0; i < size; i++) {
mPendingRequests.get(i).run();
handlePendingRequest(mPendingRequests.get(i));
}
mPendingRequests.clear();
}

View File

@@ -98,7 +98,7 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
private long mNextUnbind;
/** 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.
@@ -622,6 +622,11 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
mCancelled = true;
}
S service = mWeakService.get();
if (service != null) {
service.finishRequest(this);
}
onCancel();
return true;
}