ADD_SUBDIRECTORY(pkg)
ADD_SUBDIRECTORY(bluetooth)
ADD_SUBDIRECTORY(media)
+ADD_SUBDIRECTORY(display)
ADD_SUBDIRECTORY(unittests)
--- /dev/null
+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})
--- /dev/null
+/*
+ * 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 <modes_errors.h>
+#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;
+}
--- /dev/null
+/*
+ * 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 <PluginAction.h>
+#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
+
--- /dev/null
+/*
+ * 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 <sstream>
+#include <string>
+#include <Ecore_Wl2.h>
+#include <efl_util.h>
+#include <Ecore.h>
+#include <modes_errors.h>
+#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;
+}
--- /dev/null
+/*
+ * 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 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
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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 <list>
+#include <sstream>
+#include <string>
+#include <stdlib.h>
+#include <device/display.h>
+#include <modes_errors.h>
+#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;
+}
--- /dev/null
+/*
+ * 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 <list>
+#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<int> oldValList;
+};
+
+MODES_NAMESPACE_END
--- /dev/null
+/*
+ * 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 <string>
+#include <device/power.h>
+#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;
+}
--- /dev/null
+/*
+ * 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 <map>
+#include <string>
+#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<std::string, enum actionKey> actionMap;
+};
+
+MODES_NAMESPACE_END
--- /dev/null
+/*
+ * 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 <string>
+#include <modes_errors.h>
+#include <Plugin.h>
+#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<DisplayAction*>(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;
+}
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<tizenModes xmlns="http://www.tizen.org" version="6.0">
+ <actionRule>
+ <rule name="display.brightness" type="int" since="6.0" plugin="display">
+ <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>
+ <domain>System</domain>
+ </rule>
+ <rule name="display.allowPalmTouch" type="bool" since="6.0" plugin="display">
+ <alias name="on">1</alias>
+ <alias name="off">0</alias>
+ <desc>Allow palm touch on display</desc>
+ <domain>Graphics System</domain>
+ </rule>
+ </actionRule>
+</tizenModes>
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;
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;
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)
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
%{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
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})
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})
--- /dev/null
+/*
+ * 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 <glib.h>
+#include <gtest/gtest.h>
+#include <Plugin.h>
+#include <modes_errors.h>
+#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();
+}
int IntegrationTest::result = 0;
GMainLoop *IntegrationTest::loop = NULL;
-
TEST_F(IntegrationTest, runMode_btAudioConnect)
{
g_idle_add(check_mode_idler, (gpointer)"btAudioConnect");
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);
}
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);
--- /dev/null
+<?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.allowPalmTouch">off</action>
+ </mode>
+</tizenModes>