diff options
| author | 2017-07-05 12:14:38 -0700 | |
|---|---|---|
| committer | 2017-07-05 19:26:37 +0000 | |
| commit | dfa1a47f22a017f99f1eb2146c8b54c91900c778 (patch) | |
| tree | 8d695faa28665e50e8892bde9e7e7f8ad6dccbe1 | |
| parent | 5c5f1f641934d16d5bebb11ac19c9bd868964f12 (diff) | |
Avoid a race in autofill manager service.
Test: manual
bug:63205660
Change-Id: Ie895666da1584e735f7aa7ee9208ea97becb921b
| -rw-r--r-- | services/autofill/java/com/android/server/autofill/Session.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 72ad752caf19..6bc9c9c611c9 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -217,7 +217,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState fillContextWithAllowedValues(mContexts.get(i), flags); } - request = new FillRequest(requestId, mContexts, mClientState, flags); + // Dispatch a snapshot of the current contexts list since it may change + // until the dispatch happens. The items in the list don't need to be cloned + // since we don't hold on them anywhere else. The client state is not touched + // by us, so no need to copy. + request = new FillRequest(requestId, new ArrayList<>(mContexts), + mClientState, flags); } mRemoteFillService.onFillRequest(request); @@ -932,7 +937,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // Remove pending fill requests as the session is finished. cancelCurrentRequestLocked(); - final SaveRequest saveRequest = new SaveRequest(mContexts, mClientState); + // Dispatch a snapshot of the current contexts list since it may change + // until the dispatch happens. The items in the list don't need to be cloned + // since we don't hold on them anywhere else. The client state is not touched + // by us, so no need to copy. + final SaveRequest saveRequest = new SaveRequest(new ArrayList<>(mContexts), mClientState); mRemoteFillService.onSaveRequest(saveRequest); } |