Fixed NPE on MainContentCaptureSession.handleFlushIfNeeded

Test: atest CtsContentCaptureServiceTestCases
Bug: 122959591

Change-Id: Ia3b842326b5eee839693ffc71cbc3d464aabccc7
diff --git a/core/java/android/view/contentcapture/MainContentCaptureSession.java b/core/java/android/view/contentcapture/MainContentCaptureSession.java
index 9e99c88..a2ffa2f 100644
--- a/core/java/android/view/contentcapture/MainContentCaptureSession.java
+++ b/core/java/android/view/contentcapture/MainContentCaptureSession.java
@@ -402,7 +402,7 @@
     }
 
     private void handleFlushIfNeeded(@FlushReason int reason) {
-        if (mEvents.isEmpty()) {
+        if (mEvents == null || mEvents.isEmpty()) {
             if (VERBOSE) Log.v(TAG, "Nothing to flush");
             return;
         }