Change clearEvents() to clear existing events rather than setting
mEvents to null to remove possible NPE. * clearEvents() needs to be called by destroy() which could cause race condition on whether mEvents is null for other func calls. Fixes: 185162720 Test: atest CtsContentCaptureServiceTestCases Change-Id: I7330e651bc890c8a86822158efcf17a61e927112
This commit is contained in:
@@ -583,9 +583,9 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
|
||||
// NOTE: we must save a reference to the current mEvents and then set it to to null,
|
||||
// otherwise clearing it would clear it in the receiving side if the service is also local.
|
||||
final List<ContentCaptureEvent> events = mEvents == null
|
||||
? Collections.emptyList()
|
||||
: mEvents;
|
||||
mEvents = null;
|
||||
? Collections.EMPTY_LIST
|
||||
: new ArrayList<>(mEvents);
|
||||
mEvents.clear();
|
||||
mLastComposingSpan.clear();
|
||||
return new ParceledListSlice<>(events);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user