Make state_option top-level boolean annotations

- Add AnnotationId enum stats-log-api-gen
- Rename RESET_STATE annotation to TRIGGER_STATE_RESET. Also rename the proto annotation.

Bug: 152412767
Test: stats-log-api-gen-test
Test: m statslog-framework-java-gen
Change-Id: I2c12ea0b9222ef28b8cc11ea36b272e518a96259
diff --git a/atom_field_options.proto b/atom_field_options.proto
index afee79d..8527185 100644
--- a/atom_field_options.proto
+++ b/atom_field_options.proto
@@ -23,25 +23,12 @@
 
 import "google/protobuf/descriptor.proto";
 
-enum StateField {
-    // Default value for fields that are not a primary or exclusive state field.
-    STATE_FIELD_UNSET = 0;
-    // Fields that represent the key that the state belongs to.
-    // Used on simple proto fields. Do not use on attribution chains.
-    PRIMARY_FIELD = 1;
-    // The field that represents the state. It's an exclusive state.
-    EXCLUSIVE_STATE = 2;
-    // Used on an attribution chain field to indicate that the first uid is the
-    // primary field.
-    PRIMARY_FIELD_FIRST_UID = 3;
-}
-
 // Used to annotate an atom that represents a state change. A state change atom must have exactly
 // ONE exclusive state field, and any number of primary key fields. For example, message
 // UidProcessStateChanged {
-//    optional int32 uid = 1 [(state_field_option).option = PRIMARY_FIELD];
-//    optional android.app.ProcessStateEnum state = 2 [(state_field_option).option =
-//    EXCLUSIVE_STATE];
+//    optional int32 uid = 1 [(state_field_option).primary_field = true];
+//    optional android.app.ProcessStateEnum state =
+//            2 [(state_field_option).exclusive_state = true];
 //  }
 // Each UidProcessStateChanged atom event represents a state change for a specific uid.
 // A new state automatically overrides the previous state.
@@ -50,23 +37,23 @@
 // primary fields are the primary key.
 // For example:
 // message ThreadStateChanged {
-//    optional int32 pid = 1  [(state_field_option).option = PRIMARY_FIELD];
-//    optional int32 tid = 2  [(state_field_option).option = PRIMARY_FIELD];
-//    optional int32 state = 3 [(state_field_option).option = EXCLUSIVE_STATE];
+//    optional int32 pid = 1  [(state_field_option).primary_field = true];
+//    optional int32 tid = 2  [(state_field_option).primary_field = true];
+//    optional int32 state = 3 [(state_field_option).exclusive_state = true];
 // }
 //
 // Sometimes, there is no primary key field, when the state is GLOBAL.
 // For example,
 // message ScreenStateChanged {
-//    optional android.view.DisplayStateEnum state = 1 [(state_field_option).option =
-//    EXCLUSIVE_STATE];
+//    optional android.view.DisplayStateEnum state =
+//          1 [(state_field_option).exclusive_state = true];
 // }
 //
 // For state atoms with attribution chain, sometimes the primary key is the first uid in the chain.
 // For example:
 // message AudioStateChanged {
 //   repeated AttributionNode attribution_node = 1
-//       [(stateFieldOption).option = PRIMARY_KEY_FIRST_UID];
+//       [(stateFieldOption).primary_field_first_uid = true];
 //
 //    enum State {
 //      OFF = 0;
@@ -74,10 +61,19 @@
 //      // RESET indicates all audio stopped. Used when it (re)starts (e.g. after it crashes).
 //      RESET = 2;
 //    }
-//    optional State state = 2 [(stateFieldOption).option = EXCLUSIVE_STATE];
+//    optional State state = 2 [(stateFieldOption).exclusive_state = true];
 // }
 message StateAtomFieldOption {
-    optional StateField option = 1 [default = STATE_FIELD_UNSET];
+    // Fields that represent the key that the state belongs to.
+    // Used on simple proto fields. Do not use on attribution chains.
+    optional bool primary_field = 1 [default = false];
+
+    // The field that represents the state. It's an exclusive state.
+    optional bool exclusive_state = 2 [default = false];
+
+    // Used on an attribution chain field to indicate that the first uid is the
+    // primary field.
+    optional bool primary_field_first_uid = 3 [default = false];
 
     // Note: We cannot annotate directly on the enums because many enums are imported from other
     // proto files in the platform. proto-lite cc library does not support annotations unfortunately
@@ -85,14 +81,14 @@
     // Knowing the default state value allows state trackers to remove entries that become the
     // default state. If there is no default value specified, the default value is unknown, and all
     // states will be tracked in memory.
-    optional int32 default_state_value = 2;
+    optional int32 default_state_value = 4;
 
     // A reset state signals all states go to default value. For example, BLE reset means all active
     // BLE scans are to be turned off.
-    optional int32 reset_state_value = 3;
+    optional int32 trigger_state_reset_value = 5;
 
     // If the state change needs to count nesting.
-    optional bool nested = 4 [default = true];
+    optional bool nested = 6 [default = true];
 }
 
 // Used to generate StatsLog.write APIs.
