summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Jin <jinyithu@google.com>2017-12-12 12:53:51 -0800
committerYi Jin <jinyithu@google.com>2017-12-12 13:20:46 -0800
commitf77a07df1cc71d1f25454de1b5c7da301541b837 (patch)
treec8d95c91cf7fe4c30b70eb494aec5c55cc72d54b
parentd04c00a47907452a76d31e7183e5cc37bdf4dbf3 (diff)
Create a new stream option which generates field name to id mapping
recursively for all its submessages. Also fix the wrong prefix for ro.build.version.XXX in proto. It is safe to adjust proto number for now since it is not used yet. Bug: 68774852 Test: atest incident_helper_test Change-Id: I46e43a407da6efc393eb3c39733aaf25a5cceb13
-rw-r--r--cmds/incident_helper/src/parsers/SystemPropertiesParser.cpp17
-rw-r--r--cmds/incident_helper/testdata/system_properties.txt3
-rw-r--r--cmds/incident_helper/tests/SystemPropertiesParser_test.cpp51
-rw-r--r--core/proto/android/os/system_properties.proto145
-rw-r--r--tools/streaming_proto/cpp/main.cpp14
-rw-r--r--tools/streaming_proto/stream.proto3
6 files changed, 112 insertions, 121 deletions
diff --git a/cmds/incident_helper/src/parsers/SystemPropertiesParser.cpp b/cmds/incident_helper/src/parsers/SystemPropertiesParser.cpp
index a41ed6ebaa22..23393da01d48 100644
--- a/cmds/incident_helper/src/parsers/SystemPropertiesParser.cpp
+++ b/cmds/incident_helper/src/parsers/SystemPropertiesParser.cpp
@@ -53,10 +53,16 @@ SystemPropertiesParser::Parse(const int in, const int out) const
SystemPropertiesProto::_FIELD_COUNT);
Message sysProp(&sysPropTable);
- Table aaudioT(SystemPropertiesProto::Aaudio::_FIELD_NAMES,
+ Table aacDrcTable(SystemPropertiesProto::AacDrc::_FIELD_NAMES,
+ SystemPropertiesProto::AacDrc::_FIELD_IDS,
+ SystemPropertiesProto::AacDrc::_FIELD_COUNT);
+ Message aacDrc(&aacDrcTable);
+ sysProp.addSubMessage(SystemPropertiesProto::AAC_DRC, &aacDrc);
+
+ Table aaudioTable(SystemPropertiesProto::Aaudio::_FIELD_NAMES,
SystemPropertiesProto::Aaudio::_FIELD_IDS,
SystemPropertiesProto::Aaudio::_FIELD_COUNT);
- Message aaudio(&aaudioT);
+ Message aaudio(&aaudioTable);
sysProp.addSubMessage(SystemPropertiesProto::AAUDIO, &aaudio);
Table cameraTable(SystemPropertiesProto::Camera::_FIELD_NAMES,
@@ -142,8 +148,13 @@ SystemPropertiesParser::Parse(const int in, const int out) const
SystemPropertiesProto::Ro::Product::_FIELD_IDS,
SystemPropertiesProto::Ro::Product::_FIELD_COUNT);
Message product(&productTable);
- ro.addSubMessage(SystemPropertiesProto::Ro::PRODUCT, &product);
+ Table vendorTable(SystemPropertiesProto::Ro::Product::Vendor::_FIELD_NAMES,
+ SystemPropertiesProto::Ro::Product::Vendor::_FIELD_IDS,
+ SystemPropertiesProto::Ro::Product::Vendor::_FIELD_COUNT);
+ Message vendor(&vendorTable);
+ product.addSubMessage(SystemPropertiesProto::Ro::Product::VENDOR, &vendor);
+ ro.addSubMessage(SystemPropertiesProto::Ro::PRODUCT, &product);
sysProp.addSubMessage(SystemPropertiesProto::RO, &ro);
Table sysTable(SystemPropertiesProto::Sys::_FIELD_NAMES,
diff --git a/cmds/incident_helper/testdata/system_properties.txt b/cmds/incident_helper/testdata/system_properties.txt
index 51a2dfd96869..bf7d4ad5a844 100644
--- a/cmds/incident_helper/testdata/system_properties.txt
+++ b/cmds/incident_helper/testdata/system_properties.txt
@@ -1,3 +1,4 @@
+[aac_drc_cut]: [123]
[aaudio.hw_burst_min_usec]: [2000]
[aaudio.mmap_exclusive_policy]: [2]
[dalvik.vm.appimageformat]: [lz4]
@@ -10,4 +11,6 @@
[ro.bootimage.build.fingerprint]: [google/marlin/marlin:P/MASTER/jinyithu10301320:eng/dev-keys]
[ro.hardware]: [marlin]
[ro.hardware.power]: [marlin-profile]
+[ro.product.cpu.abilist]: [arm64-v8a,armeabi-v7a,armeabi]
+[ro.product.vendor.brand]: [google]
[ro.wifi.channels]: []
diff --git a/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp b/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp
index 98838e98d796..1180f64d05ac 100644
--- a/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp
+++ b/cmds/incident_helper/tests/SystemPropertiesParser_test.cpp
@@ -61,38 +61,33 @@ TEST_F(SystemPropertiesParserTest, HasSwapInfo) {
SystemPropertiesParser parser;
SystemPropertiesProto expected;
- SystemPropertiesProto::Aaudio* aaudio = expected.mutable_aaudio();
- aaudio->set_hw_burst_min_usec(2000);
- aaudio->set_mmap_exclusive_policy(2);
-
- SystemPropertiesProto::DalvikVm* dalvikVm = expected.mutable_dalvik_vm();
- dalvikVm->set_appimageformat("lz4");
-
+ expected.mutable_aac_drc()->set_cut(123);
+ expected.mutable_aaudio()->set_hw_burst_min_usec(2000);
+ expected.mutable_aaudio()->set_mmap_exclusive_policy(2);
+ expected.mutable_dalvik_vm()->set_appimageformat("lz4");
expected.set_drm_64bit_enabled(false);
-
- SystemPropertiesProto::InitSvc* initSvc = expected.mutable_init_svc();
- initSvc->set_adbd(SystemPropertiesProto_InitSvc_Status_STATUS_RUNNING);
- initSvc->set_lmkd(SystemPropertiesProto_InitSvc_Status_STATUS_STOPPED);
-
+ expected.mutable_init_svc()->set_adbd(
+ SystemPropertiesProto_InitSvc_Status_STATUS_RUNNING);
+ expected.mutable_init_svc()->set_lmkd(
+ SystemPropertiesProto_InitSvc_Status_STATUS_STOPPED);
expected.set_media_mediadrmservice_enable(true);
SystemPropertiesProto::Ro* ro = expected.mutable_ro();
-
- SystemPropertiesProto::Ro::Boot* boot = ro->mutable_boot();
- boot->add_boottime("1BLL:85");
- boot->add_boottime("1BLE:898");
- boot->add_boottime("2BLL:0");
- boot->add_boottime("2BLE:862");
- boot->add_boottime("SW:6739");
- boot->add_boottime("KL:340");
-
- SystemPropertiesProto::Ro::BootImage* bootimage = ro->mutable_bootimage();
- bootimage->set_build_date_utc(1509394807LL);
- bootimage->set_build_fingerprint("google/marlin/marlin:P/MASTER/jinyithu10301320:eng/dev-keys");
-
- SystemPropertiesProto::Ro::Hardware* hardware = ro->mutable_hardware();
- hardware->set_value("marlin");
- hardware->set_power("marlin-profile");
+ ro->mutable_boot()->add_boottime("1BLL:85");
+ ro->mutable_boot()->add_boottime("1BLE:898");
+ ro->mutable_boot()->add_boottime("2BLL:0");
+ ro->mutable_boot()->add_boottime("2BLE:862");
+ ro->mutable_boot()->add_boottime("SW:6739");
+ ro->mutable_boot()->add_boottime("KL:340");
+ ro->mutable_bootimage()->set_build_date_utc(1509394807LL);
+ ro->mutable_bootimage()->set_build_fingerprint(
+ "google/marlin/marlin:P/MASTER/jinyithu10301320:eng/dev-keys");
+ ro->mutable_hardware()->set_value("marlin");
+ ro->mutable_hardware()->set_power("marlin-profile");
+ ro->mutable_product()->add_cpu_abilist("arm64-v8a");
+ ro->mutable_product()->add_cpu_abilist("armeabi-v7a");
+ ro->mutable_product()->add_cpu_abilist("armeabi");
+ ro->mutable_product()->mutable_vendor()->set_brand("google");
int fd = open(testFile.c_str(), O_RDONLY);
ASSERT_TRUE(fd != -1);
diff --git a/core/proto/android/os/system_properties.proto b/core/proto/android/os/system_properties.proto
index 7ffdc9628cc6..76a108b1ac08 100644
--- a/core/proto/android/os/system_properties.proto
+++ b/core/proto/android/os/system_properties.proto
@@ -26,7 +26,7 @@ package android.os;
// Android Platform Exported System Properties
// TODO: This is not the completed list, new properties need to be whitelisted.
message SystemPropertiesProto {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
+ option (stream_proto.stream_msg).enable_fields_mapping_recursively = true;
// Properties that are not specified below would be appended here.
// These values stay on device only.
@@ -38,15 +38,16 @@ message SystemPropertiesProto {
}
repeated Property extra_properties = 1;
- optional int32 aac_drc_boost = 2;
- optional int32 aac_drc_cut = 3;
- optional int32 aac_drc_enc_target_level = 4;
- optional int32 aac_drc_heavy = 5;
- optional int32 aac_drc_reference_level = 6;
+ message AacDrc {
+ optional int32 boost = 1;
+ optional int32 cut = 2;
+ optional int32 enc_target_level = 3;
+ optional int32 heavy = 4;
+ optional int32 reference_level = 5;
+ }
+ optional AacDrc aac_drc = 2;
message Aaudio {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional int32 hw_burst_min_usec = 1;
optional int32 minimum_sleep_usec = 2;
optional int32 mixer_bursts = 3;
@@ -56,23 +57,19 @@ message SystemPropertiesProto {
// Next Tag: 7
}
- optional Aaudio aaudio = 7;
+ optional Aaudio aaudio = 3;
- optional int32 af_fast_track_multiplier = 8;
+ optional int32 af_fast_track_multiplier = 4;
message Camera {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional bool disable_zsl_mode = 1;
optional int32 fifo_disable = 2;
// Next Tag: 3
}
- optional Camera camera = 9;
+ optional Camera camera = 5;
message DalvikVm {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string appimageformat = 1;
optional string backgroundgctype = 2;
optional bool checkjni = 3;
@@ -130,17 +127,15 @@ message SystemPropertiesProto {
// Next Tag: 55
}
- optional DalvikVm dalvik_vm = 10;
+ optional DalvikVm dalvik_vm = 6;
- optional bool drm_64bit_enabled = 11;
- optional bool drm_service_enabled = 12;
- optional bool dumpstate_dry_run = 13;
- optional string gsm_sim_operator_numeric = 14;
- optional bool hal_instrumentation_enable = 15;
+ optional bool drm_64bit_enabled = 7;
+ optional bool drm_service_enabled = 8;
+ optional bool dumpstate_dry_run = 9;
+ optional string gsm_sim_operator_numeric = 10;
+ optional bool hal_instrumentation_enable = 11;
message InitSvc {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
enum Status {
STATUS_UNKNOWN = 0;
STATUS_RUNNING = 1;
@@ -190,28 +185,24 @@ message SystemPropertiesProto {
// Next Tag: 42
}
- optional InitSvc init_svc = 16;
+ optional InitSvc init_svc = 12;
- optional bool keyguard_no_require_sim = 17;
- optional string libc_debug_malloc_options = 18;
- optional string libc_debug_malloc_program = 19;
+ optional bool keyguard_no_require_sim = 13;
+ optional string libc_debug_malloc_options = 14;
+ optional string libc_debug_malloc_program = 15;
message Log {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string tag_WifiHAL = 1;
optional string tag_stats_log = 2;
// Next Tag: 3
}
- optional Log log = 20;
+ optional Log log = 16;
- optional bool media_mediadrmservice_enable = 21;
- optional bool media_recorder_show_manufacturer_and_model = 22;
+ optional bool media_mediadrmservice_enable = 17;
+ optional bool media_recorder_show_manufacturer_and_model = 18;
message Persist {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string config_calibration_fac = 1;
optional int32 dbg_volte_avail_ovr = 2;
optional int32 dbg_vt_avail_ovr = 3;
@@ -226,11 +217,9 @@ message SystemPropertiesProto {
// Next Tag: 12
}
- optional Persist persist = 23;
+ optional Persist persist = 19;
message PmDexopt {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string ab_ota = 1;
optional string bg_dexopt = 2;
optional string boot = 3;
@@ -239,11 +228,9 @@ message SystemPropertiesProto {
// Next Tag: 6
}
- optional PmDexopt pm_dexopt = 24;
+ optional PmDexopt pm_dexopt = 20;
message Ro {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional int32 adb_secure = 1;
optional string arch = 2;
optional bool audio_ignore_effects = 3;
@@ -252,8 +239,6 @@ message SystemPropertiesProto {
optional string board_platform = 6;
message Boot {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string avb_version = 1;
optional string baseband = 2;
optional string bootdevice = 3;
@@ -280,8 +265,6 @@ message SystemPropertiesProto {
optional Boot boot = 7;
message BootImage {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string build_date = 1;
optional int32 build_date_utc = 2;
optional string build_fingerprint = 3;
@@ -294,8 +277,6 @@ message SystemPropertiesProto {
optional string bootmode = 10;
message Build {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string date = 1;
optional int32 date_utc = 2;
optional string description = 3;
@@ -309,15 +290,13 @@ message SystemPropertiesProto {
optional string user = 11;
message Version {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
- optional string version_base_os = 1;
- optional string version_codename = 2;
- optional string version_incremental = 3;
- optional int32 version_preview_sdk = 4;
- optional string version_release = 5;
- optional int32 version_sdk = 6;
- optional string version_security_patch = 7;
+ optional string base_os = 1;
+ optional string codename = 2;
+ optional string incremental = 3;
+ optional int32 preview_sdk = 4;
+ optional string release = 5;
+ optional int32 sdk = 6;
+ optional string security_patch = 7;
// Next Tag: 8
}
@@ -334,8 +313,6 @@ message SystemPropertiesProto {
optional string com_google_clientidbase = 16;
message Config {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string alarm_alert = 1;
optional int32 media_vol_steps = 2;
optional string notification_sound = 3;
@@ -357,8 +334,6 @@ message SystemPropertiesProto {
optional string gfx_driver_0 = 26;
message Hardware {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string value = 1; // value of ro.hardware itself
optional string activity_recognition = 2;
@@ -410,26 +385,28 @@ message SystemPropertiesProto {
optional int32 opengles_version = 31;
message Product {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string board = 1;
optional string brand = 2;
optional string cpu_abi = 3;
- optional string cpu_abilist = 4;
- optional string cpu_abilist32 = 5;
- optional string cpu_abilist64 = 6;
+ repeated string cpu_abilist = 4;
+ repeated string cpu_abilist32 = 5;
+ repeated string cpu_abilist64 = 6;
optional string device = 7;
optional int32 first_api_level = 8;
optional string manufacturer = 9;
optional string model = 10;
optional string name = 11;
- optional string vendor_brand = 12;
- optional string vendor_device = 13;
- optional string vendor_manufacturer = 14;
- optional string vendor_model = 15;
- optional string vendor_name = 16;
- // Next Tag: 17
+ message Vendor {
+ optional string brand = 1;
+ optional string device = 2;
+ optional string manufacturer = 3;
+ optional string model = 4;
+ optional string name = 5;
+ }
+ optional Vendor vendor = 12;
+
+ // Next Tag: 13
}
optional Product product = 32;
@@ -452,22 +429,18 @@ message SystemPropertiesProto {
// Next Tag: 49
}
- optional Ro ro = 25;
+ optional Ro ro = 21;
- optional string sendbug_preferred_domain = 26;
- optional int32 service_bootanim_exit = 27;
+ optional string sendbug_preferred_domain = 22;
+ optional int32 service_bootanim_exit = 23;
message Sys {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional int32 boot_completed = 1;
optional int32 boot_from_charger_mode = 2;
optional int32 retaildemo_enabled = 3;
optional string shutdown_requested = 4;
message Usb {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional string config = 1;
optional int32 configfs = 2;
optional string controller = 3;
@@ -484,16 +457,16 @@ message SystemPropertiesProto {
// Next Tag: 6
}
- optional Sys sys = 28;
+ optional Sys sys = 24;
- optional int32 telephony_lteOnCdmaDevice = 29;
- optional int32 tombstoned_max_tombstone_count = 30;
- optional string vold_decrypt = 31;
- optional int32 vold_post_fs_data_done = 32;
- optional int32 vts_native_server_on = 33;
- optional string wifi_direct_interface = 34;
- optional string wifi_interface = 35;
+ optional int32 telephony_lteOnCdmaDevice = 25;
+ optional int32 tombstoned_max_tombstone_count = 26;
+ optional string vold_decrypt = 27;
+ optional int32 vold_post_fs_data_done = 28;
+ optional int32 vts_native_server_on = 29;
+ optional string wifi_direct_interface = 30;
+ optional string wifi_interface = 31;
- // Next Tag: 36
+ // Next Tag: 32
}
diff --git a/tools/streaming_proto/cpp/main.cpp b/tools/streaming_proto/cpp/main.cpp
index 477902065f99..745b3dc51181 100644
--- a/tools/streaming_proto/cpp/main.cpp
+++ b/tools/streaming_proto/cpp/main.cpp
@@ -85,11 +85,17 @@ should_generate_fields_mapping(const DescriptorProto& message)
return message.options().GetExtension(stream_msg).enable_fields_mapping();
}
+static inline bool
+should_generate_fields_mapping_recursively(const DescriptorProto& message) {
+ return message.options().GetExtension(stream_msg).enable_fields_mapping_recursively();
+}
+
static void
-write_message(stringstream& text, const DescriptorProto& message, const string& indent)
+write_message(stringstream& text, const DescriptorProto& message, const string& indent, bool genMapping)
{
int N;
const string indented = indent + INDENT;
+ genMapping |= should_generate_fields_mapping_recursively(message);
text << indent << "// message " << message.name() << endl;
text << indent << "namespace " << message.name() << " {" << endl;
@@ -103,7 +109,7 @@ write_message(stringstream& text, const DescriptorProto& message, const string&
// Nested classes
N = message.nested_type_size();
for (int i=0; i<N; i++) {
- write_message(text, message.nested_type(i), indented);
+ write_message(text, message.nested_type(i), indented, genMapping);
}
// Fields
@@ -112,7 +118,7 @@ write_message(stringstream& text, const DescriptorProto& message, const string&
write_field(text, message.field(i), indented);
}
- if (should_generate_fields_mapping(message)) {
+ if (genMapping | should_generate_fields_mapping(message)) {
N = message.field_size();
text << indented << "const int _FIELD_COUNT = " << N << ";" << endl;
text << indented << "const char* _FIELD_NAMES[" << N << "] = {" << endl;
@@ -161,7 +167,7 @@ write_header_file(CodeGeneratorResponse* response, const FileDescriptorProto& fi
N = file_descriptor.message_type_size();
for (size_t i=0; i<N; i++) {
- write_message(text, file_descriptor.message_type(i), "");
+ write_message(text, file_descriptor.message_type(i), "", false);
}
for (vector<string>::iterator it = namespaces.begin(); it != namespaces.end(); it++) {
diff --git a/tools/streaming_proto/stream.proto b/tools/streaming_proto/stream.proto
index c08120986cc7..e9b24a8a5824 100644
--- a/tools/streaming_proto/stream.proto
+++ b/tools/streaming_proto/stream.proto
@@ -24,6 +24,9 @@ package android.stream_proto;
message MessageOptions {
// creates a mapping of field names of the message to its field ids
optional bool enable_fields_mapping = 1;
+
+ // creates mapping between field names to its field ids and recursively for its submessages.
+ optional bool enable_fields_mapping_recursively = 2;
}
extend google.protobuf.MessageOptions {