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

Commit 4cf688f1 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder: RPC with getInterfaceDescriptor

I need to follow up/add tests for all the built-in transactions, since
they need to call markForBinder, but this is required for making RPC
calls over NDK because this backend proactively retrieves the interface
descriptor (side note: potential optimization improvement).

Bug: 167966510
Test: binderRpcTest
Change-Id: I62ec7bf09040563d46aa43a685efb87e3add524f
parent 8911d46b
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -194,10 +194,13 @@ bool BpBinder::isDescriptorCached() const {
const String16& BpBinder::getInterfaceDescriptor() const
const String16& BpBinder::getInterfaceDescriptor() const
{
{
    if (isDescriptorCached() == false) {
    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.
        // do the IPC without a lock held.
        status_t err = const_cast<BpBinder*>(this)->transact(
        status_t err = thiz->transact(INTERFACE_TRANSACTION, data, &reply);
                INTERFACE_TRANSACTION, send, &reply);
        if (err == NO_ERROR) {
        if (err == NO_ERROR) {
            String16 res(reply.readString16());
            String16 res(reply.readString16());
            Mutex::Autolock _l(mLock);
            Mutex::Autolock _l(mLock);
+6 −0
Original line number Original line Diff line number Diff line
@@ -383,6 +383,12 @@ TEST_P(BinderRpc, Ping) {
    EXPECT_EQ(OK, proc.rootBinder->pingBinder());
    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) {
TEST_P(BinderRpc, TransactionsMustBeMarkedRpc) {
    auto proc = createRpcTestSocketServerProcess(1);
    auto proc = createRpcTestSocketServerProcess(1);
    Parcel data;
    Parcel data;