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

Commit 6df26071 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

Create a vendor available version of libcamera2ndk.



Bug: 110364143

Test: mm -j64
Test: AImageReaderVendorTest

Change-Id: Ic9343cc7fb10eb374197945b72be59e7ce8282fe
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent dcfd26ee
Loading
Loading
Loading
Loading
+78 −0
Original line number Original line Diff line number Diff line
@@ -70,3 +70,81 @@ cc_library_shared {
    ],
    ],
    version_script: "libcamera2ndk.map.txt",
    version_script: "libcamera2ndk.map.txt",
}
}

cc_library_shared {
    name: "libcamera2ndk_vendor",
    vendor_available: true,
    srcs: [
        "ndk_vendor/impl/ACameraDevice.cpp",
        "ndk_vendor/impl/ACameraManager.cpp",
        "ndk_vendor/impl/utils.cpp",
        "impl/ACameraMetadata.cpp",
        "impl/ACameraCaptureSession.cpp",
        "NdkCameraMetadata.cpp",
        "NdkCameraCaptureSession.cpp",
        "NdkCameraManager.cpp",
        "NdkCameraDevice.cpp",
        "NdkCaptureRequest.cpp",
    ],

    export_include_dirs: ["include"],
    export_shared_lib_headers: [
        "libcutils",
    ],
    local_include_dirs: [
        ".",
        "include",
        "impl",
    ],
    cflags: [
        "-fvisibility=hidden",
        "-DEXPORT=__attribute__((visibility(\"default\")))",
        "-D__ANDROID_VNDK__",
    ],

    shared_libs: [
        "libhwbinder",
        "libfmq",
        "libhidlbase",
        "libhardware",
        "libnativewindow",
        "liblog",
        "libutils",
        "libstagefright_foundation",
        "libcutils",
        "libcamera_metadata",
        "libmediandk",
        "android.frameworks.cameraservice.device@2.0",
        "android.frameworks.cameraservice.common@2.0",
        "android.frameworks.cameraservice.service@2.0",
    ],

    static_libs: [
        "android.hardware.camera.common@1.0-helper",
        "libarect",
    ],
    product_variables: {
        pdk: {
            enabled: false,
        },
    },
}

cc_test {
    name: "AImageReaderVendorTest",
    vendor: true,
    srcs: ["ndk_vendor/tests/AImageReaderVendorTest.cpp"],
    shared_libs: [
        "libhwbinder",
        "libcamera2ndk_vendor",
        "libmediandk",
        "libnativewindow",
        "libutils",
        "libui",
        "libcutils",
        "liblog",
    ],
    cflags: [
        "-D__ANDROID_VNDK__",
    ],
}
+15 −7
Original line number Original line Diff line number Diff line
@@ -24,7 +24,15 @@
#include <camera/NdkCameraDevice.h>
#include <camera/NdkCameraDevice.h>
#include "impl/ACameraCaptureSession.h"
#include "impl/ACameraCaptureSession.h"


using namespace android;
using namespace android::acam;

bool areWindowTypesEqual(ACameraWindowType *a, ACameraWindowType *b) {
#ifdef __ANDROID_VNDK__
    return utils::isWindowNativeHandleEqual(a, b);
#else
    return a == b;
#endif
}


