Merge changes from topic "b_144187174"
* changes: Remove this TEST_MAPPING file until I can figure out what this error means Make libincident into a stable C API.
This commit is contained in:
@@ -26,7 +26,7 @@ cc_binary {
|
||||
"libcutils",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"libincident",
|
||||
"libincidentpriv",
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -279,7 +279,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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user