virtual bool launch_app_async(const std::string& appid, bool background) = 0;
virtual boost::optional<std::string> get_appid_by_pid(pid_t pid) = 0;
virtual boost::optional<pid_t> get_pid_by_appid(const std::string& appid) = 0;
+ virtual void clear_cache() = 0;
};
#endif /* __APPLICATION_MANAGER_H__ */
#include "application_manager.h"
+#include <chrono>
+#include <map>
+#include <string>
+
class CApplicationManagerAul : public IApplicationManager {
public:
CApplicationManagerAul();
bool launch_app_async(const std::string& appid, bool background) override;
boost::optional<std::string> get_appid_by_pid(pid_t pid) override;
boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override;
+ void clear_cache() override;
+
+private:
+ typedef struct {
+ std::string appid;
+ std::chrono::time_point<std::chrono::steady_clock> updated;
+ } AppIDCache;
+ typedef struct {
+ pid_t pid;
+ std::chrono::time_point<std::chrono::steady_clock> updated;
+ } PIDCache;
+
+ std::map<pid_t, AppIDCache> mAppIDCache;
+ std::map<std::string, PIDCache> mPIDCache;
};
#endif /* __APPLICATION_MANAGER_AUL_H__ */
int retry_num = 0;
char appid[MAX_APPID_LEN] = {'\0', };
- typedef struct {
- std::string appid;
- std::chrono::time_point<std::chrono::steady_clock> updated;
- } AppInfo;
-
- static std::map<pid_t, AppInfo> appids;
- if (appids.find(pid) != appids.end()) {
- auto info = appids[pid];
+ if (mAppIDCache.find(pid) != mAppIDCache.end()) {
+ auto info = mAppIDCache[pid];
auto now = std::chrono::steady_clock::now();
if (now - info.updated < std::chrono::seconds(60)) {
ret = info.appid;
ret = std::string{appid};
succeeded = true;
- appids[pid] = AppInfo{*ret, std::chrono::steady_clock::now()};
+ mAppIDCache[pid] = AppIDCache{*ret, std::chrono::steady_clock::now()};
}
retry_num++;
} while (!succeeded && retry_num < max_retry_num);
{
boost::optional<pid_t> ret;
- typedef struct {
- pid_t pid;
- std::chrono::time_point<std::chrono::steady_clock> updated;
- } AppInfo;
-
- static std::map<std::string, AppInfo> pids;
- if (pids.find(appid) != pids.end()) {
- auto info = pids[appid];
+ if (mPIDCache.find(appid) != mPIDCache.end()) {
+ auto info = mPIDCache[appid];
auto now = std::chrono::steady_clock::now();
if (now - info.updated < std::chrono::seconds(10)) {
ret = info.pid;
pid_t pid = aul_app_get_pid(appid.c_str());
if (pid >= 0) {
ret = pid;
- pids[appid] = AppInfo{pid, std::chrono::steady_clock::now()};
+ mPIDCache[appid] = PIDCache{pid, std::chrono::steady_clock::now()};
}
}
return ret;
}
+
+void CApplicationManagerAul::clear_cache()
+{
+ mAppIDCache.clear();
+ mPIDCache.clear();
+}
\ No newline at end of file
int ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
if (PMINFO_R_OK == ret && NULL != appid) {
- for (int loop = 0; loop < MAX_MACLIENT_INFO_NUM;loop++) {
- if (clientInfo.getItems()[loop].used) {
- for (int inner_loop = 0;inner_loop < MAX_WAKEUP_ENGINES_NUM;inner_loop++) {
- LOGI("comparing appid : %s %s", clientInfo.getItems()[loop].wakeup_engine[inner_loop], appid);
- if (0 == clientInfo.getItems()[loop].wakeup_engine[inner_loop].compare(appid)) {
+ std::vector<ClientInfoItems> &items = clientInfo.getItems();
+ for (int loop = 0; loop < std::min(MAX_MACLIENT_INFO_NUM, items.size());loop++) {
+ if (items[loop].used) {
+ for (int inner_loop = 0;
+ inner_loop < std::min(MAX_WAKEUP_ENGINES_NUM, items[loop].wakeup_engine.size());
+ inner_loop++) {
+ LOGI("comparing appid : %s %s", items[loop].wakeup_engine[inner_loop], appid);
+ if (0 == items[loop].wakeup_engine[inner_loop].compare(appid)) {
is_wakeup_engine = true;
}
}
}
temp.cnt_wakeup_engine++;
if (temp.cnt_wakeup_engine >= MAX_WAKEUP_ENGINES_NUM) {
- MAS_LOGE("cnt_wakeup_engine exceeds : %d", MAX_WAKEUP_ENGINES_NUM);
+ MAS_LOGE("cnt_wakeup_engine exceeds : %zu", MAX_WAKEUP_ENGINES_NUM);
temp.cnt_wakeup_engine = MAX_WAKEUP_ENGINES_NUM - 1;
}
}
{
if (nullptr == wake_word || nullptr == language) return -1;
- bool found = false;
- for (int loop = 0;false == found && loop < MAX_WAKEUP_WORDS_NUM;loop++) {
+ size_t max_size = get_custom_wake_word_num(wakeup_word_storage, wakeup_language_storage);
+
+ for (int loop = 0;loop < max_size;loop++) {
if (0 == wakeup_word_storage[loop].compare(wake_word) &&
0 == wakeup_language_storage[loop].compare(language)) {
LOGE("The wakeup word already exists!");
return -1; /* Already exists */
}
- if (0 == wakeup_word_storage[loop].length()) {
- wakeup_word_storage[loop] = wake_word;
- wakeup_language_storage[loop] = language;
- found = true;
- }
}
- if (!found) {
+ if (max_size < MAX_WAKEUP_WORDS_NUM) {
+ wakeup_word_storage.push_back(wake_word);
+ wakeup_language_storage.push_back(language);
+ } else {
LOGE("No empty slot found while trying to add new wake word!");
return -1;
}
{
if (nullptr == wake_word || nullptr == language) return -1;
- bool found = false;
+ int found = 0;
size_t max_size = get_custom_wake_word_num(wakeup_word_storage, wakeup_language_storage);
wakeup_language_storage[max_size - 1].clear();
loop--; /* Just in case there are duplicated items */
- found = true;
+ found++;
}
}
- if (!found) return -1;
+ if (found == 0) return -1;
+
+ wakeup_word_storage.resize((max_size > found) ? max_size - found : 0);
+ wakeup_language_storage.resize((max_size > found) ? max_size - found : 0);
+
return 0;
}
MAS_LOGI("[SUCCESS] __wakeup_event_cb is called, wakeup_word(%s)", wakeup_info.wakeup_word);
int ret = -1;
- CServiceMain* service_main = nullptr;
CServicePlugin *plugin = static_cast<CServicePlugin*>(user_data);
if (plugin) {
- service_main = plugin->get_service_main();
CServiceIpcDbus* service_ipc = plugin->get_service_ipc();
if (plugin->is_ui_panel_enabled() && service_ipc) {
int retry_cnt = 0;
)
SET(TTPO_PKGS
- capi-appfw-application
glib-2.0
capi-appfw-service-application
)
)
SET(TTPO_CFLAGS
+ -DWRAP_APP_PATH_PREFIX=..
)
SET(TTPO_WRAPPERS
SET(TTPO_LDFLAGS
)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++14")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -O0")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Og")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TTPO_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TTPO_CFLAGS}")
SET(EXTRA_LDFLAGS "${TTPO_LDFLAGS}")
# Find Packages
FOREACH(flag ${pkgs_CFLAGS})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
ENDFOREACH(flag)
FIND_PACKAGE(GTest REQUIRED)
LINK_FLAGS "${TTPO_WRAPPERS}")
ADD_TEST(NAME ${TTPO_EXECUTABLE} COMMAND ${TTPO_EXECUTABLE})
-# REPLACE THE TARGET INSTALL DESTINATION AS NEEDED (default : bin)
-INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
\ No newline at end of file
+INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
void SetUp() override {
}
void TearDown() override {
+ mApplicationMgr.clear_cache();
}
CApplicationManagerAul mApplicationMgr;
ASSERT_FALSE(found);
}
-/* Uncomment the below piece of code if you need your own main() */
-/*
int main(int argc, char** argv) {
std::cout << "Starting tests" << std::endl;
testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
}
-*/
<ttpo>
<source_files>test_main.cpp ../../../src/application_manager_aul.cpp</source_files>
<include_directories>../../../inc/</include_directories>
- <required_packages>capi-appfw-application</required_packages>
<required_packages>glib-2.0</required_packages>
<required_packages>capi-appfw-service-application</required_packages>
<wrapper_functions>aul_app_get_appid_bypid</wrapper_functions>
SET(TTPO_SRCS
test_audio_manager.cpp
- ../../../plugins/wakeup-manager/src/wakeup_audio_manager.cpp
- ../../../plugins/wakeup-manager/src/heap_tracer.cpp
+ ../../../wakeup-manager/src/wakeup_audio_manager.cpp
+ ../../../wakeup-manager/src/heap_tracer.cpp
)
SET(TTPO_PKGS
gmock
- capi-appfw-application
+ capi-appfw-service-application
glib-2.0
dlog
ecore
SET(TTPO_INCLUDES
../../../inc/
- ../../../plugins/wakeup-manager/inc/
+ ../../../wakeup-manager/inc/
)
SET(TTPO_CFLAGS
ADD_TEST(NAME ${TTPO_EXECUTABLE} COMMAND ${TTPO_EXECUTABLE})
# REPLACE THE TARGET INSTALL DESTINATION AS NEEDED (default : bin)
-INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
\ No newline at end of file
+INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
# Find Packages
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
- capi-appfw-application
+ capi-appfw-service-application
capi-appfw-preference
multi-assistant
dlog
bool launch_app_async(const std::string& appid, bool background) override { return true; }
boost::optional<std::string> get_appid_by_pid(pid_t pid) override { return boost::optional<std::string>{}; }
boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override { return boost::optional<pid_t>{-1}; };
+ void clear_cache() {}
};
class StorageWithNoClient : public testing::Test
}
void TearDown() override {
}
+ const std::string sender{"Sender"};
CClientManager client_manager;
CDummyApplicationManager application_manager;
};
const std::string arbitrary_client_appid{"Client1"};
const pid_t arbitrary_client_pid{1};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
int client_num = client_manager.get_client_num();
const std::string arbitrary_client_appid{"Client1"};
const pid_t arbitrary_client_pid{1};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
bool validity = client_manager.check_client_validity_by_appid(arbitrary_client_appid);
const std::string noexist_client_appid{"Client987654321"};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
bool validity = client_manager.check_client_validity_by_appid(noexist_client_appid);
}
void SetUp() override {
client_manager.set_application_manager(&application_manager);
- client_manager.create_client(preloaded_client_pid_1, preloaded_client_appid_1);
+ client_manager.create_client(preloaded_client_pid_1, preloaded_client_appid_1, sender);
}
void TearDown() override {
}
+ const std::string sender{"Sender"};
const std::string preloaded_client_appid_1{"Client1"};
const pid_t preloaded_client_pid_1{1};
CClientManager client_manager;
const std::string arbitrary_client_appid{"Client2"};
const pid_t arbitrary_client_pid{2};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
pid_t pid = client_manager.find_client_pid_by_index(0);
const std::string arbitrary_client_appid{"Client2"};
const pid_t arbitrary_client_pid{2};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
pid_t pid = client_manager.find_client_pid_by_index(1);
const std::string arbitrary_client_appid{"Client2"};
const pid_t arbitrary_client_pid{2};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
client_manager.destroy_client_by_pid(arbitrary_client_pid);
pid_t pid = client_manager.find_client_pid_by_index(0);
const std::string arbitrary_client_appid{"Client2"};
const pid_t arbitrary_client_pid{2};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
client_manager.destroy_client_by_pid(preloaded_client_pid_1);
pid_t pid = client_manager.find_client_pid_by_index(0);
const std::string arbitrary_client_appid{"Client2"};
const pid_t arbitrary_client_pid{2};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
pid_t pid = client_manager.find_client_pid_by_appid(preloaded_client_appid_1);
const std::string arbitrary_client_appid{"Client2"};
const pid_t arbitrary_client_pid{2};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
pid_t pid = client_manager.find_client_pid_by_appid(arbitrary_client_appid);
const std::string arbitrary_client_appid{"Client2"};
const pid_t arbitrary_client_pid{2};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
std::string appid = client_manager.find_client_appid_by_pid(preloaded_client_pid_1);
const std::string arbitrary_client_appid{"Client2"};
const int arbitrary_client_pid{2};
- client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid);
+ client_manager.create_client(arbitrary_client_pid, arbitrary_client_appid, sender);
std::string appid = client_manager.find_client_appid_by_pid(arbitrary_client_pid);
# Find Packages
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
- capi-appfw-application
+ capi-appfw-service-application
capi-appfw-preference
multi-assistant
dlog
libxml-2.0
+ libtzplatform-config
)
FOREACH(flag ${pkgs_CFLAGS})
virtual ~StorageWithEmptyWakeWord() {
}
void SetUp() override {
- memset(wakeup_word_storage, 0x0, sizeof(wakeup_word_storage));
- memset(wakeup_language_storage, 0x0, sizeof(wakeup_language_storage));
+ wakeup_word_storage.clear();
+ wakeup_language_storage.clear();
}
void TearDown() override {
}
CServiceConfig config;
- char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN];
- char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
+ std::vector<std::string> wakeup_word_storage;
+ std::vector<std::string> wakeup_language_storage;
};
class StorageWithAnArbitraryWakeWord : public testing::Test {
virtual ~StorageWithAnArbitraryWakeWord() {
}
void SetUp() override {
- memset(wakeup_word_storage, 0x0, sizeof(wakeup_word_storage));
- memset(wakeup_language_storage, 0x0, sizeof(wakeup_language_storage));
+ wakeup_word_storage.clear();
+ wakeup_language_storage.clear();
config.add_custom_wake_word(
preloaded_wake_word.c_str(), preloaded_language.c_str(),
const std::string preloaded_wake_word{"Hi Preloaded"};
const std::string preloaded_language{"pr_LD"};
CServiceConfig config;
- char wakeup_word_storage[MAX_WAKEUP_WORDS_NUM][MAX_WAKEUP_WORD_LEN];
- char wakeup_language_storage[MAX_WAKEUP_WORDS_NUM][MAX_SUPPORTED_LANGUAGE_LEN];
+ std::vector<std::string> wakeup_word_storage;
+ std::vector<std::string> wakeup_language_storage;
};
TEST_F(StorageWithEmptyWakeWord, HasOneWakeWordAfterAdd) {
+# THIS FILE WAS GENERATED BY THE TIZEN TDD-PROJECT OUTLINER.
+# IT IS NOT RECOMMENDED TO MODIFY THIS FILE SINCE THE
+# MODIFICATION CAN BE OVERWRITTEN BY THE GENERATION TOOL.
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(ttpo-project CXX C)
+
LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wno-unused-function -Wno-sign-compare")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++11")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(TTPO_SRCS
+ test_package_update_monitor.cpp
+ ../../../src/package_update_monitor.cpp
+ pkgmgrinfo_mock.cpp
+)
+
+SET(TTPO_PKGS
+ dlog
+ pkgmgr-info
+ capi-appfw-package-manager
+)
+
+SET(TTPO_INCLUDES
+ ../../../inc/
+)
-ADD_DEFINITIONS("-DFULLVER=\"${FULLVER}\"")
+SET(TTPO_CFLAGS
+ -DWRAP_APP_PATH_PREFIX=..
+)
+
+SET(TTPO_WRAPPERS
+ "-Wl,\
+--wrap=pkgmgrinfo_pkginfo_get_pkginfo,\
+--wrap=pkgmgrinfo_pkginfo_destroy_pkginfo,\
+--wrap=pkgmgrinfo_appinfo_get_list,\
+--wrap=pkgmgrinfo_appinfo_get_metadata_value,\
+--wrap=pkgmgrinfo_appinfo_get_appid"
+)
-SET(TEST_SOURCES
- test_package_update_monitor.cpp
- ${CMAKE_SOURCE_DIR}/src/package_update_monitor.cpp
+SET(TTPO_LDFLAGS
)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Og")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TTPO_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TTPO_CFLAGS}")
+SET(EXTRA_LDFLAGS "${TTPO_LDFLAGS}")
+
# Find Packages
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
- capi-appfw-application
- capi-appfw-package-manager
- multi-assistant
- dlog
- pkgmgr-info
+ ${TTPO_PKGS}
)
+INCLUDE_DIRECTORIES(${TTPO_INCLUDES})
+
FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
ENDFOREACH(flag)
FIND_PACKAGE(GTest REQUIRED)
INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS})
LINK_DIRECTORIES(${GTEST_LIBRARY_DIRS})
-SET(TEST_PACKAGE_MANAGER test-package-update-monitor)
-ADD_EXECUTABLE(${TEST_PACKAGE_MANAGER}
- ${TEST_SOURCES}
- )
-
-TARGET_LINK_LIBRARIES(${TEST_PACKAGE_MANAGER} -ldl ${GTEST_LIBRARIES} pthread
- ${EXTRA_LDFLAGS} ${pkgs_LDFLAGS})
+SET(TTPO_EXECUTABLE test-package-update-monitor)
+ADD_EXECUTABLE(
+ ${TTPO_EXECUTABLE}
+ ${TTPO_SRCS}
+)
-SET_TARGET_PROPERTIES(${TEST_PACKAGE_MANAGER} PROPERTIES
- COMPILE_FLAGS "-fPIE")
+TARGET_LINK_LIBRARIES(${TTPO_EXECUTABLE} ${pkgs_LDFLAGS})
+if(NOT "${EXTRA_LDFLAGS}" STREQUAL " ")
+ TARGET_LINK_LIBRARIES(${TTPO_EXECUTABLE} ${EXTRA_LDFLAGS})
+endif()
+TARGET_LINK_LIBRARIES(${TTPO_EXECUTABLE} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
-INSTALL(TARGETS ${TEST_PACKAGE_MANAGER} DESTINATION bin)
+SET_TARGET_PROPERTIES(${TTPO_EXECUTABLE} PROPERTIES
+ COMPILE_FLAGS "-fPIE"
+ LINK_FLAGS "${TTPO_WRAPPERS}")
+ADD_TEST(NAME ${TTPO_EXECUTABLE} COMMAND ${TTPO_EXECUTABLE})
-ADD_TEST(NAME ${TEST_PACKAGE_MANAGER} COMMAND ${TEST_PACKAGE_MANAGER})
+INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
--- /dev/null
+/*
+ * Copyright 2020 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "pkgmgrinfo_mock.h"
+
+#include <string>
+
+static std::string g_voice_assistant_package;
+static std::string g_wakeup_engine_package;
+static std::string g_non_monitoring_app_package;
+
+int pkgmgrinfo_mock_set_voice_assistant_package(const char *package)
+{
+ if (package) g_voice_assistant_package = package;
+ return 0;
+}
+
+int pkgmgrinfo_mock_set_wakeup_engine_package(const char *package)
+{
+ if (package) g_wakeup_engine_package = package;
+ return 0;
+}
+
+int pkgmgrinfo_mock_set_non_monitoring_app_package(const char *package)
+{
+ if (package) g_non_monitoring_app_package = package;
+ return 0;
+}
+
+int __wrap_pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle)
+{
+ if (!pkgid) return -1;
+ if (g_voice_assistant_package.compare(pkgid) == 0) {
+ *handle = (pkgmgrinfo_pkginfo_h)(g_voice_assistant_package.c_str());
+ return 0;
+ }
+ if (g_wakeup_engine_package.compare(pkgid) == 0) {
+ *handle = (pkgmgrinfo_pkginfo_h)(g_wakeup_engine_package.c_str());
+ return 0;
+ }
+ if (g_non_monitoring_app_package.compare(pkgid) == 0) {
+ *handle = (pkgmgrinfo_pkginfo_h)(g_non_monitoring_app_package.c_str());
+ return 0;
+ }
+ return -1;
+}
+
+int __wrap_pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
+ pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
+{
+ app_func((pkgmgrinfo_appinfo_h)handle, user_data);
+ return 0;
+}
+
+int __wrap_pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value)
+{
+ if (handle == g_voice_assistant_package.c_str()) {
+ *metadata_value = (char*)g_voice_assistant_package.c_str();
+ return 0;
+ }
+ return -1;
+}
+
+int __wrap_pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
+{
+ (*appid) = (char*)handle;
+ return 0;
+}
+
+int __wrap_pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_appinfo_h handle)
+{
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2020 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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.
+ */
+
+#ifndef PKGMGRINFO_MOCK_H
+#define PKGMGRINFO_MOCK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <pkgmgr-info.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+EXPORT_API int pkgmgrinfo_mock_set_voice_assistant_package(const char *package);
+EXPORT_API int pkgmgrinfo_mock_set_wakeup_engine_package(const char *package);
+EXPORT_API int pkgmgrinfo_mock_set_non_monitoring_app_package(const char *package);
+
+EXPORT_API int __wrap_pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid, pkgmgrinfo_pkginfo_h *handle);
+EXPORT_API int __wrap_pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_app_component component,
+ pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid);
+EXPORT_API int __wrap_pkgmgrinfo_appinfo_get_metadata_value(pkgmgrinfo_appinfo_h handle, const char *metadata_key, char **metadata_value);
+EXPORT_API int __wrap_pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid);
+EXPORT_API int __wrap_pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_appinfo_h handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
#include <string>
#include "package_update_monitor.h"
+#include "pkgmgrinfo_mock.h"
enum class ObserverEvent {
None,
RestartRequired
};
+const std::string VOICE_ASSISTANT_PACKAGE{"org.tizen.sample-assistant"};
+const std::string WAKEUP_ENGINE_PACKAGE{"wakeup-engine-default"};
+const std::string NON_EXISTING_APP_PACKAGE{"org.tizen.non-existing-app"};
+const std::string NON_MONITORING_APP_PACKAGE{"org.tizen.multi-assistant-service"};
+
class CPackageUpdateMonitorFake : public CPackageUpdateMonitor
{
public:
virtual ~DefaultFixture() {
}
void SetUp() override {
+ pkgmgrinfo_mock_set_voice_assistant_package(VOICE_ASSISTANT_PACKAGE.c_str());
+ pkgmgrinfo_mock_set_wakeup_engine_package(WAKEUP_ENGINE_PACKAGE.c_str());
+ pkgmgrinfo_mock_set_non_monitoring_app_package(NON_MONITORING_APP_PACKAGE.c_str());
monitor.initialize();
}
void TearDown() override {
observer.Reset();
std::string wakeup_engine_appid{"wakeup-engine-default"};
- clientInfo.getItems()[0].used = true;
- strcpy(clientInfo.getItems()[0].wakeup_engine[0], wakeup_engine_appid.c_str());
+ ClientInfoItems info;
+ info.used = true;
+ info.wakeup_engine.push_back(wakeup_engine_appid);
+ clientInfo.getItems().push_back(info);
monitor.GenerateFakeInstallPackageEvent(wakeup_engine_appid);
observer.Reset();
std::string wakeup_engine_appid{"wakeup-engine-default"};
- clientInfo.getItems()[0].used = true;
- strcpy(clientInfo.getItems()[0].wakeup_engine[0], wakeup_engine_appid.c_str());
+ ClientInfoItems info;
+ info.used = true;
+ info.wakeup_engine.push_back(wakeup_engine_appid);
+ clientInfo.getItems().push_back(info);
monitor.GenerateFakeUpdatePackageEvent(wakeup_engine_appid);
# Find Packages
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
- capi-appfw-application
+ capi-appfw-service-application
capi-appfw-preference
multi-assistant
dlog
LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/inc/
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/inc/
)
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror")
${CMAKE_SOURCE_DIR}/src/service_plugin.cpp
${CMAKE_SOURCE_DIR}/src/service_config.cpp
${CMAKE_SOURCE_DIR}/src/client_manager.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_manager_wrapper.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/dependency_resolver.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/assistant_config_manager.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/heap_tracer.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_audio_manager.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_engine_manager.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_manager.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_manager_wrapper.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_policy.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_policy_default.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_policy_external.cpp
+ ${CMAKE_SOURCE_DIR}/wakeup-manager/src/wakeup_settings.cpp
)
# Find Packages
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
- capi-appfw-application
capi-appfw-preference
+ libtzplatform-config
capi-appfw-package-manager
capi-appfw-service-application
capi-message-port
libxml-2.0
ecore
pkgmgr-info
+ jsoncpp
+ capi-media-audio-io
+ capi-media-sound-manager
)
FOREACH(flag ${pkgs_CFLAGS})
}
boost::optional<std::string> get_appid_by_pid(pid_t pid) override { return boost::optional<std::string>{}; }
boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override { return boost::optional<pid_t>{-1}; };
+ void clear_cache() {}
public:
boost::optional<std::string> launched_appid;
boost::optional<bool> launched_option_background;
SET(TTPO_SRCS
test_main.cpp
- ../../../plugins/wakeup-manager/src/wakeup_manager.cpp
- ../../../plugins/wakeup-manager/src/wakeup_audio_manager.cpp
- ../../../plugins/wakeup-manager/src/wakeup_engine_manager.cpp
- ../../../plugins/wakeup-manager/src/wakeup_settings.cpp
- ../../../plugins/wakeup-manager/src/dependency_resolver.cpp
- ../../../plugins/wakeup-manager/src/assistant_config_manager.cpp
- ../../../plugins/wakeup-manager/src/heap_tracer.cpp
- ../../../plugins/wakeup-manager/src/wakeup_policy.cpp
- ../../../plugins/wakeup-manager/src/wakeup_policy_default.cpp
- ../../../plugins/wakeup-manager/src/wakeup_policy_external.cpp
- ../../../plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp
+ ../../../wakeup-manager/src/wakeup_manager.cpp
+ ../../../wakeup-manager/src/wakeup_audio_manager.cpp
+ ../../../wakeup-manager/src/wakeup_engine_manager.cpp
+ ../../../wakeup-manager/src/wakeup_settings.cpp
+ ../../../wakeup-manager/src/dependency_resolver.cpp
+ ../../../wakeup-manager/src/assistant_config_manager.cpp
+ ../../../wakeup-manager/src/heap_tracer.cpp
+ ../../../wakeup-manager/src/wakeup_policy.cpp
+ ../../../wakeup-manager/src/wakeup_policy_default.cpp
+ ../../../wakeup-manager/src/wakeup_policy_external.cpp
+ ../../../wakeup-manager/src/wakeup_manager_wrapper.cpp
)
SET(TTPO_PKGS
dlog
ecore
vconf
+ jsoncpp
pkgmgr-info
capi-media-audio-io
- capi-appfw-application
+ capi-appfw-service-application
capi-appfw-preference
+ libtzplatform-config
)
SET(TTPO_INCLUDES
../../../inc//
- ../../../plugins/wakeup-manager/inc//
+ ../../../wakeup-manager/inc//
)
SET(TTPO_CFLAGS
- -Wno-format-truncation
+ -DWRAP_APP_PATH_PREFIX=..
)
SET(TTPO_WRAPPERS
"-Wl,\
---wrap=ecore_main_loop_thread_safe_call_async"
+--wrap=ecore_main_loop_thread_safe_call_async,\
+--wrap=sound_manager_add_focus_state_watch_cb,\
+--wrap=sound_manager_remove_focus_state_watch_cb,\
+--wrap=sound_manager_get_current_recording_focus"
)
SET(TTPO_LDFLAGS
)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -std=c++14")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g")
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -O0")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Og")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TTPO_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TTPO_CFLAGS}")
SET(EXTRA_LDFLAGS "${TTPO_LDFLAGS}")
# Find Packages
FOREACH(flag ${pkgs_CFLAGS})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
ENDFOREACH(flag)
FIND_PACKAGE(GTest REQUIRED)
LINK_FLAGS "${TTPO_WRAPPERS}")
ADD_TEST(NAME ${TTPO_EXECUTABLE} COMMAND ${TTPO_EXECUTABLE})
-# REPLACE THE TARGET INSTALL DESTINATION AS NEEDED (default : bin)
-INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
\ No newline at end of file
+INSTALL(TARGETS ${TTPO_EXECUTABLE} DESTINATION bin)
#include "wakeup_manager.h"
+#include <sound_manager.h>
+
using namespace multiassistant::wakeup;
extern "C" {
}
*/
void __wrap_ecore_main_loop_thread_safe_call_async(Ecore_Cb callback, void *data) {}
+int __wrap_sound_manager_add_focus_state_watch_cb(sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_watch_cb callback, void *user_data, int *id)
+{
+ return 0;
+}
+int __wrap_sound_manager_remove_focus_state_watch_cb(int id)
+{
+ return 0;
+}
+int __wrap_sound_manager_get_current_recording_focus(sound_stream_focus_change_reason_e *acquired_by, int *sound_behavior, char **extra_info)
+{
+ return -1;
+}
}
{
public:
MOCK_METHOD(void, on_value_changed, (), (override));
+ MOCK_METHOD(void, on_loaded_wakeup_engine_changed, (), (override));
};
class DefaultFixture : public testing::Test
{
public:
DefaultFixture() {
+ ecore_init();
}
virtual ~DefaultFixture() {
+ ecore_shutdown();
}
void SetUp() override {
mWakeupManager.initialize();
ASSERT_EQ(mWakeupEventObserver.mFinishedReceived.load(), 1);
}
-/* Uncomment the below piece of code if you need your own main() */
-/*
int main(int argc, char** argv) {
std::cout << "Starting tests" << std::endl;
testing::InitGoogleTest(&argc, argv);
int ret = RUN_ALL_TESTS();
return ret;
}
-*/
<?xml version="1.0" encoding="UTF-8"?>
<ttpo>
<source_files>test_main.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/wakeup_manager.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/wakeup_audio_manager.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/wakeup_engine_manager.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/wakeup_settings.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/dependency_resolver.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/assistant_config_manager.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/heap_tracer.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/wakeup_policy.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/wakeup_policy_default.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/wakeup_policy_external.cpp</source_files>
- <source_files>../../../plugins/wakeup-manager/src/wakeup_manager_wrapper.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/wakeup_manager.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/wakeup_audio_manager.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/wakeup_engine_manager.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/wakeup_settings.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/dependency_resolver.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/assistant_config_manager.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/heap_tracer.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/wakeup_policy.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/wakeup_policy_default.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/wakeup_policy_external.cpp</source_files>
+ <source_files>../../../wakeup-manager/src/wakeup_manager_wrapper.cpp</source_files>
<include_directories>../../../inc/</include_directories>
- <include_directories>../../../plugins/wakeup-manager/inc/</include_directories>
+ <include_directories>../../../wakeup-manager/inc/</include_directories>
<required_packages>gmock</required_packages>
<required_packages>dlog</required_packages>
<required_packages>ecore</required_packages>
<required_packages>vconf</required_packages>
+ <required_packages>jsoncpp</required_packages>
<required_packages>pkgmgr-info</required_packages>
<required_packages>capi-media-audio-io</required_packages>
- <required_packages>capi-appfw-application</required_packages>
+ <required_packages>capi-appfw-service-application</required_packages>
<required_packages>capi-appfw-preference</required_packages>
+ <required_packages>libtzplatform-config</required_packages>
<wrapper_functions>ecore_main_loop_thread_safe_call_async</wrapper_functions>
+ <wrapper_functions>sound_manager_add_focus_state_watch_cb</wrapper_functions>
+ <wrapper_functions>sound_manager_remove_focus_state_watch_cb</wrapper_functions>
+ <wrapper_functions>sound_manager_get_current_recording_focus</wrapper_functions>
<cflags>-Wno-format-truncation</cflags>
</ttpo>
SET(TTPO_SRCS
test_main.cpp
- ../../../plugins/wakeup-manager/src/wakeup_policy.cpp
- ../../../plugins/wakeup-manager/src/wakeup_policy_default.cpp
+ ../../../wakeup-manager/src/wakeup_policy.cpp
+ ../../../wakeup-manager/src/wakeup_policy_default.cpp
)
SET(TTPO_PKGS
)
SET(TTPO_INCLUDES
- ../../../plugins/wakeup-manager/inc/
+ ../../../wakeup-manager/inc/
)
SET(TTPO_CFLAGS
using namespace multiassistant::wakeup;
+class DefaultFixture;
+
class PolicyEventObserver : public IPolicyEventObserver
{
+public:
void on_wakeup(mas_wakeup_event_info wakeup_info);
+ DefaultFixture *fixture{nullptr};
};
class DefaultFixture : public testing::Test
void SetUp() override {
eina_init();
mWakeupAppID.clear();
+ mObserver.fixture = this;
}
void TearDown() override {
eina_shutdown();
};
void PolicyEventObserver::on_wakeup(mas_wakeup_event_info wakeup_info) {
- if (wakeup_info.extra_data) {
- DefaultFixture* fixture = (DefaultFixture*)(wakeup_info.extra_data);
+ if (fixture) {
fixture->mWakeupAppID = wakeup_info.wakeup_appid;
LOGD("wakeup_appid of wakeup_info : %p, %s", wakeup_info.wakeup_appid, wakeup_info.wakeup_appid);
}
# Install libraries
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${wmpkgs_LDFLAGS} -ldl ${EXTRA_LDFLAGS})
MESSAGE("LDFLAG : ${wmpkgs_LDFLAGS}")
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/plugins/wakeup-manager/libma-wakeup-manager.so DESTINATION ${TZ_SYS_RO_SHARE}/multiassistant/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/wakeup-manager/libma-wakeup-manager.so DESTINATION ${TZ_SYS_RO_SHARE}/multiassistant/)
ADD_SUBDIRECTORY(dependency-default)
} // wakeup
} // multiassistant
-#endif _ASSISTANT_CONFIG_MANAGER_H_
+#endif // _ASSISTANT_CONFIG_MANAGER_H_
#include <dlog.h>
#include <glib.h>
+#include <stdio.h>
#ifdef LOG_TAG
#undef LOG_TAG
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include "wakeup_audio_manager.h"
#include "wakeup_manager_main.h"
wakeup_manager->set_recording_by_voice_key(false);
audio_manager->clear_audio_data();
break;
+ case STREAMING_MODE::NONE:
+ MWR_LOGE("Streaming mode is NONE");
+ break;
}
wakeup_manager->set_streaming_mode(STREAMING_MODE::NONE);