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

Commit f099b237 authored by Avichal Rakesh's avatar Avichal Rakesh
Browse files

camera: Migrate ndk_vendor client implementation to AIDL.

With HIDL deprecated, cameraservice's vndk client interfaces have been
updated to using AIDL. This CL drops support for the HIDL vndk client
interface.

When vendor partition is rebuilt for future version of android, it
should automatically pick up the new new client implementation.
Cameraservice will continue to support both HIDL and AIDL vndk clients.

The changes are simple 1:1 mapping of HIDL interface logic with AIDL
interface logic.

Bug: 243593375
Test: atest ACameraNdkVendorTest
Change-Id: Ic03bbf4e275bb3eddc4ca4e322adc84fdf03f482
parent 5d1800b4
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ cc_library_shared {
    ],

    shared_libs: [
        "libbinder_ndk",
        "libfmq",
        "libhidlbase",
        "libhardware",
@@ -151,15 +152,13 @@ cc_library_shared {
        "libcutils",
        "libcamera_metadata",
        "libmediandk",
        "android.frameworks.cameraservice.device@2.0",
        "android.frameworks.cameraservice.device@2.1",
        "android.frameworks.cameraservice.common@2.0",
        "android.frameworks.cameraservice.service@2.0",
        "android.frameworks.cameraservice.service@2.1",
        "android.frameworks.cameraservice.service@2.2",
        "android.frameworks.cameraservice.common-V1-ndk",
        "android.frameworks.cameraservice.device-V1-ndk",
        "android.frameworks.cameraservice.service-V1-ndk",
    ],
    static_libs: [
        "android.hardware.camera.common@1.0-helper",
        "libaidlcommonsupport",
        "libarect",
    ],
    // TODO: jchowdhary@, use header_libs instead b/131165718
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include "impl/ACameraCaptureSession.h"

#include "impl/ACameraCaptureSession.inc"

#include "NdkCameraCaptureSession.inc"

using namespace android;
+7 −13
Original line number Diff line number Diff line
@@ -22,18 +22,11 @@
#include <utils/Trace.h>

#include <camera/NdkCameraDevice.h>

#include "impl/ACameraCaptureSession.h"

using namespace android::acam;

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

EXPORT
camera_status_t ACameraDevice_close(ACameraDevice* device) {
    ATRACE_CALL();
@@ -183,14 +176,15 @@ camera_status_t ACaptureSessionSharedOutput_add(ACaptureSessionOutput *out,
                __FUNCTION__);
        return ACAMERA_ERROR_INVALID_OPERATION;
    }
    if (areWindowTypesEqual(out->mWindow, window)) {
    if (out->isWindowEqual(window)) {
        ALOGE("%s: Error trying to add the same window associated with the output configuration",
                __FUNCTION__);
        return ACAMERA_ERROR_INVALID_PARAMETER;
    }

    auto insert = out->mSharedWindows.insert(window);
    camera_status_t ret = (insert.second) ? ACAMERA_OK : ACAMERA_ERROR_INVALID_PARAMETER;

    bool insert = out->addSharedWindow(window);
    camera_status_t ret = (insert) ? ACAMERA_OK : ACAMERA_ERROR_INVALID_PARAMETER;
    return ret;
}

@@ -208,13 +202,13 @@ camera_status_t ACaptureSessionSharedOutput_remove(ACaptureSessionOutput *out,
                __FUNCTION__);
        return ACAMERA_ERROR_INVALID_OPERATION;
    }
    if (areWindowTypesEqual(out->mWindow, window)) {
    if (out->isWindowEqual(window)) {
        ALOGE("%s: Error trying to remove the same window associated with the output configuration",
                __FUNCTION__);
        return ACAMERA_ERROR_INVALID_PARAMETER;
    }

    auto remove = out->mSharedWindows.erase(window);
    auto remove = out->removeSharedWindow(window);
    camera_status_t ret = (remove) ? ACAMERA_OK : ACAMERA_ERROR_INVALID_PARAMETER;
    return ret;
}
+4 −4
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ camera_status_t ACameraManager_registerAvailabilityCallback(
               callback->onCameraAvailable, callback->onCameraUnavailable);
        return ACAMERA_ERROR_INVALID_PARAMETER;
    }
    CameraManagerGlobal::getInstance().registerAvailabilityCallback(callback);
    CameraManagerGlobal::getInstance()->registerAvailabilityCallback(callback);
    return ACAMERA_OK;
}

@@ -100,7 +100,7 @@ camera_status_t ACameraManager_unregisterAvailabilityCallback(
               callback->onCameraAvailable, callback->onCameraUnavailable);
        return ACAMERA_ERROR_INVALID_PARAMETER;
    }
    CameraManagerGlobal::getInstance().unregisterAvailabilityCallback(callback);
    CameraManagerGlobal::getInstance()->unregisterAvailabilityCallback(callback);
    return ACAMERA_OK;
}

