Merge "Make state atom field annotation name consistent between google3 and android."
diff --git a/cmds/statsd/src/atom_field_options.proto b/cmds/statsd/src/atom_field_options.proto
index a2a03b1..453bf7e 100644
--- a/cmds/statsd/src/atom_field_options.proto
+++ b/cmds/statsd/src/atom_field_options.proto
@@ -36,8 +36,8 @@
 // exclusive state field, and any number of primary key fields.
 // For example,
 // message UidProcessStateChanged {
-//    optional int32 uid = 1 [(stateFieldOption).option = PRIMARY];
-//    optional android.app.ProcessStateEnum state = 2 [(stateFieldOption).option = EXCLUSIVE];
+//    optional int32 uid = 1 [(state_field_option).option = PRIMARY];
+//    optional android.app.ProcessStateEnum state = 2 [(state_field_option).option = EXCLUSIVE];
 //  }
 // Each of this UidProcessStateChanged atom represents a state change for a specific uid.
 // A new state automatically overrides the previous state.
@@ -46,16 +46,16 @@
 // the primary key.
 // For example:
 // message ThreadStateChanged {
-//    optional int32 pid = 1  [(stateFieldOption).option = PRIMARY];
-//    optional int32 tid = 2  [(stateFieldOption).option = PRIMARY];
-//    optional int32 state = 3 [(stateFieldOption).option = EXCLUSIVE];
+//    optional int32 pid = 1  [(state_field_option).option = PRIMARY];
+//    optional int32 tid = 2  [(state_field_option).option = PRIMARY];
+//    optional int32 state = 3 [(state_field_option).option = EXCLUSIVE];
 // }
 //
 // Sometimes, there is no primary key field, when the state is GLOBAL.
 // For example,
 //
 // message ScreenStateChanged {
-//    optional android.view.DisplayStateEnum state = 1 [(stateFieldOption).option = EXCLUSIVE];
+//    optional android.view.DisplayStateEnum state = 1 [(state_field_option).option = EXCLUSIVE];
 // }
 //
 // Only fields of primary types can be annotated. AttributionNode cannot be primary keys (and they
