Cosmetic ContentCapture fixes.

Test: atest CtsContentCaptureServiceTestCases
Bug: 121033016
Change-Id: Ibe82fa15660a268d6fec91374c6899dd9e3b4d8d
diff --git a/core/java/android/view/contentcapture/MainContentCaptureSession.java b/core/java/android/view/contentcapture/MainContentCaptureSession.java
index 12c50ce..baf4a35 100644
--- a/core/java/android/view/contentcapture/MainContentCaptureSession.java
+++ b/core/java/android/view/contentcapture/MainContentCaptureSession.java
@@ -63,6 +63,8 @@
  */
 public final class MainContentCaptureSession extends ContentCaptureSession {
 
+    private static final String TAG = MainContentCaptureSession.class.getSimpleName();
+
     /**
      * Handler message used to flush the buffer.
      */
@@ -128,9 +130,6 @@
     // Used just for debugging purposes (on dump)
     private long mNextFlush;
 
-    // Lazily created on demand.
-    private ContentCaptureSessionId mContentCaptureSessionId;
-
     /** @hide */
     protected MainContentCaptureSession(@NonNull Context context, @NonNull Handler handler,
             @Nullable IContentCaptureManager systemServerInterface,
@@ -157,7 +156,7 @@
         if (!isContentCaptureEnabled()) return;
 
         if (VERBOSE) {
-            Log.v(mTag, "start(): token=" + applicationToken + ", comp="
+            Log.v(TAG, "start(): token=" + applicationToken + ", comp="
                     + ComponentName.flattenToShortString(activityComponent));
         }
 
@@ -179,7 +178,7 @@
     private void handleStartSession(@NonNull IBinder token, @NonNull ComponentName componentName) {
         if (mState != STATE_UNKNOWN) {
             // TODO(b/111276913): revisit this scenario
-            Log.w(mTag, "ignoring handleStartSession(" + token + ") while on state "
+            Log.w(TAG, "ignoring handleStartSession(" + token + ") while on state "
                     + getStateAsString(mState));
             return;
         }
@@ -188,7 +187,7 @@
         mComponentName = componentName;
 
         if (VERBOSE) {
-            Log.v(mTag, "handleStartSession(): token=" + token + ", act="
+            Log.v(TAG, "handleStartSession(): token=" + token + ", act="
                     + getActivityDebugName() + ", id=" + mId);
         }
         final int flags = 0; // TODO(b/111276913): get proper flags
@@ -202,7 +201,7 @@
                             if (resultData != null) {
                                 binder = resultData.getBinder(EXTRA_BINDER);
                                 if (binder == null) {
-                                    Log.wtf(mTag, "No " + EXTRA_BINDER + " extra result");
+                                    Log.wtf(TAG, "No " + EXTRA_BINDER + " extra result");
                                     handleResetState();
                                     return;
                                 }
@@ -211,7 +210,7 @@
                         }
                     });
         } catch (RemoteException e) {
-            Log.w(mTag, "Error starting session for " + componentName.flattenToShortString() + ": "
+            Log.w(TAG, "Error starting session for " + componentName.flattenToShortString() + ": "
                     + e);
         }
     }
@@ -229,13 +228,13 @@
         if (binder != null) {
             mDirectServiceInterface = IContentCaptureDirectManager.Stub.asInterface(binder);
             mDirectServiceVulture = () -> {
-                Log.w(mTag, "Destroying session " + mId + " because service died");
+                Log.w(TAG, "Destroying session " + mId + " because service died");
                 destroy();
             };
             try {
                 binder.linkToDeath(mDirectServiceVulture, 0);
             } catch (RemoteException e) {
-                Log.w(mTag, "Failed to link to death on " + binder + ": " + e);
+                Log.w(TAG, "Failed to link to death on " + binder + ": " + e);
             }
         }
         if (resultCode == STATE_DISABLED || resultCode == STATE_DISABLED_DUPLICATED_ID) {
@@ -245,7 +244,7 @@
             mDisabled.set(false);
         }
         if (VERBOSE) {
-            Log.v(mTag, "handleSessionStarted() result: code=" + resultCode + ", id=" + mId
+            Log.v(TAG, "handleSessionStarted() result: code=" + resultCode + ", id=" + mId
                     + ", state=" + getStateAsString(mState) + ", disabled=" + mDisabled.get()
                     + ", binder=" + binder);
         }
@@ -254,7 +253,7 @@
     private void handleSendEvent(@NonNull ContentCaptureEvent event, boolean forceFlush) {
         if (mEvents == null) {
             if (VERBOSE) {
-                Log.v(mTag, "Creating buffer for " + MAX_BUFFER_SIZE + " events");
+                Log.v(TAG, "Creating buffer for " + MAX_BUFFER_SIZE + " events");
             }
             mEvents = new ArrayList<>(MAX_BUFFER_SIZE);
         }
@@ -266,7 +265,7 @@
             if (lastEvent.getType() == TYPE_VIEW_TEXT_CHANGED
                     && lastEvent.getId().equals(event.getId())) {
                 if (VERBOSE) {
-                    Log.v(mTag, "Buffering VIEW_TEXT_CHANGED event, updated text = "
+                    Log.v(TAG, "Buffering VIEW_TEXT_CHANGED event, updated text = "
                             + event.getText());
                 }
                 lastEvent.setText(event.getText());
@@ -293,7 +292,7 @@
             // not complete instead. Similarly, the manager service should return right away
             // when the user does not have a service set
             if (VERBOSE) {
-                Log.v(mTag, "Closing session for " + getActivityDebugName()
+                Log.v(TAG, "Closing session for " + getActivityDebugName()
                         + " after " + numberEvents + " delayed events and state "
                         + getStateAsString(mState));
             }
@@ -313,7 +312,7 @@
         }
         mNextFlush = SystemClock.elapsedRealtime() + FLUSHING_FREQUENCY_MS;
         if (VERBOSE) {
-            Log.v(mTag, "Scheduled to flush in " + FLUSHING_FREQUENCY_MS + "ms: " + mNextFlush);
+            Log.v(TAG, "Scheduled to flush in " + FLUSHING_FREQUENCY_MS + "ms: " + mNextFlush);
         }
         mHandler.sendMessageDelayed(
                 obtainMessage(MainContentCaptureSession::handleFlushIfNeeded, this)
@@ -322,7 +321,7 @@
 
     private void handleFlushIfNeeded() {
         if (mEvents.isEmpty()) {
-            if (VERBOSE) Log.v(mTag, "Nothing to flush");
+            if (VERBOSE) Log.v(TAG, "Nothing to flush");
             return;
         }
         handleForceFlush();
@@ -332,7 +331,7 @@
         if (mEvents == null) return;
 
         if (mDirectServiceInterface == null) {
-            if (DEBUG) Log.d(mTag, "handleForceFlush(): hold your horses, client not ready yet!");
+            if (DEBUG) Log.d(TAG, "handleForceFlush(): hold your horses, client not ready yet!");
             if (!mHandler.hasMessages(MSG_FLUSH)) {
                 handleScheduleFlush(/* checkExisting= */ false);
             }
@@ -342,14 +341,14 @@
         final int numberEvents = mEvents.size();
         try {
             if (DEBUG) {
-                Log.d(mTag, "Flushing " + numberEvents + " event(s) for " + getActivityDebugName());
+                Log.d(TAG, "Flushing " + numberEvents + " event(s) for " + getActivityDebugName());
             }
             mHandler.removeMessages(MSG_FLUSH);
 
             final ParceledListSlice<ContentCaptureEvent> events = handleClearEvents();
             mDirectServiceInterface.sendEvents(events);
         } catch (RemoteException e) {
-            Log.w(mTag, "Error sending " + numberEvents + " for " + getActivityDebugName()
+            Log.w(TAG, "Error sending " + numberEvents + " for " + getActivityDebugName()
                     + ": " + e);
         }
     }
@@ -370,7 +369,7 @@
 
     private void handleDestroySession() {
         if (DEBUG) {
-            Log.d(mTag, "Destroying session (ctx=" + mContext + ", id=" + mId + ") with "
+            Log.d(TAG, "Destroying session (ctx=" + mContext + ", id=" + mId + ") with "
                     + (mEvents == null ? 0 : mEvents.size()) + " event(s) for "
                     + getActivityDebugName());
         }
@@ -378,7 +377,7 @@
         try {
             mSystemServerInterface.finishSession(mContext.getUserId(), mId);
         } catch (RemoteException e) {
-            Log.e(mTag, "Error destroying system-service session " + mId + " for "
+            Log.e(TAG, "Error destroying system-service session " + mId + " for "
                     + getActivityDebugName() + ": " + e);
         }
     }
@@ -395,8 +394,6 @@
         }
 
         // TODO(b/121033016): must reset children (which currently is owned by superclass)
-
-        mContentCaptureSessionId = null;
         mApplicationToken = null;
         mComponentName = null;
         mEvents = null;
@@ -482,9 +479,6 @@
         }
         pw.print(prefix); pw.print("mDisabled: "); pw.println(mDisabled.get());
         pw.print(prefix); pw.print("isEnabled(): "); pw.println(isContentCaptureEnabled());
-        if (mContentCaptureSessionId != null) {
-            pw.print(prefix); pw.print("public id: "); pw.println(mContentCaptureSessionId);
-        }
         pw.print(prefix); pw.print("state: "); pw.print(mState); pw.print(" (");
         pw.print(getStateAsString(mState)); pw.println(")");
         if (mApplicationToken != null) {