diff options
author | Joe Onorato <joeo@google.com> | 2019-02-11 15:55:13 +0000 |
---|---|---|
committer | Joe Onorato <joeo@google.com> | 2019-03-26 11:20:48 -0700 |
commit | 99598ee6ee52a6b2f1bc101187df17a46fe81ad2 (patch) | |
tree | 75e9eb540ee305b1c54aec3b175f704667b2624e /libs/services | |
parent | 21638cb830c218d6e1c723cb14b39b6705d58d2c (diff) |
incidentd can now handle multiple callers asking it for incident reports
Test: bit incident_test:* GtsIncidentManagerTestCases:*
Bug: 123543706
Change-Id: I9f671dd5d8b2ad139f952a23e575c2be16120459
Diffstat (limited to 'libs/services')
-rw-r--r-- | libs/services/Android.bp | 1 | ||||
-rw-r--r-- | libs/services/include/android/content/ComponentName.h | 56 | ||||
-rw-r--r-- | libs/services/src/content/ComponentName.cpp | 88 | ||||
-rw-r--r-- | libs/services/src/os/DropBoxManager.cpp | 5 |
4 files changed, 149 insertions, 1 deletions
diff --git a/libs/services/Android.bp b/libs/services/Android.bp index 3d57fbdd0dcd..1b9939d9a598 100644 --- a/libs/services/Android.bp +++ b/libs/services/Android.bp @@ -18,6 +18,7 @@ cc_library_shared { name: "libservices", srcs: [ ":IDropBoxManagerService.aidl", + "src/content/ComponentName.cpp", "src/os/DropBoxManager.cpp", "src/os/StatsDimensionsValue.cpp", "src/os/StatsLogEventWrapper.cpp", diff --git a/libs/services/include/android/content/ComponentName.h b/libs/services/include/android/content/ComponentName.h new file mode 100644 index 000000000000..6bf46b4bc28e --- /dev/null +++ b/libs/services/include/android/content/ComponentName.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2019 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. + */ + +#pragma once + +#include <binder/Parcel.h> +#include <binder/Parcelable.h> +#include <binder/Status.h> +#include <string> +#include <vector> + +namespace android { +namespace content { + +using namespace std; + +class ComponentName: public android::Parcelable { + public: + ComponentName(); + ComponentName(const ComponentName& that); + ComponentName(const string& pkg, const string& cls); + virtual ~ComponentName(); + + bool operator<(const ComponentName& that) const; + + const string& getPackageName() const { return mPackage; } + const string& getClassName() const { return mClass; } + + virtual android::status_t writeToParcel(android::Parcel* out) const override; + virtual android::status_t readFromParcel(const android::Parcel* in) override; + +private: + string mPackage; + string mClass; +}; + + + +} // namespace os +} // namespace android + + + diff --git a/libs/services/src/content/ComponentName.cpp b/libs/services/src/content/ComponentName.cpp new file mode 100644 index 000000000000..adb67ee7c61a --- /dev/null +++ b/libs/services/src/content/ComponentName.cpp @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2016 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/content/ComponentName.h> + +namespace android { +namespace content { + +ComponentName::ComponentName() + :mPackage(), + mClass() { +} + +ComponentName::ComponentName(const ComponentName& that) + :mPackage(that.mPackage), + mClass(that.mClass) { +} + +ComponentName::ComponentName(const string& pkg, const string& cls) + :mPackage(pkg), + mClass(cls) { +} + +ComponentName::~ComponentName() { +} + +bool ComponentName::operator<(const ComponentName& that) const { + if (mPackage < that.mPackage) { + return true; + } else if (mPackage > that.mPackage) { + return false; + } + return mClass < that.mClass; +} + +status_t ComponentName::readFromParcel(const Parcel* in) { + status_t err; + + // Note: This is a subtle variation from the java version, which + // requires non-null strings, but does not require non-empty strings. + // This code implicitly requires non-null strings, because it's impossible, + // but reading null strings that were somehow written by the java + // code would turn them into empty strings. + + err = in->readUtf8FromUtf16(&mPackage); + if (err != NO_ERROR) { + return err; + } + + err = in->readUtf8FromUtf16(&mClass); + if (err != NO_ERROR) { + return err; + } + + return NO_ERROR; +} + +status_t ComponentName::writeToParcel(android::Parcel* out) const { + status_t err; + + err = out->writeUtf8AsUtf16(mPackage); + if (err != NO_ERROR) { + return err; + } + + err = out->writeUtf8AsUtf16(mClass); + if (err != NO_ERROR) { + return err; + } + + return NO_ERROR; +} + +}} // namespace android::content + diff --git a/libs/services/src/os/DropBoxManager.cpp b/libs/services/src/os/DropBoxManager.cpp index 681d5f780739..429f996bd65e 100644 --- a/libs/services/src/os/DropBoxManager.cpp +++ b/libs/services/src/os/DropBoxManager.cpp @@ -225,7 +225,10 @@ DropBoxManager::add(const Entry& entry) if (service == NULL) { return Status::fromExceptionCode(Status::EX_NULL_POINTER, "can't find dropbox service"); } - return service->add(entry); + ALOGD("About to call service->add()"); + Status status = service->add(entry); + ALOGD("service->add returned %s", status.toString8().string()); + return status; } }} // namespace android::os |