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

Commit 80173a93 authored by Austin Borger's avatar Austin Borger
Browse files

CameraService: Check if the camera is disabled via device policy by user.

The current approach to checking the camera device policy is multi-user
agnostic. This patch takes the user into account.

Test: Tested GCA with device policy set via TestDPC
Bug: 230026863
Change-Id: I3937f75ebfc219906a3c379b6b4cfacd801a40bf
Merged-In: I3937f75ebfc219906a3c379b6b4cfacd801a40bf
parent 1f0ac9da
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -48,5 +48,5 @@ interface ICameraServiceProxy
    /**
     * Checks if the camera has been disabled via device policy.
     */
    boolean isCameraDisabled();
    boolean isCameraDisabled(int userId);
}
+7 −1
Original line number Diff line number Diff line
@@ -1698,7 +1698,13 @@ Status CameraService::connectDevice(
        return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, msg.string());
    }

    if (CameraServiceProxyWrapper::isCameraDisabled()) {
    userid_t clientUserId = multiuser_get_user_id(clientUid);
    int callingUid = CameraThreadState::getCallingUid();
    if (clientUid == USE_CALLING_UID) {
        clientUserId = multiuser_get_user_id(callingUid);
    }

    if (CameraServiceProxyWrapper::isCameraDisabled(clientUserId)) {
        String8 msg =
                String8::format("Camera disabled by device policy");
        ALOGE("%s: %s", __FUNCTION__, msg.string());
+2 −2
Original line number Diff line number Diff line
@@ -262,11 +262,11 @@ void CameraServiceProxyWrapper::logClose(const String8& id, int32_t latencyMs) {
    sessionStats->onClose(latencyMs);
}

bool CameraServiceProxyWrapper::isCameraDisabled() {
bool CameraServiceProxyWrapper::isCameraDisabled(int userId) {
    sp<ICameraServiceProxy> proxyBinder = getCameraServiceProxy();
    if (proxyBinder == nullptr) return true;
    bool ret = false;
    auto status = proxyBinder->isCameraDisabled(&ret);
    auto status = proxyBinder->isCameraDisabled(userId, &ret);
    if (!status.isOk()) {
        ALOGE("%s: Failed during camera disabled query: %s", __FUNCTION__,
                status.exceptionMessage().c_str());
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public:
    static int getRotateAndCropOverride(String16 packageName, int lensFacing, int userId);

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

} // android