Don't try to connect camera service if it is disabled.
On Android Wear devices we don't have cameras, so we don't need the
proxy service as well. If it is disabled by the system property, don't
wait for it to start, but rather return null pointer in
getCameraService(), which causes getNumberOfCameras() to report zero
cameras available.
The same logic applies to ACameraManager, where we return an empty list.
Bug: 28560707
Change-Id: I4c0bc29f061f1b66710c8188a7916bfaf089d23f
diff --git a/camera/CameraBase.cpp b/camera/CameraBase.cpp
index 15d7715..194e1d3 100644
--- a/camera/CameraBase.cpp
+++ b/camera/CameraBase.cpp
@@ -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 @@
{
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 {