EXPORT
EXPORT
camera_status_t ACameraDevice_close(ACameraDevice* device) {
camera_status_t ACameraDevice_close(ACameraDevice* device) {
@@ -96,7 +104,7 @@ void ACaptureSessionOutputContainer_free(ACaptureSessionOutputContainer* contain


EXPORT
EXPORT
camera_status_t ACaptureSessionOutput_create(
camera_status_t ACaptureSessionOutput_create(
        ANativeWindow* window, /*out*/ACaptureSessionOutput** out) {
        ACameraWindowType* window, /*out*/ACaptureSessionOutput** out) {
    ATRACE_CALL();
    ATRACE_CALL();
    if (window == nullptr || out == nullptr) {
    if (window == nullptr || out == nullptr) {
        ALOGE("%s: Error: bad argument. window %p, out %p",
        ALOGE("%s: Error: bad argument. window %p, out %p",
@@ -109,7 +117,7 @@ camera_status_t ACaptureSessionOutput_create(


EXPORT
EXPORT
camera_status_t ACaptureSessionSharedOutput_create(
camera_status_t ACaptureSessionSharedOutput_create(
        ANativeWindow* window, /*out*/ACaptureSessionOutput** out) {
        ACameraWindowType* window, /*out*/ACaptureSessionOutput** out) {
    ATRACE_CALL();
    ATRACE_CALL();
    if (window == nullptr || out == nullptr) {
    if (window == nullptr || out == nullptr) {
        ALOGE("%s: Error: bad argument. window %p, out %p",
        ALOGE("%s: Error: bad argument. window %p, out %p",
@@ -122,7 +130,7 @@ camera_status_t ACaptureSessionSharedOutput_create(


EXPORT
EXPORT
camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out,
camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out,
        ANativeWindow* window) {
        ACameraWindowType* window) {
    ATRACE_CALL();
    ATRACE_CALL();
    if ((window == nullptr) || (out == nullptr)) {
    if ((window == nullptr) || (out == nullptr)) {
        ALOGE("%s: Error: bad argument. window %p, out %p",
        ALOGE("%s: Error: bad argument. window %p, out %p",
@@ -134,7 +142,7 @@ camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out,
                __FUNCTION__);
                __FUNCTION__);
        return ACAMERA_ERROR_INVALID_OPERATION;
        return ACAMERA_ERROR_INVALID_OPERATION;
    }
    }
    if (out->mWindow == window) {
    if (areWindowTypesEqual(out->mWindow, window)) {
        ALOGE("%s: Error trying to add the same window associated with the output configuration",
        ALOGE("%s: Error trying to add the same window associated with the output configuration",
                __FUNCTION__);
                __FUNCTION__);
        return ACAMERA_ERROR_INVALID_PARAMETER;
        return ACAMERA_ERROR_INVALID_PARAMETER;
@@ -147,7 +155,7 @@ camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out,


EXPORT
EXPORT
camera_status_t ACaptureSessionSharedOutput_remove(ACaptureSessionOutput *out,
camera_status_t ACaptureSessionSharedOutput_remove(ACaptureSessionOutput *out,
        ANativeWindow* window) {
        ACameraWindowType* window) {
    ATRACE_CALL();
    ATRACE_CALL();
    if ((window == nullptr) || (out == nullptr)) {
    if ((window == nullptr) || (out == nullptr)) {
        ALOGE("%s: Error: bad argument. window %p, out %p",
        ALOGE("%s: Error: bad argument. window %p, out %p",
@@ -159,7 +167,7 @@ camera_status_t ACaptureSessionSharedOutput_remove(ACaptureSessionOutput *out,
                __FUNCTION__);
                __FUNCTION__);
        return ACAMERA_ERROR_INVALID_OPERATION;
        return ACAMERA_ERROR_INVALID_OPERATION;
    }
    }
    if (out->mWindow == window) {
    if (areWindowTypesEqual(out->mWindow, window)) {
        ALOGE("%s: Error trying to remove the same window associated with the output configuration",
        ALOGE("%s: Error trying to remove the same window associated with the output configuration",
                __FUNCTION__);
                __FUNCTION__);
        return ACAMERA_ERROR_INVALID_PARAMETER;
        return ACAMERA_ERROR_INVALID_PARAMETER;
+6 −1
Original line number Original line Diff line number Diff line
@@ -22,10 +22,15 @@
#include <utils/Trace.h>
#include <utils/Trace.h>


#include <camera/NdkCameraManager.h>
#include <camera/NdkCameraManager.h>

#ifdef __ANDROID_VNDK__
#include "ndk_vendor/impl/ACameraManager.h"
#else
#include "impl/ACameraManager.h"
#include "impl/ACameraManager.h"
#endif
#include "impl/ACameraMetadata.h"
#include "impl/ACameraMetadata.h"


using namespace android;
using namespace android::acam;


EXPORT
EXPORT
ACameraManager* ACameraManager_create() {
ACameraManager* ACameraManager_create() {
+1 −1
Original line number Original line Diff line number Diff line
@@ -27,7 +27,7 @@


EXPORT
EXPORT
camera_status_t ACameraOutputTarget_create(
camera_status_t ACameraOutputTarget_create(
        ANativeWindow* window, ACameraOutputTarget** out) {
        ACameraWindowType* window, ACameraOutputTarget** out) {
    ATRACE_CALL();
    ATRACE_CALL();
    if (window == nullptr) {
    if (window == nullptr) {
        ALOGE("%s: Error: input window is null", __FUNCTION__);
        ALOGE("%s: Error: input window is null", __FUNCTION__);
+10 −10
Original line number Original line Diff line number Diff line
@@ -23,7 +23,7 @@ using namespace android;


ACameraCaptureSession::~ACameraCaptureSession() {
ACameraCaptureSession::~ACameraCaptureSession() {
    ALOGV("~ACameraCaptureSession: %p notify device end of life", this);
    ALOGV("~ACameraCaptureSession: %p notify device end of life", this);
    sp<CameraDevice> dev = getDeviceSp();
    sp<acam::CameraDevice> dev = getDeviceSp();
    if (dev != nullptr && !dev->isClosed()) {
    if (dev != nullptr && !dev->isClosed()) {
        dev->lockDeviceForSessionOps();
        dev->lockDeviceForSessionOps();
        {
        {
@@ -48,7 +48,7 @@ ACameraCaptureSession::closeByApp() {
        mClosedByApp = true;
        mClosedByApp = true;
    }
    }


    sp<CameraDevice> dev = getDeviceSp();
    sp<acam::CameraDevice> dev = getDeviceSp();
    if (dev != nullptr) {
    if (dev != nullptr) {
        dev->lockDeviceForSessionOps();
        dev->lockDeviceForSessionOps();
    }
    }
@@ -73,7 +73,7 @@ ACameraCaptureSession::closeByApp() {


camera_status_t
camera_status_t
ACameraCaptureSession::stopRepeating() {
ACameraCaptureSession::stopRepeating() {
    sp<CameraDevice> dev = getDeviceSp();
    sp<acam::CameraDevice> dev = getDeviceSp();
    if (dev == nullptr) {
    if (dev == nullptr) {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return ACAMERA_ERROR_SESSION_CLOSED;
        return ACAMERA_ERROR_SESSION_CLOSED;
@@ -91,7 +91,7 @@ ACameraCaptureSession::stopRepeating() {


camera_status_t
camera_status_t
ACameraCaptureSession::abortCaptures() {
ACameraCaptureSession::abortCaptures() {
    sp<CameraDevice> dev = getDeviceSp();
    sp<acam::CameraDevice> dev = getDeviceSp();
    if (dev == nullptr) {
    if (dev == nullptr) {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return ACAMERA_ERROR_SESSION_CLOSED;
        return ACAMERA_ERROR_SESSION_CLOSED;
@@ -112,7 +112,7 @@ ACameraCaptureSession::setRepeatingRequest(
        /*optional*/ACameraCaptureSession_captureCallbacks* cbs,
        /*optional*/ACameraCaptureSession_captureCallbacks* cbs,
        int numRequests, ACaptureRequest** requests,
        int numRequests, ACaptureRequest** requests,
        /*optional*/int* captureSequenceId) {
        /*optional*/int* captureSequenceId) {
    sp<CameraDevice> dev = getDeviceSp();
    sp<acam::CameraDevice> dev = getDeviceSp();
    if (dev == nullptr) {
    if (dev == nullptr) {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return ACAMERA_ERROR_SESSION_CLOSED;
        return ACAMERA_ERROR_SESSION_CLOSED;
@@ -133,7 +133,7 @@ camera_status_t ACameraCaptureSession::capture(
        /*optional*/ACameraCaptureSession_captureCallbacks* cbs,
        /*optional*/ACameraCaptureSession_captureCallbacks* cbs,
        int numRequests, ACaptureRequest** requests,
        int numRequests, ACaptureRequest** requests,
        /*optional*/int* captureSequenceId) {
        /*optional*/int* captureSequenceId) {
    sp<CameraDevice> dev = getDeviceSp();
    sp<acam::CameraDevice> dev = getDeviceSp();
    if (dev == nullptr) {
    if (dev == nullptr) {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return ACAMERA_ERROR_SESSION_CLOSED;
        return ACAMERA_ERROR_SESSION_CLOSED;
@@ -149,7 +149,7 @@ camera_status_t ACameraCaptureSession::capture(
}
}


camera_status_t ACameraCaptureSession::updateOutputConfiguration(ACaptureSessionOutput *output) {
camera_status_t ACameraCaptureSession::updateOutputConfiguration(ACaptureSessionOutput *output) {
    sp<CameraDevice> dev = getDeviceSp();
    sp<acam::CameraDevice> dev = getDeviceSp();
    if (dev == nullptr) {
    if (dev == nullptr) {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return ACAMERA_ERROR_SESSION_CLOSED;
        return ACAMERA_ERROR_SESSION_CLOSED;
@@ -168,7 +168,7 @@ camera_status_t ACameraCaptureSession::updateOutputConfiguration(ACaptureSession
ACameraDevice*
ACameraDevice*
ACameraCaptureSession::getDevice() {
ACameraCaptureSession::getDevice() {
    Mutex::Autolock _l(mSessionLock);
    Mutex::Autolock _l(mSessionLock);
    sp<CameraDevice> dev = getDeviceSp();
    sp<acam::CameraDevice> dev = getDeviceSp();
    if (dev == nullptr) {
    if (dev == nullptr) {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return nullptr;
        return nullptr;
@@ -182,9 +182,9 @@ ACameraCaptureSession::closeByDevice() {
    mIsClosed = true;
    mIsClosed = true;
}
}


sp<CameraDevice>
sp<acam::CameraDevice>
ACameraCaptureSession::getDeviceSp() {
ACameraCaptureSession::getDeviceSp() {
    sp<CameraDevice> device = mDevice.promote();
    sp<acam::CameraDevice> device = mDevice.promote();
    if (device == nullptr || device->isClosed()) {
    if (device == nullptr || device->isClosed()) {
        ALOGW("Device is closed but session %d is not notified", mId);
        ALOGW("Device is closed but session %d is not notified", mId);
        return nullptr;
        return nullptr;
Loading