[Power] Changed obtaining brightness levels.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Fri, 15 May 2015 10:02:50 +0000 (12:02 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Fri, 15 May 2015 10:02:50 +0000 (12:02 +0200)
[Verification] PowerManager_setScreenBrightness, PowerManager_getScreenBrightness_check_change pass.

Change-Id: I37f9e82685de41908b540264023775308b6c4518
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/power/power_manager.cc
src/power/power_platform_proxy.cc
src/power/power_platform_proxy.h

index 85fd2ad..afcf873 100755 (executable)
@@ -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, &current_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);
 
index e0bcef6..026a89f 100755 (executable)
@@ -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
index 53898de..bf98cd1 100755 (executable)
@@ -17,6 +17,8 @@ class PowerPlatformProxy {
        int SetBrightnessFromSettings();
        int SetBrightness(int val);
 
+  int GetBrightness();
+
   static PowerPlatformProxy& GetInstance();
 
  private: