#define UAM_IP_ADDRESS_MAX_STRING_LEN 50
#define UAM_USER_NAME_MAX_STRING_LEN 254
#define UAM_USER_ACCOUNT_MAX_STRING_LEN 254
+#define UAM_APP_ID_MAX_STRING_LEN 100
#define FOREACH_EVENT(EVENT) \
EVENT(UAM_EVENT_USER_ADDED) \
int _uam_stop_search_active_devices(unsigned int bitmask);
+int _uam_register_app(const char *app_id, unsigned short uid);
+
+int _uam_deregister_app(const char *app_id, unsigned short uid);
+
typedef enum {
UAM_PRESENCE_STATE_INVALID = 0x00,
UAM_PRESENCE_STATE_PRESENT,
int retries;
} uam_detection_params_t;
+typedef struct {
+ char* sender;
+ unsigned short uid;
+ char app_id[UAM_APP_ID_MAX_STRING_LEN];
+} uam_app_info_t;
+
int _uam_get_registered_users(GPtrArray **user_list);
int _uam_is_device_registered(
REQUEST(UAM_REQUEST_SET_DETECTION_PARAMS) \
REQUEST(UAM_REQUEST_START_SEARCH_ACTIVE_DEVICES) \
REQUEST(UAM_REQUEST_STOP_SEARCH_ACTIVE_DEVICES) \
+ REQUEST(UAM_REQUEST_REGISTER_APP) \
+ REQUEST(UAM_REQUEST_DEREGISTER_APP) \
REQUEST(UAM_REQUEST_MAX)
#define GENERATE_REQUEST_ENUM(ENUM) ENUM,
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(json-c)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(aul)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
FUNC_EXIT;
return ret;
}
+
+UAM_EXPORT_API int _uam_register_app(const char *app_id, unsigned short uid)
+{
+ FUNC_ENTRY;
+ int ret;
+ uam_app_info_t app_info;
+
+ UAM_INIT_PARAMS();
+ UAM_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_strlcpy(app_info.app_id, app_id, UAM_APP_ID_MAX_STRING_LEN);
+ app_info.uid = uid;
+
+ g_array_append_vals(in_param1, &app_info, sizeof(uam_app_info_t));
+ ret = _uam_sync_request(UAM_REQUEST_REGISTER_APP,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ FUNC_EXIT;
+ return ret;
+}
+
+UAM_EXPORT_API int _uam_deregister_app(const char *app_id, unsigned short uid)
+{
+ FUNC_ENTRY;
+ int ret;
+ uam_app_info_t app_info;
+
+ UAM_INIT_PARAMS();
+ UAM_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ g_strlcpy(app_info.app_id, app_id, UAM_APP_ID_MAX_STRING_LEN);
+ app_info.uid = uid;
+
+ g_array_append_vals(in_param1, &app_info, sizeof(uam_app_info_t));
+ ret = _uam_sync_request(UAM_REQUEST_DEREGISTER_APP,
+ in_param1, in_param2, in_param3, in_param4, &out_param);
+
+ UAM_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+
+ FUNC_EXIT;
+ return ret;
+}
#include "ua-api.h"
#include "ua-internal.h"
-
#include "ua-common.h"
typedef struct {
libtzplatform-config
sqlite3
json-c
+ bundle
+ aul
)
INCLUDE(FindPkgConfig)
const char* _uam_get_sensor_str(unsigned int ids);
+int _uam_register_app_info(char* sender, uam_app_info_t app_info);
+
+int _uam_deregister_app_info(char* sender, uam_app_info_t app_info);
+
#ifdef __cplusplus
}
#endif
uam_active_scan_event_e _pm_util_uas_scan_event_to_uam_scan_event(uas_active_scan_event_e event)
{
switch (event) {
- case UAS_ACTIVE_DEVICE_FOUND :
+ case UAS_ACTIVE_DEVICE_FOUND:
return UAM_ACTIVE_DEVICE_FOUND;
- case UAS_ACTIVE_SCAN_COMPLETED :
+ case UAS_ACTIVE_SCAN_COMPLETED:
return UAM_ACTIVE_SCAN_COMPLETED;
default:
UAM_WARN("Unknown event 0x%8.8X", event);
uam_device_info_t *dev_info = NULL;
uam_active_scan_event_e event_info;
- if(UAS_ACTIVE_DEVICE_FOUND == event){
+ if (UAS_ACTIVE_DEVICE_FOUND == event) {
ret_if(NULL == device);
dev_info = _pm_util_uas_dev_info_to_uam_dev_info(device);
if (!scanner || !scanner->name)
continue;
- if (scanner->sensors & sensors){
+ if (scanner->sensors & sensors) {
ret = _uam_pm_stop_search_active_devices(sensors);
if (UAM_ERROR_NONE != ret) {
UAM_ERR("Failed with error: %s (0x%4.4X)",
_uam_manager_error_to_str(ret), ret);
return ret;
}
- scanners = g_slist_remove(scanners,scanner);
+ scanners = g_slist_remove(scanners, scanner);
g_free(scanner->name);
g_free(scanner);
}
if (!scanner || !scanner->name)
continue;
- if (scanner->sensors & sensor){
+ if (scanner->sensors & sensor) {
name = g_strdup(scanner->name);
- if(event == UAM_ACTIVE_SCAN_COMPLETED){
+ if (event == UAM_ACTIVE_SCAN_COMPLETED) {
scanner->sensors &= ~(sensor);
- if(scanner->sensors == 0){
+ if (scanner->sensors == 0) {
done = 1;
scanners = g_slist_remove(scanners, scanner);
g_free(scanner->name);
}
}
- if(event == UAM_ACTIVE_DEVICE_FOUND){
+ if (event == UAM_ACTIVE_DEVICE_FOUND) {
param = g_variant_new("(iiisss)",
UAM_ERROR_NONE,
dev_info->operating_system,
/* Send device event to application */
if (UAM_ERROR_NONE != _uam_manager_send_event(name, UAM_EVENT_DEVICE_FOUND, param))
UAM_ERR("Failed to send %s", _uam_manager_event_to_str(event));
- }
- else if(done == 1 && event == UAM_ACTIVE_SCAN_COMPLETED){
+ } else if (done == 1 && event == UAM_ACTIVE_SCAN_COMPLETED) {
UAM_INFO_C("Send %s to applications", _uam_manager_event_to_str(UAM_EVENT_SCAN_COMPLETED));
/* Send device event to application */
if (UAM_ERROR_NONE != _uam_manager_send_event(name, UAM_EVENT_SCAN_COMPLETED, param))
#include "ua-api.h"
#include "ua-internal.h"
-
#include "ua-manager-common.h"
+#include <aul.h>
+#include <aul_svc.h>
+#include <bundle_internal.h>
+
+GSList *apps; /* List of apps to launch - uam_app_info_t*/
+
+# define APP_CONTROL_DATA_PUSH_LAUNCH_TYPE "http://tizen.org/appcontrol/data/push/launch_type"
+# define EXTRA_DATA_FROM_REGISTRATION_CHANGE "registration_change"
+
+static void __uam_app_launcher(uam_app_info_t *app_info)
+{
+ FUNC_ENTRY;
+ int r = 0;
+
+ r = aul_app_get_status_for_uid((const char *)app_info->app_id, app_info->uid);
+ UAM_INFO("returned r: [%d] ", r);
+ if (r == -1) {
+ /* Send launch request to wake application */
+ UAM_INFO("[%s] will be launched for receiving registration change callback", (const char*)app_info->app_id);
+
+ bundle *bund = NULL;
+ bund = bundle_create();
+
+ bundle_add(bund, APP_CONTROL_DATA_PUSH_LAUNCH_TYPE, EXTRA_DATA_FROM_REGISTRATION_CHANGE);
+
+ int result;
+ result = aul_svc_set_background_launch(bund, TRUE);
+ if (result < AUL_R_OK)
+ UAM_ERR("ERROR : aul_svc_set_background_launch failed. app_id [%s] bundle[%p] result[%d : %s]", app_info->app_id, bund, result, get_error_message(result));
+
+ result = aul_launch_app_async_for_uid(app_info->app_id, bund, app_info->uid);
+ if (result < AUL_R_OK)
+ UAM_ERR("ERROR : aul_launch_app failed. app_id [%s] bundle[%p] result[%d : %s]", app_info->app_id, bund, result, get_error_message(result));
+
+ bundle_free(bund);
+ }
+ FUNC_EXIT;
+}
+
+static void __uam_resume_app(const char* dest)
+{
+ FUNC_ENTRY;
+ GSList *l;
+
+ UAM_INFO("dest: [%s] ", dest);
+ if (NULL == dest) {
+ for (l = apps; NULL != l; l = g_slist_next(l)) {
+ uam_app_info_t *app_info = l->data;
+ if (NULL == app_info)
+ continue;
+
+ UAM_INFO("app_id: [%s] ", (const char*)app_info->app_id);
+ UAM_INFO("uid: [%d] ", app_info->uid);
+ __uam_app_launcher(app_info);
+ }
+ } else {
+ for (l = apps; NULL != l; l = g_slist_next(l)) {
+ uam_app_info_t *app_info = l->data;
+ if (NULL == app_info)
+ continue;
+
+ UAM_INFO("app_id: [%s] ", (const char*)app_info->app_id);
+ UAM_INFO("uid: [%d] ", app_info->uid);
+ if (!g_strcmp0(app_info->sender, dest)) {
+ __uam_app_launcher(app_info);
+ break;
+ }
+ }
+ }
+
+ FUNC_EXIT;
+}
+
int _uam_manager_send_event(
const char* dest, int event, GVariant *param)
{
UAM_INFO_C("Destination: [%s], event: [%s], signal: [%s]",
dest, _uam_manager_event_to_str(event), signal);
+ /* Check if application requires resume before sending event */
+ __uam_resume_app(dest);
+
if (!g_dbus_connection_emit_signal(conn, dest, UAM_EVENT_PATH,
UAM_EVENT_INTERFACE, signal, param, &error)) {
UAM_ERR("Error while sending Signal: %s", signal);
FUNC_EXIT;
return UAM_ERROR_NONE;
}
+
+static uam_app_info_t *__uam_find_app(const char *name)
+{
+// FUNC_ENTRY;
+ GSList *l;
+
+ retv_if(NULL == name, NULL);
+
+ for (l = apps; NULL != l; l = g_slist_next(l)) {
+ uam_app_info_t *app_info = l->data;
+
+ if (!app_info || !app_info->sender)
+ continue;
+
+ if (0 == g_strcmp0(app_info->sender, name)) {
+ UAM_DBG("Monitoring application found in list");
+ return app_info;
+ }
+ }
+
+// FUNC_EXIT;
+ return NULL;
+}
+
+int _uam_register_app_info(char* sender, uam_app_info_t app_info)
+{
+ FUNC_ENTRY;
+
+ int ret;
+ uam_app_info_t *app;
+
+ app = __uam_find_app(sender);
+
+ if (app) {
+ ret = UAM_ERROR_ALREADY_DONE;
+ UAM_ERR("Failed with error: %s (0x%4.4X)",
+ _uam_manager_error_to_str(ret), ret);
+ return ret;
+ }
+
+ app = g_malloc0(sizeof(uam_app_info_t));
+ app->sender = g_strdup(sender);
+ g_strlcpy(app->app_id, app_info.app_id, UAM_APP_ID_MAX_STRING_LEN);
+ app->uid = app_info.uid;
+
+ apps = g_slist_append(apps, app);
+ ret = UAM_ERROR_NONE;
+
+ FUNC_EXIT;
+ return ret;
+}
+
+int _uam_deregister_app_info(char* sender, uam_app_info_t app_info)
+{
+ FUNC_ENTRY;
+
+ int ret;
+ uam_app_info_t *app;
+
+ app = __uam_find_app(sender);
+
+ if (!app) {
+ ret = UAM_ERROR_ALREADY_DONE;
+ UAM_ERR("Failed with error: %s (0x%4.4X)",
+ _uam_manager_error_to_str(ret), ret);
+ return ret;
+ }
+
+ UAM_DBG("Remove app from list");
+ apps = g_slist_remove(apps, app);
+ g_free(app->sender);
+ g_free(app);
+
+ ret = UAM_ERROR_NONE;
+
+ FUNC_EXIT;
+ return ret;
+}
result = _uam_core_stop_search_active_devices(sender, sensors);
break;
}
+ case UAM_REQUEST_REGISTER_APP: {
+ uam_app_info_t app_info;
+
+ __uam_manager_copy_params(in_param1,
+ &app_info, sizeof(uam_app_info_t));
+
+ result = _uam_register_app_info(sender, app_info);
+ break;
+ }
+ case UAM_REQUEST_DEREGISTER_APP: {
+ uam_app_info_t app_info;
+
+ __uam_manager_copy_params(in_param1,
+ &app_info, sizeof(uam_app_info_t));
+
+ result = _uam_deregister_app_info(sender, app_info);
+ break;
+ }
default:
UAM_WARN("UnSupported function [%s(0x%4.4X)]",
_uam_manager_request_to_str(function), function);
case UAM_REQUEST_SET_DETECTION_PARAMS:
case UAM_REQUEST_START_SEARCH_ACTIVE_DEVICES:
case UAM_REQUEST_STOP_SEARCH_ACTIVE_DEVICES:
+ case UAM_REQUEST_REGISTER_APP:
+ case UAM_REQUEST_DEREGISTER_APP:
return TRUE;
default:
return FALSE;