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

Commit 5c05de19 authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk Committed by Gerrit Code Review
Browse files

Merge "Disable native_handle outside of Android" into main

parents 42f5052b 232d0b37
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -374,6 +374,22 @@ cc_library_static {
    ],
}

cc_library_static {
    name: "libbinder_rpc_no_native_handle",
    vendor_available: true,
    defaults: [
        "libbinder_common_defaults",
        "libbinder_android_defaults",
        "libbinder_kernel_defaults",
    ],
    cflags: [
        "-DBINDER_DISABLE_NATIVE_HANDLE",
    ],
    visibility: [
        ":__subpackages__",
    ],
}

cc_library_static {
    name: "libbinder_rpc_single_threaded",
    defaults: [
+4 −0
Original line number Diff line number Diff line
@@ -1436,6 +1436,7 @@ status_t Parcel::writeRawNullableParcelable(const Parcelable* parcelable) {
    return writeParcelable(*parcelable);
}

#ifndef BINDER_DISABLE_NATIVE_HANDLE
status_t Parcel::writeNativeHandle(const native_handle* handle)
{
    if (!handle || handle->version != sizeof(native_handle))
@@ -1458,6 +1459,7 @@ status_t Parcel::writeNativeHandle(const native_handle* handle)
    err = write(handle->data + handle->numFds, sizeof(int)*handle->numInts);
    return err;
}
#endif

status_t Parcel::writeFileDescriptor(int fd, bool takeOwnership) {
    if (auto* rpcFields = maybeRpcFields()) {
@@ -2239,6 +2241,7 @@ int32_t Parcel::readExceptionCode() const
    return status.exceptionCode();
}

#ifndef BINDER_DISABLE_NATIVE_HANDLE
native_handle* Parcel::readNativeHandle() const
{
    int numFds, numInts;
@@ -2271,6 +2274,7 @@ native_handle* Parcel::readNativeHandle() const
    }
    return h;
}
#endif

int Parcel::readFileDescriptor() const {
    if (const auto* rpcFields = maybeRpcFields()) {
+7 −2
Original line number Diff line number Diff line
@@ -26,7 +26,9 @@
#include <vector>

#include <android-base/unique_fd.h>
#ifndef BINDER_DISABLE_NATIVE_HANDLE
#include <cutils/native_handle.h>
#endif
#include <utils/Errors.h>
#include <utils/RefBase.h>
#include <utils/String16.h>
@@ -324,11 +326,13 @@ public:
    template<typename T>
    status_t            writeVectorSize(const std::unique_ptr<std::vector<T>>& val) __attribute__((deprecated("use std::optional version instead")));

#ifndef BINDER_DISABLE_NATIVE_HANDLE
    // Place a native_handle into the parcel (the native_handle's file-
    // descriptors are dup'ed, so it is safe to delete the native_handle
    // when this function returns).
    // Doesn't take ownership of the native_handle.
    status_t            writeNativeHandle(const native_handle* handle);
#endif

    // Place a file descriptor into the parcel.  The given fd must remain
    // valid for the lifetime of the parcel.
@@ -559,12 +563,13 @@ public:
    // response headers rather than doing it by hand.
    int32_t             readExceptionCode() const;

#ifndef BINDER_DISABLE_NATIVE_HANDLE
    // Retrieve native_handle from the parcel. This returns a copy of the
    // parcel's native_handle (the caller takes ownership). The caller
    // must free the native_handle with native_handle_close() and
    // native_handle_delete().
    native_handle*     readNativeHandle() const;

#endif

    // Retrieve a file descriptor from the parcel.  This returns the raw fd
    // in the parcel, which you do not own -- use dup() to get your own copy.