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

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

Merge changes I89e4de2e,I673d7a4c,Icfb454c2,I5924a82c am: a54c8618 am: d612489a

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

Change-Id: Iefab3593ba5f4b4b4e7b3ba8de3490af7f369acf
parents f4b83741 d612489a
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -510,7 +510,7 @@ void BpBinder::onLastStrongRef(const void* /*id*/)
{
{
    ALOGV("onLastStrongRef BpBinder %p handle %d\n", this, binderHandle());
    ALOGV("onLastStrongRef BpBinder %p handle %d\n", this, binderHandle());
    if (CC_UNLIKELY(isRpcBinder())) {
    if (CC_UNLIKELY(isRpcBinder())) {
        (void)rpcSession()->sendDecStrong(rpcAddress());
        (void)rpcSession()->sendDecStrong(this);
        return;
        return;
    }
    }
    IF_ALOGV() {
    IF_ALOGV() {
+2 −2
Original line number Original line Diff line number Diff line
@@ -237,7 +237,7 @@ status_t Parcel::flattenBinder(const sp<IBinder>& binder) {
                    return INVALID_OPERATION;
                    return INVALID_OPERATION;
                }
                }
            }
            }
            const int32_t handle = proxy ? proxy->getPrivateAccessorForId().binderHandle() : 0;
            const int32_t handle = proxy ? proxy->getPrivateAccessor().binderHandle() : 0;
            obj.hdr.type = BINDER_TYPE_HANDLE;
            obj.hdr.type = BINDER_TYPE_HANDLE;
            obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */
            obj.binder = 0; /* Don't pass uninitialized stack data to a remote process */
            obj.handle = handle;
            obj.handle = handle;
@@ -572,7 +572,7 @@ void Parcel::markForBinder(const sp<IBinder>& binder) {
    LOG_ALWAYS_FATAL_IF(mData != nullptr, "format must be set before data is written");
    LOG_ALWAYS_FATAL_IF(mData != nullptr, "format must be set before data is written");


    if (binder && binder->remoteBinder() && binder->remoteBinder()->isRpcBinder()) {
    if (binder && binder->remoteBinder() && binder->remoteBinder()->isRpcBinder()) {
        markForRpc(binder->remoteBinder()->getPrivateAccessorForId().rpcSession());
        markForRpc(binder->remoteBinder()->getPrivateAccessor().rpcSession());
    }
    }
}
}


+2 −2
Original line number Original line Diff line number Diff line
@@ -212,7 +212,7 @@ ssize_t ProcessState::getStrongRefCountForNode(const sp<BpBinder>& binder) {
    binder_node_info_for_ref info;
    binder_node_info_for_ref info;
    memset(&info, 0, sizeof(binder_node_info_for_ref));
    memset(&info, 0, sizeof(binder_node_info_for_ref));


    info.handle = binder->getPrivateAccessorForId().binderHandle();
    info.handle = binder->getPrivateAccessor().binderHandle();


    status_t result = ioctl(mDriverFD, BINDER_GET_NODE_INFO_FOR_REF, &info);
    status_t result = ioctl(mDriverFD, BINDER_GET_NODE_INFO_FOR_REF, &info);


@@ -301,7 +301,7 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle)
                   return nullptr;
                   return nullptr;
            }
            }


            sp<BpBinder> b = BpBinder::create(handle);
            sp<BpBinder> b = BpBinder::PrivateAccessor::create(handle);
            e->binder = b.get();
            e->binder = b.get();
            if (b) e->refs = b->getWeakRefs();
            if (b) e->refs = b->getWeakRefs();
            result = b;
            result = b;
+12 −5
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@
#include <android-base/hex.h>
#include <android-base/hex.h>
#include <android-base/macros.h>
#include <android-base/macros.h>
#include <android_runtime/vm.h>
#include <android_runtime/vm.h>
#include <binder/BpBinder.h>
#include <binder/Parcel.h>
#include <binder/Parcel.h>
#include <binder/RpcServer.h>
#include <binder/RpcServer.h>
#include <binder/RpcTransportRaw.h>
#include <binder/RpcTransportRaw.h>
@@ -191,7 +192,7 @@ bool RpcSession::shutdownAndWait(bool wait) {


    if (wait) {
    if (wait) {
        LOG_ALWAYS_FATAL_IF(mShutdownListener == nullptr, "Shutdown listener not installed");
        LOG_ALWAYS_FATAL_IF(mShutdownListener == nullptr, "Shutdown listener not installed");
        mShutdownListener->waitForShutdown(_l);
        mShutdownListener->waitForShutdown(_l, sp<RpcSession>::fromExisting(this));


        LOG_ALWAYS_FATAL_IF(!mThreads.empty(), "Shutdown failed");
        LOG_ALWAYS_FATAL_IF(!mThreads.empty(), "Shutdown failed");
    }
    }
@@ -215,6 +216,10 @@ status_t RpcSession::transact(const sp<IBinder>& binder, uint32_t code, const Pa
                             sp<RpcSession>::fromExisting(this), reply, flags);
                             sp<RpcSession>::fromExisting(this), reply, flags);
}
}


