From fb9a003d2e291931892dff914f7df788db3228e3 Mon Sep 17 00:00:00 2001 From: aqxyjay Date: Mon, 26 Sep 2022 10:13:40 +0800 Subject: [PATCH] fix: add system permission for set brightness Signed-off-by: aqxyjay --- service/BUILD.gn | 1 + service/native/src/display_power_mgr_service.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/service/BUILD.gn b/service/BUILD.gn index b1c4a98..488c2e7 100644 --- a/service/BUILD.gn +++ b/service/BUILD.gn @@ -52,6 +52,7 @@ ohos_shared_library("displaymgrservice") { deps = [ "${powermgr_utils_path}/param:power_sysparam", + "${powermgr_utils_path}/permission:power_permission", "${powermgr_utils_path}/setting:power_setting", ] diff --git a/service/native/src/display_power_mgr_service.cpp b/service/native/src/display_power_mgr_service.cpp index d1a1a04..3193812 100644 --- a/service/native/src/display_power_mgr_service.cpp +++ b/service/native/src/display_power_mgr_service.cpp @@ -26,6 +26,7 @@ #include "watchdog.h" #include "display_log.h" #include "display_param_helper.h" +#include "permission.h" #include "setting_provider.h" namespace OHOS { @@ -231,6 +232,9 @@ uint32_t DisplayPowerMgrService::GetMainDisplayId() bool DisplayPowerMgrService::SetBrightness(uint32_t value, uint32_t displayId) { + if (!Permission::IsSystem()) { + return false; + } auto brightness = GetSafeBrightness(value); DISPLAY_HILOGI(FEAT_BRIGHTNESS, "SetBrightness displayId=%{public}u, value=%{public}u", displayId, brightness); auto iter = controllerMap_.find(displayId); -- Gitee