ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
if (ret != SQLITE_OK) {
- _LOGE("failed to open db: %d", ret);
+ _LOGE("failed to open db(%s): %d", dbpath, ret);
free(dbpath);
return PMINFO_R_ERROR;
}
{
label_x *ptr;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ char *lbl = NULL;
+ const char *locale;
+ GList *tmp;
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
- if (info->app_info == NULL || info->app_info->label == NULL)
+ if (info->app_info == NULL)
return PMINFO_R_ERROR;
- ptr = (label_x *)info->app_info->label->data;
- if (ptr == NULL)
- return PMINFO_R_ERROR;
+ locale = info->locale;
+ if (locale == NULL)
+ locale = DEFAULT_LOCALE;
- if (ptr->text == NULL)
- return PMINFO_R_ERROR;
- else
- *label = ptr->text;
+ for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
+ ptr = (label_x *)tmp->data;
+ if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
+ continue;
+ lbl = ptr->text;
+ break;
+ }
+
+ if (lbl != NULL) {
+ *label = lbl;
+ return PMINFO_R_OK;
+ }
+
+ for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
+ ptr = (label_x *)tmp->data;
+ if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
+ continue;
+ lbl = ptr->text;
+ break;
+ }
+
+ *label = lbl ? lbl : "";
return PMINFO_R_OK;
}
type, _getuid(), appid, is_trusted);
}
+API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(const char *providerid, const char *type,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data, uid_t uid)
+{
+ retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
+
+ int ret = PMINFO_R_OK;
+ char *query = NULL;
+ sqlite3_stmt *stmt = NULL;
+
+ /*open db*/
+ ret = __open_manifest_db(uid, true);
+ retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+
+ /*Start constructing query*/
+ query = sqlite3_mprintf("SELECT privilege FROM package_app_data_control_privilege "
+ "WHERE providerid=%Q AND type=%Q", providerid, type);
+ tryvm_if(query == NULL, ret = PMINFO_R_ERROR, "Out of memory");
+
+ /*prepare query*/
+ ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
+ tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR, "sqlite3_prepare_v2 failed[%s]\n", query);
+
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ char *privilege;
+ privilege = (char *)sqlite3_column_text(stmt, 0);
+ ret = privilege_func(privilege, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ ret = PMINFO_R_OK;
+
+catch:
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+ __close_manifest_db();
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(const char *providerid, const char *type,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
+{
+ return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(providerid, type, privilege_func,
+ user_data, _getuid());
+}
API int pkgmgrinfo_appinfo_get_support_mode(pkgmgrinfo_appinfo_h handle, int *support_mode)
{