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

Commit 244f8c26 authored by Chih-Chung Chang's avatar Chih-Chung Chang
Browse files

Fix 2083478: Camera needs an auto-focus cancel API

Change-Id: I13bda991b32aee47e82b5cf9d43b3021c416a9a2
parent 54c06152
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -265,6 +265,11 @@ status_t CameraHardwareStub::autoFocus()
    return NO_ERROR;
}

status_t CameraHardwareStub::cancelAutoFocus()
{
    return NO_ERROR;
}

/*static*/ int CameraHardwareStub::beginPictureThread(void *cookie)
{
    CameraHardwareStub *c = (CameraHardwareStub *)cookie;
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public:
    virtual void        releaseRecordingFrame(const sp<IMemory>& mem);

    virtual status_t    autoFocus();
    virtual status_t    cancelAutoFocus();
    virtual status_t    takePicture();
    virtual status_t    cancelPicture();
    virtual status_t    dump(int fd, const Vector<String16>& args) const;
+16 −1
Original line number Diff line number Diff line
@@ -798,7 +798,6 @@ static void dump_to_file(const char *fname,
}
#endif

// take a picture - image is returned in callback
status_t CameraService::Client::autoFocus()
{
    LOGD("autoFocus (pid %d)", getCallingPid());
@@ -815,6 +814,22 @@ status_t CameraService::Client::autoFocus()
    return mHardware->autoFocus();
}

status_t CameraService::Client::cancelAutoFocus()
{
    LOGD("cancelAutoFocus (pid %d)", getCallingPid());

    Mutex::Autolock lock(mLock);
    status_t result = checkPid();
    if (result != NO_ERROR) return result;

    if (mHardware == 0) {
        LOGE("mHardware is NULL, returning.");
        return INVALID_OPERATION;
    }

    return mHardware->cancelAutoFocus();
}

// take a picture - image is returned in callback
status_t CameraService::Client::takePicture()
{
+3 −0
Original line number Diff line number Diff line
@@ -110,6 +110,9 @@ private:
        // auto focus
        virtual status_t        autoFocus();

        // cancel auto focus
        virtual status_t        cancelAutoFocus();

        // take a picture - returns an IMemory (ref-counted mmap)
        virtual status_t        takePicture();

+14 −2
Original line number Diff line number Diff line
@@ -382,6 +382,20 @@ public class Camera {
    }
    private native final void native_autoFocus();

    /**
     * Cancels auto-focus function. If the auto-focus is still in progress,
     * this function will cancel it. Whether the auto-focus is in progress
     * or not, this function will return the focus position to the default.
     * If the camera does not support auto-focus, this is a no-op.
     * @hide
     */
    public final void cancelAutoFocus()
    {
        mAutoFocusCallback = null;
        native_cancelAutoFocus();
    }
    private native final void native_cancelAutoFocus();

    /**
     * An interface which contains a callback for the shutter closing after taking a picture.
     */
@@ -1338,5 +1352,3 @@ public class Camera {
        }
    };
}

Loading