Merge "Remove libstatsmetadata" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
271cbbd708
@@ -116,7 +116,6 @@ cc_defaults {
|
|||||||
"libcutils",
|
"libcutils",
|
||||||
"libgtest_prod",
|
"libgtest_prod",
|
||||||
"libprotoutil",
|
"libprotoutil",
|
||||||
"libstatsmetadata",
|
|
||||||
"libstatslog_statsd",
|
"libstatslog_statsd",
|
||||||
"libsysutils",
|
"libsysutils",
|
||||||
"libutils",
|
"libutils",
|
||||||
@@ -129,51 +128,6 @@ cc_defaults {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
// ================
|
|
||||||
// libstatsmetadata
|
|
||||||
// ================
|
|
||||||
|
|
||||||
genrule {
|
|
||||||
name: "atoms_info.h",
|
|
||||||
tools: ["stats-log-api-gen"],
|
|
||||||
cmd: "$(location stats-log-api-gen) --atomsInfoHeader $(genDir)/atoms_info.h",
|
|
||||||
out: [
|
|
||||||
"atoms_info.h",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
genrule {
|
|
||||||
name: "atoms_info.cpp",
|
|
||||||
tools: ["stats-log-api-gen"],
|
|
||||||
cmd: "$(location stats-log-api-gen) --atomsInfoCpp $(genDir)/atoms_info.cpp",
|
|
||||||
out: [
|
|
||||||
"atoms_info.cpp",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_library_static {
|
|
||||||
name: "libstatsmetadata",
|
|
||||||
host_supported: true,
|
|
||||||
generated_sources: [
|
|
||||||
"atoms_info.cpp",
|
|
||||||
],
|
|
||||||
generated_headers: [
|
|
||||||
"atoms_info.h",
|
|
||||||
],
|
|
||||||
cflags: [
|
|
||||||
"-Wall",
|
|
||||||
"-Werror",
|
|
||||||
],
|
|
||||||
export_generated_headers: [
|
|
||||||
"atoms_info.h",
|
|
||||||
],
|
|
||||||
apex_available: [
|
|
||||||
//TODO(b/149782403): Remove this once statsd no longer links against libstatsmetadata
|
|
||||||
"com.android.os.statsd",
|
|
||||||
"test_com.android.os.statsd",
|
|
||||||
],
|
|
||||||
}
|
|
||||||
|
|
||||||
genrule {
|
genrule {
|
||||||
name: "statslog_statsd.h",
|
name: "statslog_statsd.h",
|
||||||
tools: ["stats-log-api-gen"],
|
tools: ["stats-log-api-gen"],
|
||||||
|
|||||||
@@ -110,8 +110,6 @@ extend google.protobuf.FieldOptions {
|
|||||||
|
|
||||||
optional LogMode log_mode = 50002 [default = MODE_AUTOMATIC];
|
optional LogMode log_mode = 50002 [default = MODE_AUTOMATIC];
|
||||||
|
|
||||||
optional bool allow_from_any_uid = 50003 [default = false];
|
|
||||||
|
|
||||||
repeated string module = 50004;
|
repeated string module = 50004;
|
||||||
|
|
||||||
optional bool truncate_timestamp = 50005 [default = false];
|
optional bool truncate_timestamp = 50005 [default = false];
|
||||||
|
|||||||
@@ -145,8 +145,7 @@ message Atom {
|
|||||||
PacketWakeupOccurred packet_wakeup_occurred = 44 [(module) = "framework"];
|
PacketWakeupOccurred packet_wakeup_occurred = 44 [(module) = "framework"];
|
||||||
WallClockTimeShifted wall_clock_time_shifted = 45 [(module) = "framework"];
|
WallClockTimeShifted wall_clock_time_shifted = 45 [(module) = "framework"];
|
||||||
AnomalyDetected anomaly_detected = 46 [(module) = "statsd"];
|
AnomalyDetected anomaly_detected = 46 [(module) = "statsd"];
|
||||||
AppBreadcrumbReported app_breadcrumb_reported =
|
AppBreadcrumbReported app_breadcrumb_reported = 47 [(module) = "statsd"];
|
||||||
47 [(allow_from_any_uid) = true, (module) = "statsd"];
|
|
||||||
AppStartOccurred app_start_occurred = 48 [(module) = "framework", (module) = "statsdtest"];
|
AppStartOccurred app_start_occurred = 48 [(module) = "framework", (module) = "statsdtest"];
|
||||||
AppStartCanceled app_start_canceled = 49 [(module) = "framework"];
|
AppStartCanceled app_start_canceled = 49 [(module) = "framework"];
|
||||||
AppStartFullyDrawn app_start_fully_drawn = 50 [(module) = "framework"];
|
AppStartFullyDrawn app_start_fully_drawn = 50 [(module) = "framework"];
|
||||||
@@ -157,7 +156,7 @@ message Atom {
|
|||||||
AppStartMemoryStateCaptured app_start_memory_state_captured = 55 [(module) = "framework"];
|
AppStartMemoryStateCaptured app_start_memory_state_captured = 55 [(module) = "framework"];
|
||||||
ShutdownSequenceReported shutdown_sequence_reported = 56 [(module) = "framework"];
|
ShutdownSequenceReported shutdown_sequence_reported = 56 [(module) = "framework"];
|
||||||
BootSequenceReported boot_sequence_reported = 57;
|
BootSequenceReported boot_sequence_reported = 57;
|
||||||
DaveyOccurred davey_occurred = 58 [(allow_from_any_uid) = true, (module) = "statsd"];
|
DaveyOccurred davey_occurred = 58 [(module) = "statsd"];
|
||||||
OverlayStateChanged overlay_state_changed =
|
OverlayStateChanged overlay_state_changed =
|
||||||
59 [(module) = "framework", (module) = "statsdtest"];
|
59 [(module) = "framework", (module) = "statsdtest"];
|
||||||
ForegroundServiceStateChanged foreground_service_state_changed
|
ForegroundServiceStateChanged foreground_service_state_changed
|
||||||
@@ -186,8 +185,7 @@ message Atom {
|
|||||||
WTFOccurred wtf_occurred = 80 [(module) = "framework"];
|
WTFOccurred wtf_occurred = 80 [(module) = "framework"];
|
||||||
LowMemReported low_mem_reported = 81 [(module) = "framework"];
|
LowMemReported low_mem_reported = 81 [(module) = "framework"];
|
||||||
GenericAtom generic_atom = 82;
|
GenericAtom generic_atom = 82;
|
||||||
KeyValuePairsAtom key_value_pairs_atom =
|
KeyValuePairsAtom key_value_pairs_atom = 83 [(module) = "framework", (module) = "statsd"];
|
||||||
83 [(allow_from_any_uid) = true, (module) = "framework", (module) = "statsd"];
|
|
||||||
VibratorStateChanged vibrator_state_changed = 84 [(module) = "framework"];
|
VibratorStateChanged vibrator_state_changed = 84 [(module) = "framework"];
|
||||||
DeferredJobStatsReported deferred_job_stats_reported = 85 [(module) = "framework"];
|
DeferredJobStatsReported deferred_job_stats_reported = 85 [(module) = "framework"];
|
||||||
ThermalThrottlingStateChanged thermal_throttling = 86 [deprecated=true];
|
ThermalThrottlingStateChanged thermal_throttling = 86 [deprecated=true];
|
||||||
@@ -317,7 +315,7 @@ message Atom {
|
|||||||
AssistGestureFeedbackReported assist_gesture_feedback_reported = 175 [(module) = "sysui"];
|
AssistGestureFeedbackReported assist_gesture_feedback_reported = 175 [(module) = "sysui"];
|
||||||
AssistGestureProgressReported assist_gesture_progress_reported = 176 [(module) = "sysui"];
|
AssistGestureProgressReported assist_gesture_progress_reported = 176 [(module) = "sysui"];
|
||||||
TouchGestureClassified touch_gesture_classified = 177 [(module) = "framework"];
|
TouchGestureClassified touch_gesture_classified = 177 [(module) = "framework"];
|
||||||
HiddenApiUsed hidden_api_used = 178 [(allow_from_any_uid) = true, (module) = "framework"];
|
HiddenApiUsed hidden_api_used = 178 [(module) = "framework"];
|
||||||
StyleUIChanged style_ui_changed = 179 [(module) = "sysui"];
|
StyleUIChanged style_ui_changed = 179 [(module) = "sysui"];
|
||||||
PrivacyIndicatorsInteracted privacy_indicators_interacted =
|
PrivacyIndicatorsInteracted privacy_indicators_interacted =
|
||||||
180 [(module) = "permissioncontroller"];
|
180 [(module) = "permissioncontroller"];
|
||||||
@@ -383,7 +381,7 @@ message Atom {
|
|||||||
UpdateEngineSuccessfulUpdateReported update_engine_successful_update_reported = 226;
|
UpdateEngineSuccessfulUpdateReported update_engine_successful_update_reported = 226;
|
||||||
CameraActionEvent camera_action_event = 227 [(module) = "framework"];
|
CameraActionEvent camera_action_event = 227 [(module) = "framework"];
|
||||||
AppCompatibilityChangeReported app_compatibility_change_reported =
|
AppCompatibilityChangeReported app_compatibility_change_reported =
|
||||||
228 [(allow_from_any_uid) = true, (module) = "framework"];
|
228 [(module) = "framework"];
|
||||||
PerfettoUploaded perfetto_uploaded = 229 [(module) = "perfetto"];
|
PerfettoUploaded perfetto_uploaded = 229 [(module) = "perfetto"];
|
||||||
VmsClientConnectionStateChanged vms_client_connection_state_changed =
|
VmsClientConnectionStateChanged vms_client_connection_state_changed =
|
||||||
230 [(module) = "car"];
|
230 [(module) = "car"];
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include <private/android_filesystem_config.h>
|
#include <private/android_filesystem_config.h>
|
||||||
|
|
||||||
#include "CountMetricProducer.h"
|
#include "CountMetricProducer.h"
|
||||||
#include "atoms_info.h"
|
|
||||||
#include "condition/CombinationConditionTracker.h"
|
#include "condition/CombinationConditionTracker.h"
|
||||||
#include "condition/SimpleConditionTracker.h"
|
#include "condition/SimpleConditionTracker.h"
|
||||||
#include "guardrail/StatsdStats.h"
|
#include "guardrail/StatsdStats.h"
|
||||||
@@ -372,13 +371,6 @@ void MetricsManager::onDumpReport(const int64_t dumpTimeStampNs,
|
|||||||
|
|
||||||
|
|
||||||
bool MetricsManager::checkLogCredentials(const LogEvent& event) {
|
bool MetricsManager::checkLogCredentials(const LogEvent& event) {
|
||||||
// TODO(b/154856835): Remove this check once we get whitelist from the config.
|
|
||||||
if (android::util::AtomsInfo::kWhitelistedAtoms.find(event.GetTagId()) !=
|
|
||||||
android::util::AtomsInfo::kWhitelistedAtoms.end())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mWhitelistedAtomIds.find(event.GetTagId()) != mWhitelistedAtomIds.end()) {
|
if (mWhitelistedAtomIds.find(event.GetTagId()) != mWhitelistedAtomIds.end()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ cc_binary_host {
|
|||||||
name: "stats-log-api-gen",
|
name: "stats-log-api-gen",
|
||||||
srcs: [
|
srcs: [
|
||||||
"Collation.cpp",
|
"Collation.cpp",
|
||||||
"atoms_info_writer.cpp",
|
|
||||||
"java_writer.cpp",
|
"java_writer.cpp",
|
||||||
"java_writer_q.cpp",
|
"java_writer_q.cpp",
|
||||||
"main.cpp",
|
"main.cpp",
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ AtomDecl::AtomDecl(const AtomDecl& that)
|
|||||||
defaultState(that.defaultState),
|
defaultState(that.defaultState),
|
||||||
triggerStateReset(that.triggerStateReset),
|
triggerStateReset(that.triggerStateReset),
|
||||||
nested(that.nested),
|
nested(that.nested),
|
||||||
uidField(that.uidField),
|
uidField(that.uidField) {
|
||||||
whitelisted(that.whitelisted),
|
|
||||||
truncateTimestamp(that.truncateTimestamp) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomDecl::AtomDecl(int c, const string& n, const string& m) : code(c), name(n), message(m) {
|
AtomDecl::AtomDecl(int c, const string& n, const string& m) : code(c), name(n), message(m) {
|
||||||
@@ -520,13 +518,6 @@ int collate_atoms(const Descriptor* descriptor, const string& moduleName, Atoms*
|
|||||||
shared_ptr<AtomDecl> atomDecl =
|
shared_ptr<AtomDecl> atomDecl =
|
||||||
make_shared<AtomDecl>(atomField->number(), atomField->name(), atom->name());
|
make_shared<AtomDecl>(atomField->number(), atomField->name(), atom->name());
|
||||||
|
|
||||||
if (atomField->options().GetExtension(os::statsd::allow_from_any_uid) == true) {
|
|
||||||
atomDecl->whitelisted = true;
|
|
||||||
if (dbg) {
|
|
||||||
printf("%s is whitelisted\n", atomField->name().c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (atomDecl->code < PULL_ATOM_START_ID &&
|
if (atomDecl->code < PULL_ATOM_START_ID &&
|
||||||
atomField->options().GetExtension(os::statsd::truncate_timestamp)) {
|
atomField->options().GetExtension(os::statsd::truncate_timestamp)) {
|
||||||
addAnnotationToAtomDecl(atomDecl.get(), ATOM_ID_FIELD_NUMBER,
|
addAnnotationToAtomDecl(atomDecl.get(), ATOM_ID_FIELD_NUMBER,
|
||||||
|
|||||||
@@ -164,10 +164,6 @@ struct AtomDecl {
|
|||||||
|
|
||||||
int uidField = 0;
|
int uidField = 0;
|
||||||
|
|
||||||
bool whitelisted = false;
|
|
||||||
|
|
||||||
bool truncateTimestamp = false;
|
|
||||||
|
|
||||||
AtomDecl();
|
AtomDecl();
|
||||||
AtomDecl(const AtomDecl& that);
|
AtomDecl(const AtomDecl& that);
|
||||||
AtomDecl(int code, const string& name, const string& message);
|
AtomDecl(int code, const string& name, const string& message);
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "atoms_info_writer.h"
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <set>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
namespace stats_log_api_gen {
|
|
||||||
|
|
||||||
static void write_atoms_info_header_body(FILE* out) {
|
|
||||||
fprintf(out, "struct AtomsInfo {\n");
|
|
||||||
fprintf(out, " const static std::set<int> kWhitelistedAtoms;\n");
|
|
||||||
fprintf(out, "};\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) {
|
|
||||||
|
|
||||||
fprintf(out, "const std::set<int> AtomsInfo::kWhitelistedAtoms = {\n");
|
|
||||||
for (AtomDeclSet::const_iterator atomIt = atoms.decls.begin(); atomIt != atoms.decls.end();
|
|
||||||
atomIt++) {
|
|
||||||
if ((*atomIt)->whitelisted) {
|
|
||||||
const string constant = make_constant_name((*atomIt)->name);
|
|
||||||
fprintf(out, " %d, // %s\n", (*atomIt)->code, constant.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(out, "};\n");
|
|
||||||
fprintf(out, "\n");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int write_atoms_info_header(FILE* out, const string& namespaceStr) {
|
|
||||||
// Print prelude
|
|
||||||
fprintf(out, "// This file is autogenerated\n");
|
|
||||||
fprintf(out, "\n");
|
|
||||||
fprintf(out, "#pragma once\n");
|
|
||||||
fprintf(out, "\n");
|
|
||||||
fprintf(out, "#include <vector>\n");
|
|
||||||
fprintf(out, "#include <map>\n");
|
|
||||||
fprintf(out, "#include <set>\n");
|
|
||||||
fprintf(out, "\n");
|
|
||||||
|
|
||||||
write_namespace(out, namespaceStr);
|
|
||||||
|
|
||||||
write_atoms_info_header_body(out);
|
|
||||||
|
|
||||||
fprintf(out, "\n");
|
|
||||||
write_closing_namespace(out, namespaceStr);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int write_atoms_info_cpp(FILE* out, const Atoms& atoms, const string& namespaceStr,
|
|
||||||
const string& importHeader) {
|
|
||||||
// Print prelude
|
|
||||||
fprintf(out, "// This file is autogenerated\n");
|
|
||||||
fprintf(out, "\n");
|
|
||||||
fprintf(out, "#include <%s>\n", importHeader.c_str());
|
|
||||||
fprintf(out, "\n");
|
|
||||||
|
|
||||||
write_namespace(out, namespaceStr);
|
|
||||||
|
|
||||||
write_atoms_info_cpp_body(out, atoms);
|
|
||||||
|
|
||||||
// Print footer
|
|
||||||
fprintf(out, "\n");
|
|
||||||
write_closing_namespace(out, namespaceStr);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace stats_log_api_gen
|
|
||||||
} // namespace android
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019, 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "Collation.h"
|
|
||||||
|
|
||||||
namespace android {
|
|
||||||
namespace stats_log_api_gen {
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
int write_atoms_info_cpp(FILE* out, const Atoms& atoms, const string& namespaceStr,
|
|
||||||
const string& importHeader);
|
|
||||||
|
|
||||||
int write_atoms_info_header(FILE* out, const string& namespaceStr);
|
|
||||||
|
|
||||||
} // namespace stats_log_api_gen
|
|
||||||
} // namespace android
|
|
||||||
@@ -9,7 +9,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Collation.h"
|
#include "Collation.h"
|
||||||
#include "atoms_info_writer.h"
|
|
||||||
#include "frameworks/base/cmds/statsd/src/atoms.pb.h"
|
#include "frameworks/base/cmds/statsd/src/atoms.pb.h"
|
||||||
#include "java_writer.h"
|
#include "java_writer.h"
|
||||||
#include "java_writer_q.h"
|
#include "java_writer_q.h"
|
||||||
@@ -30,12 +29,6 @@ static void print_usage() {
|
|||||||
fprintf(stderr, "OPTIONS\n");
|
fprintf(stderr, "OPTIONS\n");
|
||||||
fprintf(stderr, " --cpp FILENAME the header file to output for write helpers\n");
|
fprintf(stderr, " --cpp FILENAME the header file to output for write helpers\n");
|
||||||
fprintf(stderr, " --header FILENAME the cpp file to output for write helpers\n");
|
fprintf(stderr, " --header FILENAME the cpp file to output for write helpers\n");
|
||||||
fprintf(stderr,
|
|
||||||
" --atomsInfoCpp FILENAME the header file to output for "
|
|
||||||
"statsd metadata\n");
|
|
||||||
fprintf(stderr,
|
|
||||||
" --atomsInfoHeader FILENAME the cpp file to output for statsd "
|
|
||||||
"metadata\n");
|
|
||||||
fprintf(stderr, " --help this message\n");
|
fprintf(stderr, " --help this message\n");
|
||||||
fprintf(stderr, " --java FILENAME the java file to output\n");
|
fprintf(stderr, " --java FILENAME the java file to output\n");
|
||||||
fprintf(stderr, " --module NAME optional, module name to generate outputs for\n");
|
fprintf(stderr, " --module NAME optional, module name to generate outputs for\n");
|
||||||
@@ -49,10 +42,6 @@ static void print_usage() {
|
|||||||
" --importHeader NAME required for cpp/jni to say which header to "
|
" --importHeader NAME required for cpp/jni to say which header to "
|
||||||
"import "
|
"import "
|
||||||
"for write helpers\n");
|
"for write helpers\n");
|
||||||
fprintf(stderr,
|
|
||||||
" --atomsInfoImportHeader NAME required for cpp to say which "
|
|
||||||
"header to import "
|
|
||||||
"for statsd metadata\n");
|
|
||||||
fprintf(stderr, " --javaPackage PACKAGE the package for the java file.\n");
|
fprintf(stderr, " --javaPackage PACKAGE the package for the java file.\n");
|
||||||
fprintf(stderr, " required for java with module\n");
|
fprintf(stderr, " required for java with module\n");
|
||||||
fprintf(stderr, " --javaClass CLASS the class name of the java class.\n");
|
fprintf(stderr, " --javaClass CLASS the class name of the java class.\n");
|
||||||
@@ -74,15 +63,12 @@ static int run(int argc, char const* const* argv) {
|
|||||||
string cppFilename;
|
string cppFilename;
|
||||||
string headerFilename;
|
string headerFilename;
|
||||||
string javaFilename;
|
string javaFilename;
|
||||||
string atomsInfoCppFilename;
|
|
||||||
string atomsInfoHeaderFilename;
|
|
||||||
string javaPackage;
|
string javaPackage;
|
||||||
string javaClass;
|
string javaClass;
|
||||||
|
|
||||||
string moduleName = DEFAULT_MODULE_NAME;
|
string moduleName = DEFAULT_MODULE_NAME;
|
||||||
string cppNamespace = DEFAULT_CPP_NAMESPACE;
|
string cppNamespace = DEFAULT_CPP_NAMESPACE;
|
||||||
string cppHeaderImport = DEFAULT_CPP_HEADER_IMPORT;
|
string cppHeaderImport = DEFAULT_CPP_HEADER_IMPORT;
|
||||||
string atomsInfoCppHeaderImport = DEFAULT_ATOMS_INFO_CPP_HEADER_IMPORT;
|
|
||||||
bool supportQ = false;
|
bool supportQ = false;
|
||||||
bool supportWorkSource = false;
|
bool supportWorkSource = false;
|
||||||
bool compileQ = false;
|
bool compileQ = false;
|
||||||
@@ -148,27 +134,6 @@ static int run(int argc, char const* const* argv) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
javaClass = argv[index];
|
javaClass = argv[index];
|
||||||
} else if (0 == strcmp("--atomsInfoHeader", argv[index])) {
|
|
||||||
index++;
|
|
||||||
if (index >= argc) {
|
|
||||||
print_usage();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
atomsInfoHeaderFilename = argv[index];
|
|
||||||
} else if (0 == strcmp("--atomsInfoCpp", argv[index])) {
|
|
||||||
index++;
|
|
||||||
if (index >= argc) {
|
|
||||||
print_usage();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
atomsInfoCppFilename = argv[index];
|
|
||||||
} else if (0 == strcmp("--atomsInfoImportHeader", argv[index])) {
|
|
||||||
index++;
|
|
||||||
if (index >= argc) {
|
|
||||||
print_usage();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
atomsInfoCppHeaderImport = argv[index];
|
|
||||||
} else if (0 == strcmp("--supportQ", argv[index])) {
|
} else if (0 == strcmp("--supportQ", argv[index])) {
|
||||||
supportQ = true;
|
supportQ = true;
|
||||||
} else if (0 == strcmp("--worksource", argv[index])) {
|
} else if (0 == strcmp("--worksource", argv[index])) {
|
||||||
@@ -180,8 +145,7 @@ static int run(int argc, char const* const* argv) {
|
|||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cppFilename.size() == 0 && headerFilename.size() == 0 && javaFilename.size() == 0 &&
|
if (cppFilename.size() == 0 && headerFilename.size() == 0 && javaFilename.size() == 0) {
|
||||||
atomsInfoHeaderFilename.size() == 0 && atomsInfoCppFilename.size() == 0) {
|
|
||||||
print_usage();
|
print_usage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -210,29 +174,6 @@ static int run(int argc, char const* const* argv) {
|
|||||||
collate_atom(android::os::statsd::AttributionNode::descriptor(), &attributionDecl,
|
collate_atom(android::os::statsd::AttributionNode::descriptor(), &attributionDecl,
|
||||||
&attributionSignature);
|
&attributionSignature);
|
||||||
|
|
||||||
// Write the atoms info .cpp file
|
|
||||||
if (atomsInfoCppFilename.size() != 0) {
|
|
||||||
FILE* out = fopen(atomsInfoCppFilename.c_str(), "w");
|
|
||||||
if (out == NULL) {
|
|
||||||
fprintf(stderr, "Unable to open file for write: %s\n", atomsInfoCppFilename.c_str());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
errorCount = android::stats_log_api_gen::write_atoms_info_cpp(out, atoms, cppNamespace,
|
|
||||||
atomsInfoCppHeaderImport);
|
|
||||||
fclose(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the atoms info .h file
|
|
||||||
if (atomsInfoHeaderFilename.size() != 0) {
|
|
||||||
FILE* out = fopen(atomsInfoHeaderFilename.c_str(), "w");
|
|
||||||
if (out == NULL) {
|
|
||||||
fprintf(stderr, "Unable to open file for write: %s\n", atomsInfoHeaderFilename.c_str());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
errorCount = android::stats_log_api_gen::write_atoms_info_header(out, cppNamespace);
|
|
||||||
fclose(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the .cpp file
|
// Write the .cpp file
|
||||||
if (cppFilename.size() != 0) {
|
if (cppFilename.size() != 0) {
|
||||||
FILE* out = fopen(cppFilename.c_str(), "w");
|
FILE* out = fopen(cppFilename.c_str(), "w");
|
||||||
|
|||||||
@@ -187,24 +187,6 @@ message GoodStateAtom3 {
|
|||||||
optional int32 state = 3 [(android.os.statsd.state_field_option).exclusive_state = true];
|
optional int32 state = 3 [(android.os.statsd.state_field_option).exclusive_state = true];
|
||||||
}
|
}
|
||||||
|
|
||||||
message WhitelistedAtom {
|
|
||||||
optional int32 field = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message NonWhitelistedAtom {
|
|
||||||
optional int32 field = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ListedAtoms {
|
|
||||||
oneof event {
|
|
||||||
// Atoms can be whitelisted i.e. they can be triggered by any source
|
|
||||||
WhitelistedAtom whitelisted_atom = 1 [(android.os.statsd.allow_from_any_uid) = true];
|
|
||||||
// Atoms are not whitelisted by default, so they can only be triggered
|
|
||||||
// by whitelisted sources
|
|
||||||
NonWhitelistedAtom non_whitelisted_atom = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
message ModuleOneAtom {
|
message ModuleOneAtom {
|
||||||
optional int32 field = 1 [(android.os.statsd.is_uid) = true];
|
optional int32 field = 1 [(android.os.statsd.is_uid) = true];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,25 +225,6 @@ TEST(CollationTest, FailOnBadBinaryFieldAtom) {
|
|||||||
EXPECT_TRUE(errorCount > 0);
|
EXPECT_TRUE(errorCount > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CollationTest, PassOnWhitelistedAtom) {
|
|
||||||
Atoms atoms;
|
|
||||||
int errorCount = collate_atoms(ListedAtoms::descriptor(), DEFAULT_MODULE_NAME, &atoms);
|
|
||||||
EXPECT_EQ(errorCount, 0);
|
|
||||||
EXPECT_EQ(atoms.decls.size(), 2ul);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(CollationTest, RecogniseWhitelistedAtom) {
|
|
||||||
Atoms atoms;
|
|
||||||
collate_atoms(ListedAtoms::descriptor(), DEFAULT_MODULE_NAME, &atoms);
|
|
||||||
for (const auto& atomDecl : atoms.decls) {
|
|
||||||
if (atomDecl->code == 1) {
|
|
||||||
EXPECT_TRUE(atomDecl->whitelisted);
|
|
||||||
} else {
|
|
||||||
EXPECT_FALSE(atomDecl->whitelisted);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST(CollationTest, PassOnLogFromModuleAtom) {
|
TEST(CollationTest, PassOnLogFromModuleAtom) {
|
||||||
Atoms atoms;
|
Atoms atoms;
|
||||||
int errorCount = collate_atoms(ModuleAtoms::descriptor(), DEFAULT_MODULE_NAME, &atoms);
|
int errorCount = collate_atoms(ModuleAtoms::descriptor(), DEFAULT_MODULE_NAME, &atoms);
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ using namespace std;
|
|||||||
|
|
||||||
const string DEFAULT_CPP_NAMESPACE = "android,util";
|
const string DEFAULT_CPP_NAMESPACE = "android,util";
|
||||||
const string DEFAULT_CPP_HEADER_IMPORT = "statslog.h";
|
const string DEFAULT_CPP_HEADER_IMPORT = "statslog.h";
|
||||||
const string DEFAULT_ATOMS_INFO_CPP_HEADER_IMPORT = "atoms_info.h";
|
|
||||||
|
|
||||||
const int JAVA_MODULE_REQUIRES_FLOAT = 0x01;
|
const int JAVA_MODULE_REQUIRES_FLOAT = 0x01;
|
||||||
const int JAVA_MODULE_REQUIRES_ATTRIBUTION = 0x02;
|
const int JAVA_MODULE_REQUIRES_ATTRIBUTION = 0x02;
|
||||||
|
|||||||
Reference in New Issue
Block a user