New FIELD_AUTOFILL_COMPAT_MODE field.

This field is used on pretty much all Autofill metrics, except
AUTOFILL_USERDATA_UPDATED, AUTOFILL_SERVICE_DISABLED_SELF, and
AUTOFILL_INVALID_PERMISSION.

Test: atest CtsAutoFillServiceTestCases
Test: adb shell logcat -b events | grep sysui

Bug: 79351659

Change-Id: I2e2f3dcc780a3896162b158926f5ee89c7cb342d
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index 88300db..4c7dc11 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -1132,8 +1132,7 @@
             if (mSaveTriggerId != null && mSaveTriggerId.equals(id)) {
                 if (sDebug) Log.d(TAG, "triggering commit by click of " + id);
                 commitLocked();
-                mMetricsLogger.action(MetricsEvent.AUTOFILL_SAVE_EXPLICITLY_TRIGGERED,
-                        mContext.getPackageName());
+                mMetricsLogger.write(newLog(MetricsEvent.AUTOFILL_SAVE_EXPLICITLY_TRIGGERED));
             }
         }
     }
@@ -1893,14 +1892,19 @@
                 }
             }
 
-            final LogMaker log = new LogMaker(MetricsEvent.AUTOFILL_DATASET_APPLIED)
-                    .setPackageName(mContext.getPackageName())
+            mMetricsLogger.write(newLog(MetricsEvent.AUTOFILL_DATASET_APPLIED)
                     .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_VALUES, itemCount)
-                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_VIEWS_FILLED, numApplied);
-            mMetricsLogger.write(log);
+                    .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_VIEWS_FILLED, numApplied));
         }
     }
 
+    private LogMaker newLog(int category) {
+        return new LogMaker(category)
+                .setPackageName(mContext.getPackageName())
+                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_COMPAT_MODE,
+                        isCompatibilityModeEnabledLocked() ? 1 : 0);
+    }
+
     /**
      *  Set the tracked views.
      *