Add check essential action value while restore
authorJinWang An <jinwang.an@samsung.com>
Tue, 19 May 2020 09:05:04 +0000 (18:05 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Mon, 15 Jun 2020 07:21:25 +0000 (16:21 +0900)
Change-Id: If1754e880c34646d12a8f4e0e8cf5d690e572160

plugin/TestPluginAction.cpp
plugin/TestPluginAction.h
supervisor/Action.h
supervisor/ModeCareTaker.cpp
supervisor/TAction.h

index 6fcc114fa21696157b588c1bcb0965270e22ca8d..90f7777bb89a1e746718ba0296e62ef4fe3fca26 100644 (file)
@@ -26,14 +26,19 @@ MODES_NAMESPACE_USE;
 int TestPluginAction::printIntVal = 0;
 
 TestPluginAction::TestPluginAction(const std::string &actionKey)
-       : PluginAction(actionKey), cb(nullptr), cbData(nullptr)
+       : PluginAction(actionKey), changeTimeVal(0), cb(nullptr), cbData(nullptr)
 {
 }
 
 bool TestPluginAction::IsCurrentValue(int val)
 {
-       if (val == printIntVal)
-               return true;
+       if ("changeTime" == key) {
+               if (val == changeTimeVal)
+                       return true;
+       } else {
+               if (val == printIntVal)
+                       return true;
+       }
        return false;
 }
 
@@ -63,6 +68,7 @@ int TestPluginAction::set(int val)
        } else if ("changeTime" == key) {
                g_timeout_add_seconds(val, changeTimeout, this);
                DBG("set(%s, %d)", key.c_str(), val);
+               changeTimeVal = val;
        } else {
                ERR("Unknown key(%s)", key.c_str());
                return MODES_ERROR_NOT_SUPPORTED;
index c847c54975e506d2f21b74790182fa15103f480c..fb94e1b1a6978fc13f629270402664febe519bf2 100644 (file)
@@ -44,6 +44,7 @@ private:
        static gboolean changeTimeout(gpointer data);
 
        static int printIntVal;
+       int changeTimeVal;
        valueChangedCB cb;
        void *cbData;
 };
index 3ade714079e76af2cdc01aa383848d0639c3da11..2eeb4a35c3627ac7d3596f0c12db47023a76e6c7 100644 (file)
@@ -70,6 +70,7 @@ public:
        std::string backupUndoInfo();
        int restoreUndoInfo(const std::string &info);
        virtual int setValue(const std::string &val) = 0;
+       virtual bool checkChanged() = 0;
        virtual std::string getStringOfValue() = 0;
        virtual int apply() = 0;
        virtual int applyOneShot() = 0;
index b0b1e81231dc604ff21338eb73bdb6494821d2c5..382d660e69111ef88364d43d216360e47edd21d5 100644 (file)
@@ -167,6 +167,10 @@ void ModeCareTaker::handleEssentialAction(const Mode &mode)
                if ((*it)->getRestrict() == Action::ESSENTIAL) {
                        DBG("Essential Action(%s)", (*it)->getRuleName().c_str());
                        essentialMap.insert(std::make_pair((*it).get(), mode.getName()));
+                       if (true == (*it)->checkChanged()) {
+                               EssentialHandler::undoHandler(mode.getName());
+                               return;
+                       }
                        (*it)->attachObserver(this);
                }
        }
index ec0e79752e09c5bc710faa1f84b6b08354eb0857..bcbb5ee5ae4ee8068389935ede039a2a0b914da4 100644 (file)
@@ -80,6 +80,15 @@ public:
                return MODES_ERROR_NONE;
        }
 
+       bool checkChanged() override
+       {
+               if (false == piAction->IsCurrentValue(value)) {
+                       INFO("Action(%s) is changed", ruleName.c_str());
+                       return true;
+               }
+               return false;
+       }
+
        int apply() override
        {
                std::lock_guard<std::mutex> lock(actionMutex);