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

Commit 34b48cb7 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder: finish{F,Unf}lattenBinder symmetry

Before, both of these functions wrote stability information, but only
finishFlattenBinder wrote binder-specific objects to the Parcel. This
was because in order to function, unflattenBinder needed to read object
data, but flattenBinder was able to delegate this. Now, the
binder-specific object logic is moved into flattenBinder. This
organization makes it easy to re-use finishFlattenBinder for RPC
binders, which would write stability information but not the
binder-driver-specific objects.

Bug: 167966510
Test: boot
Change-Id: I0d1e48bf439dfd928e284c7c8c4284cd955a2850
parent 4aaa3105
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -164,12 +164,8 @@ static void release_object(const sp<ProcessState>& proc,
    ALOGE("Invalid object type 0x%08x", obj.hdr.type);
}

status_t Parcel::finishFlattenBinder(
    const sp<IBinder>& binder, const flat_binder_object& flat)
status_t Parcel::finishFlattenBinder(const sp<IBinder>& binder)
{
    status_t status = writeObject(flat, false);
    if (status != OK) return status;

    internal::Stability::tryMarkCompilationUnit(binder.get());
    auto category = internal::Stability::getCategory(binder.get());
    return writeInt32(category.repr());
@@ -238,7 +234,10 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder)

    obj.flags |= schedBits;

    return finishFlattenBinder(binder, obj);
    status_t status = writeObject(obj, false);
    if (status != OK) return status;

    return finishFlattenBinder(binder);
}

status_t Parcel::unflattenBinder(sp<IBinder>* out) const
+1 −2
Original line number Diff line number Diff line
@@ -522,8 +522,7 @@ private:
    status_t            validateReadData(size_t len) const;
    void                updateWorkSourceRequestHeaderPosition() const;

    status_t            finishFlattenBinder(const sp<IBinder>& binder,
                                            const flat_binder_object& flat);
    status_t            finishFlattenBinder(const sp<IBinder>& binder);
    status_t            finishUnflattenBinder(const sp<IBinder>& binder, sp<IBinder>* out) const;
    status_t            flattenBinder(const sp<IBinder>& binder);
    status_t            unflattenBinder(sp<IBinder>* out) const;