Name: sync-service
-Version: 0.1.17
+Version: 0.1.18
Release: 1
License: Apache-2.0
Summary: Sync manager daemon
#include "sync-log.h"
#include "sync-error.h"
+
typedef enum {
SYNC_STATUS_SUCCESS = 0,
SYNC_STATUS_CANCELLED = -1,
} SyncSatus;
-#define SYNC_THREAD 0 /*As sync adapter itself runs in service app*/
+#define SYNC_THREAD 0 /* As sync adapter itself runs in service app */
#define SYNC_MANAGER_DBUS_SERVICE "org.tizen.sync"
#define SYNC_MANAGER_DBUS_PATH "/org/tizen/sync/manager"
g_sync_adapter->__syncRunning = true;
- int ret = SYNC_STATUS_SUCCESS;
account_h account = NULL;
if (accountId != -1) {
account_create(&account);
account_query_account_by_account_id(accountId, &account);
}
+
bundle *sync_job_user_data = umarshal_bundle(pSyncJobUserData);
bool is_sync_success;
else
is_sync_success = g_sync_adapter->start_sync_cb(account, pSyncJobName, NULL, sync_job_user_data);
+ int ret = SYNC_STATUS_SUCCESS;
if (!is_sync_success)
ret = SYNC_STATUS_FAILURE;
g_sync_adapter->__syncRunning = false;
bundle_free(sync_job_user_data);
free(command_line);
- LOG_LOGD("Sync completed");
+ LOG_LOGD("Sync operation completed");
if (ret == SYNC_STATUS_FAILURE)
return false;
/* flag == false => de-register */
int __register_sync_adapter(bool flag)
{
- bool ret = true;
-
GError *error = NULL;
GDBusConnection *connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
SYNC_LOGE_RET_RES(connection != NULL, SYNC_ERROR_IO_ERROR, "tizen_sync_manager_proxy_new_sync failed %s", error->message);
&error);
SYNC_LOGE_RET_RES(error == NULL && ipcObj != NULL, SYNC_ERROR_IO_ERROR, "tizen_sync_manager_proxy_new_sync failed %s", error->message);
+ bool ret = true;
char *command_line = proc_get_cmdline_self();
if (flag) {
ret = tizen_sync_manager_call_add_sync_adapter_sync(ipcObj, command_line, NULL, &error);
SYNC_LOGE_RET_RES(ret && !error, SYNC_ERROR_QUOTA_EXCEEDED, "Register sync adapter failed %s", error->message);
- } else
+ } else {
tizen_sync_manager_call_remove_sync_adapter_sync(ipcObj, command_line, NULL, &error);
+ }
free(command_line);
g_sync_adapter->sync_adapter_obj = NULL;
g_sync_adapter->__syncRunning = false;
g_sync_adapter->sync_adapter_obj = pSyncAdapter;
- } else
+ } else {
return ret;
+ }
}
g_sync_adapter->start_sync_cb = on_start_cb;
{
SYNC_LOGE_RET_RES(g_sync_adapter != NULL, SYNC_ERROR_SYSTEM, "sync_adapter_set_callbacks should be called first");
+ LOG_LOGD("sync_adapter_destroy");
+
__register_sync_adapter(false);
+
g_sync_adapter->start_sync_cb = NULL;
g_sync_adapter->cancel_sync_cb = NULL;
- LOG_LOGD("sync_adapter_destroy");
if (g_sync_adapter) {
free(g_sync_adapter);
g_sync_adapter = NULL;
#include "sync-log.h"
#include "sync-error.h"
+
#define SYNC_MANAGER_DBUS_PATH "/org/tizen/sync/manager"
#define SYNC_ADAPTER_DBUS_PATH "/org/tizen/sync/adapter"
#define SYNC_ERROR_PREFIX "org.tizen.sync.Error"
static sync_manager_s *g_sync_manager;
+
int read_proc(const char *path, char *buf, int size)
{
int fd;
fd = open(path, O_RDONLY);
if (fd < 0) {
LOG_LOGD("fd = [%d]", fd);
-
return -1;
}
ret = read(fd, buf, size - 1);
if (ret <= 0) {
close(fd);
-
return -1;
- } else
+ } else {
buf[ret] = 0;
+ }
close(fd);
return ret;
}
+
char *proc_get_cmdline_self()
{
char cmdline[1024];
LOG_LOGD("Can not read /proc/self/cmdline");
return NULL;
}
+
LOG_LOGD("sync client: cmdLine [%s]", cmdline);
return strdup(cmdline);
{
if (!is_success) {
LOG_LOGD("Received error Domain[%d] Message[%s] Code[%d]", error->domain, error->message, error->code);
-
if (g_dbus_error_is_remote_error(error)) {
gchar *remote_error = g_dbus_error_get_remote_error(error);
if (remote_error) {
LOG_LOGD("Remote error [%s]", remote_error);
-
int error_enum_count = G_N_ELEMENTS(_sync_errors);
int i = 0;
for (i = 0; i < error_enum_count; i++) {
}
}
}
- /*All undocumented errors mapped to SYNC_ERROR_UNKNOWN*/
+ /* All undocumented errors mapped to SYNC_ERROR_UNKNOWN */
return SYNC_ERROR_UNKNOWN;
}
return SYNC_ERROR_NONE;
{
SYNC_LOGE_RET_RES(g_sync_manager == NULL, SYNC_ERROR_NONE, "sync manager already connected");
- pid_t pid = getpid();
- char *appId = NULL;
-
GDBusConnection *connection = NULL;
GError *error = NULL;
connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
"/org/tizen/sync/manager",
NULL,
&error);
+
if (error != NULL) {
LOG_LOGC("sync client: gdbus error [%s]", error->message);
g_sync_manager = NULL;
-
return SYNC_ERROR_IO_ERROR;
}
if (ipcObj == NULL) {
g_sync_manager = NULL;
-
return SYNC_ERROR_SYSTEM;
}
if (g_sync_manager == NULL)
return SYNC_ERROR_OUT_OF_MEMORY;
+ pid_t pid = getpid();
+ char *appId = NULL;
+
int ret = app_manager_get_app_id(pid, &appId);
if (ret != APP_MANAGER_ERROR_NONE)
appId = proc_get_cmdline_self();
int get_interval(sync_period_e period)
{
int frequency = 0;
+
switch (period) {
case SYNC_PERIOD_INTERVAL_30MIN:
{
return SYNC_ERROR_SYSTEM;
}
LOG_LOGC("appid [%s] accid [%d] sync_job_name [%s]", g_sync_manager->appid, id, sync_job_name);
- } else
+ } else {
LOG_LOGC("appid [%s] sync_job_name [%s]", g_sync_manager->appid, sync_job_name);
+ }
- GError *error = NULL;
GVariant *user_data = marshal_bundle(sync_job_user_data);
+ GError *error = NULL;
bool is_success = tizen_sync_manager_call_add_on_demand_job_sync(g_sync_manager->ipcObj, g_sync_manager->appid, id, sync_job_name, sync_option, user_data, sync_job_id, NULL, &error);
if (!is_success || error) {
int error_code = _sync_get_error_code(is_success, error);
LOG_LOGC("sync client: gdbus error [%s]", error->message);
g_clear_error(&error);
-
return error_code;
}
+
if (*sync_job_id == -1)
return SYNC_ERROR_QUOTA_EXCEEDED;
return SYNC_ERROR_SYSTEM;
}
LOG_LOGC("appid [%s] accid [%d] sync_job_name [%s]", g_sync_manager->appid, id, sync_job_name);
- } else
+ } else {
LOG_LOGC("appid [%s] sync_job_name [%s]", g_sync_manager->appid, sync_job_name);
+ }
int sync_interval = get_interval(sync_period);
- GError *error = NULL;
GVariant *user_data = marshal_bundle(sync_job_user_data);
+ GError *error = NULL;
bool is_success = tizen_sync_manager_call_add_periodic_job_sync(g_sync_manager->ipcObj, g_sync_manager->appid, id, sync_job_name, sync_interval, sync_option, user_data, sync_job_id, NULL, &error);
if (!is_success || error) {
int error_code = _sync_get_error_code(is_success, error);
LOG_LOGC("sync client: gdbus error [%s]", error->message);
g_clear_error(&error);
-
return error_code;
}
return SYNC_ERROR_SYSTEM;
}
LOG_LOGC("appid [%s] accid [%d] capability [%s]", g_sync_manager->appid, id, sync_capability);
- } else
+ } else {
LOG_LOGC("appid [%s] capability [%s]", g_sync_manager->appid, sync_capability);
+ }
- GError *error = NULL;
GVariant *user_data = marshal_bundle(sync_job_user_data);
+ GError *error = NULL;
bool is_success = tizen_sync_manager_call_add_data_change_job_sync(g_sync_manager->ipcObj, g_sync_manager->appid, id, sync_capability, sync_option, user_data, sync_job_id, NULL, &error);
if (!is_success || error) {
int error_code = _sync_get_error_code(is_success, error);
LOG_LOGC("sync client: gdbus error [%s]", error->message);
g_clear_error(&error);
-
return error_code;
}
LOG_LOGC("sync client: [%s] removing sync job with sync_job_id [%d]", g_sync_manager->appid, sync_job_id);
GError *error = NULL;
- bool is_success = tizen_sync_manager_call_remove_job_sync(g_sync_manager->ipcObj, g_sync_manager->appid, sync_job_id, NULL, &error);
+ bool is_success = tizen_sync_manager_call_remove_job_sync(g_sync_manager->ipcObj, g_sync_manager->appid, sync_job_id, NULL, &error);
if (!is_success || error) {
int error_code = _sync_get_error_code(is_success, error);
LOG_LOGC("sync client: gdbus error [%s]", error->message);
g_clear_error(&error);
-
return error_code;
}
g_sync_manager->sync_job_cb = sync_job_cb;
- GError *error = NULL;
GVariant *sync_job_list_variant = NULL;
+ GError *error = NULL;
gboolean is_success = tizen_sync_manager_call_get_all_sync_jobs_sync(g_sync_manager->ipcObj, g_sync_manager->appid, &sync_job_list_variant, NULL, &error);
if (!is_success || error) {
int error_code = _sync_get_error_code(is_success, error);
LOG_LOGC("sync client: gdbus error [%s]", error->message);
g_clear_error(&error);
-
return error_code;
} else {
umarshal_sync_job_list(sync_job_list_variant, sync_job_cb, user_data);
tizen_sync_manager_call_set_sync_status_sync(g_sync_manager->ipcObj, true, NULL, &error);
if (error != NULL) {
LOG_LOGC("sync client: gdbus error [%s]", error->message);
-
return SYNC_ERROR_IO_ERROR;
}
tizen_sync_manager_call_set_sync_status_sync(g_sync_manager->ipcObj, false, NULL, &error);
if (error != NULL) {
LOG_LOGC("sync client: gdbus error [%s]", error->message);
-
return SYNC_ERROR_IO_ERROR;
}
cur = cur->xmlChildrenNode;
while (cur != NULL) {
if (!xmlStrcmp(cur->name, XML_NODE_SYNCADAPTER)) {
- xmlChar* pServiceAppId = xmlGetProp(cur, XML_ATTR_SYNCADAPTER_SERVICE_APP_ID);
+ xmlChar* pServiceAppUID = xmlGetProp(cur, XML_ATTR_SYNCADAPTER_SERVICE_APP_ID);
xmlChar* pPackageId = xmlGetProp(cur, XML_ATTR_PACKAGE_ID);
xmlChar* pAppStatus = xmlGetProp(cur, XML_ATTR_APP_STATUS);
+ char pAppUID[100];
+ if (!strstr((char*)pServiceAppUID, "#"))
+ snprintf(pAppUID, 100, "%s#%d", pServiceAppUID, 5001);
+ else
+ strcpy(pAppUID, (char*)pServiceAppUID);
+
+ char *pServiceAppId;
+ pServiceAppId = strtok((char*)pServiceAppUID, "#");
+
+ LOG_LOGD("pAppUID [%s], pServiceAppId [%s]", pAppUID, pServiceAppId);
+
pkgmgrinfo_appinfo_h handle_appinfo;
if (pkgmgrinfo_appinfo_get_appinfo((char*)pServiceAppId, &handle_appinfo) == PMINFO_R_OK) {
if (!pAppStatus)
- pAggregator->SetAppStatus((char*)pServiceAppId, "enabled");
+ pAggregator->SetAppStatus((char*)pAppUID, "enabled");
else
- pAggregator->SetAppStatus((char*)pServiceAppId, (char*)pAppStatus);
+ pAggregator->SetAppStatus((char*)pAppUID, (char*)pAppStatus);
- pAggregator->AddSyncAdapter((char*)pPackageId, (char*)pServiceAppId);
+ pAggregator->AddSyncAdapter((char*)pPackageId, (char*)pAppUID);
pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
} else {
pAggregator->HandlePackageUninstalled((char*)pPackageId);
}
+ if (pServiceAppId)
+ free(pServiceAppId);
}
cur = cur->next;
}
/* LCOV_EXCL_START */
void
-SyncAdapterAggregator::SetAppStatus(const char* pServiceAppId, const char* pAppStatus) {
- /* Update the application's status */
+SyncAdapterAggregator::SetAppStatus(const char* pServiceAppUID, const char* pAppStatus) {
+ /* Update the application status */
for (map<string, string>::iterator iter = __syncAppStatus.begin(); iter != __syncAppStatus.end(); ++iter) {
string appID = iter->first;
- if (!strcmp(pServiceAppId, appID.c_str())) {
+ if (!strcmp(pServiceAppUID, appID.c_str())) {
LOG_LOGD("Sync status already exist and it is set as [%s]", pAppStatus);
iter->second = pAppStatus;
return;
}
}
LOG_LOGD("Sync status is set as [%s]", pAppStatus);
- __syncAppStatus.insert(pair<string, string> (pServiceAppId, pAppStatus));
+ __syncAppStatus.insert(pair<string, string> (pServiceAppUID, pAppStatus));
}
/* LCOV_EXCL_STOP */
void
-SyncAdapterAggregator::AddSyncAdapter(const char* pPackageId, const char* pServiceAppId) {
+SyncAdapterAggregator::AddSyncAdapter(const char* pPackageId, const char* pServiceAppUID) {
if (HasSyncAdapter(pPackageId)) {
LOG_LOGD("Sync adapter already registered for package [%s]", pPackageId); /* LCOV_EXCL_LINE */
} else {
- LOG_LOGD("Registering sync-adapter [%s] for package [%s]", pServiceAppId, pPackageId);
- __syncAdapterList.insert(pair<string, string> (pPackageId, pServiceAppId));
+ LOG_LOGD("Registering sync-adapter [%s] for package [%s]", pServiceAppUID, pPackageId);
+ __syncAdapterList.insert(pair<string, string> (pPackageId, pServiceAppUID));
+
+ /* Check the application status was written */
+ for (map<string, string>::iterator iter = __syncAppStatus.begin(); iter != __syncAppStatus.end(); ++iter) {
+ string appID = iter->first;
+ if (!strcmp(pServiceAppUID, appID.c_str())) {
+ LOG_LOGD("Sync status already exist");
+ return;
+ }
+ }
+
+ LOG_LOGD("Sync status does not exist and it is set as default value");
+ __syncAppStatus.insert(pair<string, string> (pServiceAppUID, "enabled"));
}
}
map<string, string>::iterator it = __syncAdapterList.find(PkgId.c_str());
if (it != __syncAdapterList.end()) {
+ LOG_LOGD("Sync adapter is found for account provider id [%s]", it->second.c_str());
return it->second.c_str();
}
- LOG_LOGD("Sync adapter not found for account provider id %s", pAppId);
+ LOG_LOGD("Sync adapter not found for account provider id [%s]", pAppId);
return NULL;
}
int
SyncJobDispatcher::DispatchSyncJob(SyncJob* syncJob) {
- int ret = SYNC_ERROR_NONE;
LOG_LOGD("Dispatching sync job [%s], [%s]", syncJob->__appId.c_str(), syncJob->__syncJobName.c_str());
bool isDataSync = (syncJob->GetSyncType() == SYNC_TYPE_DATA_CHANGE);
+ int ret = SYNC_ERROR_NONE;
ret = SyncService::GetInstance()->TriggerStartSync(syncJob->__appId.c_str(), syncJob->__accountId, syncJob->__syncJobName.c_str(), isDataSync, syncJob->__pExtras);
SYNC_LOGE_RET_RES(ret == SYNC_ERROR_NONE, ret, "Failed to start sync job")
if (SyncManager::GetInstance()->__pCurrentSyncJobQueue) {
pthread_mutex_lock(&(SyncManager::GetInstance()->__currJobQueueMutex));
LOG_LOGD("Add to Active Sync queue");
-
SyncManager::GetInstance()->__pCurrentSyncJobQueue->AddSyncJobToCurrentSyncQueue(syncJob);
pthread_mutex_unlock(&(SyncManager::GetInstance()->__currJobQueueMutex));
}
void
-SyncManager::OnResultReceived(SyncStatus res, string appId, string packageId, const char* syncJobName) {
+SyncManager::OnResultReceived(SyncStatus res, string svcAppUID, string packageId, const char* syncJobName) {
string key;
- key.append("id:").append(appId).append(syncJobName);
+ key.append("id:").append(svcAppUID).append(syncJobName);
LOG_LOGD("Close Sync context for key %s", key.c_str());
CurrentSyncContext *pCurrSyncContext = __pCurrentSyncJobQueue->GetCurrJobfromKey(key);
pthread_mutex_unlock(&__currJobQueueMutex);
if (pCurrSyncContext == NULL) {
- LOG_LOGD("Sync context cant be found for %s", key.c_str());
+ LOG_LOGD("Sync context can't be found for %s", key.c_str());
} else {
g_source_remove(pCurrSyncContext->GetTimerId());
SyncJob* pJob = pCurrSyncContext->GetSyncJob();
void AlertForChange();
- void OnResultReceived(SyncStatus res, string svcAppId, string packageId, const char* syncJobName);
+ void OnResultReceived(SyncStatus res, string svcAppUID, string packageId, const char* syncJobName);
string GetPkgIdByAppId(const char* pAppId);
/* LCOV_EXCL_START */
int
-SyncService::TriggerStartSync(const char* appId, int accountId, const char* syncJobName, bool isDataSync, bundle* pExtras) {
- LOG_LOGD("appId [%s] jobname [%s]", appId, syncJobName);
+SyncService::TriggerStartSync(const char* appUID, int accountId, const char* syncJobName, bool isDataSync, bundle* pExtras) {
+ LOG_LOGD("appUID [%s] syncJobName [%s]", appUID, syncJobName);
+
+ char pAppId[strlen(appUID) + 1] = { 0, };
+ strcpy(pAppId, appUID);
+
+ char pServiceAppId[strlen(pAppId) + 1] = { 0, };
+ char *temp;
+ int uid = -1;
+ int stage = 1;
+
+ /* Divide appId#uid */
+ temp = strtok(pAppId, "#");
+ while (temp != NULL) {
+ if (stage == 1) {
+ strcpy(pServiceAppId, temp);
+ LOG_LOGD("step %d. pServiceAppId [%s]", stage, pServiceAppId);
+ } else if (stage == 2) {
+ uid = atoi(temp);
+ LOG_LOGD("step %d. uid [%d]", stage, uid);
+ }
+ stage++;
+ temp = strtok(NULL, "#");
+ }
- app_control_h app_control;
int ret = SYNC_ERROR_NONE;
+ ret = aul_app_get_status_for_uid(pServiceAppId, uid);
+ if (ret == -1) {
+ /* Send launch request to wake application */
+ LOG_LOGD("[%s] is not running, launch the app and wait for signal", pServiceAppId);
- bool isRunning = false;
- app_manager_is_running(appId, &isRunning);
- if (!isRunning) {
- LOG_LOGD("app is not running, launch the app and wait for signal");
- ret = app_control_create(&app_control);
- SYNC_LOGE_RET_RES(ret == APP_CONTROL_ERROR_NONE, SYNC_ERROR_SYSTEM, "app control create failed %d", ret);
-
- ret = app_control_set_app_id(app_control, appId);
- if (ret != APP_CONTROL_ERROR_NONE) {
- app_control_destroy(app_control);
- SYNC_LOGE_RET_RES(ret == APP_CONTROL_ERROR_NONE, SYNC_ERROR_SYSTEM, "app control error [%d : %s]", ret, get_error_message(ret));
- }
+ /*
+ // for setting background launch
+ ret = aul_svc_set_background_launch(pExtras, true);
+ SYNC_LOGE_RET_RES(ret >= AUL_R_OK, SYNC_ERROR_SYSTEM, "ERROR : aul_svc_set_background_launch() failed for appId[%s], result[%d : %s]", pServiceAppId, ret, get_error_message(ret));
+ */
+
+ ret = aul_launch_app_for_uid(pServiceAppId, pExtras, uid);
+ SYNC_LOGE_RET_RES(ret >= AUL_R_OK, SYNC_ERROR_SYSTEM, "ERROR : aul_launch_app_for_uid() failed for appId[%s], result[%d : %s]", pServiceAppId, ret, get_error_message(ret));
sa_app_id.clear();
- ret = app_control_send_launch_request(app_control, NULL, NULL);
- SYNC_LOGE_RET_RES(ret == APP_CONTROL_ERROR_NONE, SYNC_ERROR_SYSTEM, "app control launch request failed %d", ret);
return SYNC_ERROR_SYSTEM;
} else {
- LOG_LOGD("app is already running");
- TizenSyncAdapter* pSyncAdapter = (TizenSyncAdapter*) g_hash_table_lookup(g_hash_table, appId);
+ LOG_LOGD("[%s] app is already running", pServiceAppId);
+
+ /* Find pSyncAdapter in hash table with appId#uid */
+ TizenSyncAdapter* pSyncAdapter = (TizenSyncAdapter*) g_hash_table_lookup(g_hash_table, appUID);
if (!pSyncAdapter) {
LOG_LOGD("Sync adapter entry not found. Preparing sync adapter object");
app_context_h app_context = NULL;
pid_t pid;
- int ret = app_manager_get_app_context(appId, &app_context);
+ int ret = app_manager_get_app_context(pServiceAppId, &app_context);
SYNC_LOGE_RET_RES(ret == APP_MANAGER_ERROR_NONE, SYNC_ERROR_SYSTEM, "getting app_context is failed");
ret = app_context_get_pid(app_context, &pid);
if (g_dbus_interface_skeleton_export(interface, gdbusConnection, obj_path, &error)) {
g_signal_connect(pSyncAdapter, "handle-send-result", G_CALLBACK(sync_adapter_handle_send_result), NULL);
- LOG_LOGD("inserting sync adapter ipc %s %x", appId, pSyncAdapter);
- g_hash_table_insert(g_hash_table, strdup(appId), pSyncAdapter);
+ /* appId#uid */
+ LOG_LOGD("inserting sync adapter ipc %s %x", appUID, pSyncAdapter);
+ g_hash_table_insert(g_hash_table, strdup(appUID), pSyncAdapter);
} else {
SYNC_LOGE_RET_RES(!(error->message), SYNC_ERROR_SYSTEM, "export failed [%s]", error->message);
return SYNC_ERROR_SYSTEM;
void
-SyncService::TriggerStopSync(const char* appId, int accountId, const char* syncJobName, bool isDataSync, bundle* pExtras) {
- LOG_LOGD("Trigger stop sync %s", appId);
+SyncService::TriggerStopSync(const char* appUID, int accountId, const char* syncJobName, bool isDataSync, bundle* pExtras) {
+ LOG_LOGD("Trigger stop sync [%s]", appUID);
- TizenSyncAdapter* pSyncAdapter = (TizenSyncAdapter*) g_hash_table_lookup(g_hash_table, appId);
+ TizenSyncAdapter* pSyncAdapter = (TizenSyncAdapter*) g_hash_table_lookup(g_hash_table, appUID);
if (!pSyncAdapter) {
LOG_LOGD("Failed to lookup syncadapter");
return;
LOG_LOGD("Sync request with job name [%s] already found. Sync job id [%d]", pSyncJobName, syncJobId);
pSyncJobEntry->Reset(accountId, pExtras, syncOption);
- LOG_LOGD("sync parameters are updated with new parameters", pSyncJobName);
+ LOG_LOGD("sync parameters are updated with new parameters [%s]", pSyncJobName);
} else {
syncJobId = pSyncJobsAggregator->GenerateSyncJobId(pPackageId);
SYNC_LOGE_RET_RES(syncJobId <= SYNC_JOB_LIMIT, SYNC_ERROR_QUOTA_EXCEEDED, "Sync job quota exceeded");
ret = __pSyncManagerInstance->AddOnDemandSync(pPackageId, pSyncJobName, accountId, pExtras, syncOption, syncJobId);
}
- if (ret == SYNC_ERROR_NONE) {
+ if (ret == SYNC_ERROR_NONE)
*pSyncJobId = syncJobId;
- }
return ret;
}
ret = __pSyncManagerInstance->AddPeriodicSyncJob(pPackageId, pSyncJobName, accountId, pExtras, syncOption, syncJobId, pollFrequency);
}
- if (ret == SYNC_ERROR_NONE) {
+ if (ret == SYNC_ERROR_NONE)
*pSyncJobId = syncJobId;
- }
return ret;
}
ret = __pSyncManagerInstance->AddDataSyncJob(pPackageId, pSyncJobName, accountId, pExtras, syncOption, syncJobId, pCapability);
}
- if (ret == SYNC_ERROR_NONE) {
+ if (ret == SYNC_ERROR_NONE)
*pSyncJobId = syncJobId;
- }
+
return ret;
}
pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(pCommandLine);
}
+ char pServiceAppUID[100];
+ snprintf(pServiceAppUID, 100, "%s#%d", pAppId, getuid());
+ LOG_LOGD("pid[%d], pServiceAppUID [%s]", (int)pid, pServiceAppUID);
+
if (!pkgIdStr.empty()) {
LOG_LOGD("Sync result received from [%s]: sync_job_name [%s] result [%d]", pAppId, sync_job_name, sync_result);
-
- SyncManager::GetInstance()->OnResultReceived((SyncStatus)sync_result, pAppId, pkgIdStr, sync_job_name);
+ SyncManager::GetInstance()->OnResultReceived((SyncStatus)sync_result, pServiceAppUID, pkgIdStr, sync_job_name);
free(pAppId);
} else {
LOG_LOGD("sync service: Get package Id fail %d", ret);
tizen_sync_adapter_complete_send_result(pObject, pInvocation);
- /// Syncadapter may kill self after sync.
- /// aul_terminate_pid(pid);
-
return true;
}
guint pid = get_caller_pid(pInvocation);
string pkgIdStr;
char* pAppId;
- int ret = APP_MANAGER_ERROR_NONE;
-
- ret = app_manager_get_app_id(pid, &pAppId);
+ int ret = app_manager_get_app_id(pid, &pAppId);
if (ret == APP_MANAGER_ERROR_NONE) {
pkgIdStr = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
free(pAppId);
pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(pCommandLine);
/* LCOV_EXCL_STOP */
}
+
if (!pkgIdStr.empty()) {
LOG_LOGD("package id [%s]", pkgIdStr.c_str());
ret = SyncManager::GetInstance()->RemoveSyncJob(pkgIdStr, sync_job_id);
guint pid = get_caller_pid(pInvocation);
string pkgIdStr;
- int sync_job_id = 0;
char* pAppId;
-
ret = app_manager_get_app_id(pid, &pAppId);
if (ret == APP_MANAGER_ERROR_NONE) {
pkgIdStr = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(pCommandLine);
/* LCOV_EXCL_STOP */
}
+
+ int sync_job_id = 0;
if (!pkgIdStr.empty()) {
LOG_LOGD("Params acc[%d] name[%s] option[%d] period[%d] package[%s]", accountId, pSyncJobName, sync_option, sync_interval, pkgIdStr.c_str());
bundle* pBundle = umarshal_bundle(pSyncJobUserData);
guint pid = get_caller_pid(pInvocation);
string pkgIdStr;
- int sync_job_id = 0;
char* pAppId;
ret = app_manager_get_app_id(pid, &pAppId);
pkgIdStr = SyncManager::GetInstance()->GetPkgIdByCommandline(pCommandLine);
/* LCOV_EXCL_STOP */
}
+
+ int sync_job_id = 0;
if (!pkgIdStr.empty()) {
LOG_LOGD("Params account [%d] job_name [%s] sync_option[%d] sync_job_id[%d] package [%s] ", accountId, pCapabilityArg, sync_option, sync_job_id, pkgIdStr.c_str());
return true;
/* LCOV_EXCL_STOP */
}
+
if (pAggregator->HasSyncAdapter(pkgIdStr.c_str())) {
/* LCOV_EXCL_START */
const char *registered_app_id = pAggregator->GetSyncAdapter(pkgIdStr.c_str());
LOG_LOGD("registered appId is [%s]", registered_app_id);
LOG_LOGD("caller appId is [%s]", pAppId);
- if (strcmp(pAppId, registered_app_id)) {
+ if (strncmp(pAppId, registered_app_id, strlen(pAppId))) {
GError* error = g_error_new(_sync_error_quark(), SYNC_ERROR_QUOTA_EXCEEDED, "Sync adapter already registered");
g_dbus_method_invocation_return_gerror(pInvocation, error);
g_clear_error(&error);
return false;
} else {
- check_jobs = true; // Probably sync service may have started this service. Alert sync manager for scheduling pending jobs.
- /* LCOV_EXCL_STOP */
+ check_jobs = true; /* Probably sync service may have started this service. Alert sync manager for scheduling pending jobs */
}
+ /* LCOV_EXCL_STOP */
}
char object_path[50];
interface = G_DBUS_INTERFACE_SKELETON(syncAdapterObj);
if (g_dbus_interface_skeleton_export(interface, gdbusConnection, object_path, &error)) {
g_signal_connect(syncAdapterObj, "handle-send-result", G_CALLBACK(sync_adapter_handle_send_result), NULL);
- pAggregator->AddSyncAdapter(pkgIdStr.c_str(), pAppId);
- LOG_LOGD("inserting sync adapter ipc %s", pAppId);
- g_hash_table_insert(g_hash_table, strdup(pAppId), syncAdapterObj);
+ char pAppUID[100];
+ snprintf(pAppUID, 100, "%s#%d", pAppId, getuid());
+
+ /* Add sync adapter as form of appId#uid */
+ pAggregator->AddSyncAdapter(pkgIdStr.c_str(), pAppUID);
+
+ LOG_LOGD("inserting sync adapter ipc %s", pAppUID);
+ g_hash_table_insert(g_hash_table, strdup(pAppUID), syncAdapterObj);
ret = SYNC_ERROR_NONE;
} else {
char* pAppId;
int ret = APP_MANAGER_ERROR_NONE;
-
ret = app_manager_get_app_id(pid, &pAppId);
+
if (ret == APP_MANAGER_ERROR_NONE) {
pkgIdStr = SyncManager::GetInstance()->GetPkgIdByAppId(pAppId);
} else {
pAggregator->RemoveSyncAdapter(pkgIdStr.c_str());
LOG_LOGD("Sync adapter removed for package [%s]", pkgIdStr.c_str());
} else {
- LOG_LOGD("sync service: Get package Id fail %d", ret); /* LCOV_EXCL_LINE */
+ LOG_LOGD("sync service: Get package Id fail [%d]", ret); /* LCOV_EXCL_LINE */
}
- TizenSyncAdapter* pSyncAdapter = (TizenSyncAdapter*) g_hash_table_lookup(g_hash_table, pAppId);
+ char pAppUID[100];
+ snprintf(pAppUID, 100, "%s#%d", pAppId, getuid());
+
+ TizenSyncAdapter* pSyncAdapter = (TizenSyncAdapter*) g_hash_table_lookup(g_hash_table, pAppUID);
if (pSyncAdapter == NULL) {
/* LCOV_EXCL_START */
- LOG_LOGD("Failed to lookup syncadapter gdbus object for [%s]", pAppId);
+ LOG_LOGD("Failed to lookup syncadapter gdbus object for [%s]", pAppUID);
char object_path[50];
snprintf(object_path, 50, "%s%d", SYNC_ADAPTER_DBUS_PATH, pid);
g_signal_connect(syncAdapterObj, "handle-send-result", G_CALLBACK(sync_adapter_handle_send_result), NULL);
pAggregator->RemoveSyncAdapter(pkgIdStr.c_str());
- LOG_LOGD("deletting sync adapter ipc %s", pAppId);
+ LOG_LOGD("deletting sync adapter ipc [%s]", pAppUID);
ret = SYNC_ERROR_NONE;
} else {
public:
int StartService(void);
- int TriggerStartSync(const char* appId, int accountId, const char* syncJobName, bool isDataSync, bundle* pExtras);
+ int TriggerStartSync(const char* appUID, int accountId, const char* syncJobName, bool isDataSync, bundle* pExtras);
- void TriggerStopSync(const char* appId, int accountId, const char* syncJobName, bool isDataSync, bundle* pExtras);
+ void TriggerStopSync(const char* appUID, int accountId, const char* syncJobName, bool isDataSync, bundle* pExtras);
int RequestOnDemandSync(const char* pPackageId, const char* pSyncJobName, int accountId, bundle* pExtras, int syncOption, int* pSyncJobId);