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

Commit cfb81966 authored by Ivan Podogov's avatar Ivan Podogov Committed by Android (Google) Code Review
Browse files

Merge "Don't try to connect camera service if it is disabled." into cw-f-dev

parents 6373b334 ee844a80
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <utils/Log.h>
#include <utils/threads.h>
#include <utils/Mutex.h>
#include <cutils/properties.h>

#include <android/hardware/ICameraService.h>

@@ -90,6 +91,12 @@ const sp<::android::hardware::ICameraService>& CameraBase<TCam, TCamTraits>::get
{
    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) {
            return gCameraService;
        }

        sp<IServiceManager> sm = defaultServiceManager();
        sp<IBinder> binder;
        do {
+18 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "ACameraMetadata.h"
#include "ACameraDevice.h"
#include <utils/Vector.h>
#include <cutils/properties.h>
#include <stdlib.h>
#include <camera/VendorTagDescriptor.h>

@@ -71,9 +72,19 @@ 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);
    if (mCameraService.get() == nullptr) {
        if (isCameraServiceDisabled()) {
            return mCameraService;
        }

        sp<IServiceManager> sm = defaultServiceManager();
        sp<IBinder> binder;
        do {
@@ -302,6 +313,13 @@ void CameraManagerGlobal::onStatusChangedLocked(
camera_status_t
ACameraManager::getOrCreateCameraIdListLocked(ACameraIdList** cameraIdList) {
    if (mCachedCameraIdList.numCameras == kCameraIdListNotInit) {
        if (isCameraServiceDisabled()) {
            mCachedCameraIdList.numCameras = 0;
            mCachedCameraIdList.cameraIds = new const char*[0];
            *cameraIdList = &mCachedCameraIdList;
            return ACAMERA_OK;
        }

        int numCameras = 0;
        Vector<char *> cameraIds;
        sp<hardware::ICameraService> cs = CameraManagerGlobal::getInstance().getCameraService();