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

Commit 85d89da8 authored by Austin Borger's avatar Austin Borger Committed by Automerger Merge Worker
Browse files

Merge "Check the device policy for the camera disabled flag before trying to...

Merge "Check the device policy for the camera disabled flag before trying to open a connection to the camera." into tm-dev am: a2469775 am: f0bb78c3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/av/+/17967941



Change-Id: I2ff33f23f35f56de001714886fbd3be9549652ae
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents aa7f1783 f0bb78c3
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -44,4 +44,9 @@ interface ICameraServiceProxy
     * {@link android.hardware.camera2.CameraMetadata#SCALER_ROTATE_AND_CROP_270}).
     */
    int getRotateAndCropOverride(String packageName, int lensFacing, int userId);

    /**
     * Checks if the camera has been disabled via device policy.
     */
    boolean isCameraDisabled();
}
+7 −0
Original line number Diff line number Diff line
@@ -1688,6 +1688,13 @@ Status CameraService::connectDevice(
        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())) {
+12 −0
Original line number Diff line number Diff line
@@ -260,4 +260,16 @@ void CameraServiceProxyWrapper::logClose(const String8& id, int32_t latencyMs) {
    sessionStats->onClose(latencyMs);
}

bool CameraServiceProxyWrapper::isCameraDisabled() {
    sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy();
    if (proxyBinder == nullptr) return true;
    bool ret = false;
    auto status = proxyBinder->isCameraDisabled(&ret);
    if (!status.isOk()) {
        ALOGE("%s: Failed during camera disabled query: %s", __FUNCTION__,
                status.exceptionMessage().c_str());
    }
    return ret;
}

}; // namespace android
+3 −0
Original line number Diff line number Diff line
@@ -95,6 +95,9 @@ public:

    // Return the current top activity rotate and crop override.
    static int getRotateAndCropOverride(String16 packageName, int lensFacing, int userId);

    // Detect if the camera is disabled by device policy.
    static bool isCameraDisabled();
};

} // android