diff options
author | Wenjie Zhou <zhouwenjie@google.com> | 2020-05-15 16:04:32 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-05-15 16:04:32 +0000 |
commit | bbd12bc783ffad92194bd4864f779e8634d07608 (patch) | |
tree | 5d9783792ee2478396011e72df3e7f3897bed5dd /cmds/incidentd | |
parent | 5af17bc87fe2cc3e665a1831c8eec9eaa2ad8c0b (diff) | |
parent | ad24e49e2f8ab44c9a89a4a22dac4180a8355fdd (diff) |
Merge "mCallback defined in BringYourOwnSection should be an object instead of a reference." into rvc-dev am: ad24e49e2f
Change-Id: Ia39b5ca803f3962ab2e864a16e7ceedb47788a9e
Diffstat (limited to 'cmds/incidentd')
-rw-r--r-- | cmds/incidentd/src/IncidentService.cpp | 8 | ||||
-rw-r--r-- | cmds/incidentd/src/Section.cpp | 4 | ||||
-rw-r--r-- | cmds/incidentd/src/Section.h | 2 |
3 files changed, 8 insertions, 6 deletions
diff --git a/cmds/incidentd/src/IncidentService.cpp b/cmds/incidentd/src/IncidentService.cpp index 9e6d0a23de10..dc1612575f38 100644 --- a/cmds/incidentd/src/IncidentService.cpp +++ b/cmds/incidentd/src/IncidentService.cpp @@ -351,9 +351,9 @@ 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(); + const String8 name = String8(name16); const uid_t callingUid = IPCThreadState::self()->getCallingUid(); - ALOGI("Uid %d registers section %d '%s'", callingUid, id, name); + ALOGI("Uid %d registers section %d '%s'", callingUid, id, name.c_str()); if (callback == nullptr) { return Status::fromExceptionCode(Status::EX_NULL_POINTER); } @@ -363,11 +363,11 @@ Status IncidentService::registerSection(const int id, const String16& name16, ALOGW("Error registering section %d: calling uid does not match", id); return Status::fromExceptionCode(Status::EX_SECURITY); } - mRegisteredSections.at(i) = new BringYourOwnSection(id, name, callingUid, callback); + mRegisteredSections.at(i) = new BringYourOwnSection(id, name.c_str(), callingUid, callback); return Status::ok(); } } - mRegisteredSections.push_back(new BringYourOwnSection(id, name, callingUid, callback)); + mRegisteredSections.push_back(new BringYourOwnSection(id, name.c_str(), callingUid, callback)); return Status::ok(); } diff --git a/cmds/incidentd/src/Section.cpp b/cmds/incidentd/src/Section.cpp index b629e4251762..7fc999af6f78 100644 --- a/cmds/incidentd/src/Section.cpp +++ b/cmds/incidentd/src/Section.cpp @@ -875,7 +875,9 @@ BringYourOwnSection::~BringYourOwnSection() {} status_t BringYourOwnSection::BlockingCall(unique_fd& pipeWriteFd) const { android::os::ParcelFileDescriptor pfd(std::move(pipeWriteFd)); - mCallback->onDumpSection(pfd); + if(mCallback != nullptr) { + mCallback->onDumpSection(pfd); + } return NO_ERROR; } diff --git a/cmds/incidentd/src/Section.h b/cmds/incidentd/src/Section.h index 7f4b66482c73..698cc04c160e 100644 --- a/cmds/incidentd/src/Section.h +++ b/cmds/incidentd/src/Section.h @@ -207,7 +207,7 @@ public: virtual status_t BlockingCall(unique_fd& pipeWriteFd) const; private: - const sp<IIncidentDumpCallback>& mCallback; + const sp<IIncidentDumpCallback> mCallback; }; |