summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2020-01-17 01:30:02 -0800
committerJoe Onorato <joeo@google.com>2020-02-05 08:29:23 -0800
commit255ffff56d7c99fb756c20f9f5a6c4ea93504813 (patch)
tree567088d48df2c3b0e53224300eaec46bb1054884 /cmds
parent374ba3fcff8c3fa6cd6f8f5b58ddcbdb96584d72 (diff)
Make libincident into a stable C API.
Test: atest GtsIncidentConfirmationTestCases GtsIncidentManagerTestCases libincident_test Bug: 144187174 Change-Id: I65b5a13cfb6a57aa56f738e25a76c5ecb8e7a1a8
Diffstat (limited to 'cmds')
-rw-r--r--cmds/incident/Android.bp2
-rw-r--r--cmds/incidentd/Android.bp4
-rw-r--r--cmds/incidentd/TEST_MAPPING13
-rw-r--r--cmds/statsd/Android.bp1
-rw-r--r--cmds/statsd/src/subscriber/IncidentdReporter.cpp27
-rw-r--r--cmds/statsd/tests/external/IncidentReportArgs_test.cpp72
6 files changed, 24 insertions, 95 deletions
diff --git a/cmds/incident/Android.bp b/cmds/incident/Android.bp
index 9e9dac14c802..94855aa0311f 100644
--- a/cmds/incident/Android.bp
+++ b/cmds/incident/Android.bp
@@ -26,7 +26,7 @@ cc_binary {
"libcutils",
"liblog",
"libutils",
- "libincident",
+ "libincidentpriv",
],
static_libs: [
diff --git a/cmds/incidentd/Android.bp b/cmds/incidentd/Android.bp
index 25e0328b4f38..cc724a626baf 100644
--- a/cmds/incidentd/Android.bp
+++ b/cmds/incidentd/Android.bp
@@ -54,7 +54,7 @@ cc_binary {
"libbinder",
"libdebuggerd_client",
"libdumputils",
- "libincident",
+ "libincidentpriv",
"liblog",
"libprotoutil",
"libservices",
@@ -128,7 +128,7 @@ cc_test {
"libbinder",
"libdebuggerd_client",
"libdumputils",
- "libincident",
+ "libincidentpriv",
"liblog",
"libprotobuf-cpp-full",
"libprotoutil",
diff --git a/cmds/incidentd/TEST_MAPPING b/cmds/incidentd/TEST_MAPPING
new file mode 100644
index 000000000000..f5b0b7a120ca
--- /dev/null
+++ b/cmds/incidentd/TEST_MAPPING
@@ -0,0 +1,13 @@
+{
+ "presubmit": [
+ {
+ "name": "incidentd_test"
+ }
+ ],
+ "postsubmit": [
+ ],
+ "imports": [
+ ]
+}
+
+
diff --git a/cmds/statsd/Android.bp b/cmds/statsd/Android.bp
index 2237bf2b2acb..6f71d97d9dad 100644
--- a/cmds/statsd/Android.bp
+++ b/cmds/statsd/Android.bp
@@ -278,7 +278,6 @@ cc_test {
"tests/e2e/ValueMetric_pull_e2e_test.cpp",
"tests/e2e/WakelockDuration_e2e_test.cpp",
"tests/external/GpuStatsPuller_test.cpp",
- "tests/external/IncidentReportArgs_test.cpp",
"tests/external/puller_util_test.cpp",
"tests/external/StatsCallbackPuller_test.cpp",
"tests/external/StatsPuller_test.cpp",
diff --git a/cmds/statsd/src/subscriber/IncidentdReporter.cpp b/cmds/statsd/src/subscriber/IncidentdReporter.cpp
index d86e29131661..30c90b1e1f71 100644
--- a/cmds/statsd/src/subscriber/IncidentdReporter.cpp
+++ b/cmds/statsd/src/subscriber/IncidentdReporter.cpp
@@ -21,10 +21,8 @@
#include "packages/UidMap.h"
#include "stats_log_util.h"
-#include <android/os/IIncidentManager.h>
-#include <android/os/IncidentReportArgs.h>
#include <android/util/ProtoOutputStream.h>
-#include <binder/IServiceManager.h>
+#include <incident/incident_report.h>
#include <vector>
@@ -132,7 +130,7 @@ bool GenerateIncidentReport(const IncidentdDetails& config, int64_t rule_id, int
return false;
}
- IncidentReportArgs incidentReport;
+ android::os::IncidentReportRequest incidentReport;
vector<uint8_t> protoData;
getProtoData(rule_id, metricId, dimensionKey, metricValue, configKey,
@@ -146,30 +144,21 @@ bool GenerateIncidentReport(const IncidentdDetails& config, int64_t rule_id, int
uint8_t dest;
switch (config.dest()) {
case IncidentdDetails_Destination_AUTOMATIC:
- dest = android::os::PRIVACY_POLICY_AUTOMATIC;
+ dest = INCIDENT_REPORT_PRIVACY_POLICY_AUTOMATIC;
break;
case IncidentdDetails_Destination_EXPLICIT:
- dest = android::os::PRIVACY_POLICY_EXPLICIT;
+ dest = INCIDENT_REPORT_PRIVACY_POLICY_EXPLICIT;
break;
default:
- dest = android::os::PRIVACY_POLICY_AUTOMATIC;
+ dest = INCIDENT_REPORT_PRIVACY_POLICY_AUTOMATIC;
}
incidentReport.setPrivacyPolicy(dest);
- incidentReport.setReceiverPkg(config.receiver_pkg());
+ incidentReport.setReceiverPackage(config.receiver_pkg());
- incidentReport.setReceiverCls(config.receiver_cls());
+ incidentReport.setReceiverClass(config.receiver_cls());
- sp<IIncidentManager> service = interface_cast<IIncidentManager>(
- defaultServiceManager()->getService(android::String16("incident")));
- if (service == nullptr) {
- ALOGW("Failed to fetch incident service.");
- return false;
- }
- VLOG("Calling incidentd %p", service.get());
- binder::Status s = service->reportIncident(incidentReport);
- VLOG("Report incident status: %s", s.toString8().string());
- return s.isOk();
+ return incidentReport.takeReport() == NO_ERROR;
}
} // namespace statsd
diff --git a/cmds/statsd/tests/external/IncidentReportArgs_test.cpp b/cmds/statsd/tests/external/IncidentReportArgs_test.cpp
deleted file mode 100644
index 38bc19452afa..000000000000
--- a/cmds/statsd/tests/external/IncidentReportArgs_test.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (C) 2018 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 <android/os/IncidentReportArgs.h>
-
-#include <gtest/gtest.h>
-
-namespace android {
-namespace os {
-namespace statsd {
-
-TEST(IncidentReportArgsTest, testSerialization) {
- IncidentReportArgs args;
- args.setAll(0);
- args.addSection(1000);
- args.addSection(1001);
-
- vector<uint8_t> header1;
- header1.push_back(0x1);
- header1.push_back(0x2);
- vector<uint8_t> header2;
- header1.push_back(0x22);
- header1.push_back(0x33);
-
- args.addHeader(header1);
- args.addHeader(header2);
-
- args.setPrivacyPolicy(1);
-
- args.setReceiverPkg("com.android.os");
- args.setReceiverCls("com.android.os.Receiver");
-
- Parcel out;
- status_t err = args.writeToParcel(&out);
- EXPECT_EQ(NO_ERROR, err);
-
- out.setDataPosition(0);
-
- IncidentReportArgs args2;
- err = args2.readFromParcel(&out);
- EXPECT_EQ(NO_ERROR, err);
-
- EXPECT_EQ(0, args2.all());
- set<int> sections;
- sections.insert(1000);
- sections.insert(1001);
- EXPECT_EQ(sections, args2.sections());
- EXPECT_EQ(1, args2.getPrivacyPolicy());
-
- EXPECT_EQ(string("com.android.os"), args2.receiverPkg());
- EXPECT_EQ(string("com.android.os.Receiver"), args2.receiverCls());
-
- vector<vector<uint8_t>> headers;
- headers.push_back(header1);
- headers.push_back(header2);
- EXPECT_EQ(headers, args2.headers());
-}
-
-} // namespace statsd
-} // namespace os
-} // namespace android