!607 fix: add IsNativePermissionGranted permission check

Merge pull request !607 from cjw123qq/0921
This commit is contained in:
openharmony_ci 2024-09-26 03:05:59 +00:00 committed by Gitee
commit 39f02ff8dc
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -502,7 +502,7 @@ void BatteryService::SetLowCapacityThreshold()
BatteryError BatteryService::SetBatteryConfig(const std::string& sceneName, const std::string& value)
{
if (!Permission::IsSystem()) {
if (!Permission::IsSystem() || !Permission::IsNativePermissionGranted("ohos.permission.POWER_OPTIMIZATION")) {
BATTERY_HILOGI(FEATURE_BATT_INFO, "SetBatteryConfig failed, System permission intercept");
return BatteryError::ERR_SYSTEM_API_DENIED;
}