From: JinWang An Date: Wed, 30 Oct 2019 07:29:57 +0000 (+0900) Subject: Add display plugin X-Git-Tag: submit/tizen/20200406.072014~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7f4bb9a804a2ce3b9868714689b2b4e759b09b3;p=platform%2Fcore%2Fsystem%2Fmodes-plugins.git Add display plugin --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2080283..fd4247e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,4 +21,5 @@ ADD_SUBDIRECTORY(app) ADD_SUBDIRECTORY(pkg) ADD_SUBDIRECTORY(bluetooth) ADD_SUBDIRECTORY(media) +ADD_SUBDIRECTORY(display) ADD_SUBDIRECTORY(unittests) diff --git a/display/CMakeLists.txt b/display/CMakeLists.txt new file mode 100644 index 0000000..85bf7cc --- /dev/null +++ b/display/CMakeLists.txt @@ -0,0 +1,14 @@ +SET(DISPLAY_PLUGIN "modes-plugin-display") +ADD_DEFINITIONS("-DEFL_BETA_API_SUPPORT") + +FILE(GLOB DISPLAY_SRCS *.cpp) + +PKG_CHECK_MODULES(DISPLAY_pkgs REQUIRED modes dlog capi-base-common capi-system-device ecore ecore-wl2 capi-ui-efl-util vconf) +INCLUDE_DIRECTORIES(${DISPLAY_pkgs_INCLUDE_DIRS}) +LINK_DIRECTORIES(${DISPLAY_pkgs_LIBRARY_DIRS}) + +ADD_LIBRARY(${DISPLAY_PLUGIN} SHARED ${DISPLAY_SRCS}) +TARGET_LINK_LIBRARIES(${DISPLAY_PLUGIN} ${DISPLAY_pkgs_LIBRARIES}) +SET_TARGET_PROPERTIES(${DISPLAY_PLUGIN} PROPERTIES NO_SONAME 1 ) +INSTALL(TARGETS ${DISPLAY_PLUGIN} DESTINATION ${MODES_PLUGIN_DEFAULT_DIR}) +INSTALL(FILES tizen_display_rule.xml DESTINATION ${MODES_ACTIONRULE_DEFAULT_DIR}) diff --git a/display/DisplayAction.cpp b/display/DisplayAction.cpp new file mode 100644 index 0000000..9a327db --- /dev/null +++ b/display/DisplayAction.cpp @@ -0,0 +1,36 @@ +/* + * 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 "DisplayAction.h" + +#include +#include "plugin-def.h" + +MODES_NAMESPACE_USE; + +DisplayAction::DisplayAction(const std::string &name) + :PluginAction(name) +{ +} + +int DisplayAction::set(int val) +{ + return MODES_ERROR_NOT_SUPPORTED; +} + +int DisplayAction::set(bool val) +{ + return MODES_ERROR_NOT_SUPPORTED; +} diff --git a/display/DisplayAction.h b/display/DisplayAction.h new file mode 100644 index 0000000..e04be7c --- /dev/null +++ b/display/DisplayAction.h @@ -0,0 +1,33 @@ +/* + * 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" + +MODES_NAMESPACE_BEGIN + +class DisplayAction : public PluginAction { +public: + DisplayAction(const std::string &name); + virtual ~DisplayAction() = default; + + virtual int set(int val); + virtual int set(bool val); +}; + +MODES_NAMESPACE_END + diff --git a/display/DisplayAllowPalmTouch.cpp b/display/DisplayAllowPalmTouch.cpp new file mode 100644 index 0000000..29c22a3 --- /dev/null +++ b/display/DisplayAllowPalmTouch.cpp @@ -0,0 +1,98 @@ +/* + * 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 "DisplayAllowPalmTouch.h" +#include +#include +#include +#include +#include +#include +#include "plugin-log.h" + +MODES_NAMESPACE_USE; + +const std::string DisplayAllowPalmTouch::NAME = "allowPalmTouch"; + +DisplayAllowPalmTouch::DisplayAllowPalmTouch() + :DisplayAction(NAME) +{ +} + +DisplayAllowPalmTouch::~DisplayAllowPalmTouch() +{ +} + +int DisplayAllowPalmTouch::set(bool val) +{ + int ret = EFL_UTIL_ERROR_NONE; + int modesRet; + Ecore_Wl2_Display *displayHandle; + efl_util_gesture_h gestureHandle = NULL; + + char *envString = getenv("XDG_RUNTIME_DIR"); + if (NULL == envString) + setenv("XDG_RUNTIME_DIR", "/run", 1); + + ecore_wl2_init(); + displayHandle = ecore_wl2_display_connect(NULL); + if (!displayHandle) { + ret = get_last_result(); + ERR("ecore_wl2_display_connect() Fail(%s)\n", get_error_message(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)); + return MODES_ERROR_SYSTEM; + } + + ret = efl_util_gesture_activate_set(gestureHandle, + EFL_UTIL_GESTURE_TYPE_PALM_COVER, val); + + + if (EFL_UTIL_ERROR_NONE == ret) { + modesRet = MODES_ERROR_NONE; + } else { + ERR("efl_util_gesture_activate_set() Fail(%s)", get_error_message(ret)); + modesRet = MODES_ERROR_SYSTEM; + } + + ecore_wl2_display_disconnect(displayHandle); + ecore_wl2_shutdown(); + return modesRet; +} + +int DisplayAllowPalmTouch::undo() +{ + return set(true); +} + +std::string DisplayAllowPalmTouch::serialize() +{ + std::ostringstream ostr; + + ostr << 1; + return ostr.str(); +} + +int DisplayAllowPalmTouch::parse(const std::string &archive) +{ + DBG("parse() Called()"); + + return MODES_ERROR_NONE; +} diff --git a/display/DisplayAllowPalmTouch.h b/display/DisplayAllowPalmTouch.h new file mode 100644 index 0000000..a3cf5c7 --- /dev/null +++ b/display/DisplayAllowPalmTouch.h @@ -0,0 +1,37 @@ +/* + * 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 DisplayAllowPalmTouch : public DisplayAction { +public: + DisplayAllowPalmTouch(); + ~DisplayAllowPalmTouch(); + + int set(bool val) override; + int undo() override; + std::string serialize() override; + int parse(const std::string &archive) override; + + static const std::string NAME; +}; + +MODES_NAMESPACE_END diff --git a/display/DisplayAlwaysOn.cpp b/display/DisplayAlwaysOn.cpp new file mode 100644 index 0000000..3b7e441 --- /dev/null +++ b/display/DisplayAlwaysOn.cpp @@ -0,0 +1,84 @@ +/* + * 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 new file mode 100644 index 0000000..b59b8c0 --- /dev/null +++ b/display/DisplayAlwaysOn.h @@ -0,0 +1,41 @@ +/* + * 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/DisplayBrightness.cpp b/display/DisplayBrightness.cpp new file mode 100644 index 0000000..d3ccf15 --- /dev/null +++ b/display/DisplayBrightness.cpp @@ -0,0 +1,99 @@ +/* + * 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 "DisplayBrightness.h" +#include +#include +#include +#include +#include +#include +#include "plugin-log.h" + +MODES_NAMESPACE_USE; + +const std::string DisplayBrightness::NAME = "brightness"; + +DisplayBrightness::DisplayBrightness() + :DisplayAction(NAME) +{ + device_display_get_numbers(&numDisplay); +} + +DisplayBrightness::~DisplayBrightness() +{ +} + +int DisplayBrightness::set(int val) +{ + for (int i = 0; i < numDisplay ; i++) { + int oldVal = 0; + int ret = device_display_get_brightness(i, &oldVal); + if (DEVICE_ERROR_NONE != ret) { + ERR("device_display_get_brightness(%d) Fail(%s)", i, get_error_message(ret)); + return MODES_ERROR_SYSTEM; + } + oldValList.push_back(oldVal); + } + + for (int i = 0; i < numDisplay ; i++) { + int ret = device_display_set_brightness(i, val); + if (DEVICE_ERROR_NONE != ret) { + ERR("device_display_set_brightness(%d, %d) Fail(%s)", i, val, get_error_message(ret)); + return MODES_ERROR_SYSTEM; + } + } + + return MODES_ERROR_NONE; +} + +int DisplayBrightness::undo() +{ + int i = 0; + for (auto it = oldValList.begin(); it != oldValList.end(); ++it, ++i) { + int ret = device_display_set_brightness(i, *it); + if (DEVICE_ERROR_NONE != ret) { + ERR("device_display_set_brightness(%d, %d) Fail(%s)", i, *it, get_error_message(ret)); + return MODES_ERROR_SYSTEM; + } + } + return MODES_ERROR_NONE; +} + +std::string DisplayBrightness::serialize() +{ + std::ostringstream ostr; + + for (auto it = oldValList.begin(); it != oldValList.end(); ++it) { + ostr << *it << delimiter; + } + return ostr.str(); +} + +int DisplayBrightness::parse(const std::string &data) +{ + size_t pos; + size_t start = 0; + oldValList.clear(); + while ((pos = data.find(delimiter, start)) != std::string::npos) { + int oldVal = 0; + std::istringstream iss(data.substr(start, pos - start)); + iss >> oldVal; + start = pos + 1; + oldValList.push_back(oldVal); + } + + return MODES_ERROR_NONE; +} diff --git a/display/DisplayBrightness.h b/display/DisplayBrightness.h new file mode 100644 index 0000000..ac36a19 --- /dev/null +++ b/display/DisplayBrightness.h @@ -0,0 +1,43 @@ +/* + * 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 +#include "plugin-def.h" +#include "DisplayAction.h" + +MODES_NAMESPACE_BEGIN + +class DisplayBrightness : public DisplayAction { +public: + DisplayBrightness(); + ~DisplayBrightness(); + + 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 delimiter = '#'; + int numDisplay; + std::list oldValList; +}; + +MODES_NAMESPACE_END diff --git a/display/DisplayFactory.cpp b/display/DisplayFactory.cpp new file mode 100644 index 0000000..94bb1aa --- /dev/null +++ b/display/DisplayFactory.cpp @@ -0,0 +1,63 @@ +/* + * 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 "DisplayFactory.h" +#include +#include +#include "plugin-log.h" +#include "DisplayBrightness.h" +#include "DisplayAlwaysOn.h" +#include "DisplayAllowPalmTouch.h" + +MODES_NAMESPACE_USE; + +DisplayFactory::DisplayFactory() +{ + actionMap[DisplayBrightness::NAME] = BRIGHTNESS; + actionMap[DisplayAlwaysOn::NAME] = ALWAYS_ON; + actionMap[DisplayAllowPalmTouch::NAME] = ALLOW_PALM_TOUCH; +} + +DisplayAction* DisplayFactory::createAction(const std::string &key) +{ + auto search = actionMap.find(key); + if (search == actionMap.end()) { + ERR("No DisplayAction(%s)", key.c_str()); + return nullptr; + } + + DisplayAction *action; + switch (search->second) { + case BRIGHTNESS: + action = new DisplayBrightness(); + break; + case ALWAYS_ON: + action = new DisplayAlwaysOn(); + break; + case ALLOW_PALM_TOUCH: + action = new DisplayAllowPalmTouch(); + break; + default: + action = nullptr; + break; + } + + return action; +} + +void DisplayFactory::destroyAction(DisplayAction *action) +{ + delete action; +} diff --git a/display/DisplayFactory.h b/display/DisplayFactory.h new file mode 100644 index 0000000..a69a707 --- /dev/null +++ b/display/DisplayFactory.h @@ -0,0 +1,41 @@ +/* + * 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 +#include "DisplayAction.h" + +MODES_NAMESPACE_BEGIN + +class DisplayFactory { +public: + DisplayFactory(); + ~DisplayFactory() = default; + + DisplayAction* createAction(const std::string &key); + void destroyAction(DisplayAction *action); +private: + enum actionKey{ + BRIGHTNESS, + ALWAYS_ON, + ALLOW_PALM_TOUCH, + }; + + std::map actionMap; +}; + +MODES_NAMESPACE_END diff --git a/display/DisplayPlugin.cpp b/display/DisplayPlugin.cpp new file mode 100644 index 0000000..a6e53f2 --- /dev/null +++ b/display/DisplayPlugin.cpp @@ -0,0 +1,119 @@ +/* + * 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 pkglicable 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 +#include +#include +#include "plugin-log.h" +#include "plugin-def.h" +#include "DisplayFactory.h" +#include "DisplayAction.h" + +MODES_NAMESPACE_USE; + +class DisplayPlugin : public Plugin { +public: + DisplayPlugin(); + ~DisplayPlugin(); + + int set(const std::string &key, int val, PluginAction **pluginAction) override; + int set(const std::string &key, bool val, PluginAction **pluginAction) override; + PluginAction* getUndoAction(const std::string &key, const std::string &info) override; + + int undo(PluginAction *pluginAction) override; + +private: + DisplayFactory displayFactory; +}; + +extern "C" API Plugin *objectCreate(void) +{ + return new DisplayPlugin; +} + +extern "C" API void objectDelete(Plugin *plugin) +{ + delete plugin; +} + +DisplayPlugin::DisplayPlugin() +{ + setName("display"); +} + +DisplayPlugin::~DisplayPlugin() +{ +} + +int DisplayPlugin::set(const std::string &key, int val, PluginAction **pluginAction) +{ + DisplayAction *action = displayFactory.createAction(key); + RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str()); + + int ret = action->set(val); + + DBG("Action(%s) set(%d)", key.c_str(), val); + + if ((ret == MODES_ERROR_NONE) && pluginAction) + *pluginAction = action; + else + displayFactory.destroyAction(action); + return ret; +} + +int DisplayPlugin::set(const std::string &key, bool val, PluginAction **pluginAction) +{ + DisplayAction *action = displayFactory.createAction(key); + RETVM_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER, "action(%s) is null", key.c_str()); + + int ret = action->set(val); + + DBG("Action(%s) set(%d)", key.c_str(), val); + + if ((ret == MODES_ERROR_NONE) && pluginAction) + *pluginAction = action; + else + displayFactory.destroyAction(action); + return ret; +} + +PluginAction* DisplayPlugin::getUndoAction(const std::string &key, const std::string &info) +{ + DisplayAction *action = displayFactory.createAction(key); + RETVM_IF(nullptr == action, nullptr, "action(%s) is null", key.c_str()); + + int ret = action->parse(info); + if (MODES_ERROR_NONE != ret) { + ERR("Action(%s) parse(%s) Fail(%d)", key.c_str(), info.c_str(), ret); + displayFactory.destroyAction(action); + return nullptr; + } + + return action; +} + +int DisplayPlugin::undo(PluginAction *pluginAction) +{ + DisplayAction *action = static_cast(pluginAction); + RETV_IF(nullptr == action, MODES_ERROR_INVALID_PARAMETER); + + DBG("Action(%s) undo", action->getName().c_str()); + + int ret = action->undo(); + displayFactory.destroyAction(action); + + return ret; +} + diff --git a/display/tizen_display_rule.xml b/display/tizen_display_rule.xml new file mode 100644 index 0000000..a52501b --- /dev/null +++ b/display/tizen_display_rule.xml @@ -0,0 +1,21 @@ + + + + + Display brightness + System + + + 1 + 0 + Always on display + System + + + 1 + 0 + Allow palm touch on display + Graphics System + + + diff --git a/media/MediaPlayer.cpp b/media/MediaPlayer.cpp index 7e5c0df..af0acfb 100644 --- a/media/MediaPlayer.cpp +++ b/media/MediaPlayer.cpp @@ -38,21 +38,21 @@ void MediaPlayer::playerCompletedCb(void *data) int MediaPlayer::createPlayer() { - int ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, NULL, NULL, &stream_info); - if (SOUND_MANAGER_ERROR_NONE != ret) { - ERR("sound_manager_create_stream_information() Fail(%s)", get_error_message(ret)); + int soundRet = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, NULL, NULL, &stream_info); + if (SOUND_MANAGER_ERROR_NONE != soundRet) { + ERR("sound_manager_create_stream_information() Fail(%s)", get_error_message(soundRet)); return MODES_ERROR_SYSTEM; } - ret = player_create(&player); - if (PLAYER_ERROR_NONE != ret) { - ERR("player_create() Fail(%s)", get_error_message(ret)); + int playerRet = player_create(&player); + if (PLAYER_ERROR_NONE != playerRet) { + ERR("player_create() Fail(%s)", get_error_message(playerRet)); return MODES_ERROR_SYSTEM; } - ret = player_set_sound_stream_info(player, stream_info); - if (PLAYER_ERROR_NONE != ret) { - ERR("player_set_sound_stream_info() Fail(%s)", get_error_message(ret)); + playerRet = player_set_sound_stream_info(player, stream_info); + if (PLAYER_ERROR_NONE != playerRet) { + ERR("player_set_sound_stream_info() Fail(%s)", get_error_message(playerRet)); return MODES_ERROR_SYSTEM; } return MODES_ERROR_NONE; @@ -80,13 +80,13 @@ int MediaPlayer::destroyPlayer() int MediaPlayer::set(std::string val) { - int ret = createPlayer(); - if (MODES_ERROR_SYSTEM == ret) { - ERR("createPlayer() Fail(%d)", ret); + int modesRet = createPlayer(); + if (MODES_ERROR_SYSTEM == modesRet) { + ERR("createPlayer() Fail(%d)", modesRet); return MODES_ERROR_SYSTEM; } - ret = player_set_uri(player, val.c_str()); + int ret = player_set_uri(player, val.c_str()); if (PLAYER_ERROR_NONE != ret) { ERR("player_set_uri() Fail(%s)", get_error_message(ret)); return MODES_ERROR_SYSTEM; diff --git a/packaging/modes-plugins.spec b/packaging/modes-plugins.spec index 931dd2a..792a4df 100644 --- a/packaging/modes-plugins.spec +++ b/packaging/modes-plugins.spec @@ -16,6 +16,7 @@ BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(capi-media-sound-manager) BuildRequires: pkgconfig(capi-media-player) +BuildRequires: pkgconfig(capi-system-device) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(capi-network-wifi-manager) @@ -25,6 +26,9 @@ BuildRequires: pkgconfig(gmock) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(pkgmgr-info) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(ecore-wl2) +BuildRequires: pkgconfig(capi-ui-efl-util) %description Plugin Libraries for Mode Supervisor @@ -85,6 +89,7 @@ export XDG_RUNTIME_DIR=/run %{modes_plugin_test_dir}/modes-plugintest-bt %{modes_plugin_test_dir}/modes-plugintest-mode %{modes_plugin_test_dir}/modes-plugintest-pkg +%{modes_plugin_test_dir}/modes-plugintest-display %postun -p /sbin/ldconfig diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 0f0e016..65d9a7f 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -1,11 +1,13 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIE") ADD_DEFINITIONS("-DMDS_TEST") +ADD_DEFINITIONS("-DEFL_BETA_API_SUPPORT") PKG_CHECK_MODULES(test_pkgs REQUIRED modes dlog gmock capi-network-wifi-manager capi-network-bluetooth vconf capi-appfw-application capi-appfw-app-manager aul capi-media-sound-manager capi-media-player - pkgmgr pkgmgr-info) + pkgmgr pkgmgr-info capi-system-device + evas elementary ecore ecore-wl2 capi-ui-efl-util) INCLUDE_DIRECTORIES(${test_pkgs_INCLUDE_DIRS}) LINK_DIRECTORIES(${test_pkgs_LIBRARY_DIRS}) @@ -70,3 +72,12 @@ SET(MEDIA_SRCS ${MEDIA_SRCS} "mdsp_test_media.cpp") ADD_EXECUTABLE(${MEDIA_PLUGIN_TEST} ${MEDIA_SRCS}) TARGET_LINK_LIBRARIES(${MEDIA_PLUGIN_TEST} ${test_pkgs_LIBRARIES}) INSTALL(TARGETS ${MEDIA_PLUGIN_TEST} DESTINATION ${TEST_INSTALL_DIR}) +#===================================================================# +SET(DISPLAY_SRC_DIR "${CMAKE_SOURCE_DIR}/display" ) +SET(DISPLAY_PLUGIN_TEST "modes-plugintest-display") +FILE(GLOB DISPLAY_SRCS ${DISPLAY_SRC_DIR}/*.cpp) +SET(DISPLAY_SRCS ${DISPLAY_SRCS} "mdsp_test_display.cpp") + +ADD_EXECUTABLE(${DISPLAY_PLUGIN_TEST} ${DISPLAY_SRCS}) +TARGET_LINK_LIBRARIES(${DISPLAY_PLUGIN_TEST} ${test_pkgs_LIBRARIES}) +INSTALL(TARGETS ${DISPLAY_PLUGIN_TEST} DESTINATION ${TEST_INSTALL_DIR}) diff --git a/unittests/mdsp_test_display.cpp b/unittests/mdsp_test_display.cpp new file mode 100644 index 0000000..b27694a --- /dev/null +++ b/unittests/mdsp_test_display.cpp @@ -0,0 +1,114 @@ +/* + * 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 displaylicable 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 +#include +#include +#include +#include "plugin-def.h" + +MODES_NAMESPACE_USE; + +extern "C" API Plugin *objectCreate(void); +extern "C" API void objectDelete(Plugin *plugin); + +class displayPluginTest : public ::testing::Test { +protected: + void SetUp() override + { + loop = g_main_loop_new(NULL, FALSE); + plugin = objectCreate(); + } + + void TearDown() override + { + g_main_loop_unref(loop); + loop = NULL; + objectDelete(plugin); + plugin = NULL; + } + + static gboolean displayPluginBrightnessIdler(gpointer data) + { + PluginAction *action; + result = plugin->set("brightness", 100, &action); + EXPECT_EQ(MODES_ERROR_NONE, result); + + result = plugin->undo(action); + EXPECT_EQ(MODES_ERROR_NONE, result); + + g_main_loop_quit(loop); + + return G_SOURCE_REMOVE; + } + + static gboolean displayPluginAllowPalmTouchIdler(gpointer data) + { + PluginAction *action; + result = plugin->set("allowPalmTouch", true, &action); + EXPECT_EQ(MODES_ERROR_NONE, result); + + result = plugin->undo(action); + EXPECT_EQ(MODES_ERROR_NONE, result); + + g_main_loop_quit(loop); + + return G_SOURCE_REMOVE; + } + + static gboolean displayPluginAlwaysOnIdler(gpointer data) + { + PluginAction *action; + result = plugin->set("alwaysOn", true, &action); + EXPECT_EQ(MODES_ERROR_NONE, result); + + result = plugin->undo(action); + EXPECT_EQ(MODES_ERROR_NONE, result); + + g_main_loop_quit(loop); + + return G_SOURCE_REMOVE; + } + static int result; + static GMainLoop *loop; + static Plugin *plugin; +}; + +int displayPluginTest::result = 0; +Plugin *displayPluginTest::plugin = NULL; +GMainLoop *displayPluginTest::loop = NULL; + +TEST_F(displayPluginTest, setBrightness) +{ + g_idle_add(displayPluginBrightnessIdler, plugin); + g_main_loop_run(loop); +} + +TEST_F(displayPluginTest, setAlwaysOn) +{ + g_idle_add(displayPluginAlwaysOnIdler, plugin); + g_main_loop_run(loop); +} + +TEST_F(displayPluginTest, setAllowPalmTouch) +{ + g_idle_add(displayPluginAllowPalmTouchIdler, plugin); + g_main_loop_run(loop); +} + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/unittests/mdsp_test_integration.cpp b/unittests/mdsp_test_integration.cpp index 0f232e4..f8a57cd 100644 --- a/unittests/mdsp_test_integration.cpp +++ b/unittests/mdsp_test_integration.cpp @@ -49,7 +49,6 @@ protected: int IntegrationTest::result = 0; GMainLoop *IntegrationTest::loop = NULL; - TEST_F(IntegrationTest, runMode_btAudioConnect) { g_idle_add(check_mode_idler, (gpointer)"btAudioConnect"); @@ -78,9 +77,9 @@ TEST_F(IntegrationTest, runMode_powerSave) EXPECT_EQ(MODES_ERROR_NONE, result); } -TEST_F(IntegrationTest, runMode_waterlock) +TEST_F(IntegrationTest, runMode_displayBlock) { - g_idle_add(check_mode_idler, (gpointer)"waterlock"); + g_idle_add(check_mode_idler, (gpointer)"displayBlock"); g_main_loop_run(loop); EXPECT_EQ(MODES_ERROR_NONE, result); } @@ -92,6 +91,14 @@ TEST_F(IntegrationTest, runMode_wifiOn) EXPECT_EQ(MODES_ERROR_NONE, result); } +TEST_F(IntegrationTest, runMode_waterlock) +{ + g_idle_add(check_mode_idler, (gpointer)"waterlock"); + g_main_loop_run(loop); + EXPECT_EQ(MODES_ERROR_NONE, result); +} + + int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); diff --git a/unittests/mode/tizen_displayBlock_mode.xml b/unittests/mode/tizen_displayBlock_mode.xml new file mode 100644 index 0000000..aeb66d3 --- /dev/null +++ b/unittests/mode/tizen_displayBlock_mode.xml @@ -0,0 +1,7 @@ + + + + on + off + +