/* TODO: add doxygen comment here */
int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users);
-int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled);
-int pkgmgrinfo_appinfo_set_usr_state_enabled(const char *appid, bool enabled, uid_t uid);
-int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label);
-int pkgmgrinfo_appinfo_set_usr_default_label(const char *appid, const char *label, uid_t uid);
/**
* @fn int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_pkginfo_h *clone)
int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool *status);
/**
- * @fn int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
- * @brief This API sets the application 'guest mode visibility' value in the DB
- *
- * @par This API is for package-manager client application
- * @par Sync (or) Async : Synchronous API
- *
- * @param[in] handle pointer to application info handle
- * @param[out] status app guest mode visibility value
- * @return 0 if success, error code(<0) if fail
- * @retval PMINFO_R_OK success
- * @retval PMINFO_R_EINVAL invalid argument
- * @retval PMINFO_R_ERROR internal error
- * @pre pkgmgrinfo_appinfo_get_appinfo()
- * @post pkgmgrinfo_appinfo_destroy_appinfo()
- * @see pkgmgrinfo_appinfo_get_appid()
- * @see pkgmgrinfo_appinfo_is_multiple()
- * @code
-static int set_app_guestmode_visibility(const char *appid, bool value)
-{
- int ret = 0;
- pkgmgrinfo_appinfo_h handle;
- ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
- if (ret != PMINFO_R_OK)
- return -1;
- ret = pkgmgrinfo_appinfo_set_guestmode_visibility(handle, value);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_destroy_appinfo(handle);
- return -1;
- }
- pkgmgrinfo_appinfo_destroy_appinfo(handle);
- return 0;
-}
- * @endcode
- */
-int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status);
-int pkgmgrinfo_appinfo_set_usr_guestmode_visibility(pkgmgrinfo_appinfo_h handle, uid_t uid, bool status);
-
-/**
* @fn int pkgmgrinfo_pkginfo_set_installed_storage(const char *pkgid, INSTALL_LOCATION location)
* @brief This API sets the package 'installed_storage' value in db
*
*str = strdup(val);
}
-API int pkgmgrinfo_pkginfo_set_state_enabled(const char *pkgid, bool enabled)
-{
- /* Should be implemented later */
- return 0;
-}
-
-API int pkgmgrinfo_appinfo_set_usr_state_enabled(const char *appid, bool enabled, uid_t uid)
-{
- int ret;
- char query[MAX_QUERY_LEN] = {'\0'};
- char *error_message;
-
- retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
-
- /* Open db.*/
- ret = __open_manifest_db(uid, false);
- if (ret != SQLITE_OK) {
- _LOGE("connect db [%d] failed!\n", uid);
- return PMINFO_R_ERROR;
- }
-
- /*Begin transaction*/
- ret = sqlite3_exec(GET_DB(manifest_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("Failed to begin transaction\n");
- __close_manifest_db();
- return PMINFO_R_ERROR;
- }
- _LOGD("Transaction Begin\n");
-
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN,
- "update package_app_info set app_enabled='%s' where app_id='%s'",
- enabled ? "true" : "false", appid);
-
- if (SQLITE_OK !=
- 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);
- return PMINFO_R_ERROR;
- }
- sqlite3_free(error_message);
-
- /*Commit transaction*/
- 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(GET_DB(manifest_db), "ROLLBACK", NULL, NULL, NULL);
- __close_manifest_db();
- return PMINFO_R_ERROR;
- }
- _LOGD("Transaction Commit and End\n");
- __close_manifest_db();
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_set_state_enabled(const char *appid, bool enabled)
-{
- return pkgmgrinfo_appinfo_set_usr_state_enabled(appid, enabled, _getuid());
-}
-
-API int pkgmgrinfo_appinfo_set_usr_default_label(const char *appid, const char *label, uid_t uid)
-{
- int ret;
- char query[MAX_QUERY_LEN] = {'\0'};
- char *error_message;
-
- retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL\n");
-
- ret = __open_manifest_db(uid, false);
- if (ret == -1) {
- _LOGE("Fail to open manifest DB\n");
- return PMINFO_R_ERROR;
- }
-
- /*Begin transaction*/
- ret = sqlite3_exec(GET_DB(manifest_db), "BEGIN EXCLUSIVE", NULL, NULL, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("Failed to begin transaction\n");
- __close_manifest_db();
- return PMINFO_R_ERROR;
- }
- _LOGD("Transaction Begin\n");
-
- memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN,
- "update package_app_localized_info set app_label='%s' where app_id='%s' and app_locale='No Locale'", label, appid);
-
- if (SQLITE_OK !=
- sqlite3_exec(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);
- return PMINFO_R_ERROR;
- }
-
- /*Commit transaction*/
- 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(GET_DB(manifest_db), "ROLLBACK", NULL, NULL, NULL);
- __close_manifest_db();
- return PMINFO_R_ERROR;
- }
- _LOGD("Transaction Commit and End\n");
- __close_manifest_db();
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_set_default_label(const char *appid, const char *label)
-{
- return pkgmgrinfo_appinfo_set_usr_default_label(appid, label, _getuid());
-}
-
-API int pkgmgrinfo_appinfo_set_usr_guestmode_visibility(pkgmgrinfo_appinfo_h handle, uid_t uid, bool status)
-{
- const char *val;
- int ret;
- char query[MAX_QUERY_LEN] = {'\0'};
- char *errmsg;
- sqlite3 *pkgmgr_parser_db;
- char *db_path;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
-
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- val = info->app_info->guestmode_visibility;
- if (val) {
- db_path = getUserPkgParserDBPathUID(uid);
- if (db_path == NULL) {
- _LOGE("Failed to get pkg parser db path - %d", uid);
- return PMINFO_R_ERROR;
- }
-
- ret = db_util_open_with_options(db_path, &pkgmgr_parser_db,
- SQLITE_OPEN_READWRITE, NULL);
- if (ret != SQLITE_OK) {
- _LOGE("DB Open Failed\n");
- free(db_path);
- return PMINFO_R_ERROR;
- }
- free(db_path);
-
- /*TODO: Write to DB here*/
- if (status == true)
- snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'true' where app_id = '%s'", (char *)info->app_info->appid);
- else
- snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->app_info->appid);
-
- 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);
- return PMINFO_R_ERROR;
- }
- }
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_set_guestmode_visibility(pkgmgrinfo_appinfo_h handle, bool status)
-{
- return pkgmgrinfo_appinfo_set_usr_guestmode_visibility(handle, _getuid(), status);
-}
-
API int pkgmgrinfo_pkginfo_set_usr_installed_storage(const char *pkgid, INSTALL_LOCATION location, uid_t uid)
{
retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "pkgid is NULL\n");