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

Commit fca2e742 authored by Yin-Chia Yeh's avatar Yin-Chia Yeh
Browse files

Camera: call setCallback before open_legacy

Some open_legacy implementations require a valid callback.

Test: the failing open_legacy call succeeds
Bug: 34854786
Change-Id: I461c7622bdf46a7cb7febfb7eeeb083288b4af03
parent f2336a17
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -369,9 +369,11 @@ int CameraModule::getNumberOfCameras() {
}

int CameraModule::setCallbacks(const camera_module_callbacks_t *callbacks) {
    int res;
    int res = OK;
    ATRACE_BEGIN("camera_module->set_callbacks");
    if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_1) {
        res = mModule->set_callbacks(callbacks);
    }
    ATRACE_END();
    return res;
}
+12 −7
Original line number Diff line number Diff line
@@ -184,13 +184,20 @@ bool CameraProvider::initialize() {
    mModule = new CameraModule(rawModule);
    err = mModule->init();
    if (err != OK) {
        ALOGE("Could not initialize camera HAL module: %d (%s)", err,
            strerror(-err));
        ALOGE("Could not initialize camera HAL module: %d (%s)", err, strerror(-err));
        mModule.clear();
        return true;
    }
    ALOGI("Loaded \"%s\" camera module", mModule->getModuleName());

    // Setup callback now because we are going to try openLegacy next
    err = mModule->setCallbacks(this);
    if (err != OK) {
        ALOGE("Could not set camera module callback: %d (%s)", err, strerror(-err));
        mModule.clear();
        return true;
    }

    mNumberOfLegacyCameras = mModule->getNumberOfCameras();
    for (int i = 0; i < mNumberOfLegacyCameras; i++) {
        char cameraId[kMaxCameraIdLen];
@@ -289,11 +296,9 @@ bool CameraProvider::setUpVendorTags() {

// Methods from ::android::hardware::camera::provider::V2_4::ICameraProvider follow.
Return<Status> CameraProvider::setCallback(const sp<ICameraProviderCallback>& callback)  {
    {
    Mutex::Autolock _l(mCbLock);
    mCallbacks = callback;
    } // release lock here because HAL might send callbacks in setCallbacks call
    return getHidlStatus(mModule->setCallbacks(this));
    return Status::OK;
}

Return<void> CameraProvider::getVendorTags(getVendorTags_cb _hidl_cb)  {