@@ -66,7 +66,7 @@
 
 extend google.protobuf.FieldOptions {
     // Flags to decorate an atom that presents a state change.
-    optional StateAtomFieldOption stateFieldOption = 50000;
+    optional StateAtomFieldOption state_field_option = 50000;
 
     // Flags to decorate the uid fields in an atom.
     optional bool is_uid = 50001 [default = false];
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index f704fb7..957a9b4 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -274,7 +274,7 @@
  */
 message ScreenStateChanged {
     // New screen state, from frameworks/base/core/proto/android/view/enums.proto.
-    optional android.view.DisplayStateEnum state = 1 [(stateFieldOption).option = EXCLUSIVE];
+    optional android.view.DisplayStateEnum state = 1 [(state_field_option).option = EXCLUSIVE];
 }
 
 /**
@@ -285,10 +285,10 @@
  *   frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
  */
 message UidProcessStateChanged {
-    optional int32 uid = 1 [(stateFieldOption).option = PRIMARY, (is_uid) = true];
+    optional int32 uid = 1 [(state_field_option).option = PRIMARY, (is_uid) = true];
 
     // The state, from frameworks/base/core/proto/android/app/enums.proto.
-    optional android.app.ProcessStateEnum state = 2 [(stateFieldOption).option = EXCLUSIVE];
+    optional android.app.ProcessStateEnum state = 2 [(state_field_option).option = EXCLUSIVE];
 }
 
 /**
@@ -320,7 +320,7 @@
         ASLEEP = 1;
         AWAKE = 2;
     }
-    optional State state = 1 [(stateFieldOption).option = EXCLUSIVE];
+    optional State state = 1 [(state_field_option).option = EXCLUSIVE];
 }
 
 /**
@@ -339,7 +339,7 @@
         CRITICAL = 4;   // critical memory.
 
     }
-    optional State factor = 1 [(stateFieldOption).option = EXCLUSIVE];
+    optional State factor = 1 [(state_field_option).option = EXCLUSIVE];
 }
 
 /**
@@ -1940,7 +1940,7 @@
  */
 message AppDied {
     // timestamp(elapsedRealtime) of record creation
-    optional uint64 timestamp_millis = 1 [(stateFieldOption).option = EXCLUSIVE];
+    optional uint64 timestamp_millis = 1 [(state_field_option).option = EXCLUSIVE];
 }
 
 /**
diff --git a/tools/stats_log_api_gen/Collation.cpp b/tools/stats_log_api_gen/Collation.cpp
index 4245700..d1f42f8 100644
--- a/tools/stats_log_api_gen/Collation.cpp
+++ b/tools/stats_log_api_gen/Collation.cpp
@@ -251,7 +251,7 @@
     }
     atomDecl->fields.push_back(atField);
 
-    if (field->options().GetExtension(os::statsd::stateFieldOption).option() ==
+    if (field->options().GetExtension(os::statsd::state_field_option).option() ==
         os::statsd::StateField::PRIMARY) {
         if (javaType == JAVA_TYPE_UNKNOWN ||
             javaType == JAVA_TYPE_ATTRIBUTION_CHAIN ||
@@ -261,7 +261,7 @@
         atomDecl->primaryFields.push_back(it->first);
     }
 
-    if (field->options().GetExtension(os::statsd::stateFieldOption).option() ==
+    if (field->options().GetExtension(os::statsd::state_field_option).option() ==
         os::statsd::StateField::EXCLUSIVE) {
         if (javaType == JAVA_TYPE_UNKNOWN ||
             javaType == JAVA_TYPE_ATTRIBUTION_CHAIN ||
diff --git a/tools/stats_log_api_gen/test.proto b/tools/stats_log_api_gen/test.proto
index 264a865..f635974 100644
--- a/tools/stats_log_api_gen/test.proto
+++ b/tools/stats_log_api_gen/test.proto
@@ -127,33 +127,33 @@
 // The atom has only primary field but no exclusive state field.
 message BadStateAtom1 {
     optional int32 uid = 1
-            [(android.os.statsd.stateFieldOption).option = PRIMARY];
+            [(android.os.statsd.state_field_option).option = PRIMARY];
 }
 
 // Only primative types can be annotated.
 message BadStateAtom2 {
     repeated android.os.statsd.AttributionNode attribution = 1
-            [(android.os.statsd.stateFieldOption).option = PRIMARY];
+            [(android.os.statsd.state_field_option).option = PRIMARY];
     optional int32 state = 2
-            [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
+            [(android.os.statsd.state_field_option).option = EXCLUSIVE];
 }
 
 // Having 2 exclusive state field in the atom means the atom is badly designed.
 // E.g., putting bluetooth state and wifi state in the same atom.
 message BadStateAtom3 {
     optional int32 uid = 1
-            [(android.os.statsd.stateFieldOption).option = PRIMARY];
+            [(android.os.statsd.state_field_option).option = PRIMARY];
     optional int32 state = 2
-            [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
+            [(android.os.statsd.state_field_option).option = EXCLUSIVE];
     optional int32 state2 = 3
-            [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
+            [(android.os.statsd.state_field_option).option = EXCLUSIVE];
 }
 
 message GoodStateAtom1 {
     optional int32 uid = 1
-            [(android.os.statsd.stateFieldOption).option = PRIMARY];
+            [(android.os.statsd.state_field_option).option = PRIMARY];
     optional int32 state = 2
-            [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
+            [(android.os.statsd.state_field_option).option = EXCLUSIVE];
 }
 
 // Atoms can have exclusive state field, but no primary field. That means
@@ -161,16 +161,16 @@
 message GoodStateAtom2 {
     optional int32 uid = 1;
     optional int32 state = 2
-            [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
+            [(android.os.statsd.state_field_option).option = EXCLUSIVE];
 }
 
 // We can have more than one primary fields. That means their combination is a
 // primary key.
 message GoodStateAtom3 {
     optional int32 uid = 1
-            [(android.os.statsd.stateFieldOption).option = PRIMARY];
+            [(android.os.statsd.state_field_option).option = PRIMARY];
     optional int32 tid = 2
-            [(android.os.statsd.stateFieldOption).option = PRIMARY];
+            [(android.os.statsd.state_field_option).option = PRIMARY];
     optional int32 state = 3
-            [(android.os.statsd.stateFieldOption).option = EXCLUSIVE];
+            [(android.os.statsd.state_field_option).option = EXCLUSIVE];
 }
\ No newline at end of file