Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b05c1f4 authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "libbinder: ParcelableHolder - avoid utf-8<->utf-16" am: 664d7089 am: 581b253d

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1543708

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I844101c4a3f12e37cfc27f091c5d2a0b60456d38
parents 6c1a109e 581b253d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ status_t ParcelableHolder::writeToParcel(Parcel* p) const {
        size_t sizePos = p->dataPosition();
        RETURN_ON_FAILURE(p->writeInt32(0));
        size_t dataStartPos = p->dataPosition();
        RETURN_ON_FAILURE(p->writeUtf8AsUtf16(this->mParcelableName));
        RETURN_ON_FAILURE(p->writeString16(this->mParcelableName));
        this->mParcelable->writeToParcel(p);
        size_t dataSize = p->dataPosition() - dataStartPos;

+5 −4
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <binder/Parcel.h>
#include <binder/Parcelable.h>
#include <utils/String16.h>
#include <mutex>
#include <optional>
#include <tuple>
@@ -72,7 +73,7 @@ public:
    template <typename T>
    status_t getParcelable(std::shared_ptr<T>* ret) const {
        static_assert(std::is_base_of<Parcelable, T>::value, "T must be derived from Parcelable");
        const std::string& parcelableDesc = T::getParcelableDescriptor();
        const String16& parcelableDesc = T::getParcelableDescriptor();
        if (!this->mParcelPtr) {
            if (!this->mParcelable || !this->mParcelableName) {
                ALOGD("empty ParcelableHolder");
@@ -80,7 +81,7 @@ public:
                return android::OK;
            } else if (parcelableDesc != *mParcelableName) {
                ALOGD("extension class name mismatch expected:%s actual:%s",
                      mParcelableName->c_str(), parcelableDesc.c_str());
                      String8(*mParcelableName).c_str(), String8(parcelableDesc).c_str());
                *ret = nullptr;
                return android::BAD_VALUE;
            }
@@ -88,7 +89,7 @@ public:
            return android::OK;
        }
        this->mParcelPtr->setDataPosition(0);
        status_t status = this->mParcelPtr->readUtf8FromUtf16(&this->mParcelableName);
        status_t status = this->mParcelPtr->readString16(&this->mParcelableName);
        if (status != android::OK || parcelableDesc != this->mParcelableName) {
            this->mParcelableName = std::nullopt;
            *ret = nullptr;
@@ -130,7 +131,7 @@ public:

private:
    mutable std::shared_ptr<Parcelable> mParcelable;
    mutable std::optional<std::string> mParcelableName;
    mutable std::optional<String16> mParcelableName;
    mutable std::unique_ptr<Parcel> mParcelPtr;
    Stability mStability;
};