change calling account_type_insert API. 10/46510/1 accepted/tizen/mobile/20150825.061221 accepted/tizen/tv/20150825.061312 submit/tizen_mobile/20150825.032448 submit/tizen_tv/20150825.032629
authorjiseob.jang <jiseob.jang@samsung.com>
Fri, 21 Aug 2015 08:13:34 +0000 (17:13 +0900)
committerjiseob.jang <jiseob.jang@samsung.com>
Fri, 21 Aug 2015 08:13:34 +0000 (17:13 +0900)
Change-Id: I763e77d1e01c7db55c284507afe71ab9a7e03246
Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
src/account.c

index efc5f18..f9ce435 100644 (file)
@@ -442,7 +442,12 @@ int _register_account_provider(xmlDocPtr docPtr, char* account_provider_app_id)
        // Insert the account type to the account DB
        {
                int account_type_db_id = 0;
-               ret = account_type_insert_to_db_offline(account_type_handle, &account_type_db_id);
+               if (getuid() == 0) {
+                       ret = account_type_insert_to_db_offline(account_type_handle, &account_type_db_id);
+               } else {
+                       ret = account_type_insert_to_db(account_type_handle, &account_type_db_id);
+               }
+
                if(ret != ACCOUNT_ERROR_NONE) {
                        _E("[%d]Failed to perform account_type_insert_to_db().", ret);
                        goto CATCH;
@@ -475,15 +480,18 @@ int _unregister_account_provider(pkgmgrinfo_appinfo_h package_info_handle, void*
 
        int ret = ACCOUNT_ERROR_NONE;
 
-       int ret2 = ACCOUNT_ERROR_NONE;
-
        ret = account_delete_from_db_by_package_name_without_permission((char*)app_id);
        if((ret != ACCOUNT_ERROR_NONE) && (ret !=  ACCOUNT_ERROR_RECORD_NOT_FOUND)) {
                _E("Failed to perform account_delete_from_db_by_package_name_without_permission().");
                goto CATCH;
        }
 
-       ret = account_type_delete_by_app_id_offline((char*)app_id);
+       if (getuid() == 0) {
+               ret = account_type_delete_by_app_id_offline((char*)app_id);
+       } else {
+               ret = account_type_delete_by_app_id((char*)app_id);
+       }
+
        if(ret != ACCOUNT_ERROR_NONE) {
                _E("Failed to perform account_type_delete_by_app_id().");
                goto CATCH;
@@ -500,11 +508,17 @@ int _on_package_app_list_received_cb(pkgmgrinfo_appinfo_h handle, void *user_dat
        ENTER();
        _D("Pkgmgr parser plugin pre upgrade.");
 
+       int ret = ACCOUNT_ERROR_NONE;
        char* app_id = NULL;
        pkgmgrinfo_appinfo_get_appid(handle, &app_id);
        _D("appid : %s", app_id);
 
-       int ret = account_type_delete_by_app_id_offline((char*)app_id);
+       if (getuid() == 0) {
+               ret = account_type_delete_by_app_id_offline((char*)app_id);
+       } else {
+               ret = account_type_delete_by_app_id((char*)app_id);
+       }
+
        if(ret == ACCOUNT_ERROR_NONE) {
                _D("PKGMGR_PARSER_PLUGIN_PRE_UPGRADE: app ID - %s", app_id);
                strncpy(__old_account_provider_app_id, app_id, 128);
@@ -587,8 +601,6 @@ int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char* packageId)
        int ret = _register_account_provider(docPtr, account_provider_app_id);
        retvm_if(ret != 0, ret, "[%d]Failed to register the account provider.", ret);
 
-       int ret2 = 0;
-
        ret = account_query_account_by_package_name(_on_account_received_cb, __old_account_provider_app_id, (void*)account_provider_app_id);
        if((ret != ACCOUNT_ERROR_NONE) && (ret != ACCOUNT_ERROR_RECORD_NOT_FOUND)) {
                _E("Failed to perform account_query_account_by_package_name().");