* @param [in] pkgid The package ID
* @param [in] package_type The package type of the given privilege list
* @param [in] api_version The api-version of package
- * @param [in] is_privacy_requestable Indicates if the application package can request privacy
* @param [in] critical_privilege_list The ciritical privilege list
* @return 0 on success, otherwise a negative error value.
* @retval #PRIVILEGE_DB_MANAGER_ERR_NONE Successful.
* @retval #PRIVILEGE_DB_MANAGER_ERR_DB_FULL_FAIL Write could not complete due to the disk is full.
* @retval #PRIVILEGE_DB_MANAGER_ERR_DB_UPDATE_FAIL DB update failed.
*/
-int privilege_db_manager_set_package_critical_privilege_info(const uid_t uid, const char* pkgid, privilege_manager_package_type_e package_type, const char* api_version, bool is_privacy_requestable, GList* critical_privilege_list);
+int privilege_db_manager_set_package_critical_privilege_info(const uid_t uid, const char* pkgid, privilege_manager_package_type_e package_type, const char* api_version, GList* critical_privilege_list);
/**
* @brief Set application package's privacy privilege information
* @param [in] pkgid The package ID
* @param [in] package_type The package type of the given privilege list
* @param [in] api_version The api-version of the package
- * @param [in] is_privacy_requestable Indicates if the application package can request privacy
* @param [in] privilege_list The privacy privilege list
* @return 0 on success, otherwise a negative error value.
* @retval #PRIVILEGE_DB_MANAGER_ERR_NONE Successful.
* @retval #PRIVILEGE_DB_MANAGER_ERR_DB_FULL_FAIL Write could not complete due to the disk is full.
* @retval #PRIVILEGE_DB_MANAGER_ERR_DB_UPDATE_FAIL DB update failed.
*/
-int privilege_db_manager_set_package_privacy_privilege_info(const uid_t uid, const char* pkgid, privilege_manager_package_type_e package_type, const char* api_version, bool is_privacy_requestable, GList* privilege_list);
+int privilege_db_manager_set_package_privacy_privilege_info(const uid_t uid, const char* pkgid, privilege_manager_package_type_e package_type, const char* api_version, GList* privilege_list);
/**
* @brief Delete all privacy, critical privilege info of the given application package.
int privilege_db_manager_unset_package_privilege_info(const uid_t uid, const char* pkgid);
/**
- * @brief Get is_privacy_requestable value of the package
+ * @brief See if the package's api_version says it can request privacy to the user
* @remarks If the package have no privacy privilege then it will return PRIVILEGE_DB_MANAGER_ERR_NO_EXIST_RESULT
* @param [in] uid The uid
* @param [in] pkgid The package ID
return PRIVILEGE_DB_MANAGER_ERR_NONE;
}
-int privilege_db_manager_set_package_critical_privilege_info(const uid_t uid, const char* pkgid, privilege_manager_package_type_e package_type, const char* api_version, bool is_privacy_requestable, GList* critical_privilege_list)
+int privilege_db_manager_set_package_critical_privilege_info(const uid_t uid, const char* pkgid, privilege_manager_package_type_e package_type, const char* api_version, GList* critical_privilege_list)
{
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
char * privacy_name = NULL;
ret = privilege_db_manager_get_privacy_by_privilege(privilege_name, &privacy_name);
if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && privacy_name != NULL && strstr(privacy_name, "N/A") == NULL) {
- sql = sqlite3_mprintf("insert or replace into privacy_package (uid, pkg_id, privacy_name, privilege_name, api_version, is_privacy_requestable, is_critical) values (%d, %Q, %Q, %Q, %Q, %d, 1)", uid, pkgid, privacy_name, privilege_name, api_version, is_privacy_requestable);
+ sql = sqlite3_mprintf("insert or replace into privacy_package (uid, pkg_id, privacy_name, privilege_name, api_version, is_critical) values (%d, %Q, %Q, %Q, %Q, 1)", uid, pkgid, privacy_name, privilege_name, api_version);
TryReturn(sql != NULL, sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL); g_list_free_full(mapped_privilege_list, free); free(privacy_name); __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
TryReturn(ret == SQLITE_OK, sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL); g_list_free_full(mapped_privilege_list, free); free(privacy_name); __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] fail to prepare database: %s", sqlite3_errmsg(db));
return PRIVILEGE_DB_MANAGER_ERR_NONE;
}
-int privilege_db_manager_set_package_privacy_privilege_info(const uid_t uid, const char* pkgid, privilege_manager_package_type_e package_type, const char* api_version, bool is_privacy_requestable, GList* privilege_list)
+int privilege_db_manager_set_package_privacy_privilege_info(const uid_t uid, const char* pkgid, privilege_manager_package_type_e package_type, const char* api_version, GList* privilege_list)
{
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
char * privacy_name = NULL;
ret = privilege_db_manager_get_privacy_by_privilege(privilege_name, &privacy_name);
if (ret == PRIVILEGE_DB_MANAGER_ERR_NONE && privacy_name != NULL && strstr(privacy_name, "N/A") == NULL) {
- sql = sqlite3_mprintf("insert or ignore into privacy_package (uid, pkg_id, privacy_name, privilege_name, api_version, is_privacy_requestable, is_critical) values (%d, %Q, %Q, %Q, %Q, %d, 0)", uid, pkgid, privacy_name, privilege_name, api_version, is_privacy_requestable);
+ sql = sqlite3_mprintf("insert or ignore into privacy_package (uid, pkg_id, privacy_name, privilege_name, api_version, is_critical) values (%d, %Q, %Q, %Q, %Q, 0)", uid, pkgid, privacy_name, privilege_name, api_version);
TryReturn(sql != NULL, sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL); g_list_free_full(mapped_privilege_list, free); free(privacy_name); __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
TryReturn(ret == SQLITE_OK, sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL); g_list_free_full(mapped_privilege_list, free); free(privacy_name); __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] fail to prepare database: %s", sqlite3_errmsg(db));
if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE)
return ret;
- char* sql = sqlite3_mprintf("select is_privacy_requestable from privacy_package where (uid=%d or uid=%d) and pkg_id=%Q", uid, GLOBAL_USER, pkgid);
+ char* sql = sqlite3_mprintf("select (case when api_version < 4.0 then 0 else 1 end) from privacy_package where (uid=%d or uid=%d) and pkg_id=%Q", uid, GLOBAL_USER, pkgid);
TryReturn(sql != NULL, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] sqlite3_mprintf failed");
ret = sqlite3_prepare_v2(db, sql, strlen(sql), &stmt, NULL);
TryReturn(ret == SQLITE_OK, __finalize_db(db, stmt, sql), PRIVILEGE_DB_MANAGER_ERR_INVALID_QUERY, "[DB_FAIL] fail to prepare database: %s", sqlite3_errmsg(db));
int privilege_package_info_set_privacy_privilege(const uid_t uid, const char* pkgid, privilege_manager_package_type_e pkg_type, const char* api_version, GList* privilege_list)
{
TryReturn(pkgid != NULL && api_version != NULL && privilege_list != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] pkgid, api_version, and privilege_list must not be NULL.");
- int is_privacy_requestable = __is_privacy_requestable_api_version(api_version);
- TryReturn(is_privacy_requestable == 1 || is_privacy_requestable == 0, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] fail to get is_privacy_requestable value.");
- int ret = privilege_db_manager_set_package_privacy_privilege_info(uid, pkgid, pkg_type, api_version, is_privacy_requestable, privilege_list);
+ int ret = privilege_db_manager_set_package_privacy_privilege_info(uid, pkgid, pkg_type, api_version, privilege_list);
if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE) {
LOGE("privilege_db_manager_set_package_privacy_privilege_info failed. ret = %d", ret);
return PRVMGR_ERR_INTERNAL_ERROR;
int privilege_package_info_set_critical_privilege(const uid_t uid, const char* pkgid, privilege_manager_package_type_e pkg_type, const char* api_version, GList* critical_privilege_list)
{
TryReturn(pkgid != NULL && api_version != NULL && critical_privilege_list != NULL, , PRVMGR_ERR_INVALID_PARAMETER, "[PRVMGR_ERR_INVALID_PARAMETER] pkgid, api_version, and critical_privilege_list must not be NULL.");
- int is_privacy_requestable = __is_privacy_requestable_api_version(api_version);
- TryReturn(is_privacy_requestable == 1 || is_privacy_requestable == 0, , PRVMGR_ERR_INTERNAL_ERROR, "[PRVMGR_ERR_INTERNAL_ERROR] fail to get is_privacy_requestable value.");
- int ret = privilege_db_manager_set_package_critical_privilege_info(uid, pkgid, pkg_type, api_version, is_privacy_requestable, critical_privilege_list);
+ int ret = privilege_db_manager_set_package_critical_privilege_info(uid, pkgid, pkg_type, api_version, critical_privilege_list);
if (ret != PRIVILEGE_DB_MANAGER_ERR_NONE) {
LOGE("privilege_db_manager_set_package_critical_privilege_info failed. ret = %d", ret);
return PRVMGR_ERR_INTERNAL_ERROR;