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

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

Merge changes I63739a0d,I62ec7bf0 am: b326ca55 am: a111e646 am: 2ffd2700 am: f27166c0

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

Change-Id: Id068a70dfc5772cad7234fcdd65bd0cf3e102dd4
parents 994aa3c1 f27166c0
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -194,10 +194,13 @@ bool BpBinder::isDescriptorCached() const {
const String16& BpBinder::getInterfaceDescriptor() const
{
    if (isDescriptorCached() == false) {
        Parcel send, reply;
        sp<BpBinder> thiz = const_cast<BpBinder*>(this);

        Parcel data;
        data.markForBinder(thiz);
        Parcel reply;
        // do the IPC without a lock held.
        status_t err = const_cast<BpBinder*>(this)->transact(
                INTERFACE_TRANSACTION, send, &reply);
        status_t err = thiz->transact(INTERFACE_TRANSACTION, data, &reply);
        if (err == NO_ERROR) {
            String16 res(reply.readString16());
            Mutex::Autolock _l(mLock);
+8 −5
Original line number Diff line number Diff line
@@ -27,10 +27,13 @@ struct AParcel {
    const ::android::Parcel* get() const { return mParcel; }
    ::android::Parcel* get() { return mParcel; }

    explicit AParcel(const AIBinder* binder)
        : AParcel(binder, new ::android::Parcel, true /*owns*/) {}
    AParcel(const AIBinder* binder, ::android::Parcel* parcel, bool owns)
        : mBinder(binder), mParcel(parcel), mOwns(owns) {}
    explicit AParcel(AIBinder* binder) : AParcel(binder, new ::android::Parcel, true /*owns*/) {}
    AParcel(AIBinder* binder, ::android::Parcel* parcel, bool owns)
        : mBinder(binder), mParcel(parcel), mOwns(owns) {
        if (binder != nullptr) {
            parcel->markForBinder(binder->getBinder());
        }
    }

    ~AParcel() {
        if (mOwns) {
@@ -38,7 +41,7 @@ struct AParcel {
        }
    }

    static const AParcel readOnly(const AIBinder* binder, const ::android::Parcel* parcel) {
    static const AParcel readOnly(AIBinder* binder, const ::android::Parcel* parcel) {
        return AParcel(binder, const_cast<::android::Parcel*>(parcel), false);
    }

+29 −3
Original line number Diff line number Diff line
@@ -104,6 +104,21 @@ cc_test {
    require_root: true,
}

aidl_interface {
    name: "binderRpcTestIface",
    host_supported: true,
    unstable: true,
    srcs: [
        "IBinderRpcSession.aidl",
        "IBinderRpcTest.aidl",
    ],
    backend: {
        java: {
            enabled: false,
        },
    },
}

cc_test {
    name: "binderRpcTest",
    host_supported: true,
@@ -112,20 +127,26 @@ cc_test {
            enabled: false,
        },
    },
    defaults: ["binder_test_defaults"],
    defaults: [
        "binder_test_defaults",
        "libbinder_ndk_host_user",
    ],

    srcs: [
        "IBinderRpcSession.aidl",
        "IBinderRpcTest.aidl",
        "binderRpcTest.cpp",
    ],
    shared_libs: [
        "libbinder",
        "libbinder_ndk",
        "libbase",
        "libutils",
        "libcutils",
        "liblog",
    ],
    static_libs: [
        "binderRpcTestIface-cpp",
        "binderRpcTestIface-ndk_platform",
    ],
    test_suites: ["general-tests"],
    require_root: true,
}
@@ -216,6 +237,11 @@ aidl_interface {
    srcs: [
        "IBinderStabilityTest.aidl",
    ],
    backend: {
        java: {
            enabled: false,
        },
    },
}

cc_test {
+33 −0
Original line number Diff line number Diff line
@@ -16,7 +16,10 @@

#include <BnBinderRpcSession.h>
#include <BnBinderRpcTest.h>
#include <aidl/IBinderRpcTest.h>
#include <android-base/logging.h>
#include <android/binder_auto_utils.h>
#include <android/binder_libbinder.h>
#include <binder/Binder.h>
#include <binder/BpBinder.h>
#include <binder/IServiceManager.h>
@@ -383,6 +386,12 @@ TEST_P(BinderRpc, Ping) {
    EXPECT_EQ(OK, proc.rootBinder->pingBinder());
}

TEST_P(BinderRpc, GetInterfaceDescriptor) {
    auto proc = createRpcTestSocketServerProcess(1);
    ASSERT_NE(proc.rootBinder, nullptr);
    EXPECT_EQ(IBinderRpcTest::descriptor, proc.rootBinder->getInterfaceDescriptor());
}

TEST_P(BinderRpc, TransactionsMustBeMarkedRpc) {
    auto proc = createRpcTestSocketServerProcess(1);
    Parcel data;
@@ -786,6 +795,30 @@ TEST_P(BinderRpc, Die) {
    }
}

TEST_P(BinderRpc, WorksWithLibbinderNdkPing) {
    auto proc = createRpcTestSocketServerProcess(1);

    ndk::SpAIBinder binder = ndk::SpAIBinder(AIBinder_fromPlatformBinder(proc.rootBinder));
    ASSERT_NE(binder, nullptr);

    ASSERT_EQ(STATUS_OK, AIBinder_ping(binder.get()));
}

TEST_P(BinderRpc, WorksWithLibbinderNdkUserTransaction) {
    auto proc = createRpcTestSocketServerProcess(1);

    ndk::SpAIBinder binder = ndk::SpAIBinder(AIBinder_fromPlatformBinder(proc.rootBinder));
    ASSERT_NE(binder, nullptr);

    auto ndkBinder = aidl::IBinderRpcTest::fromBinder(binder);
    ASSERT_NE(ndkBinder, nullptr);

    std::string out;
    ndk::ScopedAStatus status = ndkBinder->doubleString("aoeu", &out);
    ASSERT_TRUE(status.isOk()) << status.getDescription();
    ASSERT_EQ("aoeuaoeu", out);
}

ssize_t countFds() {
    DIR* dir = opendir("/proc/self/fd/");
    if (dir == nullptr) return -1;