[Tizen.Applications.PackageManager] Add new API for package info (#742)
authorilho159kim <dlfgh951@naver.com>
Fri, 22 Mar 2019 05:50:56 +0000 (14:50 +0900)
committerpjh9216 <jh9216.park@samsung.com>
Fri, 22 Mar 2019 05:50:56 +0000 (14:50 +0900)
* [Tizen.Applications.PackageManager] Add new API for package info

* Change the way getting the package's main application info

* Adjust MainApplication property's location

src/Tizen.Applications.PackageManager/Interop/Interop.Package.cs
src/Tizen.Applications.PackageManager/Tizen.Applications/Package.cs

index 67de930..adf0479 100644 (file)
@@ -73,6 +73,9 @@ internal static partial class Interop
         [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_package")]
         internal static extern ErrorCode PackageInfoGetPackage(IntPtr handle, out string packageId);
 
+        [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_main_app_id")]
+        internal static extern ErrorCode PackageInfoGetMainAppId(IntPtr handle, out string mainAppId);
+
         [DllImport(Libraries.PackageManager, EntryPoint = "package_info_get_label")]
         internal static extern ErrorCode PackageInfoGetLabel(IntPtr handle, out string label);
 
index 2bc73f3..8cf14cc 100644 (file)
@@ -30,6 +30,7 @@ namespace Tizen.Applications
         private const string LogTag = "Tizen.Applications";
 
         private string _id = string.Empty;
+        private string _mainAppId = string.Empty;
         private string _label = string.Empty;
         private string _iconPath = string.Empty;
         private string _version = string.Empty;
@@ -146,6 +147,19 @@ namespace Tizen.Applications
         public int InstalledTime { get { return _installedTime; } }
 
         /// <summary>
+        /// Main application info of the package.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public ApplicationInfo MainApplication
+        {
+            get
+            {
+                ApplicationInfo applicaionInfo = new ApplicationInfo(_mainAppId);
+                return applicaionInfo;
+            }
+        }
+
+        /// <summary>
         /// Retrieves all the application IDs of this package.
         /// </summary>
         /// <returns>Returns a dictionary containing all the application information for a given application type.</returns>
@@ -266,6 +280,11 @@ namespace Tizen.Applications
             Package package = new Package(pkgId);
 
             var err = Interop.PackageManager.ErrorCode.None;
+            err = Interop.Package.PackageInfoGetMainAppId(handle, out package._mainAppId);
+            if (err != Interop.PackageManager.ErrorCode.None)
+            {
+                Log.Warn(LogTag, "Failed to get package main app id of " + pkgId);
+            }
             err = Interop.Package.PackageInfoGetLabel(handle, out package._label);
             if (err != Interop.PackageManager.ErrorCode.None)
             {