Loading Android.bp +4 −1 Original line number Diff line number Diff line Loading @@ -689,7 +689,10 @@ gensrcs { " $(in) " + "&& $(location soong_zip) -jar -o $(out) -C $(genDir)/$(in) -D $(genDir)/$(in)", srcs: ["core/proto/**/*.proto"], srcs: [ "core/proto/**/*.proto", "libs/incident/**/*.proto", ], output_extension: "srcjar", } Loading Android.mk +4 −2 Original line number Diff line number Diff line Loading @@ -806,7 +806,8 @@ LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \ store_unknown_fields = true LOCAL_JAVA_LIBRARIES := core-oj core-libart LOCAL_SRC_FILES := \ $(call all-proto-files-under, core/proto) $(call all-proto-files-under, core/proto) \ $(call all-proto-files-under, libs/incident/proto/android/os) include $(BUILD_STATIC_JAVA_LIBRARY) Loading @@ -818,7 +819,8 @@ LOCAL_PROTOC_OPTIMIZE_TYPE := lite LOCAL_PROTOC_FLAGS := \ -Iexternal/protobuf/src LOCAL_SRC_FILES := \ $(call all-proto-files-under, core/proto) $(call all-proto-files-under, core/proto) \ $(call all-proto-files-under, libs/incident/proto/android/os) include $(BUILD_STATIC_JAVA_LIBRARY) # Include subdirectory makefiles Loading cmds/incidentd/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libincident \ liblog \ libprotobuf-cpp-lite \ libprotoutil \ libselinux \ libservices \ Loading cmds/incidentd/src/IncidentService.cpp +8 −3 Original line number Diff line number Diff line Loading @@ -45,22 +45,27 @@ String16 const USAGE_STATS_PERMISSION("android.permission.PACKAGE_USAGE_STATS"); static Status checkIncidentPermissions(const IncidentReportArgs& args) { uid_t callingUid = IPCThreadState::self()->getCallingUid(); if (callingUid == AID_ROOT || callingUid == AID_SHELL) { // root doesn't have permission.DUMP if don't do this! return Status::ok(); } // checking calling permission. if (!checkCallingPermission(DUMP_PERMISSION)) { ALOGW("Calling pid %d and uid %d does not have permission: android.permission.DUMP", IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid()); IPCThreadState::self()->getCallingPid(), callingUid); return Status::fromExceptionCode(Status::EX_SECURITY, "Calling process does not have permission: android.permission.DUMP"); } if (!checkCallingPermission(USAGE_STATS_PERMISSION)) { ALOGW("Calling pid %d and uid %d does not have permission: android.permission.USAGE_STATS", IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid()); IPCThreadState::self()->getCallingPid(), callingUid); return Status::fromExceptionCode(Status::EX_SECURITY, "Calling process does not have permission: android.permission.USAGE_STATS"); } // checking calling request uid permission. uid_t callingUid = IPCThreadState::self()->getCallingUid(); switch (args.dest()) { case DEST_LOCAL: if (callingUid != AID_SHELL || callingUid != AID_ROOT) { Loading cmds/incidentd/tests/Reporter_test.cpp +11 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include "Reporter.h" #include <android/os/BnIncidentReportStatusListener.h> #include <frameworks/base/libs/incident/proto/android/os/header.pb.h> #include <android-base/file.h> #include <android-base/test_utils.h> Loading @@ -29,6 +30,7 @@ using namespace android; using namespace android::base; using namespace android::binder; using namespace android::os; using namespace std; using ::testing::StrEq; using ::testing::Test; Loading Loading @@ -141,7 +143,8 @@ TEST_F(ReporterTest, RunReportWithHeaders) { IncidentReportArgs args1, args2; args1.addSection(1); args2.addSection(2); std::vector<uint8_t> header {'a', 'b', 'c', 'd', 'e'}; IncidentHeaderProto header; header.set_alert_id(12); args2.addHeader(header); sp<ReportRequest> r1 = new ReportRequest(args1, l, tf.fd); sp<ReportRequest> r2 = new ReportRequest(args2, l, tf.fd); Loading @@ -153,7 +156,7 @@ TEST_F(ReporterTest, RunReportWithHeaders) { string result; ReadFileToString(tf.path, &result); EXPECT_THAT(result, StrEq("\n\x5" "abcde")); EXPECT_THAT(result, StrEq("\n\x2" "\b\f")); EXPECT_EQ(l->startInvoked, 2); EXPECT_EQ(l->finishInvoked, 2); Loading @@ -164,13 +167,16 @@ TEST_F(ReporterTest, RunReportWithHeaders) { TEST_F(ReporterTest, RunReportToGivenDirectory) { IncidentReportArgs args; args.addHeader({'1', '2', '3'}); args.addHeader({'a', 'b', 'c', 'd'}); IncidentHeaderProto header1, header2; header1.set_alert_id(12); header2.set_reason("abcd"); args.addHeader(header1); args.addHeader(header2); sp<ReportRequest> r = new ReportRequest(args, l, -1); reporter->batch.add(r); ASSERT_EQ(Reporter::REPORT_FINISHED, reporter->runReport()); vector<string> results = InspectFiles(); ASSERT_EQ((int)results.size(), 1); EXPECT_EQ(results[0], "\n\x3" "123\n\x4" "abcd"); EXPECT_EQ(results[0], "\n\x2" "\b\f\n\x6" "\x12\x4" "abcd"); } Loading
Android.bp +4 −1 Original line number Diff line number Diff line Loading @@ -689,7 +689,10 @@ gensrcs { " $(in) " + "&& $(location soong_zip) -jar -o $(out) -C $(genDir)/$(in) -D $(genDir)/$(in)", srcs: ["core/proto/**/*.proto"], srcs: [ "core/proto/**/*.proto", "libs/incident/**/*.proto", ], output_extension: "srcjar", } Loading
Android.mk +4 −2 Original line number Diff line number Diff line Loading @@ -806,7 +806,8 @@ LOCAL_PROTO_JAVA_OUTPUT_PARAMS := \ store_unknown_fields = true LOCAL_JAVA_LIBRARIES := core-oj core-libart LOCAL_SRC_FILES := \ $(call all-proto-files-under, core/proto) $(call all-proto-files-under, core/proto) \ $(call all-proto-files-under, libs/incident/proto/android/os) include $(BUILD_STATIC_JAVA_LIBRARY) Loading @@ -818,7 +819,8 @@ LOCAL_PROTOC_OPTIMIZE_TYPE := lite LOCAL_PROTOC_FLAGS := \ -Iexternal/protobuf/src LOCAL_SRC_FILES := \ $(call all-proto-files-under, core/proto) $(call all-proto-files-under, core/proto) \ $(call all-proto-files-under, libs/incident/proto/android/os) include $(BUILD_STATIC_JAVA_LIBRARY) # Include subdirectory makefiles Loading
cmds/incidentd/Android.mk +1 −0 Original line number Diff line number Diff line Loading @@ -134,6 +134,7 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libincident \ liblog \ libprotobuf-cpp-lite \ libprotoutil \ libselinux \ libservices \ Loading
cmds/incidentd/src/IncidentService.cpp +8 −3 Original line number Diff line number Diff line Loading @@ -45,22 +45,27 @@ String16 const USAGE_STATS_PERMISSION("android.permission.PACKAGE_USAGE_STATS"); static Status checkIncidentPermissions(const IncidentReportArgs& args) { uid_t callingUid = IPCThreadState::self()->getCallingUid(); if (callingUid == AID_ROOT || callingUid == AID_SHELL) { // root doesn't have permission.DUMP if don't do this! return Status::ok(); } // checking calling permission. if (!checkCallingPermission(DUMP_PERMISSION)) { ALOGW("Calling pid %d and uid %d does not have permission: android.permission.DUMP", IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid()); IPCThreadState::self()->getCallingPid(), callingUid); return Status::fromExceptionCode(Status::EX_SECURITY, "Calling process does not have permission: android.permission.DUMP"); } if (!checkCallingPermission(USAGE_STATS_PERMISSION)) { ALOGW("Calling pid %d and uid %d does not have permission: android.permission.USAGE_STATS", IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid()); IPCThreadState::self()->getCallingPid(), callingUid); return Status::fromExceptionCode(Status::EX_SECURITY, "Calling process does not have permission: android.permission.USAGE_STATS"); } // checking calling request uid permission. uid_t callingUid = IPCThreadState::self()->getCallingUid(); switch (args.dest()) { case DEST_LOCAL: if (callingUid != AID_SHELL || callingUid != AID_ROOT) { Loading
cmds/incidentd/tests/Reporter_test.cpp +11 −5 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #include "Reporter.h" #include <android/os/BnIncidentReportStatusListener.h> #include <frameworks/base/libs/incident/proto/android/os/header.pb.h> #include <android-base/file.h> #include <android-base/test_utils.h> Loading @@ -29,6 +30,7 @@ using namespace android; using namespace android::base; using namespace android::binder; using namespace android::os; using namespace std; using ::testing::StrEq; using ::testing::Test; Loading Loading @@ -141,7 +143,8 @@ TEST_F(ReporterTest, RunReportWithHeaders) { IncidentReportArgs args1, args2; args1.addSection(1); args2.addSection(2); std::vector<uint8_t> header {'a', 'b', 'c', 'd', 'e'}; IncidentHeaderProto header; header.set_alert_id(12); args2.addHeader(header); sp<ReportRequest> r1 = new ReportRequest(args1, l, tf.fd); sp<ReportRequest> r2 = new ReportRequest(args2, l, tf.fd); Loading @@ -153,7 +156,7 @@ TEST_F(ReporterTest, RunReportWithHeaders) { string result; ReadFileToString(tf.path, &result); EXPECT_THAT(result, StrEq("\n\x5" "abcde")); EXPECT_THAT(result, StrEq("\n\x2" "\b\f")); EXPECT_EQ(l->startInvoked, 2); EXPECT_EQ(l->finishInvoked, 2); Loading @@ -164,13 +167,16 @@ TEST_F(ReporterTest, RunReportWithHeaders) { TEST_F(ReporterTest, RunReportToGivenDirectory) { IncidentReportArgs args; args.addHeader({'1', '2', '3'}); args.addHeader({'a', 'b', 'c', 'd'}); IncidentHeaderProto header1, header2; header1.set_alert_id(12); header2.set_reason("abcd"); args.addHeader(header1); args.addHeader(header2); sp<ReportRequest> r = new ReportRequest(args, l, -1); reporter->batch.add(r); ASSERT_EQ(Reporter::REPORT_FINISHED, reporter->runReport()); vector<string> results = InspectFiles(); ASSERT_EQ((int)results.size(), 1); EXPECT_EQ(results[0], "\n\x3" "123\n\x4" "abcd"); EXPECT_EQ(results[0], "\n\x2" "\b\f\n\x6" "\x12\x4" "abcd"); }