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

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

Revert "libbinder: test parcel allocted on another thread" am: c0c9f77b am:...

Revert "libbinder: test parcel allocted on another thread" am: c0c9f77b am: 46d15de3 am: 104656ba am: 883caeb3

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

Change-Id: Ied6987041d1b0b24e580abc476873b6d3fa985a0
parents 091303fd 883caeb3
Loading
Loading
Loading
Loading
+0 −31
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@
#include <binder/IBinder.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/ParcelRef.h>
#include <binder/RpcServer.h>
#include <binder/RpcSession.h>

@@ -932,36 +931,6 @@ TEST_F(BinderLibTest, FreedBinder) {
    }
}

TEST_F(BinderLibTest, ParcelAllocatedOnAnotherThread) {
    sp<IBinder> server = addServer();
    ASSERT_TRUE(server != nullptr);

    Parcel data;
    sp<ParcelRef> reply = ParcelRef::create();

    // when we have a Parcel which is deleted on another thread, if it gets
    // deleted, it will tell the kernel this, and it will drop strong references
    // to binder, so that we can't BR_ACQUIRE would fail
    IPCThreadState::self()->createTransactionReference(reply.get());
    ASSERT_EQ(NO_ERROR, server->transact(BINDER_LIB_TEST_CREATE_BINDER_TRANSACTION,
                                         data,
                                         reply.get()));

    // we have sp to binder, but it is not actually acquired by kernel, the
    // transaction is sitting on an out buffer
    sp<IBinder> binder = reply->readStrongBinder();

    std::thread([&] {
        // without the transaction reference, this would cause the Parcel to be
        // deallocated before the first thread flushes BR_ACQUIRE
        reply = nullptr;
        IPCThreadState::self()->flushCommands();
    }).join();

    ASSERT_NE(nullptr, binder);
    ASSERT_EQ(NO_ERROR, binder->pingBinder());
}

TEST_F(BinderLibTest, CheckNoHeaderMappedInUser) {
    Parcel data, reply;
    sp<BinderLibTestCallBack> callBack = new BinderLibTestCallBack();