@@ -131,7 +131,7 @@ camera_status_t ACameraManager_registerExtendedAvailabilityCallback(
            return ACAMERA_ERROR_INVALID_PARAMETER;
        }
    }
    CameraManagerGlobal::getInstance().registerExtendedAvailabilityCallback(callback);
    CameraManagerGlobal::getInstance()->registerExtendedAvailabilityCallback(callback);
    return ACAMERA_OK;
}

@@ -154,7 +154,7 @@ camera_status_t ACameraManager_unregisterExtendedAvailabilityCallback(
               callback->onCameraAccessPrioritiesChanged);
        return ACAMERA_ERROR_INVALID_PARAMETER;
    }
    CameraManagerGlobal::getInstance().unregisterExtendedAvailabilityCallback(callback);
    CameraManagerGlobal::getInstance()->unregisterExtendedAvailabilityCallback(callback);
    return ACAMERA_OK;
}

+36 −2
Original line number Diff line number Diff line
@@ -23,7 +23,11 @@ using namespace android;

ACameraCaptureSession::~ACameraCaptureSession() {
    ALOGV("~ACameraCaptureSession: %p notify device end of life", this);
#ifdef __ANDROID_VNDK__
    std::shared_ptr<acam::CameraDevice> dev = getDevicePtr();
#else
    sp<acam::CameraDevice> dev = getDeviceSp();
#endif
    if (dev != nullptr && !dev->isClosed()) {
        dev->lockDeviceForSessionOps();
        {
@@ -50,7 +54,11 @@ ACameraCaptureSession::closeByApp() {
        mClosedByApp = true;
    }

#ifdef __ANDROID_VNDK__
    std::shared_ptr<acam::CameraDevice> dev = getDevicePtr();
#else
    sp<acam::CameraDevice> dev = getDeviceSp();
#endif
    if (dev != nullptr) {
        dev->lockDeviceForSessionOps();
    }
@@ -75,7 +83,11 @@ ACameraCaptureSession::closeByApp() {

camera_status_t
ACameraCaptureSession::stopRepeating() {
#ifdef __ANDROID_VNDK__
    std::shared_ptr<acam::CameraDevice> dev = getDevicePtr();
#else
    sp<acam::CameraDevice> dev = getDeviceSp();
#endif
    if (dev == nullptr) {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return ACAMERA_ERROR_SESSION_CLOSED;
@@ -93,7 +105,11 @@ ACameraCaptureSession::stopRepeating() {

camera_status_t
ACameraCaptureSession::abortCaptures() {
#ifdef __ANDROID_VNDK__
    std::shared_ptr<acam::CameraDevice> dev = getDevicePtr();
#else
    sp<acam::CameraDevice> dev = getDeviceSp();
#endif
    if (dev == nullptr) {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return ACAMERA_ERROR_SESSION_CLOSED;
@@ -110,7 +126,11 @@ ACameraCaptureSession::abortCaptures() {
}

camera_status_t ACameraCaptureSession::updateOutputConfiguration(ACaptureSessionOutput *output) {
#ifdef __ANDROID_VNDK__
    std::shared_ptr<acam::CameraDevice> dev = getDevicePtr();
#else
    sp<acam::CameraDevice> dev = getDeviceSp();
#endif
    if (dev == nullptr) {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return ACAMERA_ERROR_SESSION_CLOSED;
@@ -129,7 +149,11 @@ camera_status_t ACameraCaptureSession::updateOutputConfiguration(ACaptureSession
ACameraDevice*
ACameraCaptureSession::getDevice() {
    Mutex::Autolock _l(mSessionLock);
#ifdef __ANDROID_VNDK__
    std::shared_ptr<acam::CameraDevice> dev = getDevicePtr();
#else
    sp<acam::CameraDevice> dev = getDeviceSp();
#endif
    if (dev == nullptr) {
        ALOGE("Error: Device associated with session %p has been closed!", this);
        return nullptr;
@@ -143,6 +167,17 @@ ACameraCaptureSession::closeByDevice() {
    mIsClosed = true;
}

#ifdef __ANDROID_VNDK__
std::shared_ptr<acam::CameraDevice>
ACameraCaptureSession::getDevicePtr() {
    std::shared_ptr<acam::CameraDevice> device = mDevice.lock();
    if (device == nullptr || device->isClosed()) {
        ALOGW("Device is closed but session %d is not notified", mId);
        return nullptr;
    }
    return device;
}
#else
sp<acam::CameraDevice>
ACameraCaptureSession::getDeviceSp() {
    sp<acam::CameraDevice> device = mDevice.promote();
@@ -152,5 +187,4 @@ ACameraCaptureSession::getDeviceSp() {
    }
    return device;
}

#endif
Loading