summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Jin <jinyithu@google.com>2017-12-18 15:55:19 -0800
committerYi Jin <jinyithu@google.com>2017-12-18 17:37:50 -0800
commitf68e747e05628c0d2544080aa7c8cc8e68eeae29 (patch)
tree10917fec1af65c090458259ca6bc93ffb40b5542
parent39b4499d943d2a078b7c7ca2936908d7aac719d1 (diff)
Remove stream.proto and cpp-streaming-proto generates field name to id
mapping by default Test: atest incident_helper_test Change-Id: Iab04973ea78b942e44503fcd6ae60808caf3b9e0
-rw-r--r--Android.bp1
-rw-r--r--Android.mk1
-rw-r--r--core/proto/android/os/cpuinfo.proto14
-rw-r--r--core/proto/android/os/kernelwake.proto4
-rw-r--r--core/proto/android/os/pagetypeinfo.proto3
-rw-r--r--core/proto/android/os/procrank.proto2
-rw-r--r--core/proto/android/os/system_properties.proto2
-rw-r--r--tools/streaming_proto/Android.bp21
-rw-r--r--tools/streaming_proto/cpp/main.cpp32
-rw-r--r--tools/streaming_proto/stream.proto45
10 files changed, 7 insertions, 118 deletions
diff --git a/Android.bp b/Android.bp
index a5bbb1825ae1..d84cfb4dfc39 100644
--- a/Android.bp
+++ b/Android.bp
@@ -693,7 +693,6 @@ cc_library {
srcs: [
"core/proto/**/*.proto",
"libs/incident/**/*.proto",
- "tools/streaming_proto/stream.proto",
],
target: {
diff --git a/Android.mk b/Android.mk
index 103536297838..ec8c346d1ae5 100644
--- a/Android.mk
+++ b/Android.mk
@@ -999,7 +999,6 @@ LOCAL_PROTOC_FLAGS := \
-Iexternal/protobuf/src
LOCAL_SOURCE_FILES_ALL_GENERATED := true
LOCAL_SRC_FILES := \
- tools/streaming_proto/stream.proto \
cmds/am/proto/instrumentation_data.proto \
$(call all-proto-files-under, core/proto) \
$(call all-proto-files-under, libs/incident/proto) \
diff --git a/core/proto/android/os/cpuinfo.proto b/core/proto/android/os/cpuinfo.proto
index a95fa57ac2b2..522ff24c1e60 100644
--- a/core/proto/android/os/cpuinfo.proto
+++ b/core/proto/android/os/cpuinfo.proto
@@ -18,8 +18,6 @@ syntax = "proto2";
option java_multiple_files = true;
option java_outer_classname = "CpuInfoProto";
-import "frameworks/base/tools/streaming_proto/stream.proto";
-
package android.os;
/**
@@ -31,8 +29,6 @@ package android.os;
message CpuInfo {
message TaskStats {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional int32 total = 1; // total number of cpu tasks
optional int32 running = 2; // number of running tasks
optional int32 sleeping = 3; // number of sleeping tasks
@@ -42,8 +38,6 @@ message CpuInfo {
optional TaskStats task_stats = 1;
message MemStats { // unit in kB
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional int32 total = 1;
optional int32 used = 2;
optional int32 free = 3;
@@ -54,8 +48,6 @@ message CpuInfo {
optional MemStats swap = 3;
message CpuUsage { // unit is percentage %
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional int32 cpu = 1; // 400% cpu indicates 4 cores
optional int32 user = 2;
optional int32 nice = 3;
@@ -70,8 +62,6 @@ message CpuInfo {
// Next Tag: 13
message Task {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
optional int32 pid = 1;
optional int32 tid = 2;
optional string user = 3;
@@ -80,8 +70,6 @@ message CpuInfo {
optional float cpu = 6; // precentage of cpu usage of the task
enum Status {
- option (stream_proto.stream_enum).enable_enums_mapping = true;
-
STATUS_UNKNOWN = 0;
STATUS_D = 1; // uninterruptible sleep
STATUS_R = 2; // running
@@ -95,8 +83,6 @@ message CpuInfo {
// How Android memory manager will treat the task
enum Policy {
- option (stream_proto.stream_enum).enable_enums_mapping = true;
-
POLICY_UNKNOWN = 0;
POLICY_fg = 1; // foreground, the name is lower case for parsing the value
POLICY_bg = 2; // background, the name is lower case for parsing the value
diff --git a/core/proto/android/os/kernelwake.proto b/core/proto/android/os/kernelwake.proto
index eaad37af2ebc..7e5be9d39f69 100644
--- a/core/proto/android/os/kernelwake.proto
+++ b/core/proto/android/os/kernelwake.proto
@@ -18,8 +18,6 @@ syntax = "proto2";
option java_multiple_files = true;
option java_outer_classname = "WakeupSourcesProto";
-import "frameworks/base/tools/streaming_proto/stream.proto";
-
package android.os;
message KernelWakeSources {
@@ -29,8 +27,6 @@ message KernelWakeSources {
// Next Tag: 11
message WakeupSourceProto {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
-
// Name of the event which triggers application processor
optional string name = 1;
diff --git a/core/proto/android/os/pagetypeinfo.proto b/core/proto/android/os/pagetypeinfo.proto
index b86ee01f31b7..f82ea7672879 100644
--- a/core/proto/android/os/pagetypeinfo.proto
+++ b/core/proto/android/os/pagetypeinfo.proto
@@ -18,8 +18,6 @@ syntax = "proto2";
option java_multiple_files = true;
option java_outer_classname = "PageTypeInfoProto";
-import "frameworks/base/tools/streaming_proto/stream.proto";
-
package android.os;
/*
@@ -63,7 +61,6 @@ message MigrateTypeProto {
// Next tag: 9
message BlockProto {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
optional int32 node = 1;
diff --git a/core/proto/android/os/procrank.proto b/core/proto/android/os/procrank.proto
index f684c84c12e9..204a5af70947 100644
--- a/core/proto/android/os/procrank.proto
+++ b/core/proto/android/os/procrank.proto
@@ -19,7 +19,6 @@ option java_multiple_files = true;
option java_outer_classname = "ProcrankProto";
import "frameworks/base/libs/incident/proto/android/privacy.proto";
-import "frameworks/base/tools/streaming_proto/stream.proto";
package android.os;
@@ -36,7 +35,6 @@ message Procrank {
// Next Tag: 11
message ProcessProto {
- option (stream_proto.stream_msg).enable_fields_mapping = true;
option (android.msg_privacy).dest = DEST_AUTOMATIC;
// ID of the process
diff --git a/core/proto/android/os/system_properties.proto b/core/proto/android/os/system_properties.proto
index 76a108b1ac08..a51253f550c2 100644
--- a/core/proto/android/os/system_properties.proto
+++ b/core/proto/android/os/system_properties.proto
@@ -19,14 +19,12 @@ syntax = "proto2";
option java_multiple_files = true;
import "frameworks/base/libs/incident/proto/android/privacy.proto";
-import "frameworks/base/tools/streaming_proto/stream.proto";
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_recursively = true;
// Properties that are not specified below would be appended here.
// These values stay on device only.
diff --git a/tools/streaming_proto/Android.bp b/tools/streaming_proto/Android.bp
index 4e9391db9a5b..1121eadca967 100644
--- a/tools/streaming_proto/Android.bp
+++ b/tools/streaming_proto/Android.bp
@@ -32,26 +32,6 @@ cc_defaults {
shared_libs: ["libprotoc"],
}
-cc_library {
- name: "streamingflags",
- host_supported: true,
- proto: {
- export_proto_headers: true,
- include_dirs: ["external/protobuf/src"],
- },
-
- target: {
- host: {
- proto: {
- type: "full",
- },
- srcs: [
- "stream.proto",
- ],
- },
- },
-}
-
cc_binary_host {
name: "protoc-gen-javastream",
srcs: [
@@ -68,5 +48,4 @@ cc_binary_host {
],
defaults: ["protoc-gen-stream-defaults"],
- static_libs: ["streamingflags"],
}
diff --git a/tools/streaming_proto/cpp/main.cpp b/tools/streaming_proto/cpp/main.cpp
index 745b3dc51181..d6b9d81137ac 100644
--- a/tools/streaming_proto/cpp/main.cpp
+++ b/tools/streaming_proto/cpp/main.cpp
@@ -2,8 +2,6 @@
#include "stream_proto_utils.h"
#include "string_utils.h"
-#include <frameworks/base/tools/streaming_proto/stream.pb.h>
-
#include <iomanip>
#include <iostream>
#include <sstream>
@@ -12,18 +10,14 @@ using namespace android::stream_proto;
using namespace google::protobuf::io;
using namespace std;
+const bool GENERATE_MAPPING = true;
+
static string
make_filename(const FileDescriptorProto& file_descriptor)
{
return file_descriptor.name() + ".h";
}
-static inline bool
-should_generate_enums_mapping(const EnumDescriptorProto& enu)
-{
- return enu.options().GetExtension(stream_enum).enable_enums_mapping();
-}
-
static void
write_enum(stringstream& text, const EnumDescriptorProto& enu, const string& indent)
{
@@ -36,7 +30,7 @@ write_enum(stringstream& text, const EnumDescriptorProto& enu, const string& ind
<< " = " << value.number() << ";" << endl;
}
- if (should_generate_enums_mapping(enu)) {
+ if (GENERATE_MAPPING) {
string name = make_constant_name(enu.name());
string prefix = name + "_";
text << indent << "const int _ENUM_" << name << "_COUNT = " << N << ";" << endl;
@@ -79,23 +73,11 @@ write_field(stringstream& text, const FieldDescriptorProto& field, const string&
text << endl;
}
-static inline bool
-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, bool genMapping)
+write_message(stringstream& text, const DescriptorProto& message, const string& indent)
{
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;
@@ -109,7 +91,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, genMapping);
+ write_message(text, message.nested_type(i), indented);
}
// Fields
@@ -118,7 +100,7 @@ write_message(stringstream& text, const DescriptorProto& message, const string&
write_field(text, message.field(i), indented);
}
- if (genMapping | should_generate_fields_mapping(message)) {
+ if (GENERATE_MAPPING) {
N = message.field_size();
text << indented << "const int _FIELD_COUNT = " << N << ";" << endl;
text << indented << "const char* _FIELD_NAMES[" << N << "] = {" << endl;
@@ -167,7 +149,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), "", false);
+ write_message(text, file_descriptor.message_type(i), "");
}
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
deleted file mode 100644
index e9b24a8a5824..000000000000
--- a/tools/streaming_proto/stream.proto
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-syntax = "proto2";
-
-import "google/protobuf/descriptor.proto";
-
-package android.stream_proto;
-
-// This option tells streaming proto plugin to compile .proto files with extra features.
-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 {
- // Flags used by streaming proto plugins
- optional MessageOptions stream_msg = 126856794;
-}
-
-message EnumOptions {
- // creates a mapping of enum names to its values, strip its prefix enum type for each value
- optional bool enable_enums_mapping = 1;
-}
-
-extend google.protobuf.EnumOptions {
- // Flags used by streaming proto plugins
- optional EnumOptions stream_enum = 126856794;
-}