"package_url text," \
"root_path text," \
"csc_path text," \
- "package_support_disable text DEFAULT 'false')"
+ "package_support_disable text DEFAULT 'false', " \
+ "package_disable text DEFAULT 'false')"
#define QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO "create table if not exists package_localized_info " \
"(package text not null, " \
"app_launch_mode text NOT NULL DEFAULT 'caller', " \
"app_ui_gadget text DEFAULT 'false', " \
"app_support_disable text DEFAULT 'false', " \
+ "app_disable text DEFAULT 'false', " \
"component_type text, " \
"package text not null, " \
"app_tep_name text, " \
"REFERENCES package_app_info(app_id) " \
"ON DELETE CASCADE)"
+#define QUERY_CREATE_TABLE_PACKAGE_APP_DISABLE_FOR_USER "CREATE TABLE IF NOT EXISTS package_app_disable_for_user " \
+ "(app_id text not null, " \
+ "uid text not null, " \
+ "PRIMARY KEY(app_id, uid))"
+
static int __insert_application_info(manifest_x *mfx);
static int __insert_application_appcategory_info(manifest_x *mfx);
static int __insert_application_appcontrol_info(manifest_x *mfx);
return 0;
}
+static int __disable_global_app_for_user(const char *appid, uid_t uid)
+{
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+
+ sqlite3_snprintf(MAX_QUERY_LEN, query, "INSERT INTO " \
+ "package_app_disable_for_user(app_id, uid) VALUES(%Q, %Q)",
+ appid, (int)uid);
+ ret = __exec_query(query);
+ if (ret == -1)
+ _LOGD("Insert global app disable failed\n");
+
+ return ret;
+}
+
+static int __enable_global_app_for_user(const char *appid, uid_t uid)
+{
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+
+ sqlite3_snprintf(MAX_QUERY_LEN, query, "DELETE FROM " \
+ "package_app_disable_for_user WHERE app_id=%Q AND uid=%Q",
+ appid, (int)uid);
+ ret = __exec_query(query);
+ if (ret == -1)
+ _LOGD("Delete global app disable failed\n");
+
+ return ret;
+}
+
static int __update_preload_condition_in_db()
{
int ret = -1;
_LOGD("package app data control DB initialization failed\n");
return ret;
}
+
+ ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_APP_DISABLE_FOR_USER);
+ if (ret == -1) {
+ _LOGD("package app disable for user DB initialization failed\n");
+ return ret;
+ }
+
/*Cert DB*/
/* TODO: refactor this code */
ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TABLE_PACKAGE_CERT_INFO);
pkgmgr_parser_close_db();
return ret;
}
+
+API int pkgmgr_parser_update_global_app_disable_info_in_db(const char *appid, uid_t uid, int is_disable)
+{
+ int ret = -1;
+
+ ret = pkgmgr_parser_check_and_create_db(GLOBAL_USER);
+ if (ret == -1) {
+ _LOGD("Failed to open DB\n");
+ return ret;
+ }
+
+ /*Begin transaction*/
+ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGD("Failed to begin transaction\n");
+ ret = -1;
+ goto err;
+ }
+ _LOGD("Transaction Begin\n");
+ if (is_disable)
+ ret = __disable_global_app_for_user(appid, uid);
+ else
+ ret = __enable_global_app_for_user(appid, uid);
+ if (ret == -1) {
+ _LOGD("__update_preload_condition_in_db failed. Rollback now\n");
+ sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
+ goto err;
+ }
+ /*Commit transaction*/
+ ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGD("Failed to commit transaction, Rollback now\n");
+ sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
+ ret = -1;
+ goto err;
+ }
+ _LOGD("Transaction Commit and End\n");
+err:
+ pkgmgr_parser_close_db();
+ return ret;
+
+}
"app_support_disable, "
"component_type, package, app_process_pool, app_installed_storage, "
"app_background_category "
- "FROM package_app_info WHERE app_id=%Q";
+ "FROM package_app_info WHERE app_id='%s' AND app_disable='false' "
+ "AND app_id NOT IN "
+ "(SELECT app_id from package_app_disable_for_user WHERE uid='%d')";
int ret;
- char *query;
+ char query[MAX_QUERY_LEN] = { '\0' };
sqlite3_stmt *stmt;
int idx;
application_x *info;
char *bg_category_str = NULL;
-
- query = sqlite3_mprintf(query_raw, appid);
- if (query == NULL) {
- LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
-
+ snprintf(query, MAX_QUERY_LEN - 1, query_raw, appid, (int)getuid());
ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
- sqlite3_free(query);
if (ret != SQLITE_OK) {
LOGE("prepare failed: %s", sqlite3_errmsg(db));
return PMINFO_R_ERROR;
return PMINFO_R_ERROR;
}
+ if (uid == GLOBAL_USER) {
+ if (pkgmgrinfo_appinfo_filter_add_int(filter,
+ PMINFO_APPINFO_PROP_APP_DISABLE_FOR_USER, (int)getuid())) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+ }
switch (component) {
case PMINFO_UI_APP:
" ON package_info.package=package_localized_info.package"
" AND package_localized_info.package_locale=%Q "
" LEFT OUTER JOIN package_privilege_info"
- " ON package_info.package=package_privilege_info.package";
+ " ON package_info.package=package_privilege_info.package"
+ " WHERE package_info.package_disable='false'";
int ret;
char *query;
char *query_localized;
"installed_storage, storeclient_id, mainapp_id, package_url, "
"root_path, csc_path, package_nodisplay, package_api_version, "
"package_support_disable, package_tep_name "
- "FROM package_info WHERE package=%Q";
+ "FROM package_info WHERE package=%Q AND package_disable='false'";
int ret;
char *query;
sqlite3_stmt *stmt;