Modify from AlwaysOn to Timeout in display plugin
authorJinWang An <jinwang.an@samsung.com>
Wed, 6 Nov 2019 02:26:34 +0000 (11:26 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Thu, 19 Mar 2020 04:30:37 +0000 (13:30 +0900)
display/DisplayAllowPalmTouch.cpp
display/DisplayAlwaysOn.cpp [deleted file]
display/DisplayAlwaysOn.h [deleted file]
display/DisplayFactory.cpp
display/DisplayFactory.h
display/DisplayTimeout.cpp [new file with mode: 0644]
display/DisplayTimeout.h [new file with mode: 0644]
display/tizen_display_rule.xml
unittests/mdsp_test_display.cpp
unittests/mode/tizen_displayBlock_mode.xml

index 29c22a319496f1ac70f980af5047e1ef7d036bfd..b527591f90a688f85c5c1f593e8f3641b88d42a1 100644 (file)
@@ -50,14 +50,14 @@ int DisplayAllowPalmTouch::set(bool val)
        displayHandle = ecore_wl2_display_connect(NULL);
        if (!displayHandle) {
                ret = get_last_result();
-               ERR("ecore_wl2_display_connect() Fail(%s)\n", get_error_message(ret));
+               ERR("ecore_wl2_display_connect() Fail(%d)", ret);
                return MODES_ERROR_SYSTEM;
        }
 
        gestureHandle = efl_util_gesture_initialize();
        if (NULL == gestureHandle) {
                ret = get_last_result();
-               ERR("efl_util_gesture_initialize() Fail(%s)", get_error_message(ret));
+               ERR("efl_util_gesture_initialize() Fail(%d)", ret);
                return MODES_ERROR_SYSTEM;
        }
 
@@ -68,7 +68,7 @@ int DisplayAllowPalmTouch::set(bool val)
        if (EFL_UTIL_ERROR_NONE == ret) {
                modesRet = MODES_ERROR_NONE;
        } else {
-               ERR("efl_util_gesture_activate_set() Fail(%s)", get_error_message(ret));
+               ERR("efl_util_gesture_activate_set() Fail(%d)", ret);
                modesRet = MODES_ERROR_SYSTEM;
        }
 
diff --git a/display/DisplayAlwaysOn.cpp b/display/DisplayAlwaysOn.cpp
deleted file mode 100644 (file)
index 3b7e441..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "DisplayAlwaysOn.h"
-#include <sstream>
-#include <string>
-#include <vconf.h>
-#include <modes_errors.h>
-#include "plugin-log.h"
-
-MODES_NAMESPACE_USE;
-
-const std::string DisplayAlwaysOn::NAME = "alwaysOn";
-DisplayAlwaysOn::DisplayAlwaysOn()
-       :DisplayAction(NAME), key(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL), oldDisplayTimeout(-1), curVal(false)
-{
-}
-
-DisplayAlwaysOn::~DisplayAlwaysOn()
-{
-}
-
-int DisplayAlwaysOn::set(bool val)
-{
-       int ret;
-       curVal = val;
-       if (true == val) {
-               ret = vconf_get_int(key, &oldDisplayTimeout);
-               if (0 != ret) {
-                       ERR("vconf_get_int(%s) Fail(%s)", key, get_error_message(ret));
-                       return MODES_ERROR_SYSTEM;
-               }
-               ret = vconf_set_int(key, 0);
-               if (0 != ret) {
-                       ERR("vconf_set_int(%s, 0) Fail(%s)", key, get_error_message(ret));
-                       return MODES_ERROR_SYSTEM;
-               }
-       }
-
-       return MODES_ERROR_NONE;
-}
-
-int DisplayAlwaysOn::undo()
-{
-       int ret;
-       DBG("undo AlwaysOn(%s, %d)",
-                       key, oldDisplayTimeout);
-       if (true == curVal) {
-               ret = vconf_set_int(key, oldDisplayTimeout);
-               if (0 != ret) {
-                       ERR("vconf_set_int(%s, %d) Fail(%s)", key, oldDisplayTimeout, get_error_message(ret));
-                       return MODES_ERROR_SYSTEM;
-               }
-       }
-       return MODES_ERROR_NONE;
-}
-
-std::string DisplayAlwaysOn::serialize()
-{
-       std::ostringstream ostr;
-
-       ostr << oldDisplayTimeout;
-       return ostr.str();
-}
-
-int DisplayAlwaysOn::parse(const std::string &archive)
-{
-       std::istringstream iss(archive);
-       iss >> oldDisplayTimeout;
-
-       return MODES_ERROR_NONE;
-}
diff --git a/display/DisplayAlwaysOn.h b/display/DisplayAlwaysOn.h
deleted file mode 100644 (file)
index b59b8c0..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <string>
-#include "plugin-def.h"
-#include "DisplayAction.h"
-
-MODES_NAMESPACE_BEGIN
-
-class DisplayAlwaysOn : public DisplayAction {
-public:
-       DisplayAlwaysOn();
-       ~DisplayAlwaysOn();
-
-       int set(bool val) override;
-       int undo() override;
-       std::string serialize() override;
-       int parse(const std::string &archive) override;
-
-       static const std::string NAME;
-private:
-       const char* const key;
-       int oldDisplayTimeout;
-       bool curVal;
-};
-
-MODES_NAMESPACE_END
index 94bb1aa2d873494eb26f5068a993f9426d1cac54..769770d6dcb12bd24bab62a2123e9ab829f0a01f 100644 (file)
@@ -18,7 +18,7 @@
 #include <device/power.h>
 #include "plugin-log.h"
 #include "DisplayBrightness.h"
-#include "DisplayAlwaysOn.h"
+#include "DisplayTimeout.h"
 #include "DisplayAllowPalmTouch.h"
 
 MODES_NAMESPACE_USE;
@@ -26,7 +26,7 @@ MODES_NAMESPACE_USE;
 DisplayFactory::DisplayFactory()
 {
        actionMap[DisplayBrightness::NAME] = BRIGHTNESS;
-       actionMap[DisplayAlwaysOn::NAME] = ALWAYS_ON;
+       actionMap[DisplayTimeout::NAME] = TIMEOUT;
        actionMap[DisplayAllowPalmTouch::NAME] = ALLOW_PALM_TOUCH;
 }
 
@@ -43,8 +43,8 @@ DisplayAction* DisplayFactory::createAction(const std::string &key)
        case BRIGHTNESS:
                action = new DisplayBrightness();
                break;
-       case ALWAYS_ON:
-               action = new DisplayAlwaysOn();
+       case TIMEOUT:
+               action = new DisplayTimeout();
                break;
        case ALLOW_PALM_TOUCH:
                action = new DisplayAllowPalmTouch();
index a69a70759c81d190b355aa5bc919f6a928abb782..005276886b4e24638da3dc3bf901e33129b75dc4 100644 (file)
@@ -31,7 +31,7 @@ public:
 private:
        enum actionKey{
                BRIGHTNESS,
-               ALWAYS_ON,
+               TIMEOUT,
                ALLOW_PALM_TOUCH,
        };
 
diff --git a/display/DisplayTimeout.cpp b/display/DisplayTimeout.cpp
new file mode 100644 (file)
index 0000000..c4dbc23
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "DisplayTimeout.h"
+#include <sstream>
+#include <string>
+#include <vconf.h>
+#include <modes_errors.h>
+#include "plugin-log.h"
+
+MODES_NAMESPACE_USE;
+
+const std::string DisplayTimeout::NAME = "Timeout";
+DisplayTimeout::DisplayTimeout()
+       :DisplayAction(NAME), key(VCONFKEY_SETAPPL_LCD_TIMEOUT_NORMAL), oldDisplayTimeout(-1)
+{
+}
+
+DisplayTimeout::~DisplayTimeout()
+{
+}
+
+int DisplayTimeout::set(int val)
+{
+       int ret = vconf_get_int(key, &oldDisplayTimeout);
+       if (0 != ret) {
+               ERR("vconf_get_int(%s) Fail(%d)", key, ret);
+               return MODES_ERROR_SYSTEM;
+       }
+       ret = vconf_set_int(key, val);
+       if (0 != ret) {
+               ERR("vconf_set_int(%s, %d) Fail(%d)", key, val, ret);
+               return MODES_ERROR_SYSTEM;
+       }
+
+       return MODES_ERROR_NONE;
+}
+
+int DisplayTimeout::undo()
+{
+       DBG("undo Display Timeout(%s, %d)",
+                       key, oldDisplayTimeout);
+       int ret = vconf_set_int(key, oldDisplayTimeout);
+       if (0 != ret) {
+               ERR("vconf_set_int(%s, %d) Fail(%d)", key, oldDisplayTimeout, ret);
+               return MODES_ERROR_SYSTEM;
+       }
+       return MODES_ERROR_NONE;
+}
+
+std::string DisplayTimeout::serialize()
+{
+       std::ostringstream ostr;
+
+       ostr << oldDisplayTimeout;
+       return ostr.str();
+}
+
+int DisplayTimeout::parse(const std::string &archive)
+{
+       std::istringstream iss(archive);
+       iss >> oldDisplayTimeout;
+
+       return MODES_ERROR_NONE;
+}
diff --git a/display/DisplayTimeout.h b/display/DisplayTimeout.h
new file mode 100644 (file)
index 0000000..d29d2dc
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <string>
+#include "plugin-def.h"
+#include "DisplayAction.h"
+
+MODES_NAMESPACE_BEGIN
+
+class DisplayTimeout : public DisplayAction {
+public:
+       DisplayTimeout();
+       ~DisplayTimeout();
+
+       int set(int val) override;
+       int undo() override;
+       std::string serialize() override;
+       int parse(const std::string &archive) override;
+
+       static const std::string NAME;
+private:
+       const char* const key;
+       int oldDisplayTimeout;
+};
+
+MODES_NAMESPACE_END
index a52501b54e03af886a677a16c706257bce3656c3..de543b0a2f4391293f8c6113f893fcea1a191438 100644 (file)
@@ -5,10 +5,9 @@
       <desc>Display brightness</desc>
       <domain>System</domain>
     </rule>
-    <rule name="display.alwaysOn" type="bool" since="6.0" plugin="display">
-      <alias name="on">1</alias>
-      <alias name="off">0</alias>
-      <desc>Always on display</desc>
+    <rule name="display.Timeout" type="int" since="6.0" plugin="display">
+      <alias name="ALWAYS_ON">0</alias>
+      <desc>Display Timeout</desc>
       <domain>System</domain>
     </rule>
     <rule name="display.allowPalmTouch" type="bool" since="6.0" plugin="display">
index b27694ace0f28e9d628283409d4f1064457cffe5..690c6fad2fa58bd739d4d0e6f7c97840398963bd 100644 (file)
@@ -71,7 +71,7 @@ protected:
        static gboolean displayPluginAlwaysOnIdler(gpointer data)
        {
                PluginAction *action;
-               result = plugin->set("alwaysOn", true, &action);
+               result = plugin->set("Timeout", 0, &action);
                EXPECT_EQ(MODES_ERROR_NONE, result);
 
                result = plugin->undo(action);
index aeb66d364ac7f713a5b9bb54518f382bc79da89f..5fd3b4157649b2694413a975f9732850a0783cad 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <tizenModes xmlns="http://www.tizen.org" version="6.0">
   <mode name="displayBlock" type="exclusive">
-    <action rule="display.alwaysOn">on</action>
+    <action rule="display.Timeout">ALWAYS_ON</action>
     <action rule="display.allowPalmTouch">off</action>
   </mode>
 </tizenModes>