Check the device policy for the camera disabled flag before trying to
open a connection to the camera.

When the camera is disabled from both the device policy and camera
settings, GCA will not receive onError with ERROR_CAMERA_DISABLED. This
is incorrect behavior which is fixed by this patch.

Bug: 230026863, 203063139
Test: Verified camera app closes when both settings are disabled.
Change-Id: I514b38c23a136994de702ea4aacc9be65ab46d70
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index a965080..9542b89 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -1688,6 +1688,13 @@
         return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, msg.string());
     }
 
+    if (CameraServiceProxyWrapper::isCameraDisabled()) {
+        String8 msg =
+                String8::format("Camera disabled by device policy");
+        ALOGE("%s: %s", __FUNCTION__, msg.string());
+        return STATUS_ERROR(ERROR_DISABLED, msg.string());
+    }
+
     // enforce system camera permissions
     if (oomScoreOffset > 0 &&
             !hasPermissionsForSystemCamera(callingPid, CameraThreadState::getCallingUid())) {