diff --git a/atoms.proto b/atoms.proto
index 5cd00c3..c7dbf77 100644
--- a/atoms.proto
+++ b/atoms.proto
@@ -610,7 +610,7 @@
 message ScreenStateChanged {
     // New screen state, from frameworks/base/core/proto/android/view/enums.proto.
     optional android.view.DisplayStateEnum state = 1
-            [(state_field_option).option = EXCLUSIVE_STATE, (state_field_option).nested = false];
+            [(state_field_option).exclusive_state = true, (state_field_option).nested = false];
 }
 
 /**
@@ -621,11 +621,11 @@
  *   frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
  */
 message UidProcessStateChanged {
-    optional int32 uid = 1 [(state_field_option).option = PRIMARY_FIELD, (is_uid) = true];
+    optional int32 uid = 1 [(state_field_option).primary_field = true, (is_uid) = true];
 
     // The state, from frameworks/base/core/proto/android/app/enums.proto.
     optional android.app.ProcessStateEnum state = 2
-            [(state_field_option).option = EXCLUSIVE_STATE, (state_field_option).nested = false];
+            [(state_field_option).exclusive_state = true, (state_field_option).nested = false];
 }
 
 /**
@@ -657,7 +657,7 @@
         ASLEEP = 1;
         AWAKE = 2;
     }
-    optional State state = 1 [(state_field_option).option = EXCLUSIVE_STATE];
+    optional State state = 1 [(state_field_option).exclusive_state = true];
 }
 
 /**
@@ -676,7 +676,7 @@
         CRITICAL = 4;   // critical memory.
 
     }
-    optional State factor = 1 [(state_field_option).option = EXCLUSIVE_STATE];
+    optional State factor = 1 [(state_field_option).exclusive_state = true];
 }
 
 /**
@@ -854,7 +854,7 @@
  */
 message BleScanStateChanged {
     repeated AttributionNode attribution_node = 1
-            [(state_field_option).option = PRIMARY_FIELD_FIRST_UID];
+            [(state_field_option).primary_field_first_uid = true];
 
     enum State {
         OFF = 0;
@@ -863,18 +863,18 @@
         RESET = 2;
     }
     optional State state = 2 [
-        (state_field_option).option = EXCLUSIVE_STATE,
+        (state_field_option).exclusive_state = true,
         (state_field_option).default_state_value = 0 /* State.OFF */,
-        (state_field_option).reset_state_value = 2 /* State.RESET */,
+        (state_field_option).trigger_state_reset_value = 2 /* State.RESET */,
         (state_field_option).nested = true
     ];
 
     // Does the scan have a filter.
-    optional bool is_filtered = 3 [(state_field_option).option = PRIMARY_FIELD];
+    optional bool is_filtered = 3 [(state_field_option).primary_field = true];
     // Whether the scan is a CALLBACK_TYPE_FIRST_MATCH scan. Called 'background' scan internally.
-    optional bool is_first_match = 4 [(state_field_option).option = PRIMARY_FIELD];
+    optional bool is_first_match = 4 [(state_field_option).primary_field = true];
     // Whether the scan set to piggy-back off the results of other scans (SCAN_MODE_OPPORTUNISTIC).
-    optional bool is_opportunistic = 5 [(state_field_option).option = PRIMARY_FIELD];
+    optional bool is_opportunistic = 5 [(state_field_option).primary_field = true];
 }
 
 /**
@@ -1105,15 +1105,14 @@
  */
 message WakelockStateChanged {
     repeated AttributionNode attribution_node = 1
-            [(state_field_option).option = PRIMARY_FIELD_FIRST_UID];
+            [(state_field_option).primary_field_first_uid = true];
 
     // The type (level) of the wakelock; e.g. a partial wakelock or a full wakelock.
     // From frameworks/base/core/proto/android/os/enums.proto.
-    optional android.os.WakeLockLevelEnum type = 2 [(state_field_option).option = PRIMARY_FIELD];
-    ;
+    optional android.os.WakeLockLevelEnum type = 2 [(state_field_option).primary_field = true];
 
     // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
-    optional string tag = 3 [(state_field_option).option = PRIMARY_FIELD];
+    optional string tag = 3 [(state_field_option).primary_field = true];
 
     enum State {
         RELEASE = 0;
@@ -1122,7 +1121,7 @@
         CHANGE_ACQUIRE = 3;
     }
     optional State state = 4 [
-        (state_field_option).option = EXCLUSIVE_STATE,
+        (state_field_option).exclusive_state = true,
         (state_field_option).default_state_value = 0,
         (state_field_option).nested = true
     ];
@@ -3494,9 +3493,9 @@
  *     services/core/java/com/android/server/wm/Session.java
  */
 message OverlayStateChanged {
-    optional int32 uid = 1 [(state_field_option).option = PRIMARY_FIELD, (is_uid) = true];
+    optional int32 uid = 1 [(state_field_option).primary_field = true, (is_uid) = true];
 
-    optional string package_name = 2 [(state_field_option).option = PRIMARY_FIELD];
+    optional string package_name = 2 [(state_field_option).primary_field = true];
 
     optional bool using_alert_window = 3;
 
@@ -3505,7 +3504,7 @@
         EXITED = 2;
     }
     optional State state = 4 [
-        (state_field_option).option = EXCLUSIVE_STATE,
+        (state_field_option).exclusive_state = true,
         (state_field_option).nested = false,
         (state_field_option).default_state_value = 2
     ];
@@ -3713,7 +3712,7 @@
  */
 message AppDied {
     // timestamp(elapsedRealtime) of record creation
-    optional uint64 timestamp_millis = 1 [(state_field_option).option = EXCLUSIVE_STATE];
+    optional uint64 timestamp_millis = 1 [(state_field_option).exclusive_state = true];
 }
 
 /**
@@ -4235,7 +4234,7 @@
         DIALOG_LINE_ITEM = 5;
     }
 
-    optional Type type = 1 [(state_field_option).option = EXCLUSIVE_STATE];
+    optional Type type = 1 [(state_field_option).exclusive_state = true];
 
     // Used if the type is LINE_ITEM
     optional string package_name = 2;