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

Commit f5b9cc68 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

libcamera_client: Add utils function isCameraServiceDisabled.



Note: ndk_vendor/ACameraManager.cpp is vendor code whcih can't depend on
a framework library without it being vndk, which libcamera_client isn't.

Bug: 168061412

Test: builds
Test: Camera app, native cts imagereader test(validity)

Change-Id: I87d8e056d0e8ef938d5c8f976417ca707d6471d9
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 6b5fdb53
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <binder/IMemory.h>

#include <camera/CameraBase.h>
#include <camera/CameraUtils.h>

// needed to instantiate
#include <camera/Camera.h>
@@ -124,9 +125,7 @@ const sp<::android::hardware::ICameraService> CameraBase<TCam, TCamTraits>::getC
{
    Mutex::Autolock _l(gLock);
    if (gCameraService.get() == 0) {
        char value[PROPERTY_VALUE_MAX];
        property_get("config.disable_cameraservice", value, "0");
        if (strncmp(value, "0", 2) != 0 && strncasecmp(value, "false", 6) != 0) {
        if (CameraUtils::isCameraServiceDisabled()) {
            return gCameraService;
        }

+7 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <system/window.h>
#include <system/graphics.h>

#include <cutils/properties.h>
#include <utils/Log.h>

namespace android {
@@ -122,4 +123,10 @@ status_t CameraUtils::getRotationTransform(const CameraMetadata& staticInfo,
    return OK;
}

bool CameraUtils::isCameraServiceDisabled() {
    char value[PROPERTY_VALUE_MAX];
    property_get("config.disable_cameraservice", value, "0");
    return (strncmp(value, "0", 2) != 0 && strncasecmp(value, "false", 6) != 0);
}

} /* namespace android */
+5 −0
Original line number Diff line number Diff line
@@ -47,6 +47,11 @@ class CameraUtils {
         */
        static bool isNativeHandleMetadata(const sp<IMemory>& imageData);

        /**
         * Check if camera service is disabled on this device
         */
        static bool isCameraServiceDisabled();

    private:
        CameraUtils();
};
+2 −7
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <utils/Vector.h>
#include <cutils/properties.h>
#include <stdlib.h>
#include <camera/CameraUtils.h>
#include <camera/VendorTagDescriptor.h>

using namespace android::acam;
@@ -70,12 +71,6 @@ CameraManagerGlobal::~CameraManagerGlobal() {
    mCameraService.clear();
}

static bool isCameraServiceDisabled() {
    char value[PROPERTY_VALUE_MAX];
    property_get("config.disable_cameraservice", value, "0");
    return (strncmp(value, "0", 2) != 0 && strncasecmp(value, "false", 6) != 0);
}

sp<hardware::ICameraService> CameraManagerGlobal::getCameraService() {
    Mutex::Autolock _l(mLock);
    return getCameraServiceLocked();
@@ -83,7 +78,7 @@ sp<hardware::ICameraService> CameraManagerGlobal::getCameraService() {

sp<hardware::ICameraService> CameraManagerGlobal::getCameraServiceLocked() {
    if (mCameraService.get() == nullptr) {
        if (isCameraServiceDisabled()) {
        if (CameraUtils::isCameraServiceDisabled()) {
            return mCameraService;
        }