From b80434300f4f32a6c4a39fead4eaa21ee813931f Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 12 Jan 2016 15:59:35 +0900 Subject: [PATCH 01/16] Build flags for disabling place recognition & prediction engines Change-Id: I6e346f4464f72a66c6314678c988d8df6db11367 Signed-off-by: Mu-Woong Lee --- src/place/CMakeLists.txt | 16 +++++++++++++--- src/place/place_context_provider.cpp | 9 +++++++-- src/statistics/CMakeLists.txt | 12 +++++++++++- src/statistics/statistics_context_provider.cpp | 8 ++++++++ 4 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/place/CMakeLists.txt b/src/place/CMakeLists.txt index 47ec7df..9ee741d 100644 --- a/src/place/CMakeLists.txt +++ b/src/place/CMakeLists.txt @@ -1,16 +1,22 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(target "ctx-place") +# Build flag for the place auto detection engine. +# Set this to "yes" to enable the engine. +SET(enable_recog_engine "no") + # Common Profile FILE(GLOB srcs *.cpp) # Mobile Profile IF("${PROFILE}" STREQUAL "mobile") FILE(GLOB_RECURSE srcs ${srcs} geofence/*.cpp) - FILE(GLOB_RECURSE srcs ${srcs} recognition/*.cpp) - SET(deps "${deps} capi-location-manager") SET(deps "${deps} capi-geofence-manager") - SET(deps "${deps} capi-network-wifi") + IF("${enable_recog_engine}" STREQUAL "yes") + FILE(GLOB_RECURSE srcs ${srcs} recognition/*.cpp) + SET(deps "${deps} capi-location-manager") + SET(deps "${deps} capi-network-wifi") + ENDIF("${enable_recog_engine}" STREQUAL "yes") ENDIF("${PROFILE}" STREQUAL "mobile") MESSAGE("Place Provider Sources: ${srcs}") @@ -30,5 +36,9 @@ SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEX SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) +IF(NOT "${enable_recog_engine}" STREQUAL "yes") + SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "_DISABLE_RECOG_ENGINE_") +ENDIF(NOT "${enable_recog_engine}" STREQUAL "yes") + # Install INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries) diff --git a/src/place/place_context_provider.cpp b/src/place/place_context_provider.cpp index d5adcde..934f780 100644 --- a/src/place/place_context_provider.cpp +++ b/src/place/place_context_provider.cpp @@ -21,8 +21,10 @@ #ifdef _MOBILE_ #include "geofence/place_geofence.h" +#ifndef _DISABLE_RECOG_ENGINE_ #include "recognition/place_recognition.h" -#endif +#endif /* _DISABLE_RECOG_ENGINE_ */ +#endif /* _MOBILE_ */ template void register_provider(const char *subject, const char *privilege) @@ -40,8 +42,11 @@ EXTAPI bool ctx::init_place_context_provider() register_provider(PLACE_SUBJ_GEOFENCE, PLACE_PRIV_GEOFENCE); place_geofence_provider::submit_trigger_item(); +#ifndef _DISABLE_RECOG_ENGINE_ place_recognition_provider::create(NULL); register_provider(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION); -#endif +#endif /* _DISABLE_RECOG_ENGINE_ */ + +#endif /* _MOBILE_ */ return true; } diff --git a/src/statistics/CMakeLists.txt b/src/statistics/CMakeLists.txt index d0ee7d6..1085dce 100644 --- a/src/statistics/CMakeLists.txt +++ b/src/statistics/CMakeLists.txt @@ -1,6 +1,10 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(target "ctx-statistics") +# Build flag for the prediction engine. +# Set this to "yes" to enable the engine. +SET(enable_prediction_engine "no") + # Common Options INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/shared @@ -10,7 +14,9 @@ INCLUDE_DIRECTORIES( FILE(GLOB srcs ./*.cpp) FILE(GLOB srcs ${srcs} shared/*.cpp) FILE(GLOB srcs ${srcs} app/*.cpp) -FILE(GLOB srcs ${srcs} prediction/*.cpp) +IF("${enable_prediction_engine}" STREQUAL "yes") + FILE(GLOB srcs ${srcs} prediction/*.cpp) +ENDIF("${enable_prediction_engine}" STREQUAL "yes") SET(deps "capi-system-runtime-info pkgmgr pkgmgr-info capi-appfw-package-manager") SET(deps "${deps} capi-appfw-application capi-appfw-app-manager") @@ -58,5 +64,9 @@ SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEX SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) +IF(NOT "${enable_prediction_engine}" STREQUAL "yes") + SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "_DISABLE_PREDICTION_ENGINE_") +ENDIF(NOT "${enable_prediction_engine}" STREQUAL "yes") + # Install INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries) diff --git a/src/statistics/statistics_context_provider.cpp b/src/statistics/statistics_context_provider.cpp index 62fea4d..13e9c40 100644 --- a/src/statistics/statistics_context_provider.cpp +++ b/src/statistics/statistics_context_provider.cpp @@ -20,6 +20,10 @@ #include "app/app_stats_provider.h" +#ifndef _DISABLE_PREDICTION_ENGINE_ +// include prediction engine header files here +#endif + #ifdef _MOBILE_ #include "media/media_stats_provider.h" #include "social/social_stats_provider.h" @@ -50,6 +54,10 @@ EXTAPI bool ctx::init_statistics_context_provider() register_provider(APP_SUBJ_FREQUENCY, APP_HISTORY_PRIV); app_statistics_provider::submit_trigger_item(); +#ifndef _DISABLE_PREDICTION_ENGINE_ +// initialize the prediction engine here +#endif + #ifdef _MOBILE_ media_statistics_provider::create(NULL); register_provider(MEDIA_SUBJ_PEAK_TIME_FOR_MUSIC, MEDIA_HISTORY_PRIV); -- 2.7.4 From 6133a60da3a6f4a3d9d205936cb8784734c4158a Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 14 Jan 2016 14:16:44 +0900 Subject: [PATCH 02/16] Fix issues detected by static program analysis Change-Id: I5fcb11ba212898776687ce1075803a8dbbdaf455 Signed-off-by: Mu-Woong Lee --- src/device/social/call.cpp | 2 ++ src/device/social/email.cpp | 1 + src/device/system/wifi.cpp | 1 + src/statistics/social/log_aggregator.cpp | 1 + 4 files changed, 5 insertions(+) diff --git a/src/device/social/call.cpp b/src/device/social/call.cpp index 9f945e8..52e6aa3 100644 --- a/src/device/social/call.cpp +++ b/src/device/social/call.cpp @@ -42,6 +42,8 @@ static ctx::json latest; ctx::social_status_call::social_status_call() { + handle_list.count = 0; + handle_list.handle = NULL; } ctx::social_status_call::~social_status_call() diff --git a/src/device/social/email.cpp b/src/device/social/email.cpp index 3af00b6..2324a4b 100644 --- a/src/device/social/email.cpp +++ b/src/device/social/email.cpp @@ -25,6 +25,7 @@ GENERATE_PROVIDER_COMMON_IMPL(social_status_email); ctx::social_status_email::social_status_email() + : dbus_signal_id(-1) { } diff --git a/src/device/system/wifi.cpp b/src/device/system/wifi.cpp index d6eaa10..fde2d8c 100644 --- a/src/device/system/wifi.cpp +++ b/src/device/system/wifi.cpp @@ -25,6 +25,7 @@ ctx::device_status_wifi::device_status_wifi() : last_state(_UNKNOWN) , is_initialized(false) , is_activated(false) + , conn_state(WIFI_CONNECTION_STATE_FAILURE) { IF_FAIL_VOID_TAG(start_monitor(), _W, "WiFi monitor initialization failed"); diff --git a/src/statistics/social/log_aggregator.cpp b/src/statistics/social/log_aggregator.cpp index 4e80053..c04e918 100644 --- a/src/statistics/social/log_aggregator.cpp +++ b/src/statistics/social/log_aggregator.cpp @@ -24,6 +24,7 @@ ctx::contact_log_aggregator::contact_log_aggregator() : timer_id(-1) + , time_diff(0) { create_table(); timer_id = timer_manager::set_at(3, 0, timer_types::EVERYDAY, this, NULL); -- 2.7.4 From 74358fb94a825631d1144f87fbf930ef49935cd4 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 14 Jan 2016 19:25:52 +0900 Subject: [PATCH 03/16] Fix cmake scripts to set LOG_TAG properly Change-Id: Ife8694d2d0e0d3dbc5804e4a4956bf7d78b84a89 Signed-off-by: Mu-Woong Lee --- src/device/CMakeLists.txt | 3 ++- src/place/CMakeLists.txt | 9 ++++----- src/statistics/CMakeLists.txt | 9 ++++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt index 20a8db1..94a604b 100644 --- a/src/device/CMakeLists.txt +++ b/src/device/CMakeLists.txt @@ -1,5 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(target "ctx-device") +SET(definitions LOG_TAG=\"CONTEXT-DEVICE\") # Common Profile FILE(GLOB srcs ./*.cpp) @@ -49,7 +50,7 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${srcs}) TARGET_LINK_LIBRARIES(${target} ${device_pkgs_LDFLAGS}) SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_FLAGS ${extra_cflags}) -SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEXT-DEVICE\"") +SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "${definitions}") SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) diff --git a/src/place/CMakeLists.txt b/src/place/CMakeLists.txt index 9ee741d..65d1c98 100644 --- a/src/place/CMakeLists.txt +++ b/src/place/CMakeLists.txt @@ -1,5 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(target "ctx-place") +SET(definitions LOG_TAG=\"CONTEXT-PLACE\") # Build flag for the place auto detection engine. # Set this to "yes" to enable the engine. @@ -16,6 +17,8 @@ IF("${PROFILE}" STREQUAL "mobile") FILE(GLOB_RECURSE srcs ${srcs} recognition/*.cpp) SET(deps "${deps} capi-location-manager") SET(deps "${deps} capi-network-wifi") + ELSE("${enable_recog_engine}" STREQUAL "yes") + SET(definitions ${definitions} "_DISABLE_RECOG_ENGINE_") ENDIF("${enable_recog_engine}" STREQUAL "yes") ENDIF("${PROFILE}" STREQUAL "mobile") @@ -32,13 +35,9 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${srcs}) TARGET_LINK_LIBRARIES(${target} ${place_pkgs_LDFLAGS}) SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_FLAGS ${extra_cflags}) -SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEXT-PLACE\"") +SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "${definitions}") SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) -IF(NOT "${enable_recog_engine}" STREQUAL "yes") - SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "_DISABLE_RECOG_ENGINE_") -ENDIF(NOT "${enable_recog_engine}" STREQUAL "yes") - # Install INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries) diff --git a/src/statistics/CMakeLists.txt b/src/statistics/CMakeLists.txt index 1085dce..f9f3a65 100644 --- a/src/statistics/CMakeLists.txt +++ b/src/statistics/CMakeLists.txt @@ -1,5 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(target "ctx-statistics") +SET(definitions LOG_TAG=\"CONTEXT-STATS\") # Build flag for the prediction engine. # Set this to "yes" to enable the engine. @@ -16,6 +17,8 @@ FILE(GLOB srcs ${srcs} shared/*.cpp) FILE(GLOB srcs ${srcs} app/*.cpp) IF("${enable_prediction_engine}" STREQUAL "yes") FILE(GLOB srcs ${srcs} prediction/*.cpp) +ELSE("${enable_prediction_engine}" STREQUAL "yes") + SET(definitions ${definitions} "_DISABLE_PREDICTION_ENGINE_") ENDIF("${enable_prediction_engine}" STREQUAL "yes") SET(deps "capi-system-runtime-info pkgmgr pkgmgr-info capi-appfw-package-manager") @@ -60,13 +63,9 @@ ENDFOREACH(flag) ADD_LIBRARY(${target} SHARED ${srcs}) TARGET_LINK_LIBRARIES(${target} ${stats_pkgs_LDFLAGS}) SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_FLAGS ${extra_cflags}) -SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEXT-STATS\"") +SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "${definitions}") SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER}) SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) -IF(NOT "${enable_prediction_engine}" STREQUAL "yes") - SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "_DISABLE_PREDICTION_ENGINE_") -ENDIF(NOT "${enable_prediction_engine}" STREQUAL "yes") - # Install INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries) -- 2.7.4 From 7b432655dc664ff12d8c69c279b0becfb128b772 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 14 Jan 2016 20:03:47 +0900 Subject: [PATCH 04/16] Modify the app usage logger to exploit aul signals Change-Id: I32fc3885629e3abf2aaf2798d62aa070989c98fd Signed-off-by: Mu-Woong Lee --- packaging/context-provider.spec | 11 +-- src/device/social/email.cpp | 4 +- src/statistics/CMakeLists.txt | 8 -- .../active_window_monitor.cpp | 73 ++++++---------- .../{app_use_monitor => }/active_window_monitor.h | 9 +- src/statistics/app/app_stats_provider.cpp | 7 +- .../app/app_use_monitor/launch_monitor.cpp | 98 ---------------------- .../app/app_use_monitor/launch_monitor.h | 46 ---------- 8 files changed, 34 insertions(+), 222 deletions(-) rename src/statistics/app/{app_use_monitor => }/active_window_monitor.cpp (64%) rename src/statistics/app/{app_use_monitor => }/active_window_monitor.h (81%) delete mode 100644 src/statistics/app/app_use_monitor/launch_monitor.cpp delete mode 100644 src/statistics/app/app_use_monitor/launch_monitor.h diff --git a/packaging/context-provider.spec b/packaging/context-provider.spec index 105f81b..a42991d 100644 --- a/packaging/context-provider.spec +++ b/packaging/context-provider.spec @@ -8,9 +8,6 @@ Source0: %{name}-%{version}.tar.gz %define BUILD_PROFILE %{?profile}%{!?profile:%{?tizen_profile_name}} -# Using the active window hooking for app monitoring, via ecore-x -%define ACTIVE_WINDOW_HOOK off - BuildRequires: cmake BuildRequires: pkgconfig(context-common) @@ -25,11 +22,6 @@ BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(capi-media-sound-manager) -%if "%{ACTIVE_WINDOW_HOOK}" == "on" -BuildRequires: pkgconfig(ecore) -BuildRequires: pkgconfig(ecore-x) -%endif - %if "%{?BUILD_PROFILE}" == "mobile" BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(capi-network-wifi) @@ -82,8 +74,7 @@ export CFLAGS+=" -DTIZEN_ENGINEER_MODE" export CXXFLAGS+=" -DTIZEN_ENGINEER_MODE" export FFLAGS+=" -DTIZEN_ENGINEER_MODE" -cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} \ - -DPROFILE=%{?BUILD_PROFILE} -DACTIVE_WINDOW_HOOK=%{ACTIVE_WINDOW_HOOK} +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DPROFILE=%{?BUILD_PROFILE} make %{?jobs:-j%jobs} %install diff --git a/src/device/social/email.cpp b/src/device/social/email.cpp index 2324a4b..c7c8ea5 100644 --- a/src/device/social/email.cpp +++ b/src/device/social/email.cpp @@ -75,7 +75,7 @@ void ctx::social_status_email::on_signal_received(const char* sender, const char int ctx::social_status_email::subscribe() { - dbus_signal_id = ctx::dbus_server::signal_subscribe(NULL, NULL, "User.Email.NetworkStatus", "email", this); + dbus_signal_id = ctx::dbus_server::subscribe_session_signal(NULL, NULL, "User.Email.NetworkStatus", "email", this); IF_FAIL_RETURN_TAG(dbus_signal_id >= 0, ERR_OPERATION_FAILED, _E, "Email dbus signal subscription failed"); return ERR_NONE; } @@ -83,6 +83,6 @@ int ctx::social_status_email::subscribe() int ctx::social_status_email::unsubscribe() { - ctx::dbus_server::signal_unsubscribe(dbus_signal_id); + ctx::dbus_server::unsubscribe_session_signal(dbus_signal_id); return ERR_NONE; } diff --git a/src/statistics/CMakeLists.txt b/src/statistics/CMakeLists.txt index f9f3a65..69df65a 100644 --- a/src/statistics/CMakeLists.txt +++ b/src/statistics/CMakeLists.txt @@ -25,14 +25,6 @@ SET(deps "capi-system-runtime-info pkgmgr pkgmgr-info capi-appfw-package-manager SET(deps "${deps} capi-appfw-application capi-appfw-app-manager") SET(deps "${deps} capi-media-sound-manager") -IF("${ACTIVE_WINDOW_HOOK}" STREQUAL "on") - ADD_DEFINITIONS("-D_USE_ACTIVE_WINDOW_HOOKING_") - SET(deps "${deps} ecore ecore-x") - SET(srcs ${srcs} app/app_use_monitor/active_window_monitor.cpp) -ELSE("${ACTIVE_WINDOW_HOOK}" STREQUAL "on") - SET(srcs ${srcs} app/app_use_monitor/launch_monitor.cpp) -ENDIF("${ACTIVE_WINDOW_HOOK}" STREQUAL "on") - # Mobile Profile IF("${PROFILE}" STREQUAL "mobile") FILE(GLOB srcs ${srcs} media/*.cpp) diff --git a/src/statistics/app/app_use_monitor/active_window_monitor.cpp b/src/statistics/app/active_window_monitor.cpp similarity index 64% rename from src/statistics/app/app_use_monitor/active_window_monitor.cpp rename to src/statistics/app/active_window_monitor.cpp index 1aca2c7..6299508 100644 --- a/src/statistics/app/app_use_monitor/active_window_monitor.cpp +++ b/src/statistics/app/active_window_monitor.cpp @@ -16,26 +16,24 @@ #include #include -#include #include #include #include #include #include -#include "../app_stats_types.h" +#include +#include "app_stats_types.h" #include "active_window_monitor.h" /* Active window changes frequently. * We thus consider the apps being foregrounded at least 3 secs */ #define MIN_VALID_USE_TIME 2 - #define ONE_DAY_IN_SEC 86400 -static Ecore_Event_Handler *window_property_event_handler = NULL; - ctx::app_use_monitor::app_use_monitor() - : last_cleanup_time(0) + : signal_id(-1) + , last_cleanup_time(0) , last_timestamp(0) , last_pid(-1) { @@ -49,69 +47,48 @@ ctx::app_use_monitor::~app_use_monitor() bool ctx::app_use_monitor::start_logging() { - /* This ecore_x based approach does not work with virtualization features */ - if(window_property_event_handler == NULL) { - ecore_x_init(NULL); - ecore_x_event_mask_set(ecore_x_window_root_first_get(), ECORE_X_EVENT_MASK_WINDOW_PROPERTY); - window_property_event_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, on_window_property_changed, this); - IF_FAIL_RETURN_TAG(window_property_event_handler, false, _E, "ecore_event_handler_add() failed"); - _D("Active window monitoring started"); - } - - return true; + signal_id = dbus_server::subscribe_system_signal(NULL, + "/Org/Tizen/Aul/AppStatus", "org.tizen.aul.AppStatus", "AppStatusChange", this); + _D("Active window monitoring started (%lld)", signal_id); + return (signal_id > 0); } void ctx::app_use_monitor::stop_logging() { - if (window_property_event_handler) { - ecore_event_handler_del(window_property_event_handler); - window_property_event_handler = NULL; + if (signal_id > 0) { + dbus_server::unsubscribe_system_signal(signal_id); _D("Active window monitoring stopped"); } } -Eina_Bool ctx::app_use_monitor::on_window_property_changed(void* data, int type, void* event) +void ctx::app_use_monitor::on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) { - IF_FAIL_RETURN_TAG(data && event, ECORE_CALLBACK_PASS_ON, _W, "Invalid window event"); - - Ecore_X_Event_Window_Property *property = static_cast(event); - Ecore_X_Atom atom = ecore_x_atom_get("_NET_ACTIVE_WINDOW"); + gint pid = 0; + const gchar *appid = NULL; + const gchar *pkgid = NULL; + const gchar *status = NULL; + const gchar *type = NULL; - IF_FAIL_RETURN(property->atom == atom, ECORE_CALLBACK_PASS_ON); + g_variant_get(param, "(i&s&s&s&s)", &pid, &appid, &pkgid, &status, &type); + IF_FAIL_VOID(appid && status && type); + IF_FAIL_VOID(STR_EQ(status, "fg") && STR_EQ(type, "uiapp")); - int pid = 0; - Ecore_X_Window win = 0; - - ecore_x_window_prop_window_get(property->win, atom, &win, 1); - ecore_x_netwm_pid_get(win, &pid); - - IF_FAIL_RETURN_TAG(pid > 0, ECORE_CALLBACK_PASS_ON, _W, "Invalid pid"); - - app_use_monitor *instance = static_cast(data); - instance->on_active_window_changed(pid); - - return ECORE_CALLBACK_PASS_ON; + on_active_window_changed(appid); } -void ctx::app_use_monitor::on_active_window_changed(int pid) +void ctx::app_use_monitor::on_active_window_changed(std::string app_id) { - IF_FAIL_VOID(last_pid != pid); - _D("Active window changed: PID-%d", pid); + IF_FAIL_VOID(last_app_id != app_id); + _D("New fourground app '%s'", app_id.c_str()); int timestamp = static_cast(time(NULL)); int duration = timestamp - last_timestamp; - if (!last_app_id.empty() > 0 && duration >= MIN_VALID_USE_TIME) + if (!last_app_id.empty() && duration >= MIN_VALID_USE_TIME) verify_used_app(last_app_id.c_str(), duration); last_timestamp = timestamp; - last_pid = pid; - - char *app_id = NULL; - app_manager_get_app_id(pid, &app_id); - last_app_id = (app_id ? app_id : ""); - g_free(app_id); - _D("Current Active App: %s", last_app_id.c_str()); + last_app_id = app_id; } void ctx::app_use_monitor::verify_used_app(const char *app_id, int duration) diff --git a/src/statistics/app/app_use_monitor/active_window_monitor.h b/src/statistics/app/active_window_monitor.h similarity index 81% rename from src/statistics/app/app_use_monitor/active_window_monitor.h rename to src/statistics/app/active_window_monitor.h index 443d2bc..685d41c 100644 --- a/src/statistics/app/app_use_monitor/active_window_monitor.h +++ b/src/statistics/app/active_window_monitor.h @@ -19,12 +19,13 @@ #include #include -#include +#include namespace ctx { - class app_use_monitor { + class app_use_monitor : public dbus_listener_iface { private: + int64_t signal_id; int last_cleanup_time; int last_timestamp; int last_pid; @@ -37,8 +38,8 @@ namespace ctx { void insert_log(const char *app_id, int duration); void append_cleanup_query(std::stringstream &query); - void on_active_window_changed(int pid); - static Eina_Bool on_window_property_changed(void* data, int type, void* event); + void on_active_window_changed(std::string app_id); + void on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param); public: app_use_monitor(); diff --git a/src/statistics/app/app_stats_provider.cpp b/src/statistics/app/app_stats_provider.cpp index 59a224b..7224592 100644 --- a/src/statistics/app/app_stats_provider.cpp +++ b/src/statistics/app/app_stats_provider.cpp @@ -22,12 +22,7 @@ #include "db_init.h" #include "install_monitor.h" - -#ifdef _USE_ACTIVE_WINDOW_HOOKING_ -#include "app_use_monitor/active_window_monitor.h" -#else -#include "app_use_monitor/launch_monitor.h" -#endif +#include "active_window_monitor.h" static ctx::app_install_monitor *install_mon = NULL; static ctx::app_use_monitor *launch_mon = NULL; diff --git a/src/statistics/app/app_use_monitor/launch_monitor.cpp b/src/statistics/app/app_use_monitor/launch_monitor.cpp deleted file mode 100644 index 4421063..0000000 --- a/src/statistics/app/app_use_monitor/launch_monitor.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * 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 -#include -#include -#include - -#include -#include "../app_stats_types.h" -#include "launch_monitor.h" - -ctx::app_use_monitor::app_use_monitor() -{ - start_logging(); -} - -ctx::app_use_monitor::~app_use_monitor() -{ - stop_logging(); -} - -bool ctx::app_use_monitor::start_logging() -{ - int err = app_manager_set_app_context_event_cb(app_context_event_cb, this); - IF_FAIL_RETURN_TAG(err == APP_MANAGER_ERROR_NONE, false, _E, "app_manager_set_app_context_event_cb() failed"); - return true; -} - -void ctx::app_use_monitor::stop_logging() -{ - app_manager_unset_app_context_event_cb(); -} - -void ctx::app_use_monitor::app_context_event_cb(app_context_h app_context, app_context_event_e event, void *user_data) -{ - char *app_id = NULL; - int err = app_context_get_app_id(app_context, &app_id); - IF_FAIL_VOID_TAG(err == APP_MANAGER_ERROR_NONE, _E, "app_context_get_app_id() failed"); - - app_use_monitor *monitor = static_cast(user_data); - - if (event == APP_CONTEXT_EVENT_LAUNCHED) { - monitor->log_launch_event(app_id); - } else if (event == APP_CONTEXT_EVENT_TERMINATED) { - monitor->log_terminate_event(app_id); - } - g_free(app_id); -} - -void ctx::app_use_monitor::log_launch_event(const char* app_id) -{ - int audiojack; - int system_volume; - int media_volume; - std::string bssid; - json data; - data.set(NULL, STATS_APP_ID, app_id); - - if (ctx::system_info::get_audio_jack_state(&audiojack)) - data.set(NULL, STATS_AUDIO_JACK, audiojack); - - if (ctx::system_info::get_volume(&system_volume, &media_volume)) { - data.set(NULL, STATS_SYSTEM_VOLUME, system_volume); - data.set(NULL, STATS_MEDIA_VOLUME, media_volume); - } - - if (ctx::system_info::get_wifi_bssid(bssid)) - data.set(NULL, STATS_BSSID, bssid); - - db_manager::insert(0, APP_TABLE_USAGE_LOG, data, NULL); -} - -void ctx::app_use_monitor::log_terminate_event(const char* app_id) -{ - std::stringstream query; - query << - "UPDATE " APP_TABLE_USAGE_LOG \ - " SET " STATS_DURATION " = strftime('%s', 'now') - " STATS_UNIV_TIME \ - " WHERE " STATS_COL_ROW_ID " = (" \ - "SELECT MAX(" STATS_COL_ROW_ID ") FROM " APP_TABLE_USAGE_LOG \ - " WHERE " STATS_APP_ID " = '" << app_id << "'" \ - " AND " STATS_DURATION " = 0)"; - db_manager::execute(0, query.str().c_str(), NULL); -} diff --git a/src/statistics/app/app_use_monitor/launch_monitor.h b/src/statistics/app/app_use_monitor/launch_monitor.h deleted file mode 100644 index 43b3f66..0000000 --- a/src/statistics/app/app_use_monitor/launch_monitor.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. - * - * 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. - */ - -#ifndef __CONTEXT_APP_USE_MONITOR_H__ -#define __CONTEXT_APP_USE_MONITOR_H__ - -#include -#include - -namespace ctx { - - class app_use_monitor : public db_listener_iface { - private: - bool start_logging(void); - void stop_logging(void); - - void log_launch_event(const char* app_id); - void log_terminate_event(const char* app_id); - - void on_creation_result_received(unsigned int query_id, int error) {} - void on_insertion_result_received(unsigned int query_id, int error, int64_t row_id) {} - void on_query_result_received(unsigned int query_id, int error, std::vector& records) {} - - static void app_context_event_cb(app_context_h app_context, app_context_event_e event, void *user_data); - - public: - app_use_monitor(); - ~app_use_monitor(); - }; /* class app_use_monitor */ - -} /* namespace ctx */ - -#endif /* __CONTEXT_APP_USE_MONITOR_H__ */ -- 2.7.4 From 02ced053be23e20766aa52de7e6d64cb0a6f6643 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 21 Jan 2016 10:08:29 +0900 Subject: [PATCH 05/16] Update enum names of contacts-service, which are modified Change-Id: Ic286d91f4a46e35cf8ccd1b0c94a3f3eeeee5b3d Signed-off-by: Mu-Woong Lee --- src/statistics/social/db_handle.cpp | 4 ++-- src/statistics/social/log_aggregator.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/statistics/social/db_handle.cpp b/src/statistics/social/db_handle.cpp index ccdb1c2..e6a1a01 100644 --- a/src/statistics/social/db_handle.cpp +++ b/src/statistics/social/db_handle.cpp @@ -62,12 +62,12 @@ std::string ctx::social_db_handle::create_where_clause(ctx::json filter) switch(comm_type) { case SOCIAL_COMMUNICATION_TYPE_CALL: where_clause << - " AND " SOCIAL_PHONE_LOG_TYPE " >= " << CONTACTS_PLOG_TYPE_VOICE_INCOMMING << + " AND " SOCIAL_PHONE_LOG_TYPE " >= " << CONTACTS_PLOG_TYPE_VOICE_INCOMING << " AND " SOCIAL_PHONE_LOG_TYPE " <= " << CONTACTS_PLOG_TYPE_VIDEO_BLOCKED; break; case SOCIAL_COMMUNICATION_TYPE_MESSAGE: where_clause << - " AND " SOCIAL_PHONE_LOG_TYPE " >= " << CONTACTS_PLOG_TYPE_MMS_INCOMMING << + " AND " SOCIAL_PHONE_LOG_TYPE " >= " << CONTACTS_PLOG_TYPE_MMS_INCOMING << " AND " SOCIAL_PHONE_LOG_TYPE " <= " << CONTACTS_PLOG_TYPE_MMS_BLOCKED; break; default: diff --git a/src/statistics/social/log_aggregator.cpp b/src/statistics/social/log_aggregator.cpp index c04e918..2c4af98 100644 --- a/src/statistics/social/log_aggregator.cpp +++ b/src/statistics/social/log_aggregator.cpp @@ -91,7 +91,7 @@ void ctx::contact_log_aggregator::get_updated_contact_log_list(int last_time, co err = contacts_filter_create(_contacts_phone_log._uri, &filter); IF_FAIL_CATCH_TAG(err == CONTACTS_ERROR_NONE, _E, "contacts_filter_create() failed"); - contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING); + contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMING); contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); contacts_filter_add_int(filter, _contacts_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_MMS_BLOCKED); contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND); -- 2.7.4 From f6fb4ad66985a09ba74823be776b80d1a750b9fe Mon Sep 17 00:00:00 2001 From: Marcin Masternak Date: Tue, 2 Feb 2016 11:36:50 +0100 Subject: [PATCH 06/16] [prediction] #ifndef ___H_ convention apply. Change-Id: I55a3ad34b6b239ae1b759211e9db51e8e8b28656 Signed-off-by: Marcin Masternak --- src/statistics/prediction/assoc_rule.h | 6 +++--- src/statistics/prediction/assoc_rule_miner.h | 6 +++--- src/statistics/prediction/assoc_rule_of_ids.h | 6 +++--- src/statistics/prediction/assoc_rule_producer.h | 6 +++--- src/statistics/prediction/basket.h | 6 +++--- src/statistics/prediction/basket_compressor.h | 6 +++--- src/statistics/prediction/basket_filter.h | 6 +++--- src/statistics/prediction/basket_producer.h | 6 +++--- src/statistics/prediction/baskets_agregator.h | 6 +++--- src/statistics/prediction/event.h | 6 +++--- src/statistics/prediction/event_set.h | 6 +++--- src/statistics/prediction/i_item_id_filter.h | 6 +++--- src/statistics/prediction/interval.h | 6 +++--- src/statistics/prediction/item.h | 6 +++--- src/statistics/prediction/item_catalogue.h | 6 +++--- src/statistics/prediction/item_id_set.h | 6 +++--- src/statistics/prediction/item_set.h | 6 +++--- src/statistics/prediction/item_string_converter.h | 6 +++--- src/statistics/prediction/single_category_item_id_filter.h | 6 +++--- src/statistics/prediction/weight_apriori.h | 6 +++--- 20 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/statistics/prediction/assoc_rule.h b/src/statistics/prediction/assoc_rule.h index 252684e..20d195d 100644 --- a/src/statistics/prediction/assoc_rule.h +++ b/src/statistics/prediction/assoc_rule.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_ASSOC_RULE_H_ -#define INCLUDE_ASSOC_RULE_H_ +#ifndef _PREDICTION_ASSOC_RULE_H_ +#define _PREDICTION_ASSOC_RULE_H_ #include "item_set.h" #include @@ -44,4 +44,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_ASSOC_RULE_H_ */ +#endif /* _PREDICTION_ASSOC_RULE_H_ */ diff --git a/src/statistics/prediction/assoc_rule_miner.h b/src/statistics/prediction/assoc_rule_miner.h index 6d57e3f..a9c9e97 100644 --- a/src/statistics/prediction/assoc_rule_miner.h +++ b/src/statistics/prediction/assoc_rule_miner.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ASSOC_RULE_MINER_H_ -#define ASSOC_RULE_MINER_H_ +#ifndef _PREDICTION_ASSOC_RULE_MINER_H_ +#define _PREDICTION_ASSOC_RULE_MINER_H_ #include #include @@ -49,4 +49,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* ASSOC_RULE_MINER_H_ */ +#endif /* _PREDICTION_ASSOC_RULE_MINER_H_ */ diff --git a/src/statistics/prediction/assoc_rule_of_ids.h b/src/statistics/prediction/assoc_rule_of_ids.h index b7dea9a..9597a55 100644 --- a/src/statistics/prediction/assoc_rule_of_ids.h +++ b/src/statistics/prediction/assoc_rule_of_ids.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ASSOC_RULE_OF_IDS_H_ -#define ASSOC_RULE_OF_IDS_H_ +#ifndef _PREDICTION_ASSOC_RULE_OF_IDS_H_ +#define _PREDICTION_ASSOC_RULE_OF_IDS_H_ #include "item_id_set.h" @@ -41,4 +41,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* ASSOC_RULE_OF_IDS_H_ */ +#endif /* _PREDICTION_ASSOC_RULE_OF_IDS_H_ */ diff --git a/src/statistics/prediction/assoc_rule_producer.h b/src/statistics/prediction/assoc_rule_producer.h index 03eaecf..2b02b79 100644 --- a/src/statistics/prediction/assoc_rule_producer.h +++ b/src/statistics/prediction/assoc_rule_producer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ASSOC_RULE_PRODUCER_H_ -#define ASSOC_RULE_PRODUCER_H_ +#ifndef _PREDICTION_ASSOC_RULE_PRODUCER_H_ +#define _PREDICTION_ASSOC_RULE_PRODUCER_H_ #include "assoc_rule_of_ids.h" #include "basket.h" @@ -41,4 +41,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* ASSOC_RULE_PRODUCER_H_ */ +#endif /* _PREDICTION_ASSOC_RULE_PRODUCER_H_ */ diff --git a/src/statistics/prediction/basket.h b/src/statistics/prediction/basket.h index 2b40eb6..1adb851 100644 --- a/src/statistics/prediction/basket.h +++ b/src/statistics/prediction/basket.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_BASKET_H_ -#define INCLUDE_BASKET_H_ +#ifndef _PREDICTION_BASKET_H_ +#define _PREDICTION_BASKET_H_ #include "item_id_set.h" #include @@ -45,4 +45,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_BASKET_H_ */ +#endif /* _PREDICTION_BASKET_H_ */ diff --git a/src/statistics/prediction/basket_compressor.h b/src/statistics/prediction/basket_compressor.h index a0f5a95..776f074 100644 --- a/src/statistics/prediction/basket_compressor.h +++ b/src/statistics/prediction/basket_compressor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASKET_COMPRESSOR_H_ -#define BASKET_COMPRESSOR_H_ +#ifndef _PREDICTION_BASKET_COMPRESSOR_H_ +#define _PREDICTION_BASKET_COMPRESSOR_H_ #include #include @@ -35,4 +35,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* BASKET_COMPRESSOR_H_ */ +#endif /* _PREDICTION_BASKET_COMPRESSOR_H_ */ diff --git a/src/statistics/prediction/basket_filter.h b/src/statistics/prediction/basket_filter.h index 18a03fd..6f8a114 100644 --- a/src/statistics/prediction/basket_filter.h +++ b/src/statistics/prediction/basket_filter.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASKET_FILTER_H_ -#define BASKET_FILTER_H_ +#ifndef _PREDICTION_BASKET_FILTER_H_ +#define _PREDICTION_BASKET_FILTER_H_ #include "basket.h" #include "i_item_id_filter.h" @@ -35,4 +35,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* BASKET_FILTER_H_ */ +#endif /* _PREDICTION_BASKET_FILTER_H_ */ diff --git a/src/statistics/prediction/basket_producer.h b/src/statistics/prediction/basket_producer.h index c265d94..f2c9757 100644 --- a/src/statistics/prediction/basket_producer.h +++ b/src/statistics/prediction/basket_producer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_BASKET_PRODUCER_H_ -#define INCLUDE_BASKET_PRODUCER_H_ +#ifndef _PREDICTION_BASKET_PRODUCER_H_ +#define _PREDICTION_BASKET_PRODUCER_H_ #include "event.h" #include "basket.h" @@ -47,4 +47,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_BASKET_PRODUCER_H_ */ +#endif /* _PREDICTION_BASKET_PRODUCER_H_ */ diff --git a/src/statistics/prediction/baskets_agregator.h b/src/statistics/prediction/baskets_agregator.h index e3093fe..5ce18c0 100644 --- a/src/statistics/prediction/baskets_agregator.h +++ b/src/statistics/prediction/baskets_agregator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_BASKETS_AGREGATOR_H_ -#define INCLUDE_BASKETS_AGREGATOR_H_ +#ifndef _PREDICTION_BASKETS_AGREGATOR_H_ +#define _PREDICTION_BASKETS_AGREGATOR_H_ #include #include @@ -38,4 +38,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_BASKETS_AGREGATOR_H_ */ +#endif /* _PREDICTION_BASKETS_AGREGATOR_H_ */ diff --git a/src/statistics/prediction/event.h b/src/statistics/prediction/event.h index 029296f..99048e4 100644 --- a/src/statistics/prediction/event.h +++ b/src/statistics/prediction/event.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_EVENT_H_ -#define INCLUDE_EVENT_H_ +#ifndef _PREDICTION_EVENT_H_ +#define _PREDICTION_EVENT_H_ #include "item.h" #include "interval.h" @@ -38,4 +38,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_EVENT_H_ */ +#endif /* _PREDICTION_EVENT_H_ */ diff --git a/src/statistics/prediction/event_set.h b/src/statistics/prediction/event_set.h index dda0bc2..e097ece 100644 --- a/src/statistics/prediction/event_set.h +++ b/src/statistics/prediction/event_set.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_EVENT_SET_H_ -#define INCLUDE_EVENT_SET_H_ +#ifndef _PREDICTION_EVENT_SET_H_ +#define _PREDICTION_EVENT_SET_H_ #include "event.h" @@ -25,4 +25,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_EVENT_SET_H_ */ +#endif /* _PREDICTION_EVENT_SET_H_ */ diff --git a/src/statistics/prediction/i_item_id_filter.h b/src/statistics/prediction/i_item_id_filter.h index dd4c386..1a8ac45 100644 --- a/src/statistics/prediction/i_item_id_filter.h +++ b/src/statistics/prediction/i_item_id_filter.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef I_ITEM_ID_FILTER_H_ -#define I_ITEM_ID_FILTER_H_ +#ifndef _PREDICTION_I_ITEM_ID_FILTER_H_ +#define _PREDICTION_I_ITEM_ID_FILTER_H_ namespace ctx { @@ -29,4 +29,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* I_ITEM_ID_FILTER_H_ */ +#endif /* _PREDICTION_I_ITEM_ID_FILTER_H_ */ diff --git a/src/statistics/prediction/interval.h b/src/statistics/prediction/interval.h index 2153aa0..3576da1 100644 --- a/src/statistics/prediction/interval.h +++ b/src/statistics/prediction/interval.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_INTERVAL_H_ -#define INCLUDE_INTERVAL_H_ +#ifndef _PREDICTION_INTERVAL_H_ +#define _PREDICTION_INTERVAL_H_ #include @@ -33,4 +33,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_INTERVAL_H_ */ +#endif /* _PREDICTION_INTERVAL_H_ */ diff --git a/src/statistics/prediction/item.h b/src/statistics/prediction/item.h index edf7d28..0e933ce 100644 --- a/src/statistics/prediction/item.h +++ b/src/statistics/prediction/item.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_ITEM_H_ -#define INCLUDE_ITEM_H_ +#ifndef _PREDICTION_ITEM_H_ +#define _PREDICTION_ITEM_H_ #include #include @@ -48,4 +48,4 @@ namespace std { } -#endif /* INCLUDE_ITEM_H_ */ +#endif /* _PREDICTION_ITEM_H_ */ diff --git a/src/statistics/prediction/item_catalogue.h b/src/statistics/prediction/item_catalogue.h index 96b5279..404765b 100644 --- a/src/statistics/prediction/item_catalogue.h +++ b/src/statistics/prediction/item_catalogue.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_ITEMCATALOGUE_H_ -#define INCLUDE_ITEMCATALOGUE_H_ +#ifndef _PREDICTION_ITEM_CATALOGUE_H_ +#define _PREDICTION_ITEM_CATALOGUE_H_ #include "item.h" #include @@ -57,4 +57,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_ITEMCATALOGUE_H_ */ +#endif /* _PREDICTION_ITEM_CATALOGUE_H_ */ diff --git a/src/statistics/prediction/item_id_set.h b/src/statistics/prediction/item_id_set.h index 0604fed..ce18f71 100644 --- a/src/statistics/prediction/item_id_set.h +++ b/src/statistics/prediction/item_id_set.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_ITEM_ID_SET_H_ -#define INCLUDE_ITEM_ID_SET_H_ +#ifndef _PREDICTION_ITEM_ID_SET_H_ +#define _PREDICTION_ITEM_ID_SET_H_ #include @@ -26,4 +26,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_ITEM_ID_SET_H_ */ +#endif /* _PREDICTION_ITEM_ID_SET_H_ */ diff --git a/src/statistics/prediction/item_set.h b/src/statistics/prediction/item_set.h index 98a1b6d..f13c8bc 100644 --- a/src/statistics/prediction/item_set.h +++ b/src/statistics/prediction/item_set.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_ITEM_SET_H_ -#define INCLUDE_ITEM_SET_H_ +#ifndef _PREDICTION_ITEM_SET_H_ +#define _PREDICTION_ITEM_SET_H_ #include #include "item.h" @@ -31,4 +31,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_ITEM_SET_H_ */ +#endif /* _PREDICTION_ITEM_SET_H_ */ diff --git a/src/statistics/prediction/item_string_converter.h b/src/statistics/prediction/item_string_converter.h index 961c1f3..15de8b2 100644 --- a/src/statistics/prediction/item_string_converter.h +++ b/src/statistics/prediction/item_string_converter.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_ITEMSTRINGCONVERTER_H_ -#define INCLUDE_ITEMSTRINGCONVERTER_H_ +#ifndef _PREDICTION_ITEM_STRING_CONVERTER_H_ +#define _PREDICTION_ITEM_STRING_CONVERTER_H_ #include "item.h" @@ -32,4 +32,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_ITEMSTRINGCONVERTER_H_ */ +#endif /* _PREDICTION_ITEM_STRING_CONVERTER_H_ */ diff --git a/src/statistics/prediction/single_category_item_id_filter.h b/src/statistics/prediction/single_category_item_id_filter.h index 4ef9cf4..4cc7dd6 100644 --- a/src/statistics/prediction/single_category_item_id_filter.h +++ b/src/statistics/prediction/single_category_item_id_filter.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef SINGLE_CATEGORY_ITEM_ID_FILTER_H_ -#define SINGLE_CATEGORY_ITEM_ID_FILTER_H_ +#ifndef _PREDICTION_SINGLE_CATEGORY_ITEM_ID_FILTER_H_ +#define _PREDICTION_SINGLE_CATEGORY_ITEM_ID_FILTER_H_ #include "i_item_id_filter.h" #include "item_catalogue.h" @@ -35,4 +35,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* SINGLE_CATEGORY_ITEM_ID_FILTER_H_ */ +#endif /* _PREDICTION_SINGLE_CATEGORY_ITEM_ID_FILTER_H_ */ diff --git a/src/statistics/prediction/weight_apriori.h b/src/statistics/prediction/weight_apriori.h index 94aecf2..6cb493d 100644 --- a/src/statistics/prediction/weight_apriori.h +++ b/src/statistics/prediction/weight_apriori.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef INCLUDE_WEIGHT_APRIORI_H_ -#define INCLUDE_WEIGHT_APRIORI_H_ +#ifndef _PREDICTION_WEIGHT_APRIORI_H_ +#define _PREDICTION_WEIGHT_APRIORI_H_ #include "baskets_agregator.h" #include @@ -41,4 +41,4 @@ namespace ctx { } /* namespace ctx */ -#endif /* INCLUDE_WEIGHT_APRIORI_H_ */ +#endif /* _PREDICTION_WEIGHT_APRIORI_H_ */ -- 2.7.4 From 01eafd135678725fc089a8020d9f81c534f539ed Mon Sep 17 00:00:00 2001 From: Marcin Masternak Date: Tue, 2 Feb 2016 11:41:54 +0100 Subject: [PATCH 07/16] [prediction] for brackets {} convention apply. Change-Id: I0f29bfabf91155c1d2bed493f9886e9074c2fc3e Signed-off-by: Marcin Masternak --- src/statistics/prediction/item_set.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/statistics/prediction/item_set.cpp b/src/statistics/prediction/item_set.cpp index c8dc55b..dccee66 100644 --- a/src/statistics/prediction/item_set.cpp +++ b/src/statistics/prediction/item_set.cpp @@ -33,8 +33,9 @@ std::ostream& ctx::operator<<(std::ostream& out, const ctx::ItemSet& itemSet) bool ctx::itemset_includes_in(const ctx::ItemSet& small, const ctx::ItemSet& big) { - for (const Item& s : small) + for (const Item& s : small) { if (std::find(big.begin(), big.end(), s) == big.end()) return false; + } return true; } -- 2.7.4 From 09a95804c83404b6df0f4f4fee1bb1abe9f05e1c Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 2 Feb 2016 20:58:27 +0900 Subject: [PATCH 08/16] statistics: modify foregroun app monitor to run in two-phases Creating a log record when an app goes to foreground, and update the duration attribute of the record when another app goes to foreground. Change-Id: I68f336d78b24e86056d4bfa68c753d831d0ba14d Signed-off-by: Mu-Woong Lee --- src/statistics/app/active_window_monitor.cpp | 131 +++++++++++---------------- src/statistics/app/active_window_monitor.h | 12 +-- 2 files changed, 59 insertions(+), 84 deletions(-) diff --git a/src/statistics/app/active_window_monitor.cpp b/src/statistics/app/active_window_monitor.cpp index 6299508..ee7ea66 100644 --- a/src/statistics/app/active_window_monitor.cpp +++ b/src/statistics/app/active_window_monitor.cpp @@ -28,14 +28,11 @@ /* Active window changes frequently. * We thus consider the apps being foregrounded at least 3 secs */ -#define MIN_VALID_USE_TIME 2 #define ONE_DAY_IN_SEC 86400 ctx::app_use_monitor::app_use_monitor() : signal_id(-1) , last_cleanup_time(0) - , last_timestamp(0) - , last_pid(-1) { start_logging(); } @@ -70,102 +67,84 @@ void ctx::app_use_monitor::on_signal_received(const char* sender, const char* pa const gchar *type = NULL; g_variant_get(param, "(i&s&s&s&s)", &pid, &appid, &pkgid, &status, &type); - IF_FAIL_VOID(appid && status && type); - IF_FAIL_VOID(STR_EQ(status, "fg") && STR_EQ(type, "uiapp")); - - on_active_window_changed(appid); -} - -void ctx::app_use_monitor::on_active_window_changed(std::string app_id) -{ - IF_FAIL_VOID(last_app_id != app_id); - _D("New fourground app '%s'", app_id.c_str()); - - int timestamp = static_cast(time(NULL)); - int duration = timestamp - last_timestamp; - - if (!last_app_id.empty() && duration >= MIN_VALID_USE_TIME) - verify_used_app(last_app_id.c_str(), duration); - - last_timestamp = timestamp; - last_app_id = app_id; -} + _D("AppEvent: %s, %s, %s", appid, status, type); -void ctx::app_use_monitor::verify_used_app(const char *app_id, int duration) -{ - app_info_h app_info = NULL; - int err = app_manager_get_app_info(app_id, &app_info); - IF_FAIL_VOID_TAG(err == APP_MANAGER_ERROR_NONE && app_info, _E, "app_manager_get_app_info() failed"); - - bool nodisp = false; - err = app_info_is_nodisplay(app_info, &nodisp); - IF_FAIL_CATCH_TAG(err == APP_MANAGER_ERROR_NONE, _E, "app_info_is_nodisplay() failed"); - IF_FAIL_CATCH(!nodisp); - - insert_log(app_id, duration); + IF_FAIL_VOID(appid && status && type); + IF_FAIL_VOID(STR_EQ(type, "uiapp") && !is_skippable(appid)); -CATCH: - if (app_info) - app_info_destroy(app_info); + if (STR_EQ(status, "fg")) { + create_record(appid); + } else if (STR_EQ(status, "bg")) { + finish_record(appid); + remove_expired(); + } } -void ctx::app_use_monitor::insert_log(const char *app_id, int duration) +void ctx::app_use_monitor::create_record(std::string app_id) { int audiojack; int system_volume; int media_volume; std::string bssid; + json data; + data.set(NULL, STATS_APP_ID, app_id); - std::stringstream cols; - std::stringstream vals; - - /* App ID */ - cols << STATS_APP_ID << ","; - vals << "'" << app_id << "',"; + if (ctx::system_info::get_audio_jack_state(&audiojack)) + data.set(NULL, STATS_AUDIO_JACK, audiojack); - /* Audio Jack */ - if (ctx::system_info::get_audio_jack_state(&audiojack)) { - cols << STATS_AUDIO_JACK << ","; - vals << audiojack << ","; - } - - /* Volume */ if (ctx::system_info::get_volume(&system_volume, &media_volume)) { - cols << STATS_SYSTEM_VOLUME << "," << STATS_MEDIA_VOLUME << ","; - vals << system_volume << "," << media_volume << ","; + data.set(NULL, STATS_SYSTEM_VOLUME, system_volume); + data.set(NULL, STATS_MEDIA_VOLUME, media_volume); } - /* BSSID */ - if (ctx::system_info::get_wifi_bssid(bssid)) { - cols << STATS_BSSID << ","; - vals << "'" << bssid << "',"; - } + if (ctx::system_info::get_wifi_bssid(bssid)) + data.set(NULL, STATS_BSSID, bssid); - /* Time */ - cols << STATS_UNIV_TIME << ","; - vals << "(strftime('%s', 'now')) - " << duration << ","; + db_manager::insert(0, APP_TABLE_USAGE_LOG, data, NULL); +} - cols << STATS_LOCAL_TIME << ","; - vals << "(strftime('%s', 'now', 'localtime')) - " << duration << ","; +void ctx::app_use_monitor::finish_record(std::string app_id) +{ + /* TODO: It might be necessary to update system status here */ + std::stringstream query; + query << + "UPDATE " APP_TABLE_USAGE_LOG \ + " SET " STATS_DURATION " = strftime('%s', 'now') - " STATS_UNIV_TIME \ + " WHERE " STATS_COL_ROW_ID " = (" \ + "SELECT MAX(" STATS_COL_ROW_ID ") FROM " APP_TABLE_USAGE_LOG \ + " WHERE " STATS_APP_ID " = '" << app_id << "'" \ + " AND " STATS_DURATION " = 0)"; + db_manager::execute(0, query.str().c_str(), NULL); +} - /* Duration */ - cols << STATS_DURATION; - vals << duration; +bool ctx::app_use_monitor::is_skippable(std::string app_id) +{ + /* TODO: circular cache */ + app_info_h app_info = NULL; + int err = app_manager_get_app_info(app_id.c_str(), &app_info); + IF_FAIL_RETURN_TAG(err == APP_MANAGER_ERROR_NONE && app_info, true, _E, "app_manager_get_app_info() failed"); - std::stringstream query; - append_cleanup_query(query); - query << "INSERT INTO " << APP_TABLE_USAGE_LOG << " (" - << cols.str() << ") VALUES (" << vals.str() << ")"; + bool nodisp = false; + err = app_info_is_nodisplay(app_info, &nodisp); + if (err != APP_MANAGER_ERROR_NONE) { + app_info_destroy(app_info); + _E("app_info_is_nodisplay() failed"); + return true; + } - db_manager::execute(0, query.str().c_str(), NULL); + app_info_destroy(app_info); + return nodisp; } -void ctx::app_use_monitor::append_cleanup_query(std::stringstream &query) +void ctx::app_use_monitor::remove_expired() { - IF_FAIL_VOID(last_timestamp - last_cleanup_time >= ONE_DAY_IN_SEC); + int timestamp = static_cast(time(NULL)); + IF_FAIL_VOID(timestamp - last_cleanup_time >= ONE_DAY_IN_SEC); - last_cleanup_time = last_timestamp; + last_cleanup_time = timestamp; + std::stringstream query; query << "DELETE FROM " APP_TABLE_USAGE_LOG " WHERE " \ - STATS_UNIV_TIME " < strftime('%s', 'now') - " << LOG_RETENTION_PERIOD << ";"; + STATS_UNIV_TIME " < strftime('%s', 'now') - " << LOG_RETENTION_PERIOD; + db_manager::execute(0, query.str().c_str(), NULL); } diff --git a/src/statistics/app/active_window_monitor.h b/src/statistics/app/active_window_monitor.h index 685d41c..c20f6aa 100644 --- a/src/statistics/app/active_window_monitor.h +++ b/src/statistics/app/active_window_monitor.h @@ -27,18 +27,14 @@ namespace ctx { private: int64_t signal_id; int last_cleanup_time; - int last_timestamp; - int last_pid; - std::string last_app_id; bool start_logging(void); void stop_logging(void); - void verify_used_app(const char *app_id, int duration); - void insert_log(const char *app_id, int duration); - void append_cleanup_query(std::stringstream &query); - - void on_active_window_changed(std::string app_id); + bool is_skippable(std::string app_id); + void create_record(std::string app_id); + void finish_record(std::string app_id); + void remove_expired(); void on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param); public: -- 2.7.4 From ffeaef0a9894b1d1be118ba74af3c47b86f7208a Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Wed, 3 Feb 2016 15:45:01 +0900 Subject: [PATCH 09/16] Version 0.7.1 Change-Id: I18f4ded1af595174c779d163eda7644873aee499 Signed-off-by: Mu-Woong Lee --- packaging/context-provider.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/context-provider.spec b/packaging/context-provider.spec index a42991d..ce27f64 100644 --- a/packaging/context-provider.spec +++ b/packaging/context-provider.spec @@ -1,6 +1,6 @@ Name: context-provider Summary: Context Provider -Version: 0.7.0 +Version: 0.7.1 Release: 1 Group: Service/Context License: Apache-2.0 -- 2.7.4 From c58ccaeea61e8e11c9b289c183d3b27ed64d4862 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Fri, 5 Feb 2016 14:42:49 +0900 Subject: [PATCH 10/16] Replace dbus_server with DBusSignalWatcher Change-Id: I39d5490d8899fe8311ff36aa63b75e927bb7d6f8 Signed-off-by: Mu-Woong Lee --- src/device/social/email.cpp | 8 ++++---- src/device/social/email.h | 7 ++++--- src/statistics/app/active_window_monitor.cpp | 9 ++++----- src/statistics/app/active_window_monitor.h | 7 ++++--- src/statistics/app/app_stats_provider.cpp | 3 +-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/device/social/email.cpp b/src/device/social/email.cpp index c7c8ea5..90a4efb 100644 --- a/src/device/social/email.cpp +++ b/src/device/social/email.cpp @@ -19,13 +19,13 @@ #include #include "social_types.h" -#include #include "email.h" GENERATE_PROVIDER_COMMON_IMPL(social_status_email); ctx::social_status_email::social_status_email() : dbus_signal_id(-1) + , __dbusWatcher(DBusType::SESSION) { } @@ -47,7 +47,7 @@ void ctx::social_status_email::submit_trigger_item() NULL); } -void ctx::social_status_email::on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) +void ctx::social_status_email::onSignal(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) { gint sub_type = 0; gint gi1 = 0; @@ -75,7 +75,7 @@ void ctx::social_status_email::on_signal_received(const char* sender, const char int ctx::social_status_email::subscribe() { - dbus_signal_id = ctx::dbus_server::subscribe_session_signal(NULL, NULL, "User.Email.NetworkStatus", "email", this); + dbus_signal_id = __dbusWatcher.watch(NULL, NULL, "User.Email.NetworkStatus", "email", this); IF_FAIL_RETURN_TAG(dbus_signal_id >= 0, ERR_OPERATION_FAILED, _E, "Email dbus signal subscription failed"); return ERR_NONE; } @@ -83,6 +83,6 @@ int ctx::social_status_email::subscribe() int ctx::social_status_email::unsubscribe() { - ctx::dbus_server::unsubscribe_session_signal(dbus_signal_id); + __dbusWatcher.unwatch(dbus_signal_id); return ERR_NONE; } diff --git a/src/device/social/email.h b/src/device/social/email.h index cbfc671..930da24 100644 --- a/src/device/social/email.h +++ b/src/device/social/email.h @@ -17,24 +17,25 @@ #ifndef _CONTEXT_SOCIAL_STATUS_EMAIL_H_ #define _CONTEXT_SOCIAL_STATUS_EMAIL_H_ -#include +#include #include "../provider_base.h" namespace ctx { - class social_status_email : public device_provider_base, public dbus_listener_iface { + class social_status_email : public device_provider_base, public IDBusSignalListener { GENERATE_PROVIDER_COMMON_DECL(social_status_email); public: int subscribe(); int unsubscribe(); - void on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param); + void onSignal(const char *sender, const char *path, const char *iface, const char *name, GVariant *param); static bool is_supported(); static void submit_trigger_item(); private: int64_t dbus_signal_id; + DBusSignalWatcher __dbusWatcher; social_status_email(); ~social_status_email(); diff --git a/src/statistics/app/active_window_monitor.cpp b/src/statistics/app/active_window_monitor.cpp index ee7ea66..58b0d9f 100644 --- a/src/statistics/app/active_window_monitor.cpp +++ b/src/statistics/app/active_window_monitor.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include "app_stats_types.h" #include "active_window_monitor.h" @@ -33,6 +32,7 @@ ctx::app_use_monitor::app_use_monitor() : signal_id(-1) , last_cleanup_time(0) + , __dbusWatcher(DBusType::SYSTEM) { start_logging(); } @@ -44,8 +44,7 @@ ctx::app_use_monitor::~app_use_monitor() bool ctx::app_use_monitor::start_logging() { - signal_id = dbus_server::subscribe_system_signal(NULL, - "/Org/Tizen/Aul/AppStatus", "org.tizen.aul.AppStatus", "AppStatusChange", this); + signal_id = __dbusWatcher.watch(NULL, "/Org/Tizen/Aul/AppStatus", "org.tizen.aul.AppStatus", "AppStatusChange", this); _D("Active window monitoring started (%lld)", signal_id); return (signal_id > 0); } @@ -53,12 +52,12 @@ bool ctx::app_use_monitor::start_logging() void ctx::app_use_monitor::stop_logging() { if (signal_id > 0) { - dbus_server::unsubscribe_system_signal(signal_id); + __dbusWatcher.unwatch(signal_id); _D("Active window monitoring stopped"); } } -void ctx::app_use_monitor::on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) +void ctx::app_use_monitor::onSignal(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) { gint pid = 0; const gchar *appid = NULL; diff --git a/src/statistics/app/active_window_monitor.h b/src/statistics/app/active_window_monitor.h index c20f6aa..7b5e3a0 100644 --- a/src/statistics/app/active_window_monitor.h +++ b/src/statistics/app/active_window_monitor.h @@ -19,14 +19,15 @@ #include #include -#include +#include namespace ctx { - class app_use_monitor : public dbus_listener_iface { + class app_use_monitor : public IDBusSignalListener { private: int64_t signal_id; int last_cleanup_time; + DBusSignalWatcher __dbusWatcher; bool start_logging(void); void stop_logging(void); @@ -35,7 +36,7 @@ namespace ctx { void create_record(std::string app_id); void finish_record(std::string app_id); void remove_expired(); - void on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param); + void onSignal(const char *sender, const char *path, const char *iface, const char *name, GVariant *param); public: app_use_monitor(); diff --git a/src/statistics/app/app_stats_provider.cpp b/src/statistics/app/app_stats_provider.cpp index 7224592..06aa468 100644 --- a/src/statistics/app/app_stats_provider.cpp +++ b/src/statistics/app/app_stats_provider.cpp @@ -48,13 +48,12 @@ ctx::context_provider_iface *ctx::app_statistics_provider::create(void *data) __instance = new(std::nothrow) app_statistics_provider(); IF_FAIL_RETURN_TAG(__instance, NULL, _E, "Memory allocation failed"); - _I(BLUE("Created")); - if (!__instance->init()) { destroy(data); return NULL; } + _I(BLUE("Created")); return __instance; } -- 2.7.4 From 6c5b3661c5c7ed9fdf2bb02367fb540bde50afa1 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 11 Feb 2016 13:37:03 +0900 Subject: [PATCH 11/16] Cleanup compile warning flags Change-Id: I9a390c5e77a00b06f466b4b5c7115f2a5267e785 Signed-off-by: Mu-Woong Lee --- packaging/context-provider.spec | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packaging/context-provider.spec b/packaging/context-provider.spec index ce27f64..47a9dc4 100644 --- a/packaging/context-provider.spec +++ b/packaging/context-provider.spec @@ -60,19 +60,25 @@ Context Provider %build MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -export CFLAGS+=" -Wextra -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wswitch-default" -export CXXFLAGS+=" -Wextra -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wswitch-default -Wnon-virtual-dtor -Wno-c++0x-compat" +export CFLAGS+=" -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-parameter" +export CXXFLAGS+=" -Wextra -Wcast-align -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-parameter" -export CFLAGS+=" -Wno-unused-parameter -Wno-empty-body" -export CXXFLAGS+=" -Wno-unused-parameter -Wno-empty-body" -export CXXFLAGS+=" -std=c++0x" +export CFLAGS+=" -Wno-empty-body -fno-omit-frame-pointer -fno-optimize-sibling-calls" +export CXXFLAGS+=" -Wno-empty-body -fno-omit-frame-pointer -fno-optimize-sibling-calls" -export CFLAGS+=" -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict-overflow -fno-common" -export CXXFLAGS+=" -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict-overflow" +export CFLAGS+=" -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict-overflow" +export CXXFLAGS+=" -fno-strict-aliasing -fno-unroll-loops -fsigned-char -fstrict-overflow" -export CFLAGS+=" -DTIZEN_ENGINEER_MODE" -export CXXFLAGS+=" -DTIZEN_ENGINEER_MODE" -export FFLAGS+=" -DTIZEN_ENGINEER_MODE" +export CFLAGS+=" -fno-common" +export CXXFLAGS+=" -Wnon-virtual-dtor" +export CXXFLAGS+=" -std=c++11 -Wno-c++11-compat" + +#export CFLAGS+=" -Wcast-qual" +#export CXXFLAGS+=" -Wcast-qual" + +#export CFLAGS+=" -DTIZEN_ENGINEER_MODE" +#export CXXFLAGS+=" -DTIZEN_ENGINEER_MODE" +#export FFLAGS+=" -DTIZEN_ENGINEER_MODE" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DPROFILE=%{?BUILD_PROFILE} make %{?jobs:-j%jobs} -- 2.7.4 From a38c76113e70f5bcd5caadeaa36258647d480c07 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 11 Feb 2016 14:13:45 +0900 Subject: [PATCH 12/16] Version 0.7.2 Change-Id: Ic5653b442c06edc7429c1291c52633f7b7023d90 Signed-off-by: Mu-Woong Lee --- packaging/context-provider.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/context-provider.spec b/packaging/context-provider.spec index 47a9dc4..9924dd9 100644 --- a/packaging/context-provider.spec +++ b/packaging/context-provider.spec @@ -1,6 +1,6 @@ Name: context-provider Summary: Context Provider -Version: 0.7.1 +Version: 0.7.2 Release: 1 Group: Service/Context License: Apache-2.0 -- 2.7.4 From 321a108431b75746e2e06498e8959b81ff82dfd5 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Mon, 15 Feb 2016 15:29:45 +0900 Subject: [PATCH 13/16] Remove mutexing from device_status_alarm Change-Id: Ic27042b77ada3ce4f7696afd92f87897f384cbfe Signed-off-by: Mu-Woong Lee --- src/device/system/alarm.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/device/system/alarm.cpp b/src/device/system/alarm.cpp index 2a7ebd6..0b75fb5 100644 --- a/src/device/system/alarm.cpp +++ b/src/device/system/alarm.cpp @@ -15,14 +15,11 @@ */ #include -#include #include #include #include "system_types.h" #include "alarm.h" -static GMutex timer_mutex; - GENERATE_PROVIDER_COMMON_IMPL(device_status_alarm); ctx::device_status_alarm::device_status_alarm() @@ -156,8 +153,6 @@ bool ctx::device_status_alarm::add(int minute, int day_of_week) day_of_week > 0 && day_of_week <= timer_types::EVERYDAY, false, _E, "Invalid parameter"); - ctx::scope_mutex sm(&timer_mutex); - ref_count_array_s &ref = ref_count_map[minute]; for (int d = 0; d < MAX_DAY; ++d) { @@ -175,8 +170,6 @@ bool ctx::device_status_alarm::remove(int minute, int day_of_week) day_of_week > 0 && day_of_week <= timer_types::EVERYDAY, false, _E, "Invalid parameter"); - ctx::scope_mutex sm(&timer_mutex); - ref_count_array_s &ref = ref_count_map[minute]; for (int d = 0; d < MAX_DAY; ++d) { @@ -227,8 +220,6 @@ bool ctx::device_status_alarm::reset_timer(int minute) void ctx::device_status_alarm::clear() { - ctx::scope_mutex sm(&timer_mutex); - for (timer_state_map_t::iterator it = timer_state_map.begin(); it != timer_state_map.end(); ++it) { if (it->second.timer_id > 0) { timer_manager::remove(it->second.timer_id); -- 2.7.4 From cb73638e58ab69a39c73ae2798da7396d60ff2a7 Mon Sep 17 00:00:00 2001 From: Somin Kim Date: Thu, 21 Jan 2016 13:58:06 +0900 Subject: [PATCH 14/16] Added custom provider Change-Id: I4fee414b0d952b02e0256bf71f6e4a7c05593167 Signed-off-by: Somin Kim --- include/custom_context_provider.h | 33 ++++++ src/CMakeLists.txt | 1 + src/custom/CMakeLists.txt | 25 +++++ src/custom/custom_base.cpp | 91 +++++++++++++++++ src/custom/custom_base.h | 55 ++++++++++ src/custom/custom_context_provider.cpp | 180 +++++++++++++++++++++++++++++++++ 6 files changed, 385 insertions(+) create mode 100644 include/custom_context_provider.h create mode 100644 src/custom/CMakeLists.txt create mode 100644 src/custom/custom_base.cpp create mode 100644 src/custom/custom_base.h create mode 100644 src/custom/custom_context_provider.cpp diff --git a/include/custom_context_provider.h b/include/custom_context_provider.h new file mode 100644 index 0000000..584cf3b --- /dev/null +++ b/include/custom_context_provider.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef __CONTEXT_CUSTOM_CONTEXT_PROVIDER_H__ +#define __CONTEXT_CUSTOM_CONTEXT_PROVIDER_H__ + +namespace ctx { + bool init_custom_context_provider(); + + namespace custom_context_provider { + int add_item(std::string subject, std::string name, ctx::json tmpl, const char* owner); + int remove_item(std::string subject); + int publish_data(std::string subject, ctx::json fact); + + context_provider_iface* create(void* data); + void destroy(void* data); + } +} + +#endif //__CONTEXT_CUSTOM_CONTEXT_PROVIDER_H__ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ed81952..737a746 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,6 +11,7 @@ ENDFUNCTION(add_provider) add_provider(device) add_provider(statistics) add_provider(place) +add_provider(custom) SEPARATE_ARGUMENTS(deps_list) LIST(REMOVE_DUPLICATES deps_list) diff --git a/src/custom/CMakeLists.txt b/src/custom/CMakeLists.txt new file mode 100644 index 0000000..881c3a4 --- /dev/null +++ b/src/custom/CMakeLists.txt @@ -0,0 +1,25 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(target "ctx-custom") + +# Common Profile +FILE(GLOB srcs ./*.cpp) + +MESSAGE("Custom Provider Sources: ${srcs}") + +# Build +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(custom_pkgs REQUIRED ${deps_common}) + +FOREACH(flag ${custom_pkgs_CFLAGS}) + SET(extra_cflags "${extra_cflags} ${flag}") +ENDFOREACH(flag) + +ADD_LIBRARY(${target} SHARED ${srcs}) +TARGET_LINK_LIBRARIES(${target} ${custom_pkgs_LDFLAGS}) +SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_FLAGS ${extra_cflags}) +SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITIONS "LOG_TAG=\"CONTEXT-CUSTOM\"") +SET_TARGET_PROPERTIES(${target} PROPERTIES SOVERSION ${MAJORVER}) +SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${FULLVER}) + +# Install +INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries) diff --git a/src/custom/custom_base.cpp b/src/custom/custom_base.cpp new file mode 100644 index 0000000..59cbec9 --- /dev/null +++ b/src/custom/custom_base.cpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * 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 +#include "custom_base.h" + +ctx::custom_base::custom_base(std::string subject, std::string name, ctx::json tmpl, std::string owner) : + _subject(subject), + _name(name), + _tmpl(tmpl), + _owner(owner) +{ +} + +ctx::custom_base::~custom_base() +{ +} + +bool ctx::custom_base::is_supported() +{ + return true; +} + +void ctx::custom_base::submit_trigger_item() +{ + context_manager::register_trigger_item(_subject.c_str(), OPS_SUBSCRIBE | OPS_READ, + _tmpl.str(), NULL, _owner.c_str()); +} + +void ctx::custom_base::unsubmit_trigger_item() +{ + context_manager::unregister_trigger_item(_subject.c_str()); +} + +int ctx::custom_base::subscribe(const char *subject, ctx::json option, ctx::json *request_result) +{ + return ERR_NONE; + +} + +int ctx::custom_base::unsubscribe(const char *subject, ctx::json option) +{ + return ERR_NONE; +} + +int ctx::custom_base::read(const char *subject, ctx::json option, ctx::json *request_result) +{ + ctx::json data = latest.str(); + ctx::context_manager::reply_to_read(_subject.c_str(), NULL, ERR_NONE, data); + return ERR_NONE; +} + +int ctx::custom_base::write(const char *subject, ctx::json data, ctx::json *request_result) +{ + return ERR_NONE; +} + +void ctx::custom_base::handle_update(ctx::json data) +{ + // Store latest state + latest = data.str(); + ctx::context_manager::publish(_subject.c_str(), NULL, ERR_NONE, data); +} + +const char* ctx::custom_base::get_subject() +{ + return _subject.c_str(); +} + +std::string ctx::custom_base::get_owner() +{ + return _owner; +} + +ctx::json ctx::custom_base::get_template() +{ + return _tmpl; +} diff --git a/src/custom/custom_base.h b/src/custom/custom_base.h new file mode 100644 index 0000000..e2e8bce --- /dev/null +++ b/src/custom/custom_base.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#ifndef _CUSTOM_BASE_H_ +#define _CUSTOM_BASE_H_ + +#include +#include +#include + +namespace ctx { + + class custom_base : public context_provider_iface { + public: + custom_base(std::string subject, std::string name, ctx::json tmpl, std::string owner); + ~custom_base(); + + int subscribe(const char *subject, ctx::json option, ctx::json *request_result); + int unsubscribe(const char *subject, ctx::json option); + int read(const char *subject, ctx::json option, ctx::json *request_result); + int write(const char *subject, ctx::json data, ctx::json *request_result); + + static bool is_supported(); + void submit_trigger_item(); + void unsubmit_trigger_item(); + + void handle_update(ctx::json data); + + const char* get_subject(); + std::string get_owner(); + ctx::json get_template(); + + private: + std::string _subject; + std::string _name; + ctx::json _tmpl; + std::string _owner; + ctx::json latest; + }; +} + +#endif // _CUSTOM_BASE_H_ diff --git a/src/custom/custom_context_provider.cpp b/src/custom/custom_context_provider.cpp new file mode 100644 index 0000000..923fa1a --- /dev/null +++ b/src/custom/custom_context_provider.cpp @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * + * 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 +#include +#include +#include +#include +#include "custom_base.h" + +std::map custom_map; + +static bool is_valid_fact(std::string subject, ctx::json& fact); +static bool check_value_int(ctx::json& tmpl, std::string key, int value); +static bool check_value_string(ctx::json& tmpl, std::string key, std::string value); + +void register_provider(const char *subject, const char *privilege) +{ + ctx::context_provider_info provider_info(ctx::custom_context_provider::create, + ctx::custom_context_provider::destroy, + const_cast(subject), privilege); + ctx::context_manager::register_provider(subject, provider_info); + custom_map[subject]->submit_trigger_item(); +} + +void unregister_provider(const char* subject) +{ + custom_map[subject]->unsubmit_trigger_item(); + ctx::context_manager::unregister_provider(subject); +} + +EXTAPI ctx::context_provider_iface* ctx::custom_context_provider::create(void *data) +{ + // Already created in add_item() function. Return corresponding custom provider + return custom_map[static_cast(data)]; +} + +EXTAPI void ctx::custom_context_provider::destroy(void *data) +{ + std::map::iterator it = custom_map.find(static_cast(data)); + if (it != custom_map.end()) { + delete it->second; + custom_map.erase(it); + } +} + +EXTAPI bool ctx::init_custom_context_provider() +{ + return true; +} + +EXTAPI int ctx::custom_context_provider::add_item(std::string subject, std::string name, ctx::json tmpl, const char* owner) +{ + std::map::iterator it; + it = custom_map.find(subject); + + if (it != custom_map.end()) { + if ((it->second)->get_template() != tmpl) { // Same item name, but different template + return ERR_DATA_EXIST; + } + // Same item name with same template + return ERR_NONE; + } + + // Create custom base + ctx::custom_base* custom = new(std::nothrow) custom_base(subject, name, tmpl, owner); + IF_FAIL_RETURN_TAG(custom, ERR_OUT_OF_MEMORY, _E, "Memory allocation failed"); + custom_map[subject] = custom; + + register_provider(custom->get_subject(), NULL); + + return ERR_NONE; +} + +EXTAPI int ctx::custom_context_provider::remove_item(std::string subject) +{ + std::map::iterator it; + it = custom_map.find(subject); + IF_FAIL_RETURN_TAG(it != custom_map.end(), ERR_NOT_SUPPORTED, _E, "%s not supported", subject.c_str()); + + unregister_provider(subject.c_str()); + + return ERR_NONE; +} + +EXTAPI int ctx::custom_context_provider::publish_data(std::string subject, ctx::json fact) +{ + std::map::iterator it; + it = custom_map.find(subject); + IF_FAIL_RETURN_TAG(it != custom_map.end(), ERR_NOT_SUPPORTED, _E, "%s not supported", subject.c_str()); + + bool ret = is_valid_fact(subject, fact); + IF_FAIL_RETURN_TAG(ret, ERR_INVALID_DATA, _E, "Invalid fact(%s)", subject.c_str()); + + custom_map[subject]->handle_update(fact); + return ERR_NONE; +} + +bool is_valid_fact(std::string subject, ctx::json& fact) +{ + ctx::json tmpl = custom_map[subject]->get_template(); + IF_FAIL_RETURN_TAG(tmpl != EMPTY_JSON_OBJECT, false, _E, "Failed to get template"); + + bool ret; + std::list keys; + fact.get_keys(&keys); + + for (std::list::iterator it = keys.begin(); it != keys.end(); it++) { + std::string key = *it; + + std::string type; + tmpl.get(key.c_str(), "type", &type); + if (type == "integer") { + int val; + ret = fact.get(NULL, key.c_str(), &val); + IF_FAIL_RETURN_TAG(ret, false, _E, "Custom fact: invalid data type"); + + ret = check_value_int(tmpl, key, val); + IF_FAIL_RETURN_TAG(ret, false, _E, "Custom fact: invalid value"); + } else if (type == "string") { + std::string val_str; + ret = fact.get(NULL, key.c_str(), &val_str); + IF_FAIL_RETURN_TAG(ret, false, _E, "Custom fact: invalid data type"); + + ret = check_value_string(tmpl, key, val_str); + IF_FAIL_RETURN_TAG(ret, false, _E, "Custom fact: invalid value"); + } else { + _E("Custom fact: invalid data type"); + return false; + } + } + + return true; +} + +bool check_value_int(ctx::json& tmpl, std::string key, int value) +{ + int min, max; + + if (tmpl.get(key.c_str(), "min", &min)) { + IF_FAIL_RETURN(value >= min, false); + } + + if (tmpl.get(key.c_str(), "max", &max)) { + IF_FAIL_RETURN(value <= max, false); + } + + return true; +} + +bool check_value_string(ctx::json& tmpl, std::string key, std::string value) +{ + // case1: any value is accepted + if (tmpl.array_get_size(key.c_str(), "values") <= 0) + return true; + + // case2: check acceptable value + std::string t_val; + for (int i = 0; tmpl.get_array_elem(key.c_str(), "values", i, &t_val); i++) { + if (t_val == value) + return true; + } + + return false; +} + + -- 2.7.4 From 9ce08713c4b8c36ee1a600bab22ae81431d9854c Mon Sep 17 00:00:00 2001 From: Somin Kim Date: Tue, 2 Feb 2016 13:47:51 +0900 Subject: [PATCH 15/16] Custom item recovery logic added when initialized (Uninstalled provider's item handling is still needed) Change-Id: I7e020b28174bbf2f868cd9c255fbe65dbcd1fbc2 Signed-off-by: Somin Kim --- include/custom_context_provider.h | 2 +- src/custom/custom_context_provider.cpp | 53 +++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/include/custom_context_provider.h b/include/custom_context_provider.h index 584cf3b..10e4275 100644 --- a/include/custom_context_provider.h +++ b/include/custom_context_provider.h @@ -21,7 +21,7 @@ namespace ctx { bool init_custom_context_provider(); namespace custom_context_provider { - int add_item(std::string subject, std::string name, ctx::json tmpl, const char* owner); + int add_item(std::string subject, std::string name, ctx::json tmpl, const char* owner, bool is_init = false); int remove_item(std::string subject); int publish_data(std::string subject, ctx::json fact); diff --git a/src/custom/custom_context_provider.cpp b/src/custom/custom_context_provider.cpp index 923fa1a..dd79fd5 100644 --- a/src/custom/custom_context_provider.cpp +++ b/src/custom/custom_context_provider.cpp @@ -15,9 +15,11 @@ */ #include +#include #include #include #include +#include #include #include "custom_base.h" @@ -59,10 +61,44 @@ EXTAPI void ctx::custom_context_provider::destroy(void *data) EXTAPI bool ctx::init_custom_context_provider() { + // Create custom template db + std::string q = std::string("CREATE TABLE IF NOT EXISTS context_trigger_custom_template ") + + "(subject TEXT DEFAULT '' NOT NULL PRIMARY KEY, name TEXT DEFAULT '' NOT NULL, operation INTEGER DEFAULT 3 NOT NULL, " + + "attributes TEXT DEFAULT '' NOT NULL, owner TEXT DEFAULT '' NOT NULL)"; + + std::vector record; + bool ret = db_manager::execute_sync(q.c_str(), &record); + IF_FAIL_RETURN_TAG(ret, false, _E, "Create template table failed"); + + // Register custom items + std::string q_select = "SELECT * FROM context_trigger_custom_template"; + ret = db_manager::execute_sync(q_select.c_str(), &record); + IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to query custom templates"); + IF_FAIL_RETURN(record.size() > 0, true); + + int error; + std::vector::iterator vec_end = record.end(); + for (std::vector::iterator vec_pos = record.begin(); vec_pos != vec_end; ++vec_pos) { + ctx::json elem = *vec_pos; + std::string subject; + std::string name; + std::string attributes; + std::string owner; + elem.get(NULL, "subject", &subject); + elem.get(NULL, "name", &name); + elem.get(NULL, "attributes", &attributes); + elem.get(NULL, "owner", &owner); + + error = ctx::custom_context_provider::add_item(subject, name, ctx::json(attributes), owner.c_str(), true); + if (error != ERR_NONE) { + _E("Failed to add custom item(%s): %#x", subject.c_str(), error); + } + } + return true; } -EXTAPI int ctx::custom_context_provider::add_item(std::string subject, std::string name, ctx::json tmpl, const char* owner) +EXTAPI int ctx::custom_context_provider::add_item(std::string subject, std::string name, ctx::json tmpl, const char* owner, bool is_init) { std::map::iterator it; it = custom_map.find(subject); @@ -82,6 +118,15 @@ EXTAPI int ctx::custom_context_provider::add_item(std::string subject, std::stri register_provider(custom->get_subject(), NULL); + // Add item to custom template db + if (!is_init) { + std::string q = "INSERT OR IGNORE INTO context_trigger_custom_template (subject, name, attributes, owner) VALUES ('" + + subject + "', '" + name + "', '" + tmpl.str() + "', '" + owner + "'); "; + std::vector record; + bool ret = db_manager::execute_sync(q.c_str(), &record); + IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to query custom templates"); + } + return ERR_NONE; } @@ -93,6 +138,12 @@ EXTAPI int ctx::custom_context_provider::remove_item(std::string subject) unregister_provider(subject.c_str()); + // Remove item from custom template db + std::string q = "DELETE FROM context_trigger_custom_template WHERE subject = '" + subject + "'"; + std::vector record; + bool ret = db_manager::execute_sync(q.c_str(), &record); + IF_FAIL_RETURN_TAG(ret, false, _E, "Failed to query custom templates"); + return ERR_NONE; } -- 2.7.4 From 548fce4ecf480762644b75f6c4cb861b5a2c7614 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Tue, 16 Feb 2016 21:41:41 +0900 Subject: [PATCH 16/16] Replace build dependency context-common with libcontext-shared & server Change-Id: I8bdcb6e90f29fa579cbc03f5b098a8a98037367d Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 2 +- packaging/context-provider.spec | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea5ae1a..af3b0b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ INCLUDE_DIRECTORIES( ADD_DEFINITIONS(-O2 -Wall -fPIC -fvisibility=hidden -Wl,--as-needed) # Common Dependency -SET(deps_common "context-common") +SET(deps_common "libcontext-shared libcontext-server") # Profiles IF("${PROFILE}" STREQUAL "mobile") diff --git a/packaging/context-provider.spec b/packaging/context-provider.spec index 9924dd9..2f9c5af 100644 --- a/packaging/context-provider.spec +++ b/packaging/context-provider.spec @@ -10,7 +10,8 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: cmake -BuildRequires: pkgconfig(context-common) +BuildRequires: pkgconfig(libcontext-shared) +BuildRequires: pkgconfig(libcontext-server) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(capi-system-device) -- 2.7.4