From f806594f2c6b3681a38a5ebb8e55f32d20dc251c Mon Sep 17 00:00:00 2001
From: Pawel Andruszkiewicz
Date: Fri, 15 May 2015 12:02:50 +0200
Subject: [PATCH] [Power] Changed obtaining brightness levels.
[Verification] PowerManager_setScreenBrightness, PowerManager_getScreenBrightness_check_change pass.
Change-Id: I37f9e82685de41908b540264023775308b6c4518
Signed-off-by: Pawel Andruszkiewicz
---
src/power/power_manager.cc | 21 ++++++++++-----------
src/power/power_platform_proxy.cc | 6 ++++++
src/power/power_platform_proxy.h | 2 ++
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/power/power_manager.cc b/src/power/power_manager.cc
index 85fd2adc..afcf8730 100755
--- a/src/power/power_manager.cc
+++ b/src/power/power_manager.cc
@@ -28,6 +28,7 @@ PowerManager::PowerManager()
bright_state_enabled_(false),
current_brightness_(-1),
should_be_read_from_cache_(false),
+ set_custom_brightness_(false),
current_requested_state_(POWER_STATE_NONE) {
display_state_e platform_state = DISPLAY_STATE_NORMAL;
@@ -281,8 +282,9 @@ PlatformResult PowerManager::SetScreenBrightness(double brightness) {
}
int platform_brightness = (int)(brightness * max_brightness);
- if (platform_brightness == 0)
+ if (platform_brightness == 0) {
platform_brightness = 1;
+ }
PlatformResult set_result = SetPlatformBrightness(platform_brightness);
if (set_result.IsError())
return set_result;
@@ -353,15 +355,9 @@ PlatformResult PowerManager::SetPlatformBrightness(int brightness) {
}
int PowerManager::GetPlatformBrightness(){
- int brightness = 0;
+ LoggerD("Entered");
- int current_power_state = 1;
- vconf_get_int(VCONFKEY_PM_STATE, ¤t_power_state);
- if (current_power_state == VCONFKEY_PM_STATE_NORMAL) {
- vconf_get_int(VCONFKEY_PM_CURRENT_BRIGHTNESS, &brightness);
- LoggerD("[PM_STATE_NORMAL] return VCONFKEY_PM_CURRENT_BRIGHTNESS %d", brightness);
- return brightness;
- }
+ int brightness = 0;
int is_custom_mode = 0;
vconf_get_int(VCONFKEY_PM_CUSTOM_BRIGHTNESS_STATUS, &is_custom_mode);
@@ -374,10 +370,13 @@ int PowerManager::GetPlatformBrightness(){
vconf_get_int(VCONFKEY_SETAPPL_BRIGHTNESS_AUTOMATIC_INT, &is_auto_brightness);
if (is_auto_brightness == 1) {
int ret = vconf_get_int(VCONFKEY_SETAPPL_PREFIX"/automatic_brightness_level" /*prevent RSA build error*/, &brightness);
- if (ret != 0) //RSA binary has no AUTOMATIC_BRIGHTNESS
+ if (ret != 0) {
+ // RSA binary has no AUTOMATIC_BRIGHTNESS
vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
+ }
} else {
- vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
+ LoggerD("Brightness via DBUS");
+ brightness = PowerPlatformProxy::GetInstance().GetBrightness();
}
LoggerD("BRIGHTNESS(%s) %d", is_auto_brightness == 1 ? "auto" : "fix" , brightness);
diff --git a/src/power/power_platform_proxy.cc b/src/power/power_platform_proxy.cc
index e0bcef63..026a89f7 100755
--- a/src/power/power_platform_proxy.cc
+++ b/src/power/power_platform_proxy.cc
@@ -70,11 +70,17 @@ int PowerPlatformProxy::SetBrightnessFromSettings()
int PowerPlatformProxy::SetBrightness(int val)
{
+ LoggerD("Entered");
DBusOperationArguments args;
args.AddArgumentInt32(val);
return dbus_op_.InvokeSyncGetInt("HoldBrightness", &args);
}
+int PowerPlatformProxy::GetBrightness() {
+ LoggerD("Entered");
+ return dbus_op_.InvokeSyncGetInt("CurrentBrightness", NULL);
+}
+
} // namespace power
} // namespace extension
diff --git a/src/power/power_platform_proxy.h b/src/power/power_platform_proxy.h
index 53898dec..bf98cd10 100755
--- a/src/power/power_platform_proxy.h
+++ b/src/power/power_platform_proxy.h
@@ -17,6 +17,8 @@ class PowerPlatformProxy {
int SetBrightnessFromSettings();
int SetBrightness(int val);
+ int GetBrightness();
+
static PowerPlatformProxy& GetInstance();
private:
--
2.34.1