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

Commit 23002b48 authored by Austin Borger's avatar Austin Borger Committed by Android (Google) Code Review
Browse files

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

parents 395096c6 9bfa0a7b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -48,5 +48,5 @@ interface ICameraServiceProxy
    /**
    /**
     * Checks if the camera has been disabled via device policy.
     * Checks if the camera has been disabled via device policy.
     */
     */
    boolean isCameraDisabled();
    boolean isCameraDisabled(int userId);
}
}
+7 −1
Original line number Original line Diff line number Diff line
@@ -1712,7 +1712,13 @@ Status CameraService::connectDevice(
        return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, msg.string());
        return STATUS_ERROR(ERROR_ILLEGAL_ARGUMENT, msg.string());
    }
    }


    if (mCameraServiceProxyWrapper->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 (mCameraServiceProxyWrapper->isCameraDisabled(clientUserId)) {
        String8 msg =
        String8 msg =
                String8::format("Camera disabled by device policy");
                String8::format("Camera disabled by device policy");
        ALOGE("%s: %s", __FUNCTION__, msg.string());
        ALOGE("%s: %s", __FUNCTION__, msg.string());
+3 −3
Original line number Original line Diff line number Diff line
@@ -138,12 +138,12 @@ public:
        return mCameraServiceProxy->notifyCameraState(cameraSessionStats);
        return mCameraServiceProxy->notifyCameraState(cameraSessionStats);
    }
    }


    virtual binder::Status isCameraDisabled(bool *ret) override {
    virtual binder::Status isCameraDisabled(int userId, bool *ret) override {
        if (mOverrideCameraDisabled) {
        if (mOverrideCameraDisabled) {
            *ret = mCameraDisabled;
            *ret = mCameraDisabled;
            return binder::Status::ok();
            return binder::Status::ok();
        }
        }
        return mCameraServiceProxy->isCameraDisabled(ret);
        return mCameraServiceProxy->isCameraDisabled(userId, ret);
    }
    }


    void setCameraDisabled(bool cameraDisabled) {
    void setCameraDisabled(bool cameraDisabled) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -269,11 +269,11 @@ void CameraServiceProxyWrapper::logClose(const String8& id, int32_t latencyMs) {
    sessionStats->onClose(proxyBinder, latencyMs);
    sessionStats->onClose(proxyBinder, latencyMs);
}
}


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


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


} // android
} // android