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

Commit eef93477 authored by Devin Moore's avatar Devin Moore
Browse files

HwParcel owns HwBlobs

If a HwParcel reads/writes HwBlobs, it takes a strong reference to the
JHwBlob objects.

Test: atest hidl_test_java
Bug: 333942055
Change-Id: Ibe0b518a812a9321492e1132d7da0882e3533837
parent e5e9c56f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -235,6 +235,10 @@ bool JHwParcel::wasSent() const {
    return mWasSent;
}

void JHwParcel::addBlob(const sp<JHwBlob> &blob) {
    mBlobs.emplace_back(blob);
}

}  // namespace android

////////////////////////////////////////////////////////////////////////////////
@@ -1059,6 +1063,7 @@ static void JHwParcel_native_writeBuffer(
        JHwParcel::GetNativeContext(env, thiz)->getParcel();

    sp<JHwBlob> blob = JHwBlob::GetNativeContext(env, blobObj);
    JHwParcel::GetNativeContext(env, thiz)->addBlob(blob);
    status_t err = blob->writeToParcel(parcel);

    if (err != OK) {
+6 −2
Original line number Diff line number Diff line
@@ -17,14 +17,15 @@
#ifndef ANDROID_OS_HW_PARCEL_H
#define ANDROID_OS_HW_PARCEL_H

#include "hwbinder/EphemeralStorage.h"

#include <android-base/macros.h>
#include <hwbinder/IBinder.h>
#include <hwbinder/Parcel.h>
#include <jni.h>
#include <utils/RefBase.h>

#include "android_os_HwBlob.h"
#include "hwbinder/EphemeralStorage.h"

namespace android {

struct JHwParcel : public RefBase {
@@ -44,6 +45,8 @@ struct JHwParcel : public RefBase {

    EphemeralStorage *getStorage();

    void addBlob(const sp<JHwBlob> &blob);

    void setTransactCallback(::android::hardware::IBinder::TransactCallback cb);

    void send();
@@ -60,6 +63,7 @@ private:

    ::android::hardware::IBinder::TransactCallback mTransactCallback;
    bool mWasSent;
    std::vector<sp<JHwBlob>> mBlobs;

    DISALLOW_COPY_AND_ASSIGN(JHwParcel);
};