diff options
author | Mike Ma <yanmin@google.com> | 2020-01-17 06:11:24 +0000 |
---|---|---|
committer | Mike Ma <yanmin@google.com> | 2020-01-21 18:34:18 -0800 |
commit | c2ab45a2210ef5cfbba088b816b015a7cbbdc18c (patch) | |
tree | 78c30166adf0a60bbdb6521dab180c2c10d8f3d5 /cmds/incidentd/src | |
parent | c64b68c3e2074f640a6455c516ba4c9a89c68a5a (diff) |
Public API: Incident report section registration
Mark incident report section registration and unregistration as public
APIs, and protect them with
android.permission.REGISTER_INCIDENT_REPORT_SECTION.
Bug: 144789854
Test: Build
Change-Id: I0d79ca12054292412e10a63ba2e6f45a149066a9
Diffstat (limited to 'cmds/incidentd/src')
-rw-r--r-- | cmds/incidentd/src/IncidentService.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/cmds/incidentd/src/IncidentService.cpp b/cmds/incidentd/src/IncidentService.cpp index 62312d1cccaa..6c2b8551bf73 100644 --- a/cmds/incidentd/src/IncidentService.cpp +++ b/cmds/incidentd/src/IncidentService.cpp @@ -350,11 +350,11 @@ Status IncidentService::reportIncidentToDumpstate(unique_fd stream, Status IncidentService::registerSection(const int id, const String16& name16, const sp<IIncidentDumpCallback>& callback) { const char* name = String8(name16).c_str(); - ALOGI("Register section %d: %s", id, name); + const uid_t callingUid = IPCThreadState::self()->getCallingUid(); + ALOGI("Uid %d registers section %d '%s'", callingUid, id, name); if (callback == nullptr) { return Status::fromExceptionCode(Status::EX_NULL_POINTER); } - const uid_t callingUid = IPCThreadState::self()->getCallingUid(); for (int i = 0; i < mRegisteredSections.size(); i++) { if (mRegisteredSections.at(i)->id == id) { if (mRegisteredSections.at(i)->uid != callingUid) { @@ -370,8 +370,9 @@ Status IncidentService::registerSection(const int id, const String16& name16, } Status IncidentService::unregisterSection(const int id) { - ALOGI("Unregister section %d", id); uid_t callingUid = IPCThreadState::self()->getCallingUid(); + ALOGI("Uid %d unregisters section %d", callingUid, id); + for (auto it = mRegisteredSections.begin(); it != mRegisteredSections.end(); it++) { if ((*it)->id == id) { if ((*it)->uid != callingUid) { |