status_t RpcSession::sendDecStrong(const BpBinder* binder) {
    return sendDecStrong(binder->getPrivateAccessor().rpcAddress());
}

status_t RpcSession::sendDecStrong(uint64_t address) {
status_t RpcSession::sendDecStrong(uint64_t address) {
    ExclusiveConnection connection;
    ExclusiveConnection connection;
    status_t status = ExclusiveConnection::find(sp<RpcSession>::fromExisting(this),
    status_t status = ExclusiveConnection::find(sp<RpcSession>::fromExisting(this),
@@ -245,17 +250,19 @@ status_t RpcSession::readId() {
void RpcSession::WaitForShutdownListener::onSessionAllIncomingThreadsEnded(
void RpcSession::WaitForShutdownListener::onSessionAllIncomingThreadsEnded(
        const sp<RpcSession>& session) {
        const sp<RpcSession>& session) {
    (void)session;
    (void)session;
    mShutdown = true;
}
}


void RpcSession::WaitForShutdownListener::onSessionIncomingThreadEnded() {
void RpcSession::WaitForShutdownListener::onSessionIncomingThreadEnded() {
    mCv.notify_all();
    mCv.notify_all();
}
}


void RpcSession::WaitForShutdownListener::waitForShutdown(std::unique_lock<std::mutex>& lock) {
void RpcSession::WaitForShutdownListener::waitForShutdown(std::unique_lock<std::mutex>& lock,
    while (!mShutdown) {
                                                          const sp<RpcSession>& session) {
    while (session->mIncomingConnections.size() > 0) {
        if (std::cv_status::timeout == mCv.wait_for(lock, std::chrono::seconds(1))) {
        if (std::cv_status::timeout == mCv.wait_for(lock, std::chrono::seconds(1))) {
            ALOGE("Waiting for RpcSession to shut down (1s w/o progress).");
            ALOGE("Waiting for RpcSession to shut down (1s w/o progress): %zu incoming connections "
                  "still.",
                  session->mIncomingConnections.size());
        }
        }
    }
    }
}
}
+3 −4
Original line number Original line Diff line number Diff line
@@ -56,7 +56,7 @@ status_t RpcState::onBinderLeaving(const sp<RpcSession>& session, const sp<IBind
    bool isRemote = binder->remoteBinder();
    bool isRemote = binder->remoteBinder();
    bool isRpc = isRemote && binder->remoteBinder()->isRpcBinder();
    bool isRpc = isRemote && binder->remoteBinder()->isRpcBinder();


    if (isRpc && binder->remoteBinder()->getPrivateAccessorForId().rpcSession() != session) {
    if (isRpc && binder->remoteBinder()->getPrivateAccessor().rpcSession() != session) {
        // We need to be able to send instructions over the socket for how to
        // We need to be able to send instructions over the socket for how to
        // connect to a different server, and we also need to let the host
        // connect to a different server, and we also need to let the host
        // process know that this is happening.
        // process know that this is happening.
@@ -85,8 +85,7 @@ status_t RpcState::onBinderLeaving(const sp<RpcSession>& session, const sp<IBind
        if (binder == node.binder) {
        if (binder == node.binder) {
            if (isRpc) {
            if (isRpc) {
                // check integrity of data structure
                // check integrity of data structure
                uint64_t actualAddr =
                uint64_t actualAddr = binder->remoteBinder()->getPrivateAccessor().rpcAddress();
                        binder->remoteBinder()->getPrivateAccessorForId().rpcAddress();
                LOG_ALWAYS_FATAL_IF(addr != actualAddr, "Address mismatch %" PRIu64 " vs %" PRIu64,
                LOG_ALWAYS_FATAL_IF(addr != actualAddr, "Address mismatch %" PRIu64 " vs %" PRIu64,
                                    addr, actualAddr);
                                    addr, actualAddr);
            }
            }
@@ -185,7 +184,7 @@ status_t RpcState::onBinderEntering(const sp<RpcSession>& session, uint64_t addr


    // Currently, all binders are assumed to be part of the same session (no
    // Currently, all binders are assumed to be part of the same session (no
    // device global binders in the RPC world).
    // device global binders in the RPC world).
    it->second.binder = *out = BpBinder::create(session, it->first);
    it->second.binder = *out = BpBinder::PrivateAccessor::create(session, it->first);
    it->second.timesRecd = 1;
    it->second.timesRecd = 1;
    return OK;
    return OK;
}
}
Loading