Support ResourceManager within tizen 3.0/4.0 native APIs
authorJunghoon Park <jh9216.park@samsung.com>
Thu, 27 Apr 2017 06:48:51 +0000 (15:48 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Thu, 27 Apr 2017 08:07:27 +0000 (08:07 +0000)
- Since tizen 4.0, the native API, app_get_resource_manager_get() had been
  moved to libcapi-appfw-app-common.so.0 from
libcapi-appfw-application.so.0
- Because of this stuff, the dotnet API was not easy to bind the native API.
- To cover this issue, the fallback logic for importing that API is added

Change-Id: I12a332949ebc1ce11d97149660e8bb519d5f0518
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs
src/Tizen.Applications.Common/Interop/Interop.Libraries.cs
src/Tizen.Applications.Common/Tizen.Applications/ResourceManager.cs

index 41603d2..5ad41f5 100755 (executable)
@@ -86,6 +86,9 @@ internal static partial class Interop
         [DllImport(Libraries.AppCommon, EntryPoint = "app_resource_manager_get")]
         internal static extern ErrorCode AppResourceManagerGet(ResourceCategory category, string id, out string path);
 
+        [DllImport(Libraries.Application, EntryPoint = "app_resource_manager_get")]
+        internal static extern ErrorCode LegacyAppResourceManagerGet(ResourceCategory category, string id, out string path);
+
         [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_device_orientation")]
         internal static extern ErrorCode AppEventGetDeviceOrientation(IntPtr handle, out DeviceOrientation orientation);
     }
index e9a8f47..8a417c6 100755 (executable)
@@ -26,5 +26,6 @@ internal static partial class Interop
         public const string Rua = "librua.so.0";
         public const string Glib = "libglib-2.0.so.0";
         public const string Libc = "libc.so.6";
+        public const string Application = "libcapi-appfw-application.so.0";
     }
 }
index dd36f71..c20840a 100755 (executable)
@@ -50,6 +50,24 @@ namespace Tizen.Applications
             Binary
         }
 
+        private static ErrorCode AppResourceManagerGet(Category category, string id, out string path)
+        {
+            ErrorCode err;
+
+            try
+            {
+                err = Interop.AppCommon.AppResourceManagerGet(
+                             (Interop.AppCommon.ResourceCategory)category, id, out path);
+            }
+            catch (System.TypeLoadException)
+            {
+                err = Interop.AppCommon.LegacyAppResourceManagerGet(
+                             (Interop.AppCommon.ResourceCategory)category, id, out path);
+            }
+
+            return err;
+        }
+
         /// <summary>
         /// Converts resource ID to path name.
         /// </summary>
@@ -60,8 +78,7 @@ namespace Tizen.Applications
         public static string GetPath(Category category, string id)
         {
             string path;
-            ErrorCode err = Interop.AppCommon.AppResourceManagerGet(
-                    (Interop.AppCommon.ResourceCategory)category, id, out path);
+            ErrorCode err = AppResourceManagerGet(category, id, out path);
 
             switch (err)
             {
@@ -88,8 +105,7 @@ namespace Tizen.Applications
         public static string TryGetPath(Category category, string id)
         {
             string path;
-            ErrorCode err = Interop.AppCommon.AppResourceManagerGet(
-                    (Interop.AppCommon.ResourceCategory)category, id, out path);
+            ErrorCode err = AppResourceManagerGet(category, id, out path);
 
             switch (err)
             {