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

Commit 7a2d4091 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7402811 from 266ca8e1 to sc-d1-release

Change-Id: I2bb40a893d5dfd4f7fcfa4d460e6f92707ca5d52
parents 4126a3d4 266ca8e1
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -614,12 +614,6 @@ void IPCThreadState::processPostWriteDerefs()
    mPostWriteStrongDerefs.clear();
}

void IPCThreadState::createTransactionReference(RefBase* ref)
{
    ref->incStrong(mProcess.get());
    mPostWriteStrongDerefs.push(ref);
}

void IPCThreadState::joinThreadPool(bool isMain)
{
    LOG_THREADPOOL("**** THREAD %p (PID %d) IS JOINING THE THREAD POOL\n", (void*)pthread_self(), getpid());
+1 −1
Original line number Diff line number Diff line
@@ -401,7 +401,7 @@ static int open_driver(const char *driver)
        uint32_t enable = DEFAULT_ENABLE_ONEWAY_SPAM_DETECTION;
        result = ioctl(fd, BINDER_ENABLE_ONEWAY_SPAM_DETECTION, &enable);
        if (result == -1) {
            ALOGI("Binder ioctl to enable oneway spam detection failed: %s", strerror(errno));
            ALOGD("Binder ioctl to enable oneway spam detection failed: %s", strerror(errno));
        }
    } else {
        ALOGW("Opening '%s' failed: %s\n", driver, strerror(errno));
+0 −6
Original line number Diff line number Diff line
@@ -162,12 +162,6 @@ public:
            // This constant needs to be kept in sync with Binder.UNSET_WORKSOURCE from the Java
            // side.
            static const int32_t kUnsetWorkSource = -1;

            // Create a temp reference until commands in queue flushed to driver
            // Internal only.
            // @internal
            void                 createTransactionReference(RefBase* ref);

private:
                                IPCThreadState();
                                ~IPCThreadState();
+0 −43
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once


#include <binder/Parcel.h>
#include <utils/RefBase.h>

// ---------------------------------------------------------------------------
namespace android {

/**
 * internal use only
 * @internal
 */
class ParcelRef : public Parcel, public RefBase
{
public:
    static sp<ParcelRef> create() {
        return new ParcelRef();
    }

private:
    ParcelRef() = default;
};

} // namespace android

// ---------------------------------------------------------------------------
 No newline at end of file
+0 −31
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@
#include <binder/IBinder.h>
#include <binder/IPCThreadState.h>
#include <binder/IServiceManager.h>
#include <binder/ParcelRef.h>

#include <linux/sched.h>
#include <sys/epoll.h>
@@ -891,36 +890,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();