diff options
| author | tsaichristine <tsaichristine@google.com> | 2020-01-14 17:07:39 -0800 |
|---|---|---|
| committer | tsaichristine <tsaichristine@google.com> | 2020-01-16 17:35:29 -0800 |
| commit | 5adc7e008b5057a0d47e080b5546bb7f9c4e9f04 (patch) | |
| tree | 6c05fd6d2265b139cf54f09fb7c02e82e7f7b943 /tools/stats_log_api_gen/Collation.cpp | |
| parent | 78bfd35ae1b0266cff5325a751880b9e1f0f72c0 (diff) | |
Allow default state, reset state, and nesting for binary states
Every state atom can have a customized default state and reset state by
annotating atoms.proto.
Binary state atoms (such as WakelockStateChanged) can turn on nested
counting by annotating atoms.proto as well.
Generated atoms_info.h before change: https://paste.googleplex.com/4626190063108096
Generated atoms_info.h after change: https://paste.googleplex.com/5410938863747072
Generated atoms_info.cpp before change: https://paste.googleplex.com/5726061016907776
Generated atoms_info.cpp after change: https://paste.googleplex.com/5540983737417728
Test: bit statsd_test:*
Change-Id: I845616f103e013a7927de869b8e8228cfb244090
Diffstat (limited to 'tools/stats_log_api_gen/Collation.cpp')
| -rw-r--r-- | tools/stats_log_api_gen/Collation.cpp | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/tools/stats_log_api_gen/Collation.cpp b/tools/stats_log_api_gen/Collation.cpp index 7bbac137f998..e104e4ecbf92 100644 --- a/tools/stats_log_api_gen/Collation.cpp +++ b/tools/stats_log_api_gen/Collation.cpp @@ -40,18 +40,21 @@ AtomDecl::AtomDecl() { } -AtomDecl::AtomDecl(const AtomDecl& that) - : code(that.code), - name(that.name), - message(that.message), - fields(that.fields), - primaryFields(that.primaryFields), - exclusiveField(that.exclusiveField), - uidField(that.uidField), - whitelisted(that.whitelisted), - binaryFields(that.binaryFields), - hasModule(that.hasModule), - moduleName(that.moduleName) {} +AtomDecl::AtomDecl(const AtomDecl &that) + : code(that.code), + name(that.name), + message(that.message), + fields(that.fields), + primaryFields(that.primaryFields), + exclusiveField(that.exclusiveField), + defaultState(that.defaultState), + resetState(that.resetState), + nested(that.nested), + uidField(that.uidField), + whitelisted(that.whitelisted), + binaryFields(that.binaryFields), + hasModule(that.hasModule), + moduleName(that.moduleName) {} AtomDecl::AtomDecl(int c, const string& n, const string& m) :code(c), @@ -281,7 +284,7 @@ int collate_atom(const Descriptor *atom, AtomDecl *atomDecl, atomDecl->fields.push_back(atField); if (field->options().GetExtension(os::statsd::state_field_option).option() == - os::statsd::StateField::PRIMARY) { + os::statsd::StateField::PRIMARY_FIELD) { if (javaType == JAVA_TYPE_UNKNOWN || javaType == JAVA_TYPE_ATTRIBUTION_CHAIN || javaType == JAVA_TYPE_OBJECT || javaType == JAVA_TYPE_BYTE_ARRAY) { @@ -300,7 +303,7 @@ int collate_atom(const Descriptor *atom, AtomDecl *atomDecl, } if (field->options().GetExtension(os::statsd::state_field_option).option() == - os::statsd::StateField::EXCLUSIVE) { + os::statsd::StateField::EXCLUSIVE_STATE) { if (javaType == JAVA_TYPE_UNKNOWN || javaType == JAVA_TYPE_ATTRIBUTION_CHAIN || javaType == JAVA_TYPE_OBJECT || javaType == JAVA_TYPE_BYTE_ARRAY) { @@ -312,6 +315,21 @@ int collate_atom(const Descriptor *atom, AtomDecl *atomDecl, } else { errorCount++; } + + if (field->options() + .GetExtension(os::statsd::state_field_option) + .has_default_state_value()) { + atomDecl->defaultState = field->options() + .GetExtension(os::statsd::state_field_option) + .default_state_value(); + } + + if (field->options().GetExtension(os::statsd::state_field_option).has_reset_state_value()) { + atomDecl->resetState = field->options() + .GetExtension(os::statsd::state_field_option) + .reset_state_value(); + } + atomDecl->nested = field->options().GetExtension(os::statsd::state_field_option).nested(); } if (field->options().GetExtension(os::statsd::is_uid) == true) { |
