* limitations under the License.
*
*/
-
+
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <dlfcn.h>
-#include <grp.h>
-#include <pwd.h>
#include <sys/smack.h>
+#include <linux/limits.h>
+#include <libgen.h>
+#include <grp.h>
#include <libxml/parser.h>
#include <libxml/xmlreader.h>
#include "pkgmgr-info-debug.h"
#include "pkgmgr-info.h"
#include "pkgmgr_parser_db.h"
+#include "pkgmgr_parser_internal.h"
#include <dirent.h>
#include <sys/stat.h>
#define PKG_RO_PATH tzplatform_mkpath(TZ_SYS_RO_APP, "")
#define BLOCK_SIZE 4096 /*in bytes*/
#define BUFSIZE 4096
-#define OWNER_ROOT 0
+#define ROOT_UID 0
#define MMC_PATH tzplatform_mkpath(TZ_SYS_STORAGE, "sdcard")
#define PKG_SD_PATH tzplatform_mkpath3(TZ_SYS_STORAGE, "sdcard", "app2sd/")
#define METADATA_FILTER_QUERY_UNION_CLAUSE " UNION "METADATA_FILTER_QUERY_SELECT_CLAUSE
#define LANGUAGE_LENGTH 2
-#define LIBAIL_PATH "/usr/lib/libail.so.0"
#define SERVICE_NAME "org.tizen.system.deviced"
#define PATH_NAME "/Org/Tizen/System/DeviceD/Mmc"
} pkgmgr_certindexinfo_x;
typedef struct _pkgmgr_pkginfo_x {
+ uid_t uid;
manifest_x *manifest_info;
char *locale;
} pkgmgr_appinfo_x;
typedef struct _pkgmgr_certinfo_x {
+ int for_all_users;
char *pkgid;
char *cert_value;
char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
/*For filter APIs*/
typedef struct _pkgmgrinfo_filter_x {
+ uid_t uid;
GSList *list;
} pkgmgrinfo_filter_x;
char **subapp;
} pkgmgrinfo_appcontrol_x;
+
+typedef struct _db_handle {
+ sqlite3 *dbHandle;
+ int ref;
+} db_handle;
+
+
typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
typedef int (*pkgmgr_handler)(int req_id, const char *pkg_type,
"dist2_signer_cert integer, " \
"PRIMARY KEY(package)) "
-
-#define QUERY_ATTACH "attach database '%s' as Global"
-#define QUERY_CREATE_VIEW_1 "CREATE temp VIEW package_app_app_category as select distinct * " \
- "from (select * from main.package_app_app_category m union select * from Global.package_app_app_category g WHERE m.app_id=g.app_id AND m.category=g.category)"
-#define QUERY_CREATE_VIEW_2 "CREATE temp VIEW package_app_info as select distinct * "\
- "from (select * from main.package_app_info m union select * from Global.package_app_info g WHERE m.package=g.package)"
-#define QUERY_CREATE_VIEW_3 "CREATE temp VIEW package_app_app_control as select distinct * "\
- "from (select * from main.package_app_app_control m union select * from Globalpackage_app_app_control g WHERE m.app_id=g.app_id AND m.operation=g.operation "\
- "AND m.uri_scheme=guri_scheme AND m.mime_type=g.mime_type AND m.subapp_name=g.subapp_name)"
-#define QUERY_CREATE_VIEW_4 "CREATE temp VIEW package_app_localized_info as select distinct * "\
- "from (select * from main.package_app_localized_info m union select * from Global.package_app_localized_info g WHERE m.app_id=g.app_id AND m.app_locale=g.app_locale)"
-#define QUERY_CREATE_VIEW_5 "CREATE temp VIEW package_app_app_metadata as select distinct * "\
- "from (select * from main.package_app_app_metadata m union select * from Global.package_app_app_metadata g WHERE m.app_id=g.app_id AND m.md_key=g.md_key "\
- "AND m.md_value=g.md_value)"
-#define QUERY_CREATE_VIEW_6 "CREATE temp VIEW package_app_share_allowed as select distinct * "\
- "from (select * from main.package_app_share_allowed m union select * from Global.package_app_share_allowed g WHERE m.app_id=g.app_id AND m.data_share_path=g.data_share_path "\
- "AND m.data_share_allowed=g.data_share_allowed)"
-#define QUERY_CREATE_VIEW_7 "CREATE temp VIEW package_app_app_permission as select distinct * "\
- "from (select * from main.package_app_app_permission m union select * from Global.package_app_app_permission g WHERE m.app_id=g.app_id AND m.pm_type=g.pm_type "\
- "AND m.pm_value=g.pm_value)"
-#define QUERY_CREATE_VIEW_8 "CREATE temp VIEW package_app_share_request as select distinct * "\
- "from (select * from main.package_app_share_request m union select * from Global.package_app_share_request g WHERE m.app_id=g.app_id AND m.data_share_request=g.data_share_request)"
-#define QUERY_CREATE_VIEW_9 "CREATE temp VIEW package_app_app_svc as select distinct * "\
- "from (select * from main.package_app_app_svc m union select * from Global.package_app_app_svc g WHERE m.app_id=g.app_id AND m.operation=g.operation "\
- "AND m.uri_scheme=g.uri_scheme AND m.mime_type=g.mime_type AND m.subapp_name=g.subapp_name)"
-#define QUERY_CREATE_VIEW_10 "CREATE temp VIEW package_info as select distinct * "\
- "from (select * from main.package_info m union select * from Global.package_info g WHERE m.package=g.package)"
-#define QUERY_CREATE_VIEW_11 "CREATE temp VIEW package_app_icon_section_info as select distinct * "\
- "from (select * from main.package_app_icon_section_info m union select * from Global.package_app_icon_section_info g WHERE m.app_id=g.app_id "\
- "AND m.app_icon_section=g.app_icon_section AND m.app_icon_resolution=g.app_icon_resolution)"
-#define QUERY_CREATE_VIEW_12 "CREATE temp VIEW package_localized_info as select distinct * "\
- "from (select * from main.package_localized_info m union select * from Global.package_localized_info g WHERE m.package=g.package AND m.package_locale=g.package_locale)"
-#define QUERY_CREATE_VIEW_13 "CREATE temp VIEW package_app_image_info as select distinct * "\
- "from (select * from main.package_localized_info m union select * from Global.package_localized_info g WHERE m.app_id=g.app_id AND m.app_icon_section=g.app_icon_section "\
- "AND m.app_icon_resolution=g.app_icon_resolution)"
-#define QUERY_CREATE_VIEW_14 "CREATE temp VIEW package_privilege_info as select distinct * "\
- "from (select * from main.package_privilege_info m union select * from Global.package_privilege_info g WHERE m.package=g.package AND m.privilege=g.privilege)"
-
-
-
+#define GET_DB(X) (X).dbHandle
char *pkgtype = "rpm";
-__thread sqlite3 *manifest_db = NULL;
-__thread sqlite3 *datacontrol_db = NULL;
-__thread sqlite3 *cert_db = NULL;
+__thread db_handle manifest_db;
+__thread db_handle datacontrol_db;
+__thread db_handle cert_db;
static int __open_manifest_db(uid_t uid);
+static int __close_manifest_db(void);
+static int __open_cert_db(uid_t uid, char* mode);
+static int __close_cert_db(void);
static int __exec_pkginfo_query(char *query, void *data);
static int __exec_certinfo_query(char *query, void *data);
static int __exec_certindexinfo_query(char *query, void *data);
static void __get_filter_condition(gpointer data, char **condition);
static void __get_metadata_filter_condition(gpointer data, char **condition);
static gint __compare_func(gconstpointer data1, gconstpointer data2);
-static int __delete_certinfo(const char *pkgid);
+static int __delete_certinfo(const char *pkgid, uid_t uid);
static int _check_create_Cert_db( sqlite3 *certdb);
static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data);
-static int _pkgmgr_parser_attach_create_view_certdb(sqlite3 *handle, uid_t uid)
+static int _mkdir_for_user(const char* dir, uid_t uid, gid_t gid)
{
- char *error_message = NULL;
- char query_attach[MAX_QUERY_LEN] = {'\0'};
- char query_view[MAX_QUERY_LEN] = {'\0'};
+ int ret;
+ char *fullpath;
+ char *subpath;
- if(uid != GLOBAL_USER){
- snprintf(query_attach, MAX_QUERY_LEN - 1, QUERY_ATTACH, CERT_DB);
- if (SQLITE_OK !=
- sqlite3_exec(handle, query_attach,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- query_attach, error_message);
- sqlite3_free(error_message);
+ fullpath = strdup(dir);
+ subpath = dirname(fullpath);
+ if (strlen(subpath) > 1 && strcmp(subpath, fullpath) != 0) {
+ ret = _mkdir_for_user(fullpath, uid, gid);
+ if (ret == -1) {
+ free(fullpath);
+ return ret;
}
- struct dbtable {
- char *name_table;
- char *primary_key;
- };
+ }
- snprintf(query_view, MAX_QUERY_LEN - 1, "CREATE temp VIEW %s as select distinct * from (select * from main.%s m union select * from Global.%s g WHERE m.%s=g.%s)", "package_cert_index_info", "package_cert_index_info", "package_cert_index_info", "cert_id");
- if (SQLITE_OK !=
- sqlite3_exec(handle, query_view,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- query_view, error_message);
- sqlite3_free(error_message);
- }
- snprintf(query_view, MAX_QUERY_LEN - 1, "CREATE temp VIEW %s as select distinct * from (select * from main.%s m union select * from Global.%s g WHERE m.%s=g.%s)", "package_cert_info", "package_cert_info", "package_cert_info", "package");
- if (SQLITE_OK !=
- sqlite3_exec(handle, query_view,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- query_view, error_message);
- sqlite3_free(error_message);
- }
- }
- return 0;
+ ret = mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
+ if (ret && errno != EEXIST) {
+ free(fullpath);
+ return ret;
+ } else if (ret && errno == EEXIST) {
+ free(fullpath);
+ return 0;
+ }
+
+ if (getuid() == ROOT_UID) {
+ ret = chown(dir, uid, gid);
+ if (ret == -1)
+ _LOGE("FAIL : chown %s %d.%d, because %s", dir, uid,
+ gid, strerror(errno));
+ }
+
+ free(fullpath);
+
+ return 0;
}
+static const char *_get_db_path(uid_t uid) {
+ const char *db_path = NULL;
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
+ tzplatform_set_user(uid);
+ db_path = tzplatform_getenv(TZ_USER_DB);
+ tzplatform_reset_user();
+ } else {
+ db_path = tzplatform_getenv(TZ_SYS_DB);
+ }
+ return db_path;
+}
-static int _pkgmgr_parser_attach_create_view_parserdb(sqlite3 *handle, uid_t uid)
+static int __attach_and_create_view(sqlite3 *handle, const char *db, const char *tables[], uid_t uid)
{
- char *error_message = NULL;
- char query_attach[MAX_QUERY_LEN] = {'\0'};
- char query_view[MAX_QUERY_LEN] = {'\0'};
- if(uid != GLOBAL_USER){
- snprintf(query_attach, MAX_QUERY_LEN - 1, QUERY_ATTACH, MANIFEST_DB);
- if (SQLITE_OK !=
- sqlite3_exec(handle, query_attach,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- query_attach, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_1,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_1, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_2,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_2, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_3,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_3, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_4,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_4, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_5,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_5, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_6,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_6, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_7,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_7, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_8,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_8, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_9,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_9, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_10,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_10, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_11,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_11, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_12,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_12, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_13,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_13, error_message);
- sqlite3_free(error_message);
- }
- if (SQLITE_OK !=
- sqlite3_exec(handle, QUERY_CREATE_VIEW_14,
- NULL, NULL, &error_message)) {
- _LOGD("Don't execute query = %s error message = %s\n",
- QUERY_CREATE_VIEW_14, error_message);
- sqlite3_free(error_message);
- }
+ int i;
+ char *err;
+ char query[MAX_QUERY_LEN];
+
+ if (uid == GLOBAL_USER || uid == ROOT_UID)
+ return SQLITE_OK;
+
+ snprintf(query, sizeof(query), "ATTACH DATABASE '%s' AS Global", db);
+ if (SQLITE_OK != sqlite3_exec(handle, query, NULL, NULL, &err)) {
+ _LOGD("Don't execute query = %s error message = %s\n", query, err);
+ sqlite3_free(err);
+ return SQLITE_ERROR;
}
- return 0;
-}
+ for (i = 0; tables[i]; i++) {
+ snprintf(query, sizeof(query), "CREATE TEMP VIEW '%s' AS SELECT * \
+ FROM (SELECT *,0 AS for_all_users FROM main.'%s' UNION \
+ SELECT *,1 AS for_all_users FROM Global.'%s')",
+ tables[i], tables[i], tables[i]);
+ if (SQLITE_OK != sqlite3_exec(handle, query, NULL, NULL, &err)) {
+ _LOGD("Don't execute query = %s error message = %s\n", query, err);
+ sqlite3_free(err);
+ }
+ }
+ return SQLITE_OK;
+}
static int _check_create_Cert_db( sqlite3 *certdb)
{
return ret;
}
+static gid_t _get_gid(const char *name)
+{
+ char buf[BUFSIZE];
+ struct group entry;
+ struct group *ge;
+ int ret;
+
+ ret = getgrnam_r(name, &entry, buf, sizeof(buf), &ge);
+ if (ret || ge == NULL) {
+ _LOGE("fail to get gid of %s", name);
+ return -1;
+ }
+ return entry.gr_gid;
+}
API char *getIconPath(uid_t uid)
{
- char *result = NULL;
- struct group *grpinfo = NULL;
- char * dir = NULL;
- struct passwd *userinfo = getpwuid(uid);
+ const char *path = NULL;
+ uid_t uid_caller = getuid();
+ gid_t gid = ROOT_UID;
- if (uid == 0) {
- _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
- if (uid != GLOBAL_USER) {
- if (userinfo == NULL) {
- _LOGE("getpwuid(%d) returns NULL !", uid);
- return NULL;
- }
- grpinfo = getgrnam("users");
- if (grpinfo == NULL) {
- _LOGE("getgrnam(users) returns NULL !");
- return NULL;
- }
- // Compare git_t type and not group name
- if (grpinfo->gr_gid != userinfo->pw_gid) {
- _LOGE("UID [%d] does not belong to 'users' group!", uid);
- return NULL;
- }
- asprintf(&result, "%s/.applications/icons/", userinfo->pw_dir);
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
+ tzplatform_set_user(uid);
+ path = tzplatform_mkpath(TZ_USER_ICONS, "/");
+ gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+ tzplatform_reset_user();
} else {
- result = tzplatform_mkpath(TZ_SYS_RW_ICONS, "/");
+ path = tzplatform_mkpath(TZ_SYS_RW_ICONS, "/");
}
- int ret = mkdir(result, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
- if (ret == -1 && errno != EEXIST) {
- _LOGE("FAIL : to create directory %s %d", result, errno);
- } else if (getuid() == OWNER_ROOT) {
- ret = chown(result, uid, ((grpinfo)?grpinfo->gr_gid:0));
- if (ret == -1) {
- char buf[BUFSIZE];
- strerror_r(errno, buf, sizeof(buf));
- _LOGE("FAIL : chown %s %d.%d, because %s", result, uid, ((grpinfo)?grpinfo->gr_gid:0), buf);
- }
- }
- return result;
+ // just allow certain users to create the icon directory if needed.
+ if (uid_caller == ROOT_UID || uid_caller == uid)
+ _mkdir_for_user(path, uid, gid);
+
+ return path;
}
API char *getUserPkgParserDBPath(void)
{
- return getUserPkgParserDBPathUID(GLOBAL_USER);
+ return getUserPkgParserDBPathUID(GLOBAL_USER);
}
API char *getUserPkgParserDBPathUID(uid_t uid)
{
- char *result = NULL;
- char *journal = NULL;
- struct group *grpinfo = NULL;
- char * dir = NULL;
- struct passwd *userinfo = getpwuid(uid);
+ const char *pkgmgr_parser_db = NULL;
+ uid_t uid_caller = getuid();
+ gid_t gid = ROOT_UID;
- if (uid == 0) {
- _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
- if (uid != GLOBAL_USER) {
- if (userinfo == NULL) {
- _LOGE("getpwuid(%d) returns NULL !", uid);
- return NULL;
- }
- grpinfo = getgrnam("users");
- if (grpinfo == NULL) {
- _LOGE("getgrnam(users) returns NULL !");
- return NULL;
- }
- // Compare git_t type and not group name
- if (grpinfo->gr_gid != userinfo->pw_gid) {
- _LOGE("UID [%d] does not belong to 'users' group!", uid);
- return NULL;
- }
- asprintf(&result, "%s/.applications/dbspace/.pkgmgr_parser.db", userinfo->pw_dir);
- asprintf(&journal, "%s/.applications/dbspace/.pkgmgr_parser.db-journal", userinfo->pw_dir);
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
+ tzplatform_set_user(uid);
+ pkgmgr_parser_db = tzplatform_mkpath(TZ_USER_DB, ".pkgmgr_parser.db");
+ gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+ tzplatform_reset_user();
} else {
- result = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db");
- journal = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db-journal");
+ pkgmgr_parser_db = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db");
}
- char *temp = strdup(result);
- dir = strrchr(temp, '/');
- if(!dir)
- {
- free(temp);
- return result;
- }
- *dir = 0;
- int ret = mkdir(temp, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
- if (ret == -1 && errno != EEXIST) {
- _LOGE("FAIL : to create directory %s %d", temp, errno);
- } else if (getuid() == OWNER_ROOT) {
- ret = chown(temp, uid, ((grpinfo)?grpinfo->gr_gid:0));
- if (ret == -1) {
- char buf[BUFSIZE];
- strerror_r(errno, buf, sizeof(buf));
- _LOGE("FAIL : chown %s %d.%d, because %s", temp, uid, ((grpinfo)?grpinfo->gr_gid:0), buf);
- }
+ // just allow certain users to create the dbspace directory if needed.
+ if (uid_caller == ROOT_UID || uid_caller == uid) {
+ const char *db_path = _get_db_path(uid);
+ _mkdir_for_user(db_path, uid, gid);
}
- free(temp);
- return result;
+
+ return pkgmgr_parser_db;
}
API char *getUserPkgCertDBPath(void)
API char *getUserPkgCertDBPathUID(uid_t uid)
{
- char *result = NULL;
- char *journal = NULL;
- struct group *grpinfo = NULL;
- char * dir = NULL;
- struct passwd *userinfo = getpwuid(uid);
+ const char *pkgmgr_cert_db = NULL;
+ uid_t uid_caller = getuid();
+ gid_t gid = ROOT_UID;
- if (uid == 0) {
- _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
- if (uid != GLOBAL_USER) {
- if (userinfo == NULL) {
- _LOGE("getpwuid(%d) returns NULL !", uid);
- return NULL;
- }
- grpinfo = getgrnam("users");
- if (grpinfo == NULL) {
- _LOGE("getgrnam(users) returns NULL !");
- return NULL;
- }
- // Compare git_t type and not group name
- if (grpinfo->gr_gid != userinfo->pw_gid) {
- _LOGE("UID [%d] does not belong to 'users' group!", uid);
- return NULL;
- }
- asprintf(&result, "%s/.applications/dbspace/.pkgmgr_cert.db", userinfo->pw_dir);
- asprintf(&journal, "%s/.applications/dbspace/.pkgmgr_cert.db-journal", userinfo->pw_dir);
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
+ tzplatform_set_user(uid);
+ pkgmgr_cert_db = tzplatform_mkpath(TZ_USER_DB, ".pkgmgr_cert.db");
+ gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+ tzplatform_reset_user();
} else {
- result = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db");
- journal = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db-journal");
+ pkgmgr_cert_db = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_cert.db");
}
- char *temp = strdup(result);
- dir = strrchr(temp, '/');
- if(!dir)
- {
- free(temp);
- return result;
+
+ // just allow certain users to create the dbspace directory if needed.
+ if (uid_caller == ROOT_UID || uid_caller == uid) {
+ const char *db_path = _get_db_path(uid);
+ _mkdir_for_user(db_path, uid, gid);
}
- *dir = 0;
- int ret = mkdir(temp, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
- if (ret == -1 && errno != EEXIST) {
- _LOGE("FAIL : to create directory %s %d", temp, errno);
- } else if (getuid() == OWNER_ROOT) {
- ret = chown(temp, uid, ((grpinfo)?grpinfo->gr_gid:0));
- if (ret == -1) {
- char buf[BUFSIZE];
- strerror_r(errno, buf, sizeof(buf));
- _LOGE("FAIL : chown %s %d.%d, because %s", temp, uid, ((grpinfo)?grpinfo->gr_gid:0), buf);
- }
- }
- free(temp);
- return result;
+ return pkgmgr_cert_db;
}
API const char* getUserDesktopPath(uid_t uid)
{
- char *result = NULL;
- struct group *grpinfo = NULL;
- char * dir = NULL;
- struct passwd *userinfo = getpwuid(uid);
+ const char *path = NULL;
+ uid_t uid_caller = getuid();
+ gid_t gid = ROOT_UID;
- if (uid == 0) {
- _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
- if (uid != GLOBAL_USER) {
- if (userinfo == NULL) {
- _LOGE("getpwuid(%d) returns NULL !", uid);
- return NULL;
- }
- grpinfo = getgrnam("users");
- if (grpinfo == NULL) {
- _LOGE("getgrnam(users) returns NULL !");
- return NULL;
- }
- // Compare git_t type and not group name
- if (grpinfo->gr_gid != userinfo->pw_gid) {
- _LOGE("UID [%d] does not belong to 'users' group!", uid);
- return NULL;
- }
- asprintf(&result, "%s/.applications/desktop/", userinfo->pw_dir);
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
+ tzplatform_set_user(uid);
+ path = tzplatform_mkpath(TZ_USER_DESKTOP, "/");
+ gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+ tzplatform_reset_user();
} else {
- result = tzplatform_mkpath(TZ_SYS_RW_DESKTOP_APP, "/");
+ path = tzplatform_mkpath(TZ_SYS_RW_DESKTOP_APP, "/");
}
- int ret = mkdir(result, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
- if (ret == -1 && errno != EEXIST) {
- _LOGE("FAIL : to create directory %s %d", result, errno);
- } else if (getuid() == OWNER_ROOT) {
- ret = chown(result, uid,((grpinfo)?grpinfo->gr_gid:0));
- if (ret == -1) {
- char buf[BUFSIZE];
- strerror_r(errno, buf, sizeof(buf));
- _LOGE("FAIL : chown %s %d.%d, because %s", result, uid, ((grpinfo)?grpinfo->gr_gid:0), buf);
- }
- }
- return result;
+ // just allow certain users to create the icon directory if needed.
+ if (uid_caller == ROOT_UID || uid_caller == uid)
+ _mkdir_for_user(path, uid, gid);
+
+ return path;
}
API const char* getUserManifestPath(uid_t uid)
{
- char *result = NULL;
- struct group *grpinfo = NULL;
- char * dir = NULL;
- struct passwd *userinfo = getpwuid(uid);
+ const char *path = NULL;
+ uid_t uid_caller = getuid();
+ gid_t gid = ROOT_UID;
- if (uid == 0) {
- _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
- if (uid != GLOBAL_USER) {
- if (userinfo == NULL) {
- _LOGE("getpwuid(%d) returns NULL !", uid);
- return NULL;
- }
- grpinfo = getgrnam("users");
- if (grpinfo == NULL) {
- _LOGE("getgrnam(users) returns NULL !");
- return NULL;
- }
- // Compare git_t type and not group name
- if (grpinfo->gr_gid != userinfo->pw_gid) {
- _LOGE("UID [%d] does not belong to 'users' group!", uid);
- return NULL;
- }
- asprintf(&result, "%s/.applications/manifest/", userinfo->pw_dir);
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
+ tzplatform_set_user(uid);
+ path = tzplatform_mkpath(TZ_USER_PACKAGES, "/");
+ gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+ tzplatform_reset_user();
} else {
- result = tzplatform_mkpath(TZ_SYS_RW_PACKAGES, "/");
+ path = tzplatform_mkpath(TZ_SYS_RW_PACKAGES, "/");
}
- int ret = mkdir(result, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
- if (ret == -1 && errno != EEXIST) {
- _LOGE("FAIL : to create directory %s %d", result, errno);
- } else if (getuid() == OWNER_ROOT) {
- ret = chown(result, uid, ((grpinfo)?grpinfo->gr_gid:0));
- if (ret == -1) {
- char buf[BUFSIZE];
- strerror_r(errno, buf, sizeof(buf));
- _LOGE("FAIL : chown %s %d.%d, because %s", result, uid, ((grpinfo)?grpinfo->gr_gid:0), buf);
- }
- }
+ // just allow certain users to create the icon directory if needed.
+ if (uid_caller == ROOT_UID || uid_caller == uid)
+ _mkdir_for_user(path, uid, gid);
- return result;
+ return path;
}
static gint __compare_func(gconstpointer data1, gconstpointer data2)
return;
}
+static int __close_manifest_db(void)
+{
+ if(manifest_db.ref) {
+ if(--manifest_db.ref == 0)
+ sqlite3_close(GET_DB(manifest_db));
+ return 0;
+ }
+ return -1;
+}
+
+static const char *parserdb_tables[] = {
+ "package_app_app_category",
+ "package_app_info",
+ "package_app_app_control",
+ "package_app_localized_info",
+ "package_app_app_metadata",
+ "package_app_share_allowed",
+ "package_app_app_permission",
+ "package_app_share_request",
+ "package_app_app_svc",
+ "package_info",
+ "package_app_data_control",
+ "package_localized_info",
+ "package_app_icon_section_info",
+ "package_privilege_info",
+ "package_app_image_info",
+ NULL
+};
+
static int __open_manifest_db(uid_t uid)
{
int ret = -1;
- if (access(getUserPkgParserDBPathUID(uid), F_OK) == 0) {
- ret =
- db_util_open_with_options(getUserPkgParserDBPathUID(uid), &manifest_db,
- SQLITE_OPEN_READONLY, NULL);
- retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", getUserPkgParserDBPathUID(uid));
+ if(manifest_db.ref) {
+ manifest_db.ref ++;
+ return 0;
+ }
+ const char* user_pkg_parser = getUserPkgParserDBPathUID(uid);
+ if (access(user_pkg_parser, F_OK) != 0) {
+ _LOGE("Manifest DB does not exists !! try to create\n");
+
+ if (pkgmgr_parser_check_and_create_db(uid)) {
+ _LOGE("create db failed");
+ return -1;
+ }
+
+ if (pkgmgr_parser_initialize_db()) {
+ _LOGE("initialize db failed");
+ return -1;
+ }
+ }
+
+ ret = db_util_open_with_options(user_pkg_parser, &GET_DB(manifest_db),
+ SQLITE_OPEN_READONLY, NULL);
+ retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", user_pkg_parser);
+ manifest_db.ref ++;
+ ret = __attach_and_create_view(GET_DB(manifest_db), MANIFEST_DB, parserdb_tables, uid);
+ retvm_if(ret != SQLITE_OK, -1, "attach db [%s] failed!\n", user_pkg_parser);
+
+ return 0;
+}
+
+static int __close_cert_db(void)
+{
+ if(cert_db.ref) {
+ if(--cert_db.ref == 0)
+ sqlite3_close(GET_DB(cert_db));
+ return 0;
+ }
+ _LOGE("Certificate DB is already closed !!\n");
+ return -1;
+}
+
+static const char *certdb_tables[] = {
+ "package_cert_index_info",
+ "package_cert_info",
+ NULL
+};
+
+static int __open_cert_db(uid_t uid, char* mode)
+{
+ int ret = -1;
+ if(cert_db.ref) {
+ cert_db.ref ++;
return 0;
}
- _LOGE("Manifest DB does not exists !!\n");
+
+ const char* user_cert_parser = getUserPkgCertDBPathUID(uid);
+ if (access(user_cert_parser, F_OK) == 0) {
+ ret = db_util_open_with_options(user_cert_parser, &GET_DB(cert_db),
+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
+ retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", user_cert_parser);
+ cert_db.ref ++;
+ if ((strcmp(mode, "w") != 0)) {
+ ret = __attach_and_create_view(GET_DB(cert_db), CERT_DB, certdb_tables, uid);
+ retvm_if(ret != SQLITE_OK, -1, "attach db [%s] failed!\n", user_cert_parser);
+ }
+ return 0;
+ }
+ _LOGE("Cert DB does not exists !!\n");
+ return -1;
+}
+
+static int __close_datacontrol_db(void)
+{
+ if(datacontrol_db.ref) {
+ if(--datacontrol_db.ref == 0)
+ sqlite3_close(GET_DB(datacontrol_db));
+ return 0;
+ }
+ _LOGE("Certificate DB is already closed !!\n");
return -1;
}
static int __open_datacontrol_db()
{
int ret = -1;
+ if(datacontrol_db.ref) {
+ datacontrol_db.ref ++;
+ return 0;
+ }
if (access(DATACONTROL_DB, F_OK) == 0) {
- ret =
- db_util_open_with_options(DATACONTROL_DB, &datacontrol_db,
+ ret = db_util_open_with_options(DATACONTROL_DB, &GET_DB(datacontrol_db),
SQLITE_OPEN_READONLY, NULL);
retvm_if(ret != SQLITE_OK, -1, "connect db [%s] failed!\n", DATACONTROL_DB);
+ datacontrol_db.ref ++;
return 0;
}
_LOGE("Datacontrol DB does not exists !!\n");
info->manifest_info = (manifest_x *)calloc(1, sizeof(manifest_x));
LISTADD(udata, info);
+
for(i = 0; i < ncols; i++)
{
if (strcmp(colname[i], "package") == 0) {
info->manifest_info->package = strdup(coltxt[i]);
else
info->manifest_info->package = NULL;
+ } else if (strcmp(colname[i], "for_all_users") == 0) {
+ if (coltxt[i])
+ info->manifest_info->for_all_users = strdup(coltxt[i]);
+ else
+ info->manifest_info->for_all_users = NULL;
} else
continue;
}
+
+ //by default if views are not set , the column for_all_users doesn't exist,
+ // in this case we assume we retreive information about app avaible for all users
+ if (!info->manifest_info->for_all_users)
+ info->manifest_info->for_all_users = strdup("1");
return 0;
}
info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[i]);
else
info->manifest_info->uiapplication->submode_mainid = NULL;
+ } else if (strcmp(colname, "app_launch_mode") == 0 ) {
+ if (coltxt[i])
+ info->manifest_info->uiapplication->launch_mode = strdup(coltxt[i]);
+ else
+ info->manifest_info->uiapplication->launch_mode = NULL;
} else
continue;
}
info->cert_value = strdup(coltxt[i]);
else
info->cert_value = NULL;
+ } else if (strcmp(colname[i], "for_all_users") == 0 ){
+ if (coltxt[i])
+ info->for_all_users = atoi(coltxt[i]);
+ else
+ info->for_all_users = 0;
} else
continue;
}
info->manifest_info->uiapplication->submode_mainid = strdup(coltxt[j]);
else
info->manifest_info->uiapplication->submode_mainid = NULL;
+ } else if (strcmp(colname[j], "app_launch_mode") == 0 ) {
+ if (coltxt[j])
+ info->manifest_info->uiapplication->launch_mode = strdup(coltxt[j]);
+ else
+ info->manifest_info->uiapplication->launch_mode = NULL;
} else
continue;
}
return 0;
}
+static void __parse_appcontrol(appcontrol_x **appcontrol, char *appcontrol_str)
+{
+ char *dup;
+ char *token;
+ char *ptr;
+ appcontrol_x *ac;
+
+ if (appcontrol_str == NULL)
+ return;
+
+ dup = strdup(appcontrol_str);
+ do {
+ ac = calloc(1, sizeof(appcontrol_x));
+ token = strtok_r(dup, "|", &ptr);
+ if (strcmp(token, "NULL"))
+ ac->operation = strdup(token);
+ token = strtok_r(NULL, "|", &ptr);
+ if (strcmp(token, "NULL"))
+ ac->uri = strdup(token);
+ token = strtok_r(NULL, "|", &ptr);
+ if (strcmp(token, "NULL"))
+ ac->mime = strdup(token);
+ LISTADD(*appcontrol, ac);
+ } while (token = strtok_r(NULL, ";", &ptr));
+
+ free(dup);
+}
+
static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
{
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
metadata_x *metadata = NULL;
permission_x *permission = NULL;
image_x *image = NULL;
+ appcontrol_x *appcontrol = NULL;
switch (info->app_component) {
case PMINFO_UI_APP:
info->uiapp_info->submode_mainid = strdup(coltxt[i]);
else
info->uiapp_info->submode_mainid = NULL;
+ } else if (strcmp(colname[i], "app_launch_mode") == 0 ) {
+ if (coltxt[i])
+ info->uiapp_info->launch_mode = strdup(coltxt[i]);
+ else
+ info->uiapp_info->launch_mode = NULL;
+ } else if (strcmp(colname[i], "app_control") == 0 ) {
+ __parse_appcontrol(&info->uiapp_info->appcontrol, coltxt[i]);
} else
continue;
}
info->svcapp_info->permission_type = strdup(coltxt[i]);
else
info->svcapp_info->permission_type = NULL;
+ } else if (strcmp(colname[i], "app_control") == 0 ) {
+ __parse_appcontrol(&info->svcapp_info->appcontrol, coltxt[i]);
} else
continue;
}
{
char *error_message = NULL;
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __pkginfo_cb, data, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __pkginfo_cb, data, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
{
char *error_message = NULL;
if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certinfo_cb, data, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), query, __certinfo_cb, data, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
{
char *error_message = NULL;
if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), query, __certindexinfo_cb, data, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
static int __exec_db_query(sqlite3 *db, char *query, sqlite_query_callback callback, void *data)
{
char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(db, query, callback, data, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
+ int ret = sqlite3_exec(db, query, callback, data, &error_message);
+ if (SQLITE_OK != ret) {
+ _LOGE("Don't execute query = %s error message = %s ret = %d\n", query,
+ error_message, ret);
sqlite3_free(error_message);
return -1;
}
}
-static int __delete_certinfo(const char *pkgid)
+static int __delete_certinfo(const char *pkgid, uid_t uid)
{
int ret = -1;
int i = 0;
ret = PMINFO_R_ERROR;
goto err;
}
+
+ __open_cert_db(uid, "w");
/*populate certinfo from DB*/
snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
ret = __exec_certinfo_query(query, (void *)certinfo);
snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
}
if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), query, NULL, NULL, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
/*Now delete the entry from db*/
snprintf(query, MAX_QUERY_LEN, "delete from package_cert_info where package='%s'", pkgid);
if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), query, NULL, NULL, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
(certinfo->cert_info)[i] = NULL;
}
}
+ __close_cert_db();
free(certinfo);
certinfo = NULL;
return ret;
retvm_if(pkg_list_cb == NULL, PMINFO_R_EINVAL, "callback function is NULL\n");
char *error_message = NULL;
int ret = PMINFO_R_OK;
+ int ret_db = 0;
+
char query[MAX_QUERY_LEN] = {'\0'};
char *syslocale = NULL;
char *locale = NULL;
return PMINFO_R_ERROR;
}
- ret = __open_manifest_db(uid);
- if (ret == -1) {
+ ret_db = __open_manifest_db(uid);
+ if (ret_db == -1) {
_LOGE("Fail to open manifest DB\n");
free(syslocale);
free(locale);
snprintf(query, MAX_QUERY_LEN, "select * from package_info");
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __pkg_list_cb, (void *)tmphead, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
- sqlite3_close(manifest_db);
ret = PMINFO_R_ERROR;
goto err;
}
for(node = node->next; node ; node = node->next) {
pkginfo = node;
+ pkginfo->uid = uid;
ret = pkg_list_cb( (void *)pkginfo, user_data);
if(ret < 0)
break;
ret = PMINFO_R_OK;
err:
- sqlite3_close(manifest_db);
+ __close_manifest_db();
if (syslocale) {
free(syslocale);
syslocale = NULL;
description_x *tmp3 = NULL;
author_x *tmp4 = NULL;
privilege_x *tmp5 = NULL;
- sqlite3 *pkginfo_db = NULL;
+ const char* user_pkg_parser = NULL;
+
+ *handle = NULL;
/*validate pkgid*/
- ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkginfo_db, SQLITE_OPEN_READONLY, NULL);
- retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
+ user_pkg_parser = getUserPkgParserDBPathUID(uid);
+ ret = __open_manifest_db(uid);
+ retvm_if(ret != SQLITE_OK, PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
/*check pkgid exist on db*/
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_info where package='%s')", pkgid);
- ret = __exec_db_query(pkginfo_db, query, __validate_cb, (void *)&exist);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __validate_cb, (void *)&exist);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec[%s] fail", pkgid);
tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "pkgid[%s] not found in DB", pkgid);
/*populate manifest_info from DB*/
snprintf(query, MAX_QUERY_LEN, "select * from package_info where package='%s' ", pkgid);
- ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
/*populate privilege_info from DB*/
snprintf(query, MAX_QUERY_LEN, "select * from package_privilege_info where package='%s' ", pkgid);
- ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Privilege Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
" package='%s' and package_locale='%s'", pkgid, locale);
- ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
/*Also store the values corresponding to default locales*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_localized_info where" \
" package='%s' and package_locale='%s'", pkgid, DEFAULT_LOCALE);
- ret = __exec_db_query(pkginfo_db, query, __pkginfo_cb, (void *)pkginfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __pkginfo_cb, (void *)pkginfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "Package Info DB Information retrieval failed");
if (pkginfo->manifest_info->label) {
*handle = NULL;
__cleanup_pkginfo(pkginfo);
}
- sqlite3_close(pkginfo_db);
-
+ __close_manifest_db();
if (syslocale) {
free(syslocale);
syslocale = NULL;
retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
char *val = NULL;
- char *location = NULL;
pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- location = (char *)info->manifest_info->installlocation;
val = (char *)info->manifest_info->package_size;
if (val) {
*size = atoi(val);
int ret = PMINFO_R_OK;
char query[MAX_QUERY_LEN] = {'\0'};
char *error_message = NULL;
- pkgmgr_cert_x *info= NULL;
+ sqlite3_stmt *stmt = NULL;
+ char *lhs_certinfo = NULL;
+ char *rhs_certinfo = NULL;
int lcert = 0;
int rcert = 0;
int exist = -1;
+ int i;
+ int is_global = 0;
*compare_result = PMINFO_CERT_COMPARE_ERROR;
- info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
- retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
- ret = db_util_open_with_options(getUserPkgCertDBPathUID(uid), &cert_db,
- SQLITE_OPEN_READWRITE, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("connect db [%s] failed!\n", getUserPkgCertDBPathUID(uid));
+ ret = __open_cert_db(uid, "r");
+ if (ret != 0) {
ret = PMINFO_R_ERROR;
goto err;
}
- _check_create_Cert_db(cert_db);
- _pkgmgr_parser_attach_create_view_certdb(cert_db,uid);
+ _check_create_Cert_db(GET_DB(cert_db));
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", lhs_package_id);
if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), query, __validate_cb, (void *)&exist, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
ret = PMINFO_R_ERROR;
goto err;
}
-
- if (exist == 0) {
- lcert = 0;
- } else {
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- lcert = info->cert_id;
- }
+ lcert = exist;
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), query, __validate_cb, (void *)&exist, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
ret = PMINFO_R_ERROR;
goto err;
}
+ rcert = exist;
- if (exist == 0) {
- rcert = 0;
- } else {
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
- if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __cert_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
+ if (uid == GLOBAL_USER || uid == ROOT_UID) {
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=(select author_signer_cert from package_cert_info where package=?)");
+ is_global = 1;
+ } else
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=(select author_signer_cert from package_cert_info where package=?) and for_all_users=(select for_all_users from package_cert_info where package=?)");
+ if (SQLITE_OK != sqlite3_prepare_v2(GET_DB(cert_db), query, strlen(query), &stmt, NULL)) {
+ _LOGE("sqlite3_prepare_v2 error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+
+ for (i = 1; i <= 2 - is_global; i++) {
+ if (SQLITE_OK != sqlite3_bind_text(stmt, i, lhs_package_id, -1, SQLITE_STATIC)) {
+ _LOGE("sqlite3_bind_text error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ }
+ if (SQLITE_ROW != sqlite3_step(stmt) || sqlite3_column_text(stmt, 0) == NULL) {
+ _LOGE("sqlite3_step error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+
+ lhs_certinfo = strdup((const char *)sqlite3_column_text(stmt, 0));
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+
+ for (i = 1; i <= 2 - is_global; i++) {
+ if (SQLITE_OK != sqlite3_bind_text(stmt, i, rhs_package_id, -1, SQLITE_STATIC)) {
+ _LOGE("sqlite3_bind_text error: %s", sqlite3_errmsg(GET_DB(cert_db)));
ret = PMINFO_R_ERROR;
goto err;
}
- rcert = info->cert_id;
+ }
+ if (SQLITE_ROW != sqlite3_step(stmt) || sqlite3_column_text(stmt, 0) == NULL) {
+ _LOGE("sqlite3_step error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+ ret = PMINFO_R_ERROR;
+ goto err;
}
+ rhs_certinfo = strdup((const char *)sqlite3_column_text(stmt, 0));
+
if ((lcert == 0) || (rcert == 0))
{
if ((lcert == 0) && (rcert == 0))
else if (rcert == 0)
*compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
} else {
- if (lcert == rcert)
+ if (!strcmp(lhs_certinfo, rhs_certinfo))
*compare_result = PMINFO_CERT_COMPARE_MATCH;
else
*compare_result = PMINFO_CERT_COMPARE_MISMATCH;
}
err:
+ if (stmt)
+ sqlite3_finalize(stmt);
+ if (lhs_certinfo)
+ free(lhs_certinfo);
+ if (rhs_certinfo)
+ free(rhs_certinfo);
sqlite3_free(error_message);
- sqlite3_close(cert_db);
- if (info) {
- if (info->pkgid) {
- free(info->pkgid);
- info->pkgid = NULL;
- }
- free(info);
- info = NULL;
- }
+ __close_cert_db();
+
return ret;
}
int exist = -1;
char *lpkgid = NULL;
char *rpkgid = NULL;
+ const char* user_pkg_parser = getUserPkgParserDBPath();
info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
- ret = db_util_open_with_options(getUserPkgParserDBPath(), &manifest_db,
+ ret = db_util_open_with_options(user_pkg_parser, &GET_DB(manifest_db),
SQLITE_OPEN_READONLY, NULL);
if (ret != SQLITE_OK) {
- _LOGE("connect db [%s] failed!\n", getUserPkgParserDBPath());
+ _LOGE("connect db [%s] failed!\n", user_pkg_parser);
ret = PMINFO_R_ERROR;
goto err;
}
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __validate_cb, (void *)&exist, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
ret = PMINFO_R_ERROR;
} else {
snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __cert_cb, (void *)info, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
ret = PMINFO_R_ERROR;
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __validate_cb, (void *)&exist, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
ret = PMINFO_R_ERROR;
} else {
snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __cert_cb, (void *)info, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
ret = PMINFO_R_ERROR;
ret = pkgmgrinfo_pkginfo_compare_pkg_cert_info(lpkgid, rpkgid, compare_result);
err:
sqlite3_free(error_message);
- sqlite3_close(manifest_db);
+ __close_manifest_db();
if (info) {
if (info->pkgid) {
free(info->pkgid);
info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
- ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &manifest_db,
- SQLITE_OPEN_READONLY, NULL);
+ ret = __open_manifest_db(uid);
if (ret != SQLITE_OK) {
_LOGE("connect db [%s] failed!\n", getUserPkgParserDBPathUID(uid));
ret = PMINFO_R_ERROR;
goto err;
}
- _pkgmgr_parser_attach_create_view_parserdb(manifest_db,uid);
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", lhs_app_id);
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __validate_cb, (void *)&exist, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
ret = PMINFO_R_ERROR;
} else {
snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", lhs_app_id);
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __cert_cb, (void *)info, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
ret = PMINFO_R_ERROR;
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", rhs_app_id);
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __validate_cb, (void *)&exist, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __validate_cb, (void *)&exist, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
ret = PMINFO_R_ERROR;
} else {
snprintf(query, MAX_QUERY_LEN, "select package from package_app_info where app_id='%s' ", rhs_app_id);
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __cert_cb, (void *)info, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __cert_cb, (void *)info, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
ret = PMINFO_R_ERROR;
ret = pkgmgrinfo_pkginfo_compare_usr_pkg_cert_info(lpkgid, rpkgid, uid, compare_result);
err:
sqlite3_free(error_message);
- sqlite3_close(manifest_db);
+ __close_manifest_db();
if (info) {
if (info->pkgid) {
free(info->pkgid);
return PMINFO_R_OK;
}
+API int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(for_all_users == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ char *val = NULL;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ val = (char *)info->manifest_info->for_all_users;
+ if (val) {
+ if (strcasecmp(val, "1") == 0)
+ *for_all_users = 1;
+ else if (strcasecmp(val, "0") == 0)
+ *for_all_users = 0;
+ else
+ *for_all_users = 1;
+ }
+ return PMINFO_R_OK;
+}
+
+
API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
{
retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
int ret = 0;
pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x*)handle;
+ filter->uid = uid;
/*Get current locale*/
syslocale = vconf_get_str(VCONFKEY_LANGSET);
if (syslocale == NULL) {
where[sizeof(where) - 1] = '\0';
}
}
- _LOGE("where = %s\n", where);
if (strlen(where) > 0) {
strncat(query, where, sizeof(query) - strlen(query) - 1);
query[sizeof(query) - 1] = '\0';
}
- _LOGE("query = %s\n", query);
/*Execute Query*/
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __count_cb, (void *)count, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
- sqlite3_close(manifest_db);
ret = PMINFO_R_ERROR;
*count = 0;
goto err;
free(syslocale);
syslocale = NULL;
}
- sqlite3_close(manifest_db);
+ __close_manifest_db();
return ret;
}
where[sizeof(where) - 1] = '\0';
}
}
- _LOGE("where = %s\n", where);
if (strlen(where) > 0) {
strncat(query, where, sizeof(query) - strlen(query) - 1);
query[sizeof(query) - 1] = '\0';
}
- _LOGE("query = %s\n", query);
tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
if (tmphead == NULL) {
_LOGE("Out of Memory!!!\n");
goto err;
}
+ tmphead->uid = uid;
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __pkg_list_cb, (void *)tmphead, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __pkg_list_cb, (void *)tmphead, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
for(node = node->next ; node ; node = node->next) {
pkginfo = node;
+ pkginfo->uid = uid;
ret = pkg_cb( (void *)pkginfo, user_data);
if(ret < 0)
break;
free(syslocale);
syslocale = NULL;
}
- sqlite3_close(manifest_db);
+ __close_manifest_db();
__cleanup_pkginfo(tmphead);
return ret;
}
metadata_x *ptr4 = NULL;
permission_x *ptr5 = NULL;
image_x *ptr6 = NULL;
- sqlite3 *appinfo_db = NULL;
+ appcontrol_x *ptr7 = NULL;
+ const char* user_pkg_parser = NULL;
/*get system locale*/
syslocale = vconf_get_str(VCONFKEY_LANGSET);
appinfo->app_component = PMINFO_ALL_APP;
/*open db */
- ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
- tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
+ user_pkg_parser = getUserPkgParserDBPathUID(uid);
+ ret = __open_manifest_db(uid);
+ tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
appinfo->package = strdup(info->manifest_info->package);
snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
switch(component) {
case PMINFO_UI_APP:
/*Populate ui app info */
- ret = __exec_db_query(appinfo_db, query, __uiapp_list_cb, (void *)info);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __uiapp_list_cb, (void *)info);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
uiapplication_x *tmp = NULL;
if (locale) {
free(locale);
}
- locale = __get_app_locale_by_fallback(appinfo_db, appinfo->uiapp_info->appid, syslocale);
+ locale = __get_app_locale_by_fallback(GET_DB(manifest_db), appinfo->uiapp_info->appid, syslocale);
}
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
/*store setting notification icon section*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
/*store app preview image info*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+ /*store app control info*/
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
+ memset(query, '\0', MAX_QUERY_LEN);
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->label, ptr2);
appinfo->uiapp_info->label = ptr2;
LISTHEAD(appinfo->uiapp_info->image, ptr6);
appinfo->uiapp_info->image = ptr6;
}
+ if (appinfo->uiapp_info->appcontrol) {
+ LISTHEAD(appinfo->uiapp_info->appcontrol, ptr7);
+ appinfo->uiapp_info->appcontrol = ptr7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
break;
case PMINFO_SVC_APP:
/*Populate svc app info */
- ret = __exec_db_query(appinfo_db, query, __svcapp_list_cb, (void *)info);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __svcapp_list_cb, (void *)info);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
serviceapplication_x *tmp1 = NULL;
appinfo->svcapp_info = tmp1;
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->svcapp_info->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->label, ptr2);
appinfo->svcapp_info->label = ptr2;
LISTHEAD(appinfo->svcapp_info->permission, ptr5);
appinfo->svcapp_info->permission = ptr5;
}
+ if (appinfo->svcapp_info->appcontrol) {
+ LISTHEAD(appinfo->svcapp_info->appcontrol, ptr7);
+ appinfo->svcapp_info->appcontrol = ptr7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where package='%s'", info->manifest_info->package);
/*Populate all app info */
- ret = __exec_db_query(appinfo_db, query, __allapp_list_cb, (void *)allinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __allapp_list_cb, (void *)allinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info list retrieval failed");
/*UI Apps*/
appinfo->uiapp_info = tmp2;
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, locale);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->uiapp_info->appid, DEFAULT_LOCALE);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
/*store setting notification icon section*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appinfo->uiapp_info->appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
/*store app preview image info*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appinfo->uiapp_info->appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+ /*store app control info*/
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->label, ptr2);
appinfo->uiapp_info->label = ptr2;
LISTHEAD(appinfo->uiapp_info->image, ptr6);
appinfo->uiapp_info->image = ptr6;
}
+ if (appinfo->uiapp_info->appcontrol) {
+ LISTHEAD(appinfo->uiapp_info->appcontrol, ptr7);
+ appinfo->uiapp_info->appcontrol = ptr7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
appinfo->svcapp_info = tmp3;
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, locale);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appinfo->svcapp_info->appid, DEFAULT_LOCALE);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->svcapp_info->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->label, ptr2);
appinfo->svcapp_info->label = ptr2;
LISTHEAD(appinfo->svcapp_info->permission, ptr5);
appinfo->svcapp_info->permission = ptr5;
}
+ if (appinfo->svcapp_info->appcontrol) {
+ LISTHEAD(appinfo->svcapp_info->appcontrol, ptr7);
+ appinfo->svcapp_info->appcontrol = ptr7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
}
__cleanup_pkginfo(allinfo);
- sqlite3_close(appinfo_db);
+ __close_manifest_db();
return ret;
}
pkgmgr_appinfo_x *appinfo = NULL;
uiapplication_x *ptr1 = NULL;
serviceapplication_x *ptr2 = NULL;
- sqlite3 *appinfo_db = NULL;
+ const char* user_pkg_parser = NULL;
/*open db*/
- ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
- retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
+ user_pkg_parser = getUserPkgParserDBPathUID(uid);
+ ret = __open_manifest_db(uid);
+ retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
/*calloc pkginfo*/
pkgmgr_pkginfo_x *info = NULL;
tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
- ret = __exec_db_query(appinfo_db, query, __mini_appinfo_cb, (void *)info);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __mini_appinfo_cb, (void *)info);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
if (info->manifest_info->uiapplication) {
ret = PMINFO_R_OK;
catch:
- sqlite3_close(appinfo_db);
-
+ __close_manifest_db();
if (appinfo) {
free(appinfo);
appinfo = NULL;
metadata_x *tmp4 = NULL;
permission_x *tmp5 = NULL;
image_x *tmp6 = NULL;
- sqlite3 *appinfo_db = NULL;
+ appcontrol_x *tmp7 = NULL;
+ const char *user_pkg_parser = NULL;
/*get system locale*/
syslocale = vconf_get_str(VCONFKEY_LANGSET);
tryvm_if(locale == NULL, ret = PMINFO_R_ERROR, "manifest locale is NULL");
/*open db*/
- ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
- retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
+ user_pkg_parser = getUserPkgParserDBPathUID(uid);
+ ret = __open_manifest_db(uid);
+ retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
/*calloc pkginfo*/
pkgmgr_pkginfo_x *info = NULL;
tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!");
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info");
- ret = __exec_db_query(appinfo_db, query, __app_list_cb, (void *)info);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __app_list_cb, (void *)info);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
if (info->manifest_info->uiapplication) {
snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
"from package_app_info where " \
"app_id='%s'", ptr1->appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
if (strcmp(appinfo->uiapp_info->type,"c++app") == 0){
if (locale) {
free(locale);
}
- locale = __get_app_locale_by_fallback(appinfo_db, ptr1->appid, syslocale);
+ locale = __get_app_locale_by_fallback(GET_DB(manifest_db), ptr1->appid, syslocale);
}
memset(query, '\0', MAX_QUERY_LEN);
"from package_app_localized_info where " \
"app_id='%s' and app_locale='%s'",
ptr1->appid, locale);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
"app_id='%s' and app_locale='%s'",
ptr1->appid, DEFAULT_LOCALE);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
/*store setting notification icon section*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
-
+
/*store app preview image info*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+ /*store app control info*/
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", ptr1->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->label, tmp1);
appinfo->uiapp_info->label = tmp1;
LISTHEAD(appinfo->uiapp_info->image, tmp6);
appinfo->uiapp_info->image = tmp6;
}
+ if (appinfo->uiapp_info->appcontrol) {
+ LISTHEAD(appinfo->uiapp_info->appcontrol, tmp7);
+ appinfo->uiapp_info->appcontrol = tmp7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
snprintf(query, MAX_QUERY_LEN, "select DISTINCT * " \
"from package_app_info where " \
"app_id='%s'", ptr2->appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
"from package_app_localized_info where " \
"app_id='%s' and app_locale='%s'",
ptr2->appid, locale);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
"from package_app_localized_info where " \
"app_id='%s' and app_locale='%s'",
ptr2->appid, DEFAULT_LOCALE);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", ptr2->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->label, tmp1);
appinfo->svcapp_info->label = tmp1;
LISTHEAD(appinfo->svcapp_info->permission, tmp5);
appinfo->svcapp_info->permission = tmp5;
}
+ if (appinfo->svcapp_info->appcontrol) {
+ LISTHEAD(appinfo->svcapp_info->appcontrol, tmp7);
+ appinfo->svcapp_info->appcontrol = tmp7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
free(syslocale);
syslocale = NULL;
}
- sqlite3_close(appinfo_db);
+ __close_manifest_db();
if (appinfo) {
free(appinfo);
appinfo = NULL;
metadata_x *tmp4 = NULL;
permission_x *tmp5 = NULL;
image_x *tmp6 = NULL;
+ appcontrol_x *tmp7 = NULL;
char query[MAX_QUERY_LEN] = {'\0'};
- sqlite3 *appinfo_db = NULL;
+ const char* user_pkg_parser = NULL;
- /*open db*/
- _LOGD("getUserPkgParserDBPathUID(%d) returns: [%s]", uid, getUserPkgParserDBPathUID(uid));
- ret = db_util_open_with_options(getUserPkgParserDBPathUID(uid), &appinfo_db, SQLITE_OPEN_READONLY, NULL);
- retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", getUserPkgParserDBPathUID(uid));
+ *handle = NULL;
+ /*open db*/
+ user_pkg_parser = getUserPkgParserDBPathUID(uid);
+ ret = __open_manifest_db(uid);
+ retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", user_pkg_parser);
/*check appid exist on db*/
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_app_info where app_id='%s')", appid);
- ret = __exec_db_query(appinfo_db, query, __validate_cb, (void *)&exist);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __validate_cb, (void *)&exist);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "sqlite3_exec fail");
tryvm_if(exist == 0, ret = PMINFO_R_ERROR, "Appid[%s] not found in DB", appid);
/*check app_component from DB*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select app_component, package from package_app_info where app_id='%s' ", appid);
- ret = __exec_db_query(appinfo_db, query, __appcomponent_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appcomponent_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
/*calloc app_component*/
/*populate app_info from DB*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' ", appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, locale);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
/*Also store the values corresponding to default locales*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_localized_info where app_id='%s' and app_locale='%s'", appid, DEFAULT_LOCALE);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
/*Populate app category*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_category where app_id='%s'", appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Category Info DB Information retrieval failed");
/*Populate app metadata*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_metadata where app_id='%s'", appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Metadata Info DB Information retrieval failed");
/*Populate app permission*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_app_permission where app_id='%s'", appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App permission Info DB Information retrieval failed");
/*store setting notification icon section*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
/*store app preview image info*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", appid);
- ret = __exec_db_query(appinfo_db, query, __appinfo_cb, (void *)appinfo);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+ /*store app control info*/
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
switch (appinfo->app_component) {
case PMINFO_UI_APP:
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->image, tmp6);
appinfo->uiapp_info->image = tmp6;
}
+ if (appinfo->uiapp_info->appcontrol) {
+ LISTHEAD(appinfo->uiapp_info->appcontrol, tmp7);
+ appinfo->uiapp_info->appcontrol = tmp7;
+ }
break;
case PMINFO_SVC_APP:
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->permission, tmp5);
appinfo->svcapp_info->permission = tmp5;
}
+ if (appinfo->svcapp_info->appcontrol) {
+ LISTHEAD(appinfo->svcapp_info->appcontrol, tmp7);
+ appinfo->svcapp_info->appcontrol = tmp7;
+ }
break;
default:
break;
__cleanup_appinfo(appinfo);
}
- sqlite3_close(appinfo_db);
+ __close_manifest_db();
if (syslocale) {
free(syslocale);
syslocale = NULL;
return PMINFO_R_OK;
}
+static char *_get_localed_label(const char *appid, const char *locale, uid_t uid)
+{
+ char *result = NULL;
+ char *query = NULL;
+ sqlite3_stmt *stmt = NULL;
+ sqlite3 *db = NULL;
+ char *val;
+ char *manifest_db;
+
+ manifest_db = getUserPkgParserDBPathUID(uid);
+ if (manifest_db == NULL) {
+ _LOGE("Failed to get manifest db path");
+ goto err;
+ }
+
+ if (sqlite3_open_v2(manifest_db, &db, SQLITE_OPEN_READONLY, NULL) != SQLITE_OK) {
+ _LOGE("DB open fail\n");
+ goto err;
+ }
+
+ query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", appid, locale);
+ if (query == NULL) {
+ _LOGE("Out of memory");
+ goto err;
+ }
+
+ if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) {
+ _LOGE("prepare_v2 fail\n");
+ goto err;
+ }
+
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ val = (char *)sqlite3_column_text(stmt, 0);
+ if (val != NULL)
+ result = strdup(val);
+ }
+
+err:
+ sqlite3_finalize(stmt);
+ sqlite3_free(query);
+ sqlite3_close(db);
+
+ return result;
+}
+
+API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid, const char *locale, uid_t uid, char **label)
+{
+ char *val;
+ int ret;
+
+ retvm_if(appid == NULL || locale == NULL || label == NULL, PMINFO_R_EINVAL, "Argument is NULL");
+
+ val = _get_localed_label(appid, locale, uid);
+ if (val == NULL)
+ val = _get_localed_label(appid, DEFAULT_LOCALE, uid);
+
+ if (val == NULL) {
+ ret = PMINFO_R_ERROR;
+ } else {
+ *label = val;
+ ret = PMINFO_R_OK;
+ }
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_localed_label(const char *appid, const char *locale, char **label)
+{
+ return pkgmgrinfo_appinfo_usr_get_localed_label(appid, locale, GLOBAL_USER, label);
+}
API int pkgmgrinfo_appinfo_get_component(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_component *component)
{
return PMINFO_R_OK;
}
+API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_component != PMINFO_UI_APP)
+ return PMINFO_R_EINVAL;
+
+ if (info->uiapp_info->launch_mode == NULL)
+ return PMINFO_R_ERROR;
+
+ *mode = (char *)(info->uiapp_info->launch_mode);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid, const char *type, uid_t uid, char **appid, char **access)
+{
+ retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+ retvm_if(access == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ int ret = PMINFO_R_OK;
+ char *query = NULL;
+ sqlite3_stmt *stmt = NULL;
+
+ /*open db*/
+ ret = __open_manifest_db(uid);
+ retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+
+ /*Start constructing query*/
+ query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q and type=%Q", providerid, type);
+
+ /*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);
+
+ /*step query*/
+ ret = sqlite3_step(stmt);
+ tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
+
+ *appid = strdup((char *)sqlite3_column_text(stmt, 0));
+ *access = strdup((char *)sqlite3_column_text(stmt, 2));
+
+ ret = PMINFO_R_OK;
+
+catch:
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+ __close_manifest_db();
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid, const char *type, char **appid, char **access)
+{
+ return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid, type, GLOBAL_USER, appid, access);
+}
+
+API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid, uid_t uid, char **appid)
+{
+ retvm_if(providerid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
+ retvm_if(appid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ int ret = PMINFO_R_OK;
+ char *query = NULL;
+ sqlite3_stmt *stmt = NULL;
+
+ /*open db*/
+ ret = __open_manifest_db(uid);
+ retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "connect db [%s] failed!", MANIFEST_DB);
+
+ /*Start constructing query*/
+ query = sqlite3_mprintf("select * from package_app_data_control where providerid=%Q", providerid);
+
+ /*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);
+
+ /*step query*/
+ ret = sqlite3_step(stmt);
+ tryvm_if((ret != SQLITE_ROW) || (ret == SQLITE_DONE), ret = PMINFO_R_ERROR, "No records found");
+
+ *appid = strdup((char *)sqlite3_column_text(stmt, 0));
+
+ ret = PMINFO_R_OK;
+
+catch:
+ sqlite3_free(query);
+ sqlite3_finalize(stmt);
+ __close_manifest_db();
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_datacontrol_appid(const char *providerid, char **appid)
+{
+ return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
+}
+
API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
{
return PMINFO_R_OK;
}
-API int pkgmgrinfo_usr_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data, uid_t uid)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
- int i = 0;
- int ret = -1;
- int oc = 0;
- int mc = 0;
- int uc = 0;
- int sc = 0;
- char *pkgid = NULL;
- char *manifest = NULL;
- char **operation = NULL;
- char **uri = NULL;
- char **mime = NULL;
- char **subapp = NULL;
- appcontrol_x *appcontrol = NULL;
- manifest_x *mfx = NULL;
- operation_x *op = NULL;
- uri_x *ui = NULL;
- mime_x *mi = NULL;
- subapp_x *sa = NULL;
- pkgmgrinfo_app_component component;
- pkgmgrinfo_appcontrol_x *ptr = NULL;
- ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
- if (ret < 0) {
- _LOGE("Failed to get package name\n");
- return PMINFO_R_ERROR;
- }
- ret = pkgmgrinfo_appinfo_get_component(handle, &component);
- if (ret < 0) {
- _LOGE("Failed to get app component name\n");
- return PMINFO_R_ERROR;
- }
- manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
- if (manifest == NULL) {
- _LOGE("Failed to fetch package manifest file\n");
- return PMINFO_R_ERROR;
- }
- mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
- if (mfx == NULL) {
- _LOGE("Failed to parse package manifest file\n");
- free(manifest);
- manifest = NULL;
- return PMINFO_R_ERROR;
- }
- free(manifest);
- ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
- if (ptr == NULL) {
- _LOGE("Out of Memory!!!\n");
- pkgmgr_parser_free_manifest_xml(mfx);
- return PMINFO_R_ERROR;
- }
- /*Get Operation, Uri, Mime*/
- switch (component) {
- case PMINFO_UI_APP:
- if (mfx->uiapplication) {
- if (mfx->uiapplication->appsvc) {
- appcontrol = mfx->uiapplication->appsvc;
- }
- }
- break;
- case PMINFO_SVC_APP:
- if (mfx->serviceapplication) {
- if (mfx->serviceapplication->appsvc) {
- appcontrol = mfx->serviceapplication->appsvc;
- }
- }
- break;
- default:
- break;
- }
- for (; appcontrol; appcontrol = appcontrol->next) {
- op = appcontrol->operation;
- for (; op; op = op->next)
- oc = oc + 1;
- op = appcontrol->operation;
-
- ui = appcontrol->uri;
- for (; ui; ui = ui->next)
- uc = uc + 1;
- ui = appcontrol->uri;
-
- mi = appcontrol->mime;
- for (; mi; mi = mi->next)
- mc = mc + 1;
- mi = appcontrol->mime;
-
- sa = appcontrol->subapp;
- for (; sa; sa = sa->next)
- sc = sc + 1;
- sa = appcontrol->subapp;
-
- operation = (char **)calloc(oc, sizeof(char *));
- for (i = 0; i < oc; i++) {
- operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
- op = op->next;
- }
-
- uri = (char **)calloc(uc, sizeof(char *));
- for (i = 0; i < uc; i++) {
- uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
- ui = ui->next;
- }
-
- mime = (char **)calloc(mc, sizeof(char *));
- for (i = 0; i < mc; i++) {
- mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
- mi = mi->next;
- }
-
- subapp = (char **)calloc(sc, sizeof(char *));
- for (i = 0; i < sc; i++) {
- subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
- sa = sa->next;
- }
-
- /*populate appcontrol handle*/
- ptr->operation_count = oc;
- ptr->uri_count = uc;
- ptr->mime_count = mc;
- ptr->subapp_count = sc;
- ptr->operation = operation;
- ptr->uri = uri;
- ptr->mime = mime;
- ptr->subapp = subapp;
-
- ret = appcontrol_func((void *)ptr, user_data);
- for (i = 0; i < oc; i++) {
- if (operation[i]) {
- free(operation[i]);
- operation[i] = NULL;
- }
- }
- if (operation) {
- free(operation);
- operation = NULL;
- }
- for (i = 0; i < uc; i++) {
- if (uri[i]) {
- free(uri[i]);
- uri[i] = NULL;
- }
- }
- if (uri) {
- free(uri);
- uri = NULL;
- }
- for (i = 0; i < mc; i++) {
- if (mime[i]) {
- free(mime[i]);
- mime[i] = NULL;
- }
- }
- if (mime) {
- free(mime);
- mime = NULL;
- }
- for (i = 0; i < sc; i++) {
- if (subapp[i]) {
- free(subapp[i]);
- subapp[i] = NULL;
- }
- }
- if (subapp) {
- free(subapp);
- subapp = NULL;
- }
- if (ret < 0)
- break;
- uc = 0;
- mc = 0;
- oc = 0;
- sc = 0;
- }
- pkgmgr_parser_free_manifest_xml(mfx);
- if (ptr) {
- free(ptr);
- ptr = NULL;
- }
- return PMINFO_R_OK;
-}
-
API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
{
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
- int i = 0;
- int ret = -1;
- int oc = 0;
- int mc = 0;
- int uc = 0;
- int sc = 0;
- char *pkgid = NULL;
- char *manifest = NULL;
- char **operation = NULL;
- char **uri = NULL;
- char **mime = NULL;
- char **subapp = NULL;
- appcontrol_x *appcontrol = NULL;
- manifest_x *mfx = NULL;
- operation_x *op = NULL;
- uri_x *ui = NULL;
- mime_x *mi = NULL;
- subapp_x *sa = NULL;
+ int ret;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ appcontrol_x *appcontrol;
pkgmgrinfo_app_component component;
- pkgmgrinfo_appcontrol_x *ptr = NULL;
- ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
- if (ret < 0) {
- _LOGE("Failed to get package name\n");
- return PMINFO_R_ERROR;
- }
ret = pkgmgrinfo_appinfo_get_component(handle, &component);
if (ret < 0) {
_LOGE("Failed to get app component name\n");
return PMINFO_R_ERROR;
}
- manifest = pkgmgr_parser_get_manifest_file(pkgid);
- if (manifest == NULL) {
- _LOGE("Failed to fetch package manifest file\n");
- return PMINFO_R_ERROR;
- }
- mfx = pkgmgr_parser_process_manifest_xml(manifest);
- if (mfx == NULL) {
- _LOGE("Failed to parse package manifest file\n");
- free(manifest);
- manifest = NULL;
- return PMINFO_R_ERROR;
- }
- free(manifest);
- ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
- if (ptr == NULL) {
- _LOGE("Out of Memory!!!\n");
- pkgmgr_parser_free_manifest_xml(mfx);
- return PMINFO_R_ERROR;
- }
- /*Get Operation, Uri, Mime*/
switch (component) {
case PMINFO_UI_APP:
- if (mfx->uiapplication) {
- if (mfx->uiapplication->appsvc) {
- appcontrol = mfx->uiapplication->appsvc;
- }
- }
+ if (info->uiapp_info == NULL)
+ return PMINFO_R_EINVAL;
+ appcontrol = info->uiapp_info->appcontrol;
break;
case PMINFO_SVC_APP:
- if (mfx->serviceapplication) {
- if (mfx->serviceapplication->appsvc) {
- appcontrol = mfx->serviceapplication->appsvc;
- }
- }
+ if (info->svcapp_info == NULL)
+ return PMINFO_R_EINVAL;
+ appcontrol = info->svcapp_info->appcontrol;
break;
default:
break;
}
for (; appcontrol; appcontrol = appcontrol->next) {
- op = appcontrol->operation;
- for (; op; op = op->next)
- oc = oc + 1;
- op = appcontrol->operation;
-
- ui = appcontrol->uri;
- for (; ui; ui = ui->next)
- uc = uc + 1;
- ui = appcontrol->uri;
-
- mi = appcontrol->mime;
- for (; mi; mi = mi->next)
- mc = mc + 1;
- mi = appcontrol->mime;
-
- sa = appcontrol->subapp;
- for (; sa; sa = sa->next)
- sc = sc + 1;
- sa = appcontrol->subapp;
-
- operation = (char **)calloc(oc, sizeof(char *));
- for (i = 0; i < oc; i++) {
- operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
- op = op->next;
- }
-
- uri = (char **)calloc(uc, sizeof(char *));
- for (i = 0; i < uc; i++) {
- uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
- ui = ui->next;
- }
-
- mime = (char **)calloc(mc, sizeof(char *));
- for (i = 0; i < mc; i++) {
- mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
- mi = mi->next;
- }
-
- subapp = (char **)calloc(sc, sizeof(char *));
- for (i = 0; i < sc; i++) {
- subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
- sa = sa->next;
- }
-
- /*populate appcontrol handle*/
- ptr->operation_count = oc;
- ptr->uri_count = uc;
- ptr->mime_count = mc;
- ptr->subapp_count = sc;
- ptr->operation = operation;
- ptr->uri = uri;
- ptr->mime = mime;
- ptr->subapp = subapp;
-
- ret = appcontrol_func((void *)ptr, user_data);
- for (i = 0; i < oc; i++) {
- if (operation[i]) {
- free(operation[i]);
- operation[i] = NULL;
- }
- }
- if (operation) {
- free(operation);
- operation = NULL;
- }
- for (i = 0; i < uc; i++) {
- if (uri[i]) {
- free(uri[i]);
- uri[i] = NULL;
- }
- }
- if (uri) {
- free(uri);
- uri = NULL;
- }
- for (i = 0; i < mc; i++) {
- if (mime[i]) {
- free(mime[i]);
- mime[i] = NULL;
- }
- }
- if (mime) {
- free(mime);
- mime = NULL;
- }
- for (i = 0; i < sc; i++) {
- if (subapp[i]) {
- free(subapp[i]);
- subapp[i] = NULL;
- }
- }
- if (subapp) {
- free(subapp);
- subapp = NULL;
- }
+ ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
if (ret < 0)
break;
- uc = 0;
- mc = 0;
- oc = 0;
- sc = 0;
- }
- pkgmgr_parser_free_manifest_xml(mfx);
- if (ptr) {
- free(ptr);
- ptr = NULL;
}
+
return PMINFO_R_OK;
}
return PMINFO_R_OK;
}
+API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
+ retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
+
+ category_x *ptr = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ *exist = 0;
+
+ ptr = info->uiapp_info->category;
+
+ for (; ptr; ptr = ptr->next) {
+ if (ptr->name) {
+ if (strcasecmp(ptr->name, category) == 0)
+ {
+ *exist = 1;
+ break;
+ }
+ }
+ }
+
+ return PMINFO_R_OK;
+}
+
API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
{
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
where[sizeof(where) - 1] = '\0';
}
}
- _LOGE("where = %s\n", where);
if (strlen(where) > 0) {
strncat(query, where, sizeof(query) - strlen(query) - 1);
query[sizeof(query) - 1] = '\0';
}
- _LOGE("query = %s\n", query);
/*Execute Query*/
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __count_cb, (void *)count, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __count_cb, (void *)count, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
- sqlite3_close(manifest_db);
ret = PMINFO_R_ERROR;
*count = 0;
goto err;
free(syslocale);
syslocale = NULL;
}
- sqlite3_close(manifest_db);
+ __close_manifest_db();
return ret;
}
where[sizeof(where) - 1] = '\0';
}
}
- _LOGE("where = %s\n", where);
if (strlen(where) > 0) {
strncat(query, where, sizeof(query) - strlen(query) - 1);
query[sizeof(query) - 1] = '\0';
}
- _LOGE("query = %s\n", query);
/*To get filtered list*/
pkgmgr_pkginfo_x *info = NULL;
+ pkgmgr_pkginfo_x *filtinfo = NULL;
info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
if (info == NULL) {
_LOGE("Out of Memory!!!\n");
goto err;
}
/*To get detail app info for each member of filtered list*/
- pkgmgr_pkginfo_x *filtinfo = NULL;
filtinfo = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
if (filtinfo == NULL) {
_LOGE("Out of Memory!!!\n");
goto err;
}
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __app_list_cb, (void *)info, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
- sqlite3_close(manifest_db);
ret = PMINFO_R_ERROR;
goto err;
}
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
ptr1->appid, "uiapp");
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __uiapp_list_cb, (void *)filtinfo, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
- sqlite3_close(manifest_db);
ret = PMINFO_R_ERROR;
goto err;
}
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
ptr2->appid, "svcapp");
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, __svcapp_list_cb, (void *)filtinfo, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
- sqlite3_close(manifest_db);
ret = PMINFO_R_ERROR;
goto err;
}
/*If the callback func return < 0 we break and no more call back is called*/
while(ptr1 != NULL)
{
+ appinfo->package = strdup(ptr1->package);
appinfo->locale = strdup(locale);
appinfo->uiapp_info = ptr1;
appinfo->app_component = PMINFO_UI_APP;
/*If the callback func return < 0 we break and no more call back is called*/
while(ptr2 != NULL)
{
+ appinfo->package = strdup(ptr2->package);
appinfo->locale = strdup(locale);
appinfo->svcapp_info = ptr2;
appinfo->app_component = PMINFO_SVC_APP;
free(syslocale);
syslocale = NULL;
}
- sqlite3_close(manifest_db);
+ __close_manifest_db();
if (appinfo) {
free(appinfo);
appinfo = NULL;
strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
}
}
- _LOGE("where = %s (%d)\n", where, strlen(where));
if (strlen(where) > 0) {
strncat(query, where, sizeof(query) - strlen(query) - 1);
}
- _LOGE("query = %s (%d)\n", query, strlen(query));
/*To get filtered list*/
info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
appinfo = (pkgmgr_appinfo_x *)calloc(1, sizeof(pkgmgr_appinfo_x));
tryvm_if(appinfo == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
- ret = sqlite3_exec(manifest_db, query, __app_list_cb, (void *)info, &error_message);
+ ret = sqlite3_exec(GET_DB(manifest_db), query, __app_list_cb, (void *)info, &error_message);
tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
memset(query, '\0', MAX_QUERY_LEN);
{
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
ptr1->appid, "uiapp");
- ret = sqlite3_exec(manifest_db, query, __uiapp_list_cb, (void *)filtinfo, &error_message);
+ ret = sqlite3_exec(GET_DB(manifest_db), query, __uiapp_list_cb, (void *)filtinfo, &error_message);
tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
memset(query, '\0', MAX_QUERY_LEN);
}
{
snprintf(query, MAX_QUERY_LEN, "select * from package_app_info where app_id='%s' and app_component='%s'",
ptr2->appid, "svcapp");
- ret = sqlite3_exec(manifest_db, query, __svcapp_list_cb, (void *)filtinfo, &error_message);
+ ret = sqlite3_exec(GET_DB(manifest_db), query, __svcapp_list_cb, (void *)filtinfo, &error_message);
tryvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR, "Don't execute query = %s error message = %s\n", query, error_message);
memset(query, '\0', MAX_QUERY_LEN);
}
syslocale = NULL;
}
sqlite3_free(error_message);
- sqlite3_close(manifest_db);
+ __close_manifest_db();
if (appinfo) {
free(appinfo);
appinfo = NULL;
retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_certinfo_x *certinfo = NULL;
certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
+ *handle = NULL;
retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
*handle = (void *)certinfo;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
+API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle, uid_t uid)
{
retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
int i = 0;
/*Open db.*/
- ret = db_util_open_with_options(getUserPkgCertDBPath(), &cert_db,
- SQLITE_OPEN_READWRITE, NULL);
+ ret = __open_cert_db(uid,"r");
if (ret != SQLITE_OK) {
- _LOGE("connect db [%s] failed!\n", getUserPkgCertDBPath());
- return PMINFO_R_ERROR;
+ _LOGE("connect db [%s] failed!\n");
+ ret = PMINFO_R_ERROR;
+ goto err;
}
- _check_create_Cert_db(cert_db);
+ _check_create_Cert_db(GET_DB(cert_db));
/*validate pkgid*/
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), query, __validate_cb, (void *)&exist, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
}
for (i = 0; i < MAX_CERT_TYPE; i++) {
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
+ if (uid == GLOBAL_USER || uid == ROOT_UID)
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d", (certinfo->cert_id)[i]);
+ else
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d and for_all_users=%d", (certinfo->cert_id)[i], certinfo->for_all_users);
ret = __exec_certinfo_query(query, (void *)certinfo);
if (ret == -1) {
_LOGE("Cert Info DB Information retrieval failed\n");
}
}
err:
- sqlite3_close(cert_db);
+ __close_cert_db();
return ret;
}
{
retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_instcertinfo_x *certinfo = NULL;
+ *handle = NULL;
certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
*handle = (void *)certinfo;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
+API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle, uid_t uid)
{
retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
info->pkgid = strdup(pkgid);
/*Open db.*/
- ret = db_util_open_with_options(getUserPkgCertDBPath(), &cert_db,
- SQLITE_OPEN_READWRITE, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("connect db [%s] failed!\n", getUserPkgCertDBPath());
+ ret =__open_cert_db(uid, "w");
+ if (ret != 0) {
ret = PMINFO_R_ERROR;
+ _LOGE("Failed to open cert db \n");
goto err;
}
- _check_create_Cert_db(cert_db);
+ _check_create_Cert_db(GET_DB(cert_db));
/*Begin Transaction*/
- ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("Failed to begin transaction\n");
+ ret = sqlite3_exec(GET_DB(cert_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret == -1) {
+ _LOGE("Failed to begin transaction %s\n");
ret = PMINFO_R_ERROR;
goto err;
}
- _LOGE("Transaction Begin\n");
+
/*Check if request is to insert/update*/
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", pkgid);
if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __validate_cb, (void *)&exist, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), query, __validate_cb, (void *)&exist, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
/*Update request.
We cant just issue update query directly. We need to manage index table also.
Hence it is better to delete and insert again in case of update*/
- ret = __delete_certinfo(pkgid);
+ ret = __delete_certinfo(pkgid, uid);
if (ret < 0)
_LOGE("Certificate Deletion Failed\n");
}
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
if (SQLITE_OK !=
- sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), query, __maxid_cb, (void *)&newid, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
(info->cert_id)[i] = indexinfo->cert_id;
(info->is_new)[i] = is_new;
(info->ref_count)[i] = indexinfo->cert_ref_count;
- _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
indexinfo->cert_id = 0;
indexinfo->cert_ref_count = 0;
is_new = 0;
(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
if (SQLITE_OK !=
- sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), vquery, NULL, NULL, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", vquery,
error_message);
sqlite3_free(error_message);
"where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
}
if (SQLITE_OK !=
- sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
+ sqlite3_exec(GET_DB(cert_db), vquery, NULL, NULL, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", vquery,
error_message);
sqlite3_free(error_message);
}
}
/*Commit transaction*/
- ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
+ ret = sqlite3_exec(GET_DB(cert_db), "COMMIT", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
_LOGE("Failed to commit transaction, Rollback now\n");
- sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
+ sqlite3_exec(GET_DB(cert_db), "ROLLBACK", NULL, NULL, NULL);
ret = PMINFO_R_ERROR;
goto err;
}
- _LOGE("Transaction Commit and End\n");
+
ret = PMINFO_R_OK;
err:
- sqlite3_close(cert_db);
+ __close_cert_db();
if (vquery) {
free(vquery);
vquery = NULL;
retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
int ret = -1;
/*Open db.*/
- ret = db_util_open_with_options(getUserPkgCertDBPathUID(uid), &cert_db,
- SQLITE_OPEN_READWRITE, NULL);
- if (ret != SQLITE_OK) {
+ ret = __open_cert_db(uid, "w");
+ if (ret != 0) {
_LOGE("connect db [%s] failed!\n", getUserPkgCertDBPathUID(uid));
ret = PMINFO_R_ERROR;
goto err;
}
- _check_create_Cert_db(cert_db);
+ _check_create_Cert_db(GET_DB(cert_db));
/*Begin Transaction*/
- ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ ret = sqlite3_exec(GET_DB(cert_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
_LOGE("Failed to begin transaction\n");
ret = PMINFO_R_ERROR;
goto err;
}
_LOGE("Transaction Begin\n");
- ret = __delete_certinfo(pkgid);
+ ret = __delete_certinfo(pkgid, uid);
if (ret < 0) {
_LOGE("Certificate Deletion Failed\n");
} else {
_LOGE("Certificate Deletion Success\n");
}
/*Commit transaction*/
- ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
+ ret = sqlite3_exec(GET_DB(cert_db), "COMMIT", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
_LOGE("Failed to commit transaction, Rollback now\n");
- sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
+ sqlite3_exec(GET_DB(cert_db), "ROLLBACK", NULL, NULL, NULL);
ret = PMINFO_R_ERROR;
goto err;
}
_LOGE("Transaction Commit and End\n");
ret = PMINFO_R_OK;
err:
- sqlite3_close(cert_db);
+ __close_cert_db();
return ret;
}
char *manifest = NULL;
manifest_x *mfx = NULL;
-
+ *handle = NULL;
manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
char *manifest = NULL;
manifest_x *mfx = NULL;
-
+ *handle = NULL;
manifest = pkgmgr_parser_get_manifest_file(pkgid);
retvm_if(manifest == NULL, PMINFO_R_EINVAL, "pkg[%s] dont have manifest file", pkgid);
retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
int ret = -1;
char query[MAX_QUERY_LEN] = {'\0'};
+
+ /* Open db.*/
ret = __open_manifest_db(uid);
+ if (ret != SQLITE_OK) {
+ _LOGE("connect db [%s] failed!\n", getUserPkgParserDBPathUID(uid));
+ return PMINFO_R_ERROR;
+ }
/*Begin transaction*/
- ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ ret = sqlite3_exec(GET_DB(manifest_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
_LOGE("Failed to begin transaction\n");
- sqlite3_close(manifest_db);
+ __close_manifest_db();
return PMINFO_R_ERROR;
}
_LOGD("Transaction Begin\n");
char *error_message = NULL;
if (SQLITE_OK !=
- sqlite3_exec(manifest_db, query, NULL, NULL, &error_message)) {
+ sqlite3_exec(GET_DB(manifest_db), query, NULL, NULL, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
sqlite3_free(error_message);
/*Commit transaction*/
- ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
+ ret = sqlite3_exec(GET_DB(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);
+ sqlite3_exec(GET_DB(manifest_db), "ROLLBACK", NULL, NULL, NULL);
+ __close_manifest_db();
return PMINFO_R_ERROR;
}
_LOGD("Transaction Commit and End\n");
- sqlite3_close(manifest_db);
-
+ __close_manifest_db();
return PMINFO_R_OK;
}
data = (pkgmgr_datacontrol_x *)calloc(1, sizeof(pkgmgr_datacontrol_x));
if (data == NULL) {
_LOGE("Failed to allocate memory for pkgmgr_datacontrol_x\n");
- sqlite3_close(datacontrol_db);
+ __close_datacontrol_db();
return PMINFO_R_ERROR;
}
snprintf(query, MAX_QUERY_LEN,
- "select appinfo.package_name, datacontrol.access from appinfo, datacontrol where datacontrol.id=appinfo.unique_id and datacontrol.provider_id = '%s' and datacontrol.type='%s' COLLATE NOCASE",
+ "select appinfo.package_name, datacontrol.access from appinfo, datacontrol where datacontrol.id=appinfo.unique_id and datacontrol.providerid = '%s' and datacontrol.type='%s' COLLATE NOCASE",
providerid, type);
if (SQLITE_OK !=
- sqlite3_exec(datacontrol_db, query, __datacontrol_cb, (void *)data, &error_message)) {
+ sqlite3_exec(GET_DB(datacontrol_db), query, __datacontrol_cb, (void *)data, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
- sqlite3_close(datacontrol_db);
+ __close_datacontrol_db();
return PMINFO_R_ERROR;
}
*appid = (char *)data->appid;
*access = (char *)data->access;
free(data);
- sqlite3_close(datacontrol_db);
+ __close_datacontrol_db();
return PMINFO_R_OK;
}
/*Begin transaction*/
- ret = sqlite3_exec(manifest_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ ret = sqlite3_exec(GET_DB(manifest_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
_LOGE("Failed to begin transaction\n");
- sqlite3_close(manifest_db);
+ __close_manifest_db();
return PMINFO_R_ERROR;
}
_LOGD("Transaction Begin\n");
"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)) {
+ sqlite3_exec(GET_DB(manifest_db), query, NULL, NULL, &error_message)) {
_LOGE("Don't execute query = %s error message = %s\n", query,
error_message);
sqlite3_free(error_message);
}
/*Commit transaction*/
- ret = sqlite3_exec(manifest_db, "COMMIT", NULL, NULL, NULL);
+ ret = sqlite3_exec(GET_DB(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);
+ sqlite3_exec(GET_DB(manifest_db), "ROLLBACK", NULL, NULL, NULL);
+ __close_manifest_db();
return PMINFO_R_ERROR;
}
_LOGD("Transaction Commit and End\n");
- sqlite3_close(manifest_db);
-
+ __close_manifest_db();
return PMINFO_R_OK;
}
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
char *val = NULL;
int ret = 0;
- char *noti_string = NULL;
int len = 0;
char query[MAX_QUERY_LEN] = {'\0'};
char *errmsg = NULL;
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
val = (char *)info->uiapp_info->guestmode_visibility;
if (val ) {
- ret =
- db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkgmgr_parser_db,
- SQLITE_OPEN_READWRITE, NULL);
+ ret =
+ db_util_open_with_options(getUserPkgParserDBPathUID(uid), &pkgmgr_parser_db,
+ SQLITE_OPEN_READWRITE, NULL);
- if (ret != SQLITE_OK) {
+ if (ret != SQLITE_OK) {
_LOGE("DB Open Failed\n");
return PMINFO_R_ERROR;
- }
+ }
/*TODO: Write to DB here*/
if (status == true)
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)) {
+ ret = sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg);
+ sqlite3_close(pkgmgr_parser_db);
+ if (ret != SQLITE_OK) {
_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_ERROR;
}
}
return PMINFO_R_OK;