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

Commit d859d8a3 authored by Tom Rudick's avatar Tom Rudick
Browse files

If a device does not have a camera, do not set a camera death notifier

getService("media.camera") will return a NULL binder if there is no
camera service present. This will result in a segfault when we
attempt to set the DeathListener on the binder. If the camera
binder is NULL, we should not attempt to set a notifier.

Bug: 32742216
Bug: 32742421
Change-Id: Id6e7cabdd9e2f0f5d44f4ce435121f84d891026a
parent fb071462
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -369,9 +369,13 @@ status_t MediaRecorderClient::setListener(const sp<IMediaRecorderClient>& listen


    sp<IServiceManager> sm = defaultServiceManager();
    sp<IServiceManager> sm = defaultServiceManager();
    sp<IBinder> binder = sm->getService(String16("media.camera"));
    sp<IBinder> binder = sm->getService(String16("media.camera"));

    // If the device does not have a camera, do not create a death listener for it.
    if (binder != NULL) {
        mCameraDeathListener = new ServiceDeathNotifier(binder, listener,
        mCameraDeathListener = new ServiceDeathNotifier(binder, listener,
                MediaPlayerService::CAMERA_PROCESS_DEATH);
                MediaPlayerService::CAMERA_PROCESS_DEATH);
        binder->linkToDeath(mCameraDeathListener);
        binder->linkToDeath(mCameraDeathListener);
    }


    binder = sm->getService(String16("media.codec"));
    binder = sm->getService(String16("media.codec"));
    mCodecDeathListener = new ServiceDeathNotifier(binder, listener,
    mCodecDeathListener = new ServiceDeathNotifier(binder, listener,