wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Power / PowerManager.cpp
old mode 100755 (executable)
new mode 100644 (file)
index b12f74f..26610af
 #include <power.h>
 #include <pmapi.h>
 #include <device.h>
-#include <dlog.h>
 #include <algorithm>
 #include <PlatformException.h>
-#include <Logger.h>
 #include <JSUtil.h>
 #include <vconf.h>
+#include <Logger.h>
 
 using namespace DeviceAPI::Common;
 using namespace std;
@@ -74,7 +73,7 @@ const std::string PowerState::toString(){
 void PowerManager::onPlatformStateChangedCB(power_state_e state, void *user_data){
     PowerManager* object = static_cast<PowerManager*>(user_data);
     if(object == NULL){
-        LOGE("User data is NULL");
+        LoggerE("User data is NULL");
         return;
     }
     PowerState current(PowerState::SCREENOFF);
@@ -115,7 +114,7 @@ void PowerManager::request(PowerResource resource, PowerState state){
 
             ret = power_lock_state( (power_state_e)native_state , 0);
             if( POWER_ERROR_NONE!=ret ){
-                LOGE("power_lock_state(%d) error %d",native_state, ret);
+                LoggerE("power_lock_state(%d) error %d",native_state, ret);
                 throw UnknownException("power_lock_state error");
             }
             break;
@@ -125,7 +124,7 @@ void PowerManager::request(PowerResource resource, PowerState state){
             int maxBrightness;
             ret = device_get_max_brightness(0, &maxBrightness);
             if( DEVICE_ERROR_NONE!=ret) {
-                LOGE("Platform error while getting max brightness: %d", ret);
+                LoggerE("Platform error while getting max brightness: %d", ret);
                 throw UnknownException("Platform error while getting max brightness");
             }
 
@@ -134,7 +133,7 @@ void PowerManager::request(PowerResource resource, PowerState state){
             LOGI("Succeeded setting the brightness to a max level: %d", maxBrightness);
             ret = power_lock_state(POWER_STATE_NORMAL, 0);
             if( POWER_ERROR_NONE!=ret ){
-                LOGE("Platform error while locking state %d", ret);
+                LoggerE("Platform error while locking state %d", ret);
                 throw UnknownException("Platform error while locking state");
             }
 
@@ -145,7 +144,7 @@ void PowerManager::request(PowerResource resource, PowerState state){
             break;
         }
         case PowerState::SCREENOFF:
-            LOGE("SCREEN_OFF state cannot be requested");
+            LoggerE("SCREEN_OFF state cannot be requested");
             throw InvalidValuesException("SCREEN_OFF state cannot be requested");
 
         default :
@@ -167,7 +166,7 @@ void PowerManager::release(PowerResource resource){
         if( mBrightStateEnable ){
             ret = device_set_brightness_from_settings(0);
             if( DEVICE_ERROR_NONE!=ret){
-                LOGE("Platform error while setting restore brightness %d", ret);
+                LoggerE("Platform error while setting restore brightness %d", ret);
                 throw UnknownException("Platform error while setting restore brightness");
             }
         }
@@ -198,7 +197,7 @@ void PowerManager::setScreenBrightness(double brightness){
     int maxBrightness;
     ret = device_get_max_brightness(0, &maxBrightness);
     if( ret != 0 ){
-        LOGE("Platform error while setting restore brightness: %d", ret);
+        LoggerE("Platform error while setting restore brightness: %d", ret);
         throw UnknownException("Platform error while getting max brightness");
     }
     int nativeBrightness = (int)(brightness*maxBrightness);
@@ -223,7 +222,7 @@ void PowerManager::setScreenState(bool onoff){
         ret = pm_change_state(LCD_OFF);
 
     if( ret<0 ){
-        LOGE("Platform error while changing screen state %d", ret);
+        LoggerE("Platform error while changing screen state %d", ret);
         throw UnknownException("Platform error while changing screen state");
     }
 }
@@ -232,7 +231,7 @@ void PowerManager::restoreScreenBrightness(){
     int ret;
     ret = device_set_brightness_from_settings(0);
     if( DEVICE_ERROR_NONE!=ret){
-        LOGE("Platform error while restoring brightness %d", ret);
+        LoggerE("Platform error while restoring brightness %d", ret);
         throw UnknownException("Platform error while restoring brightness");
     }
 }
@@ -266,7 +265,7 @@ void PowerManager::setPlatformBrightness(int brightness){
 
     int ret = device_set_brightness(0, brightness);
     if( ret != 0){
-        LOGE("Platform error while setting %d brightness: %d", brightness, ret);
+        LoggerE("Platform error while setting %d brightness: %d", brightness, ret);
         throw UnknownException("Platform error while setting brightness.");
     }
     mCurrentBrightness = brightness;
@@ -285,10 +284,10 @@ int PowerManager::getPlatformBrightness(){
 
     ret = vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness);
     if( ret != 0 ){
-        LOGE("Platform error while getting brightness: %d", ret);
+        LoggerE("Platform error while getting brightness: %d", ret);
         throw UnknownException("Platform error while getting brightness");
     }
-    LOGE("VCONFKEY_SETAPPL_LCD_BRIGHTNESS %d", brightness);
+    LoggerE("VCONFKEY_SETAPPL_LCD_BRIGHTNESS %d", brightness);
 
     return brightness;
 }
@@ -321,7 +320,7 @@ void PowerManager::broadcastScreenState(PowerState current){
             restoreSettedBrightness();
         }
         catch( const BasePlatformException& err){
-            LOGE("Error restore custom brightness %s", err.getMessage().c_str());
+            LoggerE("Error restore custom brightness %s", err.getMessage().c_str());
         }
     }
     if( mCurrentState.mState == PowerState::SCREENNORMAL && PreviousState.mState == PowerState::SCREENOFF){