allow use of atom definition outside of atoms.proto in pulled atoms
There will be followup cls to add support of new types that can be nested and repeated. + skip StatsLog.write signature generation for pulled atoms. Bug: 113872139 Test: manual test Change-Id: I69d0ee0b2fe8e286e48eac20ec2c8b280c477bf0
This commit is contained in:
@@ -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"],
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user