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

Commit d5cc17b3 authored by Steven Moreland's avatar Steven Moreland Committed by Gerrit Code Review
Browse files

Merge "libbinder use stronger refbase semantics"

parents 369abe01 1a3a8eff
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ cc_library {
        "-Werror",
        "-Wzero-as-null-pointer-constant",
        "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
        "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
    ],
    product_variables: {
        binder32bit: {
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ static const sp<IBinder>& getClientId() {

    pthread_mutex_lock(&gClientIdMutex);
    if (gClientId == nullptr) {
        gClientId = new BBinder();
        gClientId = sp<BBinder>::make();
    }
    pthread_mutex_unlock(&gClientIdMutex);
    return gClientId;
+7 −8
Original line number Diff line number Diff line
@@ -107,8 +107,7 @@ void BpBinder::ObjectManager::kill()

// ---------------------------------------------------------------------------


BpBinder* BpBinder::create(int32_t handle) {
sp<BpBinder> BpBinder::create(int32_t handle) {
    int32_t trackedUid = -1;
    if (sCountByUidEnabled) {
        trackedUid = IPCThreadState::self()->getCallingUid();
@@ -134,10 +133,10 @@ BpBinder* BpBinder::create(int32_t handle) {
        }
        sTrackingMap[trackedUid]++;
    }
    return new BpBinder(BinderHandle{handle}, trackedUid);
    return sp<BpBinder>::make(BinderHandle{handle}, trackedUid);
}

BpBinder* BpBinder::create(const sp<RpcConnection>& connection, const RpcAddress& address) {
sp<BpBinder> BpBinder::create(const sp<RpcConnection>& connection, const RpcAddress& address) {
    LOG_ALWAYS_FATAL_IF(connection == nullptr, "BpBinder::create null connection");

    // These are not currently tracked, since there is no UID or other
@@ -145,7 +144,7 @@ BpBinder* BpBinder::create(const sp<RpcConnection>& connection, const RpcAddress
    // needed, connection objects keep track of all BpBinder objects on a
    // per-connection basis.

    return new BpBinder(SocketHandle{connection, address});
    return sp<BpBinder>::make(SocketHandle{connection, address});
}

BpBinder::BpBinder(Handle&& handle)
@@ -194,7 +193,7 @@ bool BpBinder::isDescriptorCached() const {
const String16& BpBinder::getInterfaceDescriptor() const
{
    if (isDescriptorCached() == false) {
        sp<BpBinder> thiz = const_cast<BpBinder*>(this);
        sp<BpBinder> thiz = sp<BpBinder>::fromExisting(const_cast<BpBinder*>(this));

        Parcel data;
        data.markForBinder(thiz);
@@ -226,7 +225,7 @@ bool BpBinder::isBinderAlive() const
status_t BpBinder::pingBinder()
{
    Parcel data;
    data.markForBinder(this);
    data.markForBinder(sp<BpBinder>::fromExisting(this));
    Parcel reply;
    return transact(PING_TRANSACTION, data, &reply);
}
@@ -403,7 +402,7 @@ void BpBinder::reportOneDeath(const Obituary& obit)
    ALOGV("Reporting death to recipient: %p\n", recipient.get());
    if (recipient == nullptr) return;

    recipient->binderDied(this);
    recipient->binderDied(wp<BpBinder>::fromExisting(this));
}


+1 −1
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ BufferedTextOutput::BufferState* BufferedTextOutput::getBuffer() const
        BufferState* bs = ts.states[mIndex].get();
        if (bs != nullptr && bs->seq == mSeq) return bs;

        ts.states.editItemAt(mIndex) = new BufferState(mIndex);
        ts.states.editItemAt(mIndex) = sp<BufferState>::make(mIndex);
        bs = ts.states[mIndex].get();
        if (bs != nullptr) return bs;
    }
+2 −2
Original line number Diff line number Diff line
@@ -33,14 +33,14 @@ IInterface::~IInterface() {
sp<IBinder> IInterface::asBinder(const IInterface* iface)
{
    if (iface == nullptr) return nullptr;
    return const_cast<IInterface*>(iface)->onAsBinder();
    return sp<IBinder>::fromExisting(const_cast<IInterface*>(iface)->onAsBinder());
}

// static
sp<IBinder> IInterface::asBinder(const sp<IInterface>& iface)
{
    if (iface == nullptr) return nullptr;
    return iface->onAsBinder();
    return sp<IBinder>::fromExisting(iface->onAsBinder());
}


Loading