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

Commit a05d81a0 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Allow sending vendor- or device-specific commands to the camera HAL.

Change-Id: I2aaa9e526b6f1a35d45e96b6d23e3db972d82733
parent 09aa5c3b
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1645,6 +1645,20 @@ public class Camera {

    private native final boolean _enableShutterSound(boolean enabled);

    /**
     * Send a vendor-specific camera command
     *
     * @hide
     */
    public final void sendVendorCommand(int cmd, int arg1, int arg2) {
        if (cmd < 1000) {
            throw new IllegalArgumentException("Command numbers must be at least 1000");
        }
        _sendVendorCommand(cmd, arg1, arg2);
    }

    private native final void _sendVendorCommand(int cmd, int arg1, int arg2);

    /**
     * Callback interface for zoom changes during a smooth zoom operation.
     *
+15 −0
Original line number Diff line number Diff line
@@ -1048,6 +1048,18 @@ static void android_hardware_Camera_enableFocusMoveCallback(JNIEnv *env, jobject
    }
}

static void android_hardware_Camera_sendVendorCommand(JNIEnv *env, jobject thiz,
        jint cmd, jint arg1, jint arg2)
{
    ALOGV("sendVendorCommand");
    sp<Camera> camera = get_native_camera(env, thiz, NULL);
    if (camera == 0) return;

    if (camera->sendCommand(cmd, arg1, arg2) != NO_ERROR) {
        jniThrowRuntimeException(env, "sending vendor command failed");
    }
}

//-------------------------------------------------

static JNINativeMethod camMethods[] = {
@@ -1144,6 +1156,9 @@ static JNINativeMethod camMethods[] = {
  { "enableFocusMoveCallback",
    "(I)V",
    (void *)android_hardware_Camera_enableFocusMoveCallback},
  { "_sendVendorCommand",
    "(III)V",
    (void *)android_hardware_Camera_sendVendorCommand },
};

struct field {