Merge "Fix potential null error in clearEvents." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6ea5a55ac5
@@ -341,11 +341,7 @@ public abstract class ContentCaptureSession implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
onDestroy();
|
||||||
flush(FLUSH_REASON_SESSION_FINISHED);
|
|
||||||
} finally {
|
|
||||||
onDestroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void onDestroy();
|
abstract void onDestroy();
|
||||||
|
|||||||
@@ -263,7 +263,13 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
|
|||||||
@Override
|
@Override
|
||||||
void onDestroy() {
|
void onDestroy() {
|
||||||
mHandler.removeMessages(MSG_FLUSH);
|
mHandler.removeMessages(MSG_FLUSH);
|
||||||
mHandler.post(() -> destroySession());
|
mHandler.post(() -> {
|
||||||
|
try {
|
||||||
|
flush(FLUSH_REASON_SESSION_FINISHED);
|
||||||
|
} finally {
|
||||||
|
destroySession();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -571,9 +577,11 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
|
|||||||
private ParceledListSlice<ContentCaptureEvent> clearEvents() {
|
private ParceledListSlice<ContentCaptureEvent> clearEvents() {
|
||||||
// NOTE: we must save a reference to the current mEvents and then set it to to null,
|
// 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.
|
// otherwise clearing it would clear it in the receiving side if the service is also local.
|
||||||
final List<ContentCaptureEvent> events = mEvents == null
|
if (mEvents == null) {
|
||||||
? Collections.EMPTY_LIST
|
return new ParceledListSlice<>(Collections.EMPTY_LIST);
|
||||||
: new ArrayList<>(mEvents);
|
}
|
||||||
|
|
||||||
|
final List<ContentCaptureEvent> events = new ArrayList<>(mEvents);
|
||||||
mEvents.clear();
|
mEvents.clear();
|
||||||
return new ParceledListSlice<>(events);
|
return new ParceledListSlice<>(events);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user