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

Commit 9527a598 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala Committed by Gerrit Code Review
Browse files

Merge "Camera: Guard against asBinder() calls on NULL interfaces"

parents c5160b34 e992e750
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ public:
        ALOGV("setPreviewTarget");
        Parcel data, reply;
        data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
        sp<IBinder> b(bufferProducer->asBinder());
        sp<IBinder> b(bufferProducer != NULL ? bufferProducer->asBinder() : NULL);
        data.writeStrongBinder(b);
        remote()->transact(SET_PREVIEW_TARGET, data, &reply);
        return reply.readInt32();
+5 −2
Original line number Diff line number Diff line
@@ -1363,7 +1363,8 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
        int cameraId, int cameraFacing,
        int clientPid, uid_t clientUid,
        int servicePid) :
        CameraService::BasicClient(cameraService, cameraClient->asBinder(),
        CameraService::BasicClient(cameraService,
                cameraClient != NULL ? cameraClient->asBinder() : NULL,
                clientPackageName,
                cameraId, cameraFacing,
                clientPid, clientUid,
@@ -1476,7 +1477,9 @@ status_t CameraService::BasicClient::finishCameraOps() {

    }
    // Always stop watching, even if no camera op is active
    if (mOpsCallback != NULL) {
        mAppOpsManager.stopWatchingMode(mOpsCallback);
    }
    mOpsCallback.clear();

    return OK;
+2 −1
Original line number Diff line number Diff line
@@ -165,7 +165,8 @@ status_t Camera2Client::dump(int fd, const Vector<String16>& args) {
    String8 result;
    result.appendFormat("Client2[%d] (%p) Client: %s PID: %d, dump:\n",
            mCameraId,
            getRemoteCallback()->asBinder().get(),
            (getRemoteCallback() != NULL ?
                    getRemoteCallback()->asBinder().get() : NULL),
            String8(mClientPackageName).string(),
            mClientPid);
    result.append("  State: ");
+2 −1
Original line number Diff line number Diff line
@@ -118,7 +118,8 @@ status_t CameraClient::dump(int fd, const Vector<String16>& args) {

    size_t len = snprintf(buffer, SIZE, "Client[%d] (%p) PID: %d\n",
            mCameraId,
            getRemoteCallback()->asBinder().get(),
            (getRemoteCallback() != NULL ?
                    getRemoteCallback()->asBinder().get() : NULL),
            mClientPid);
    len = (len > SIZE - 1) ? SIZE - 1 : len;
    write(fd, buffer, len);
+13 −10
Original line number Diff line number Diff line
@@ -42,8 +42,14 @@ CameraDeviceClientBase::CameraDeviceClientBase(
        int clientPid,
        uid_t clientUid,
        int servicePid) :
    BasicClient(cameraService, remoteCallback->asBinder(), clientPackageName,
                cameraId, cameraFacing, clientPid, clientUid, servicePid),
    BasicClient(cameraService,
            remoteCallback != NULL ? remoteCallback->asBinder() : NULL,
            clientPackageName,
            cameraId,
            cameraFacing,
            clientPid,
            clientUid,
            servicePid),
    mRemoteCallback(remoteCallback) {
}

@@ -353,12 +359,8 @@ status_t CameraDeviceClient::createStream(int width, int height, int format,
        useAsync = true;
    }

    sp<IBinder> binder;
    sp<ANativeWindow> anw;
    if (bufferProducer != 0) {
        binder = bufferProducer->asBinder();
        anw = new Surface(bufferProducer, useAsync);
    }
    sp<IBinder> binder = bufferProducer->asBinder();
    sp<ANativeWindow> anw = new Surface(bufferProducer, useAsync);

    // TODO: remove w,h,f since we are ignoring them

@@ -395,7 +397,7 @@ status_t CameraDeviceClient::createStream(int width, int height, int format,
    res = mDevice->createStream(anw, width, height, format, &streamId);

    if (res == OK) {
        mStreamMap.add(bufferProducer->asBinder(), streamId);
        mStreamMap.add(binder, streamId);

        ALOGV("%s: Camera %d: Successfully created a new stream ID %d",
              __FUNCTION__, mCameraId, streamId);
@@ -514,7 +516,8 @@ status_t CameraDeviceClient::dump(int fd, const Vector<String16>& args) {
    String8 result;
    result.appendFormat("CameraDeviceClient[%d] (%p) dump:\n",
            mCameraId,
            getRemoteCallback()->asBinder().get());
            (getRemoteCallback() != NULL ?
                    getRemoteCallback()->asBinder().get() : NULL) );
    result.appendFormat("  Current client: %s (PID %d, UID %u)\n",
            String8(mClientPackageName).string(),
            mClientPid, mClientUid);
Loading