Skip to content

Commit

Permalink
[Applications.PackageManager] Add ClearUserData(package, path) (Samsu…
Browse files Browse the repository at this point in the history
…ng#4747)

* [Tizen.Applications] Add a new PackageManager API

Adds:
 - ClearUserData(packageId, filePath)

Signed-off-by: ChangGyu Choi <[email protected]>

* Fix the api description

Signed-off-by: ChangGyu Choi <[email protected]>

* Remove a remark sentence

Signed-off-by: ChangGyu Choi <[email protected]>

* Update API description

Signed-off-by: ChangGyu Choi <[email protected]>

Signed-off-by: ChangGyu Choi <[email protected]>
  • Loading branch information
upple authored and Seoyeon2Kim committed Jan 10, 2023
1 parent b6f9a12 commit 290e5c6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ internal enum StorageType
[DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_data_dir")]
internal static extern ErrorCode PackageManagerClearDataDir(string packageId);

[DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_user_data_with_path")]
internal static extern ErrorCode PackageManagerClearUserDataWithPath(string packageId, String filePath);

[DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_create")]
internal static extern ErrorCode PackageManagerFilterCreate(out IntPtr handle);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,28 @@ public static void ClearDataDirectory(string packageId)
}
}

/// <summary>
/// Removes a file or directory specified with <paramref name="path"/> from user data internal storage for the application.
/// </summary>
/// <param name="packageId">ID of the package.</param>
/// <param name="path">The path of the file or directory in the package user data folder.</param>
/// <exception cref="OutOfMemoryException">Thrown when there is not enough memory to continue the execution of the method.</exception>
/// <exception cref="System.IO.IOException">Thrown when the method failed due to an internal IO error.</exception>
/// <exception cref="UnauthorizedAccessException">Thrown when an application does not have the privilege to access this method.</exception>
/// <exception cref="SystemException">Thrown when the method failed due to an internal system error.</exception>
/// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
/// <privlevel>platform</privlevel>
/// <since_tizen> 11 </since_tizen>
public static void ClearUserData(string packageId, string path)
{
Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerClearUserDataWithPath(packageId, path);
if (err != Interop.PackageManager.ErrorCode.None)
{
Log.Warn(LogTag, string.Format("Failed to clear user data for {0} of {1}. err = {2}", path, packageId, err));
throw PackageManagerErrorFactory.GetException(err, "Failed to clear user data");
}
}

/// <summary>
/// Retrieves the package information of all installed packages.
/// </summary>
Expand Down

0 comments on commit 290e5c6

Please sign in to comment.