summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjongmyeongko <jongmyeong.ko@samsung.com>2017-03-09 18:52:53 +0900
committerjongmyeong ko <jongmyeong.ko@samsung.com>2017-03-16 02:54:42 -0700
commit28ce0b9215b092555e1dab6ed77d9ad563d2575f (patch)
tree1b69573cacf1ae2d320d7cbd8b822b97982cc65e
parente3873396ce2b60000e102713f6f767214ebb35eb (diff)
downloadapplication-28ce0b9215b092555e1dab6ed77d9ad563d2575f.tar.gz
application-28ce0b9215b092555e1dab6ed77d9ad563d2575f.tar.bz2
application-28ce0b9215b092555e1dab6ed77d9ad563d2575f.zip
Add new api for clearing cache, data directory
usage) PackageManager.ClearCacheDirectory(pkgId); // static method PackageManager.ClearDataDirectory(pkgId); // static method Move ClearCacheDirectory behavior from Package class to PackageManger class, so that all responsibility related to clearing directories are granted to PackageManager class only. Change-Id: I33b2f24b048f1e185e0a599d8650e5561af45340 Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
-rw-r--r--Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs3
-rw-r--r--Tizen.Applications.PackageManager/Tizen.Applications/Package.cs18
-rw-r--r--Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs42
3 files changed, 45 insertions, 18 deletions
diff --git a/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs b/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs
index 3d2e2bc..5d726c8 100644
--- a/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs
+++ b/Tizen.Applications.PackageManager/Interop/Interop.PackageManager.cs
@@ -130,6 +130,9 @@ internal static partial class Interop
[DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_all_cache_dir")]
internal static extern ErrorCode PackageManagerClearAllCacheDir();
+ [DllImport(Libraries.PackageManager, EntryPoint = "package_manager_clear_data_dir")]
+ internal static extern ErrorCode PackageManagerClearDataDir(string packageId);
+
[DllImport(Libraries.PackageManager, EntryPoint = "package_manager_filter_create")]
internal static extern ErrorCode PackageManagerFilterCreate(out IntPtr handle);
diff --git a/Tizen.Applications.PackageManager/Tizen.Applications/Package.cs b/Tizen.Applications.PackageManager/Tizen.Applications/Package.cs
index 44f3cc5..b589e0c 100644
--- a/Tizen.Applications.PackageManager/Tizen.Applications/Package.cs
+++ b/Tizen.Applications.PackageManager/Tizen.Applications/Package.cs
@@ -119,24 +119,6 @@ namespace Tizen.Applications
public IEnumerable<string> Privileges { get { return _privileges; } }
/// <summary>
- /// Clears the application's internal and external cache directory.
- /// </summary>
- /// <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 method failed due to internal IO error</exception>
- /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
- /// <exception cref="SystemException">Thrown when method failed due to internal system error</exception>
- /// <privilege>http://tizen.org/privilege/packagemanager.clearcache</privilege>
- public void ClearCacheDirectory()
- {
- Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerClearCacheDir(Id);
- if (err != Interop.PackageManager.ErrorCode.None)
- {
- Log.Warn(LogTag, string.Format("Failed to clear cache directory for {0}. err = {1}", Id, err));
- throw PackageManagerErrorFactory.GetException(err, "Failed to clear cache directory");
- }
- }
-
- /// <summary>
/// Retrieves all application IDs of this package.
/// </summary>
/// <returns>Returns a dictionary containing all application info for given application type.</returns>
diff --git a/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs b/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs
index 2fc3b0a..6329204 100644
--- a/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs
+++ b/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs
@@ -152,6 +152,25 @@ namespace Tizen.Applications
}
/// <summary>
+ /// Clears the application's internal and external cache directory.
+ /// </summary>
+ /// <param name="packageId">Id of the package</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 method failed due to internal IO error</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+ /// <exception cref="SystemException">Thrown when method failed due to internal system error</exception>
+ /// <privilege>http://tizen.org/privilege/packagemanager.clearcache</privilege>
+ public static void ClearCacheDirectory(string packageId)
+ {
+ Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerClearCacheDir(packageId);
+ if (err != Interop.PackageManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, string.Format("Failed to clear cache directory for {0}. err = {1}", packageId, err));
+ throw PackageManagerErrorFactory.GetException(err, "Failed to clear cache directory");
+ }
+ }
+
+ /// <summary>
/// Clears all application's internal and external cache directory.
/// </summary>
/// <exception cref="OutOfMemoryException">Thrown when there is not enough memory to continue the execution of the method</exception>
@@ -170,6 +189,29 @@ namespace Tizen.Applications
}
/// <summary>
+ /// Clears the application's internal and external data directories
+ /// </summary>
+ /// <remarks>
+ /// All files under data, shared/data and shared/trusted in the internal storage are removed.
+ /// And, If external storeage exists, then all files under data and shared/trusted in the external storage are removed.
+ /// </remarks>
+ /// <param name="packageId">Id of the package</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 method failed due to internal IO error</exception>
+ /// <exception cref="UnauthorizedAccessException">Thrown when app does not have privilege to access this method</exception>
+ /// <exception cref="SystemException">Thrown when method failed due to internal system error</exception>
+ /// <privilege>http://tizen.org/privilege/packagemanager.admin</privilege>
+ public static void ClearDataDirectory(string packageId)
+ {
+ Interop.PackageManager.ErrorCode err = Interop.PackageManager.PackageManagerClearDataDir(packageId);
+ if (err != Interop.PackageManager.ErrorCode.None)
+ {
+ Log.Warn(LogTag, string.Format("Failed to clear data directory for {0}. err = {1}", packageId, err));
+ throw PackageManagerErrorFactory.GetException(err, "Failed to clear data directory");
+ }
+ }
+
+ /// <summary>
/// Retrieves package information of all installed packages.
/// </summary>
/// <returns>Returns the list of packages.</returns>