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

Commit aabd6b7f authored by Yi Kong's avatar Yi Kong Committed by android-build-merger
Browse files

Merge "[binder] Replace NULL/0 with nullptr"

am: a800be83

Change-Id: I7e118d3def0f9643a79fa9003a89234340d941ea
parents 83af6009 a800be83
Loading
Loading
Loading
Loading
+11 −11
Original line number Original line Diff line number Diff line
@@ -42,7 +42,7 @@ static sp<IBinder> gToken;


static const sp<IBinder>& getToken(const sp<IAppOpsService>& service) {
static const sp<IBinder>& getToken(const sp<IAppOpsService>& service) {
    pthread_mutex_lock(&gTokenMutex);
    pthread_mutex_lock(&gTokenMutex);
    if (gToken == NULL || gToken->pingBinder() != NO_ERROR) {
    if (gToken == nullptr || gToken->pingBinder() != NO_ERROR) {
        gToken = service->getToken(new BBinder());
        gToken = service->getToken(new BBinder());
    }
    }
    pthread_mutex_unlock(&gTokenMutex);
    pthread_mutex_unlock(&gTokenMutex);
@@ -63,16 +63,16 @@ sp<IAppOpsService> AppOpsManager::getService()
    std::lock_guard<Mutex> scoped_lock(mLock);
    std::lock_guard<Mutex> scoped_lock(mLock);
    int64_t startTime = 0;
    int64_t startTime = 0;
    sp<IAppOpsService> service = mService;
    sp<IAppOpsService> service = mService;
    while (service == NULL || !IInterface::asBinder(service)->isBinderAlive()) {
    while (service == nullptr || !IInterface::asBinder(service)->isBinderAlive()) {
        sp<IBinder> binder = defaultServiceManager()->checkService(_appops);
        sp<IBinder> binder = defaultServiceManager()->checkService(_appops);
        if (binder == NULL) {
        if (binder == nullptr) {
            // Wait for the app ops service to come back...
            // Wait for the app ops service to come back...
            if (startTime == 0) {
            if (startTime == 0) {
                startTime = uptimeMillis();
                startTime = uptimeMillis();
                ALOGI("Waiting for app ops service");
                ALOGI("Waiting for app ops service");
            } else if ((uptimeMillis()-startTime) > 10000) {
            } else if ((uptimeMillis()-startTime) > 10000) {
                ALOGW("Waiting too long for app ops service, giving up");
                ALOGW("Waiting too long for app ops service, giving up");
                service = NULL;
                service = nullptr;
                break;
                break;
            }
            }
            sleep(1);
            sleep(1);
@@ -88,28 +88,28 @@ sp<IAppOpsService> AppOpsManager::getService()
int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingPackage)
int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingPackage)
{
{
    sp<IAppOpsService> service = getService();
    sp<IAppOpsService> service = getService();
    return service != NULL
    return service != nullptr
            ? service->checkOperation(op, uid, callingPackage)
            ? service->checkOperation(op, uid, callingPackage)
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
}


int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) {
int32_t AppOpsManager::noteOp(int32_t op, int32_t uid, const String16& callingPackage) {
    sp<IAppOpsService> service = getService();
    sp<IAppOpsService> service = getService();
    return service != NULL
    return service != nullptr
            ? service->noteOperation(op, uid, callingPackage)
            ? service->noteOperation(op, uid, callingPackage)
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
}


int32_t AppOpsManager::startOp(int32_t op, int32_t uid, const String16& callingPackage) {
int32_t AppOpsManager::startOp(int32_t op, int32_t uid, const String16& callingPackage) {
    sp<IAppOpsService> service = getService();
    sp<IAppOpsService> service = getService();
    return service != NULL
    return service != nullptr
            ? service->startOperation(getToken(service), op, uid, callingPackage)
            ? service->startOperation(getToken(service), op, uid, callingPackage)
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
}


void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage) {
void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPackage) {
    sp<IAppOpsService> service = getService();
    sp<IAppOpsService> service = getService();
    if (service != NULL) {
    if (service != nullptr) {
        service->finishOperation(getToken(service), op, uid, callingPackage);
        service->finishOperation(getToken(service), op, uid, callingPackage);
    }
    }
}
}
@@ -117,21 +117,21 @@ void AppOpsManager::finishOp(int32_t op, int32_t uid, const String16& callingPac
void AppOpsManager::startWatchingMode(int32_t op, const String16& packageName,
void AppOpsManager::startWatchingMode(int32_t op, const String16& packageName,
        const sp<IAppOpsCallback>& callback) {
        const sp<IAppOpsCallback>& callback) {
    sp<IAppOpsService> service = getService();
    sp<IAppOpsService> service = getService();
    if (service != NULL) {
    if (service != nullptr) {
        service->startWatchingMode(op, packageName, callback);
        service->startWatchingMode(op, packageName, callback);
    }
    }
}
}


void AppOpsManager::stopWatchingMode(const sp<IAppOpsCallback>& callback) {
void AppOpsManager::stopWatchingMode(const sp<IAppOpsCallback>& callback) {
    sp<IAppOpsService> service = getService();
    sp<IAppOpsService> service = getService();
    if (service != NULL) {
    if (service != nullptr) {
        service->stopWatchingMode(callback);
        service->stopWatchingMode(callback);
    }
    }
}
}


int32_t AppOpsManager::permissionToOpCode(const String16& permission) {
int32_t AppOpsManager::permissionToOpCode(const String16& permission) {
    sp<IAppOpsService> service = getService();
    sp<IAppOpsService> service = getService();
    if (service != NULL) {
    if (service != nullptr) {
        return service->permissionToOpCode(permission);
        return service->permissionToOpCode(permission);
    }
    }
    return -1;
    return -1;
+10 −10
Original line number Original line Diff line number Diff line
@@ -43,17 +43,17 @@ IBinder::~IBinder()


sp<IInterface>  IBinder::queryLocalInterface(const String16& /*descriptor*/)
sp<IInterface>  IBinder::queryLocalInterface(const String16& /*descriptor*/)
{
{
    return NULL;
    return nullptr;
}
}


BBinder* IBinder::localBinder()
BBinder* IBinder::localBinder()
{
{
    return NULL;
    return nullptr;
}
}


BpBinder* IBinder::remoteBinder()
BpBinder* IBinder::remoteBinder()
{
{
    return NULL;
    return nullptr;
}
}


bool IBinder::checkSubclass(const void* /*subclassID*/) const
bool IBinder::checkSubclass(const void* /*subclassID*/) const
@@ -76,8 +76,8 @@ status_t IBinder::shellCommand(const sp<IBinder>& target, int in, int out, int e
    for (size_t i = 0; i < numArgs; i++) {
    for (size_t i = 0; i < numArgs; i++) {
        send.writeString16(args[i]);
        send.writeString16(args[i]);
    }
    }
    send.writeStrongBinder(callback != NULL ? IInterface::asBinder(callback) : NULL);
    send.writeStrongBinder(callback != nullptr ? IInterface::asBinder(callback) : nullptr);
    send.writeStrongBinder(resultReceiver != NULL ? IInterface::asBinder(resultReceiver) : NULL);
    send.writeStrongBinder(resultReceiver != nullptr ? IInterface::asBinder(resultReceiver) : nullptr);
    return target->transact(SHELL_COMMAND_TRANSACTION, send, &reply);
    return target->transact(SHELL_COMMAND_TRANSACTION, send, &reply);
}
}


@@ -130,7 +130,7 @@ status_t BBinder::transact(
            break;
            break;
    }
    }


    if (reply != NULL) {
    if (reply != nullptr) {
        reply->setDataPosition(0);
        reply->setDataPosition(0);
    }
    }


@@ -171,7 +171,7 @@ void BBinder::attachObject(
            delete e;
            delete e;
            e = expected;  // Filled in by CAS
            e = expected;  // Filled in by CAS
        }
        }
        if (e == 0) return; // out of memory
        if (e == nullptr) return; // out of memory
    }
    }


    AutoMutex _l(e->mLock);
    AutoMutex _l(e->mLock);
@@ -181,7 +181,7 @@ void BBinder::attachObject(
void* BBinder::findObject(const void* objectID) const
void* BBinder::findObject(const void* objectID) const
{
{
    Extras* e = mExtras.load(std::memory_order_acquire);
    Extras* e = mExtras.load(std::memory_order_acquire);
    if (!e) return NULL;
    if (!e) return nullptr;


    AutoMutex _l(e->mLock);
    AutoMutex _l(e->mLock);
    return e->mObjects.find(objectID);
    return e->mObjects.find(objectID);
@@ -246,7 +246,7 @@ status_t BBinder::onTransact(
            (void)out;
            (void)out;
            (void)err;
            (void)err;


            if (resultReceiver != NULL) {
            if (resultReceiver != nullptr) {
                resultReceiver->send(INVALID_OPERATION);
                resultReceiver->send(INVALID_OPERATION);
            }
            }


@@ -273,7 +273,7 @@ enum {
};
};


BpRefBase::BpRefBase(const sp<IBinder>& o)
BpRefBase::BpRefBase(const sp<IBinder>& o)
    : mRemote(o.get()), mRefs(NULL), mState(0)
    : mRemote(o.get()), mRefs(nullptr), mState(0)
{
{
    extendObjectLifetime(OBJECT_LIFETIME_WEAK);
    extendObjectLifetime(OBJECT_LIFETIME_WEAK);


+14 −14
Original line number Original line Diff line number Diff line
@@ -62,7 +62,7 @@ void BpBinder::ObjectManager::attach(
void* BpBinder::ObjectManager::find(const void* objectID) const
void* BpBinder::ObjectManager::find(const void* objectID) const
{
{
    const ssize_t i = mObjects.indexOfKey(objectID);
    const ssize_t i = mObjects.indexOfKey(objectID);
    if (i < 0) return NULL;
    if (i < 0) return nullptr;
    return mObjects.valueAt(i).object;
    return mObjects.valueAt(i).object;
}
}


@@ -77,7 +77,7 @@ void BpBinder::ObjectManager::kill()
    ALOGV("Killing %zu objects in manager %p", N, this);
    ALOGV("Killing %zu objects in manager %p", N, this);
    for (size_t i=0; i<N; i++) {
    for (size_t i=0; i<N; i++) {
        const entry_t& e = mObjects.valueAt(i);
        const entry_t& e = mObjects.valueAt(i);
        if (e.func != NULL) {
        if (e.func != nullptr) {
            e.func(mObjects.keyAt(i), e.object, e.cleanupCookie);
            e.func(mObjects.keyAt(i), e.object, e.cleanupCookie);
        }
        }
    }
    }
@@ -91,7 +91,7 @@ BpBinder::BpBinder(int32_t handle)
    : mHandle(handle)
    : mHandle(handle)
    , mAlive(1)
    , mAlive(1)
    , mObitsSent(0)
    , mObitsSent(0)
    , mObituaries(NULL)
    , mObituaries(nullptr)
{
{
    ALOGV("Creating BpBinder %p handle %d\n", this, mHandle);
    ALOGV("Creating BpBinder %p handle %d\n", this, mHandle);


@@ -179,7 +179,7 @@ status_t BpBinder::linkToDeath(
    ob.cookie = cookie;
    ob.cookie = cookie;
    ob.flags = flags;
    ob.flags = flags;


    LOG_ALWAYS_FATAL_IF(recipient == NULL,
    LOG_ALWAYS_FATAL_IF(recipient == nullptr,
                        "linkToDeath(): recipient must be non-NULL");
                        "linkToDeath(): recipient must be non-NULL");


    {
    {
@@ -219,9 +219,9 @@ status_t BpBinder::unlinkToDeath(
    for (size_t i=0; i<N; i++) {
    for (size_t i=0; i<N; i++) {
        const Obituary& obit = mObituaries->itemAt(i);
        const Obituary& obit = mObituaries->itemAt(i);
        if ((obit.recipient == recipient
        if ((obit.recipient == recipient
                    || (recipient == NULL && obit.cookie == cookie))
                    || (recipient == nullptr && obit.cookie == cookie))
                && obit.flags == flags) {
                && obit.flags == flags) {
            if (outRecipient != NULL) {
            if (outRecipient != nullptr) {
                *outRecipient = mObituaries->itemAt(i).recipient;
                *outRecipient = mObituaries->itemAt(i).recipient;
            }
            }
            mObituaries->removeAt(i);
            mObituaries->removeAt(i);
@@ -231,7 +231,7 @@ status_t BpBinder::unlinkToDeath(
                self->clearDeathNotification(mHandle, this);
                self->clearDeathNotification(mHandle, this);
                self->flushCommands();
                self->flushCommands();
                delete mObituaries;
                delete mObituaries;
                mObituaries = NULL;
                mObituaries = nullptr;
            }
            }
            return NO_ERROR;
            return NO_ERROR;
        }
        }
@@ -250,12 +250,12 @@ void BpBinder::sendObituary()


    mLock.lock();
    mLock.lock();
    Vector<Obituary>* obits = mObituaries;
    Vector<Obituary>* obits = mObituaries;
    if(obits != NULL) {
    if(obits != nullptr) {
        ALOGV("Clearing sent death notification: %p handle %d\n", this, mHandle);
        ALOGV("Clearing sent death notification: %p handle %d\n", this, mHandle);
        IPCThreadState* self = IPCThreadState::self();
        IPCThreadState* self = IPCThreadState::self();
        self->clearDeathNotification(mHandle, this);
        self->clearDeathNotification(mHandle, this);
        self->flushCommands();
        self->flushCommands();
        mObituaries = NULL;
        mObituaries = nullptr;
    }
    }
    mObitsSent = 1;
    mObitsSent = 1;
    mLock.unlock();
    mLock.unlock();
@@ -263,7 +263,7 @@ void BpBinder::sendObituary()
    ALOGV("Reporting death of proxy %p for %zu recipients\n",
    ALOGV("Reporting death of proxy %p for %zu recipients\n",
        this, obits ? obits->size() : 0U);
        this, obits ? obits->size() : 0U);


    if (obits != NULL) {
    if (obits != nullptr) {
        const size_t N = obits->size();
        const size_t N = obits->size();
        for (size_t i=0; i<N; i++) {
        for (size_t i=0; i<N; i++) {
            reportOneDeath(obits->itemAt(i));
            reportOneDeath(obits->itemAt(i));
@@ -277,7 +277,7 @@ void BpBinder::reportOneDeath(const Obituary& obit)
{
{
    sp<DeathRecipient> recipient = obit.recipient.promote();
    sp<DeathRecipient> recipient = obit.recipient.promote();
    ALOGV("Reporting death to recipient: %p\n", recipient.get());
    ALOGV("Reporting death to recipient: %p\n", recipient.get());
    if (recipient == NULL) return;
    if (recipient == nullptr) return;


    recipient->binderDied(this);
    recipient->binderDied(this);
}
}
@@ -317,13 +317,13 @@ BpBinder::~BpBinder()


    mLock.lock();
    mLock.lock();
    Vector<Obituary>* obits = mObituaries;
    Vector<Obituary>* obits = mObituaries;
    if(obits != NULL) {
    if(obits != nullptr) {
        if (ipc) ipc->clearDeathNotification(mHandle, this);
        if (ipc) ipc->clearDeathNotification(mHandle, this);
        mObituaries = NULL;
        mObituaries = nullptr;
    }
    }
    mLock.unlock();
    mLock.unlock();


    if (obits != NULL) {
    if (obits != nullptr) {
        // XXX Should we tell any remaining DeathRecipient
        // XXX Should we tell any remaining DeathRecipient
        // objects that the last strong ref has gone away, so they
        // objects that the last strong ref has gone away, so they
        // are no longer linked?
        // are no longer linked?
+4 −4
Original line number Original line Diff line number Diff line
@@ -36,7 +36,7 @@ struct BufferedTextOutput::BufferState : public RefBase
{
{
    explicit BufferState(int32_t _seq)
    explicit BufferState(int32_t _seq)
        : seq(_seq)
        : seq(_seq)
        , buffer(NULL)
        , buffer(nullptr)
        , bufferPos(0)
        , bufferPos(0)
        , bufferSize(0)
        , bufferSize(0)
        , atFront(true)
        , atFront(true)
@@ -266,13 +266,13 @@ BufferedTextOutput::BufferState* BufferedTextOutput::getBuffer() const
    if ((mFlags&MULTITHREADED) != 0) {
    if ((mFlags&MULTITHREADED) != 0) {
        ThreadState* ts = getThreadState();
        ThreadState* ts = getThreadState();
        if (ts) {
        if (ts) {
            while (ts->states.size() <= (size_t)mIndex) ts->states.add(NULL);
            while (ts->states.size() <= (size_t)mIndex) ts->states.add(nullptr);
            BufferState* bs = ts->states[mIndex].get();
            BufferState* bs = ts->states[mIndex].get();
            if (bs != NULL && bs->seq == mSeq) return bs;
            if (bs != nullptr && bs->seq == mSeq) return bs;
            
            
            ts->states.editItemAt(mIndex) = new BufferState(mIndex);
            ts->states.editItemAt(mIndex) = new BufferState(mIndex);
            bs = ts->states[mIndex].get();
            bs = ts->states[mIndex].get();
            if (bs != NULL) return bs;
            if (bs != nullptr) return bs;
        }
        }
    }
    }
    
    
+3 −3
Original line number Original line Diff line number Diff line
@@ -165,13 +165,13 @@ void printHexData(int32_t indent, const void *buf, size_t length,
        else if (bytesPerLine >= 8) alignment = 2;
        else if (bytesPerLine >= 8) alignment = 2;
        else alignment = 1;
        else alignment = 1;
    }
    }
    if (func == NULL) func = defaultPrintFunc;
    if (func == nullptr) func = defaultPrintFunc;


    size_t offset;
    size_t offset;


    unsigned char *pos = (unsigned char *)buf;
    unsigned char *pos = (unsigned char *)buf;


    if (pos == NULL) {
    if (pos == nullptr) {
        if (singleLineBytesCutoff < 0) func(cookie, "\n");
        if (singleLineBytesCutoff < 0) func(cookie, "\n");
        func(cookie, "(NULL)");
        func(cookie, "(NULL)");
        return;
        return;
@@ -297,7 +297,7 @@ void printHexData(int32_t indent, const void *buf, size_t length,


ssize_t getBinderKernelReferences(size_t count, uintptr_t* buf) {
ssize_t getBinderKernelReferences(size_t count, uintptr_t* buf) {
    sp<ProcessState> proc = ProcessState::selfOrNull();
    sp<ProcessState> proc = ProcessState::selfOrNull();
    if (proc.get() == NULL) {
    if (proc.get() == nullptr) {
        return 0;
        return 0;
    }
    }


Loading