Remove libstatsmetadata
Remove kWhitelistedAtoms usage in MetricsManager and remove:
- atoms_info references from statsd
- libstatsmetadata usages from statsd
- libstatsmetadata library
- atoms_info_writer.h/.cpp
- references to atoms_info in rest of stats-log-api-gen
- allow_from_any_uid annotation
Fixes: 147600720
Fixes: 154856835
Fixes: 148993016
Test: m stats-log-api-gen
Test: m stats-log-api-gen-test &&
out/host/linux-x86/nativetest/stats-log-api-gen-test/stats-log-api-gen-test
Test: m statsd
Change-Id: I2e0579609ff257da934b95cdda397f3ca0ffa1f0
diff --git a/cmds/statsd/Android.bp b/cmds/statsd/Android.bp
index 3dbe413..0617eb6 100644
--- a/cmds/statsd/Android.bp
+++ b/cmds/statsd/Android.bp
@@ -116,7 +116,6 @@
"libcutils",
"libgtest_prod",
"libprotoutil",
- "libstatsmetadata",
"libstatslog_statsd",
"libsysutils",
"libutils",
@@ -129,51 +128,6 @@
],
}
-// ================
-// 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 {
name: "statslog_statsd.h",
tools: ["stats-log-api-gen"],
diff --git a/cmds/statsd/src/atom_field_options.proto b/cmds/statsd/src/atom_field_options.proto
index 8527185..ff5717e 100644
--- a/cmds/statsd/src/atom_field_options.proto
+++ b/cmds/statsd/src/atom_field_options.proto
@@ -110,8 +110,6 @@
optional LogMode log_mode = 50002 [default = MODE_AUTOMATIC];
- optional bool allow_from_any_uid = 50003 [default = false];
-
repeated string module = 50004;
optional bool truncate_timestamp = 50005 [default = false];
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index dc20a02..7a4c3b1 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -145,8 +145,7 @@
PacketWakeupOccurred packet_wakeup_occurred = 44 [(module) = "framework"];
WallClockTimeShifted wall_clock_time_shifted = 45 [(module) = "framework"];
AnomalyDetected anomaly_detected = 46 [(module) = "statsd"];
- AppBreadcrumbReported app_breadcrumb_reported =
- 47 [(allow_from_any_uid) = true, (module) = "statsd"];
+ AppBreadcrumbReported app_breadcrumb_reported = 47 [(module) = "statsd"];
AppStartOccurred app_start_occurred = 48 [(module) = "framework", (module) = "statsdtest"];
AppStartCanceled app_start_canceled = 49 [(module) = "framework"];
AppStartFullyDrawn app_start_fully_drawn = 50 [(module) = "framework"];
@@ -157,7 +156,7 @@
AppStartMemoryStateCaptured app_start_memory_state_captured = 55 [(module) = "framework"];
ShutdownSequenceReported shutdown_sequence_reported = 56 [(module) = "framework"];
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 =
59 [(module) = "framework", (module) = "statsdtest"];
ForegroundServiceStateChanged foreground_service_state_changed
@@ -186,8 +185,7 @@
WTFOccurred wtf_occurred = 80 [(module) = "framework"];
LowMemReported low_mem_reported = 81 [(module) = "framework"];
GenericAtom generic_atom = 82;
- KeyValuePairsAtom key_value_pairs_atom =
- 83 [(allow_from_any_uid) = true, (module) = "framework", (module) = "statsd"];
+ KeyValuePairsAtom key_value_pairs_atom = 83 [(module) = "framework", (module) = "statsd"];
VibratorStateChanged vibrator_state_changed = 84 [(module) = "framework"];
DeferredJobStatsReported deferred_job_stats_reported = 85 [(module) = "framework"];
ThermalThrottlingStateChanged thermal_throttling = 86 [deprecated=true];
@@ -317,7 +315,7 @@
AssistGestureFeedbackReported assist_gesture_feedback_reported = 175 [(module) = "sysui"];
AssistGestureProgressReported assist_gesture_progress_reported = 176 [(module) = "sysui"];
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"];
PrivacyIndicatorsInteracted privacy_indicators_interacted =
180 [(module) = "permissioncontroller"];
@@ -383,7 +381,7 @@
UpdateEngineSuccessfulUpdateReported update_engine_successful_update_reported = 226;
CameraActionEvent camera_action_event = 227 [(module) = "framework"];
AppCompatibilityChangeReported app_compatibility_change_reported =
- 228 [(allow_from_any_uid) = true, (module) = "framework"];
+ 228 [(module) = "framework"];
PerfettoUploaded perfetto_uploaded = 229 [(module) = "perfetto"];
VmsClientConnectionStateChanged vms_client_connection_state_changed =
230 [(module) = "car"];
diff --git a/cmds/statsd/src/metrics/MetricsManager.cpp b/cmds/statsd/src/metrics/MetricsManager.cpp
index 7e825ef..60de1a2 100644
--- a/cmds/statsd/src/metrics/MetricsManager.cpp
+++ b/cmds/statsd/src/metrics/MetricsManager.cpp
@@ -21,7 +21,6 @@
#include <private/android_filesystem_config.h>
#include "CountMetricProducer.h"
-#include "atoms_info.h"
#include "condition/CombinationConditionTracker.h"
#include "condition/SimpleConditionTracker.h"
#include "guardrail/StatsdStats.h"
@@ -372,13 +371,6 @@
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()) {
return true;
}
diff --git a/tools/stats_log_api_gen/Android.bp b/tools/stats_log_api_gen/Android.bp
index b1e2487..e3b6db0 100644
--- a/tools/stats_log_api_gen/Android.bp
+++ b/tools/stats_log_api_gen/Android.bp
@@ -21,7 +21,6 @@
name: "stats-log-api-gen",
srcs: [
"Collation.cpp",
- "atoms_info_writer.cpp",
"java_writer.cpp",
"java_writer_q.cpp",
"main.cpp",
diff --git a/tools/stats_log_api_gen/Collation.cpp b/tools/stats_log_api_gen/Collation.cpp
index 958e94e..a230de4 100644
--- a/tools/stats_log_api_gen/Collation.cpp
+++ b/tools/stats_log_api_gen/Collation.cpp
@@ -52,9 +52,7 @@
defaultState(that.defaultState),
triggerStateReset(that.triggerStateReset),
nested(that.nested),
- uidField(that.uidField),
- whitelisted(that.whitelisted),
- truncateTimestamp(that.truncateTimestamp) {
+ uidField(that.uidField) {
}
AtomDecl::AtomDecl(int c, const string& n, const string& m) : code(c), name(n), message(m) {
@@ -520,13 +518,6 @@
shared_ptr<AtomDecl> atomDecl =
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 &&
atomField->options().GetExtension(os::statsd::truncate_timestamp)) {
addAnnotationToAtomDecl(atomDecl.get(), ATOM_ID_FIELD_NUMBER,
diff --git a/tools/stats_log_api_gen/Collation.h b/tools/stats_log_api_gen/Collation.h
index 043f8b1..10b34ec 100644
--- a/tools/stats_log_api_gen/Collation.h
+++ b/tools/stats_log_api_gen/Collation.h
@@ -164,10 +164,6 @@
int uidField = 0;
- bool whitelisted = false;
-
- bool truncateTimestamp = false;
-
AtomDecl();
AtomDecl(const AtomDecl& that);
AtomDecl(int code, const string& name, const string& message);
diff --git a/tools/stats_log_api_gen/atoms_info_writer.cpp b/tools/stats_log_api_gen/atoms_info_writer.cpp
deleted file mode 100644
index 292cb21..0000000
--- a/tools/stats_log_api_gen/atoms_info_writer.cpp
+++ /dev/null
@@ -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
diff --git a/tools/stats_log_api_gen/atoms_info_writer.h b/tools/stats_log_api_gen/atoms_info_writer.h
deleted file mode 100644
index 09a4303..0000000
--- a/tools/stats_log_api_gen/atoms_info_writer.h
+++ /dev/null
@@ -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
diff --git a/tools/stats_log_api_gen/main.cpp b/tools/stats_log_api_gen/main.cpp
index 136933b..b888ce9 100644
--- a/tools/stats_log_api_gen/main.cpp
+++ b/tools/stats_log_api_gen/main.cpp
@@ -9,7 +9,6 @@
#include <vector>
#include "Collation.h"
-#include "atoms_info_writer.h"
#include "frameworks/base/cmds/statsd/src/atoms.pb.h"
#include "java_writer.h"
#include "java_writer_q.h"
@@ -30,12 +29,6 @@
fprintf(stderr, "OPTIONS\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,
- " --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, " --java FILENAME the java file to output\n");
fprintf(stderr, " --module NAME optional, module name to generate outputs for\n");
@@ -49,10 +42,6 @@
" --importHeader NAME required for cpp/jni to say which header to "
"import "
"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, " required for java with module\n");
fprintf(stderr, " --javaClass CLASS the class name of the java class.\n");
@@ -74,15 +63,12 @@
string cppFilename;
string headerFilename;
string javaFilename;
- string atomsInfoCppFilename;
- string atomsInfoHeaderFilename;
string javaPackage;
string javaClass;
string moduleName = DEFAULT_MODULE_NAME;
string cppNamespace = DEFAULT_CPP_NAMESPACE;
string cppHeaderImport = DEFAULT_CPP_HEADER_IMPORT;
- string atomsInfoCppHeaderImport = DEFAULT_ATOMS_INFO_CPP_HEADER_IMPORT;
bool supportQ = false;
bool supportWorkSource = false;
bool compileQ = false;
@@ -148,27 +134,6 @@
return 1;
}
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])) {
supportQ = true;
} else if (0 == strcmp("--worksource", argv[index])) {
@@ -180,8 +145,7 @@
index++;
}
- if (cppFilename.size() == 0 && headerFilename.size() == 0 && javaFilename.size() == 0 &&
- atomsInfoHeaderFilename.size() == 0 && atomsInfoCppFilename.size() == 0) {
+ if (cppFilename.size() == 0 && headerFilename.size() == 0 && javaFilename.size() == 0) {
print_usage();
return 1;
}
@@ -210,29 +174,6 @@
collate_atom(android::os::statsd::AttributionNode::descriptor(), &attributionDecl,
&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
if (cppFilename.size() != 0) {
FILE* out = fopen(cppFilename.c_str(), "w");
diff --git a/tools/stats_log_api_gen/test.proto b/tools/stats_log_api_gen/test.proto
index d22acc6..aaa488e 100644
--- a/tools/stats_log_api_gen/test.proto
+++ b/tools/stats_log_api_gen/test.proto
@@ -187,24 +187,6 @@
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 {
optional int32 field = 1 [(android.os.statsd.is_uid) = true];
}
diff --git a/tools/stats_log_api_gen/test_collation.cpp b/tools/stats_log_api_gen/test_collation.cpp
index 1504752..dbae588 100644
--- a/tools/stats_log_api_gen/test_collation.cpp
+++ b/tools/stats_log_api_gen/test_collation.cpp
@@ -225,25 +225,6 @@
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) {
Atoms atoms;
int errorCount = collate_atoms(ModuleAtoms::descriptor(), DEFAULT_MODULE_NAME, &atoms);
diff --git a/tools/stats_log_api_gen/utils.h b/tools/stats_log_api_gen/utils.h
index 7d6d08e..73e0cb8 100644
--- a/tools/stats_log_api_gen/utils.h
+++ b/tools/stats_log_api_gen/utils.h
@@ -32,7 +32,6 @@
const string DEFAULT_CPP_NAMESPACE = "android,util";
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_ATTRIBUTION = 0x02;