+
+API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
+{
+ if (appid == NULL) {
+ _LOGE("appid is NULL\n");
+ return PMINFO_R_EINVAL;
+ }
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ char *error_message = NULL;
+ ret = __open_manifest_db();
+
+ if (access(MANIFEST_DB, F_OK) == 0) {
+ ret = db_util_open(MANIFEST_DB, &manifest_db,
+ DB_UTIL_REGISTER_HOOK_METHOD);
+ if (ret != SQLITE_OK) {
+ _LOGE("connect db [%s] failed! Manifest DB does not exists!!\n", MANIFEST_DB);
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ /*Begin transaction*/
+ ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("Failed to begin transaction\n");
+ sqlite3_close(manifest_db);
+ return PMINFO_R_ERROR;
+ }
+ _LOGD("Transaction Begin\n");
+
+ memset(query, '\0', MAX_QUERY_LEN);
+ snprintf(query, MAX_QUERY_LEN,
+ "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid);
+
+ if (SQLITE_OK !=
+ sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
+ _LOGE("Don't execute query = %s error message = %s\n", query,
+ error_message);
+ sqlite3_free(error_message);
+ return PMINFO_R_ERROR;
+ }
+
+ /*Commit transaction*/
+ ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGE("Failed to commit transaction. Rollback now\n");
+ sqlite3_exec(manifest_db, "ROLLBACK", NULL, NULL, NULL);
+ sqlite3_close(manifest_db);
+ return PMINFO_R_ERROR;
+ }
+ _LOGD("Transaction Commit and End\n");
+ sqlite3_close(manifest_db);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status)
+{
+ if (handle == NULL) {
+ _LOGE("appinfo handle is NULL\n");
+ return PMINFO_R_EINVAL;
+ }
+ if (status == NULL) {
+ _LOGE("Argument supplied to hold return value is NULL\n");
+ return PMINFO_R_EINVAL;
+ }
+ char *val = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ val = (char *)info->uiapp_info->guestmode_visibility;
+ if (val) {
+ if (strcasecmp(val, "true") == 0){
+ *status = 1;
+ }else if (strcasecmp(val, "false") == 0){
+ *status = 0;
+ }else{
+ *status = 1;
+ }
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
+{
+ if (handle == NULL) {
+ _LOGE("appinfo handle is NULL\n");
+ return PMINFO_R_EINVAL;
+ }
+ char *val = NULL;
+ int ret = 0;
+ char *noti_string = NULL;
+ int len = 0;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ char *errmsg = NULL;
+ sqlite3 *pkgmgr_parser_db;
+
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ val = (char *)info->uiapp_info->guestmode_visibility;
+ if (val ) {
+ ret =
+ db_util_open_with_options(MANIFEST_DB, &pkgmgr_parser_db,
+ SQLITE_OPEN_READWRITE, NULL);
+
+ if (ret != SQLITE_OK) {
+ _LOGE("DB Open Failed\n");
+ return PMINFO_R_ERROR;
+ }
+
+ /*TODO: Write to DB here*/
+ if (status == true)
+ snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->uiapp_info->appid);
+ else
+ snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
+
+ if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
+ _LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
+ free(errmsg);
+ sqlite3_close(pkgmgr_parser_db);
+ return PMINFO_R_ERROR;
+ }else{
+ sqlite3_close(pkgmgr_parser_db);
+ len = strlen((char *)info->uiapp_info->appid) + 8;
+ noti_string = calloc(1, len);
+ if (noti_string == NULL){
+ return PMINFO_R_ERROR;
+ }
+ snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
+ vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
+ vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
+ free(noti_string);
+ }
+ }
+ return PMINFO_R_OK;
+}