Merge "allow use of atom definition outside of atoms.proto in pulled atoms"

This commit is contained in:
Chenjie Yu
2018-09-11 22:00:53 +00:00
committed by Android (Google) Code Review
5 changed files with 19 additions and 7 deletions

View File

@@ -46,6 +46,7 @@ cc_library_host_shared {
// ==== java proto device library (for test only) ==============================
java_library {
name: "statsdprotolite",
no_framework_libs: true,
proto: {
type: "lite",
include_dirs: ["external/protobuf/src"],

View File

@@ -30,6 +30,7 @@ import "frameworks/base/core/proto/android/telecomm/enums.proto";
import "frameworks/base/core/proto/android/telephony/enums.proto";
import "frameworks/base/core/proto/android/view/enums.proto";
import "frameworks/base/proto/src/stats_enums.proto";
import "frameworks/base/core/proto/android/service/procstats.proto";
/**
* The master atom class. This message defines all of the available
@@ -165,6 +166,7 @@ message Atom {
DirectoryUsage directory_usage = 10026;
AppSize app_size = 10027;
CategorySize category_size = 10028;
android.service.procstats.ProcessStatsSectionProto proc_stats = 10029;
}
// DO NOT USE field numbers above 100,000 in AOSP. Field numbers above

View File

@@ -195,9 +195,11 @@ int collate_atom(const Descriptor *atom, AtomDecl *atomDecl,
print_error(field, "Unkown type for field: %s\n", field->name().c_str());
errorCount++;
continue;
} else if (javaType == JAVA_TYPE_OBJECT) {
} else if (javaType == JAVA_TYPE_OBJECT &&
atomDecl->code < PULL_ATOM_START_ID) {
// Allow attribution chain, but only at position 1.
print_error(field, "Message type not allowed for field: %s\n",
print_error(field,
"Message type not allowed for field in pushed atoms: %s\n",
field->name().c_str());
errorCount++;
continue;
@@ -233,12 +235,19 @@ int collate_atom(const Descriptor *atom, AtomDecl *atomDecl,
java_type_t javaType = java_type(field);
AtomField atField(field->name(), javaType);
// Generate signature for pushed atoms
if (atomDecl->code < PULL_ATOM_START_ID) {
if (javaType == JAVA_TYPE_ENUM) {
// All enums are treated as ints when it comes to function signatures.
signature->push_back(JAVA_TYPE_INT);
collate_enums(*field->enum_type(), &atField);
} else {
signature->push_back(javaType);
}
}
if (javaType == JAVA_TYPE_ENUM) {
// All enums are treated as ints when it comes to function signatures.
signature->push_back(JAVA_TYPE_INT);
collate_enums(*field->enum_type(), &atField);
} else {
signature->push_back(javaType);
}
atomDecl->fields.push_back(atField);

View File

@@ -34,6 +34,8 @@ using std::vector;
using google::protobuf::Descriptor;
using google::protobuf::FieldDescriptor;
const int PULL_ATOM_START_ID = 10000;
/**
* The types for atom parameters.
*/

View File

@@ -18,8 +18,6 @@ using namespace std;
namespace android {
namespace stats_log_api_gen {
const int PULL_ATOM_START_ID = 1000;
int maxPushedAtomId = 2;
using android::os::statsd::Atom;