From: JinWang An Date: Wed, 6 Nov 2019 02:26:34 +0000 (+0900) Subject: Modify from AlwaysOn to Timeout in display plugin X-Git-Tag: submit/tizen/20200406.072014~28 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abec61e86e1f403ffd838c5052fdb22b92421ac4;p=platform%2Fcore%2Fsystem%2Fmodes-plugins.git Modify from AlwaysOn to Timeout in display plugin --- diff --git a/display/DisplayAllowPalmTouch.cpp b/display/DisplayAllowPalmTouch.cpp index 29c22a3..b527591 100644 --- a/display/DisplayAllowPalmTouch.cpp +++ b/display/DisplayAllowPalmTouch.cpp @@ -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 index 3b7e441..0000000 --- a/display/DisplayAlwaysOn.cpp +++ /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 -#include -#include -#include -#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 index b59b8c0..0000000 --- a/display/DisplayAlwaysOn.h +++ /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 -#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 diff --git a/display/DisplayFactory.cpp b/display/DisplayFactory.cpp index 94bb1aa..769770d 100644 --- a/display/DisplayFactory.cpp +++ b/display/DisplayFactory.cpp @@ -18,7 +18,7 @@ #include #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(); diff --git a/display/DisplayFactory.h b/display/DisplayFactory.h index a69a707..0052768 100644 --- a/display/DisplayFactory.h +++ b/display/DisplayFactory.h @@ -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 index 0000000..c4dbc23 --- /dev/null +++ b/display/DisplayTimeout.cpp @@ -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 +#include +#include +#include +#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 index 0000000..d29d2dc --- /dev/null +++ b/display/DisplayTimeout.h @@ -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 +#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 diff --git a/display/tizen_display_rule.xml b/display/tizen_display_rule.xml index a52501b..de543b0 100644 --- a/display/tizen_display_rule.xml +++ b/display/tizen_display_rule.xml @@ -5,10 +5,9 @@ Display brightness System - - 1 - 0 - Always on display + + 0 + Display Timeout System diff --git a/unittests/mdsp_test_display.cpp b/unittests/mdsp_test_display.cpp index b27694a..690c6fa 100644 --- a/unittests/mdsp_test_display.cpp +++ b/unittests/mdsp_test_display.cpp @@ -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); diff --git a/unittests/mode/tizen_displayBlock_mode.xml b/unittests/mode/tizen_displayBlock_mode.xml index aeb66d3..5fd3b41 100644 --- a/unittests/mode/tizen_displayBlock_mode.xml +++ b/unittests/mode/tizen_displayBlock_mode.xml @@ -1,7 +1,7 @@ - on + ALWAYS_ON off