fix unhandled case of wifi power
authorYoungjae Shin <yj99.shin@samsung.com>
Fri, 8 Nov 2019 01:58:34 +0000 (10:58 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Thu, 19 Mar 2020 04:30:37 +0000 (13:30 +0900)
wifi/WifiActionPower.cpp
wifi/WifiActionPower.h

index 8993a4c..0af2edd 100644 (file)
@@ -24,12 +24,13 @@ MODES_NAMESPACE_USE;
 const std::string WifiActionPower::NAME = "power";
 
 WifiActionPower::WifiActionPower()
-       : WifiAction(NAME), cb(NULL), cbData(NULL), oldVal(false)
+       : WifiAction(NAME), cb(NULL), cbData(NULL), oldVal(false), requestVal(false)
 {
 }
 
 int WifiActionPower::set(bool val)
 {
+       requestVal = val;
        wifi_manager_is_activated(handle, &oldVal);
        if (oldVal == val) {
                INFO("Already wifi is [%s]", val ? "On" : "Off");
@@ -130,7 +131,7 @@ void WifiActionPower::wifiStateChangedCB(wifi_manager_device_state_e state, void
 
        RET_IF(NULL == user_data);
 
-       bool changedVal = action->oldVal;
+       bool changedVal = action->requestVal;
        if (state == WIFI_MANAGER_DEVICE_STATE_ACTIVATED)
                changedVal = true;
        else if (state == WIFI_MANAGER_DEVICE_STATE_DEACTIVATED)
@@ -140,7 +141,7 @@ void WifiActionPower::wifiStateChangedCB(wifi_manager_device_state_e state, void
 
        INFO("state:%d", state);
 
-       if (changedVal == action->oldVal) {
+       if (changedVal != action->requestVal) {
                valueChangedCB cb = action->cb;
                void *cbData = action->cbData;
                //TODO: revise after revising the modes(because of piAction free)
index 9cc77ed..7132f01 100644 (file)
@@ -39,6 +39,7 @@ private:
        static void deactivateCB(wifi_manager_error_e result, void *user_data);
        static void wifiStateChangedCB(wifi_manager_device_state_e state, void * user_data);
        bool oldVal;
+       bool requestVal;
 };
 
 MODES_NAMESPACE_END