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

Commit bc35c715 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6906085 from d55868f7 to rvc-qpr2-release

Change-Id: Ie8079002fd26f97821208c08a28680bab42e4713
parents ea29e26e d55868f7
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;
        }

+29 −23
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <binder/IServiceManager.h>
#include <binder/MemoryHeapBase.h>
#include <binder/MemoryBase.h>
#include <camera/CameraUtils.h>
#include <codec2/hidl/client.h>
#include <cutils/atomic.h>
#include <cutils/properties.h> // for property_get
@@ -423,10 +424,14 @@ status_t MediaRecorderClient::setListener(const sp<IMediaRecorderClient>& listen

    sp<IServiceManager> sm = defaultServiceManager();

    static const bool sCameraDisabled = CameraUtils::isCameraServiceDisabled();

    if (!sCameraDisabled) {
        // WORKAROUND: We don't know if camera exists here and getService might block for 5 seconds.
        // Use checkService for camera if we don't know it exists.
        static std::atomic<bool> sCameraChecked(false);  // once true never becomes false.
        static std::atomic<bool> sCameraVerified(false); // once true never becomes false.

        sp<IBinder> binder = (sCameraVerified || !sCameraChecked)
            ? sm->getService(String16("media.camera")) : sm->checkService(String16("media.camera"));
        // If the device does not have a camera, do not create a death listener for it.
@@ -447,6 +452,7 @@ status_t MediaRecorderClient::setListener(const sp<IMediaRecorderClient>& listen
            });
        }
        sCameraChecked = true;
    }

    {
        using ::android::hidl::base::V1_0::IBase;