From 7d404acb7aac94efcd92b33d7063e003f0b58887 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Thu, 27 Apr 2017 15:48:51 +0900 Subject: [PATCH] Support ResourceManager within tizen 3.0/4.0 native APIs - 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 --- .../Interop/Interop.AppCommon.cs | 3 +++ .../Interop/Interop.Libraries.cs | 1 + .../Tizen.Applications/ResourceManager.cs | 24 ++++++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs b/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs index 41603d2..5ad41f5 100755 --- a/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.AppCommon.cs @@ -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); } diff --git a/src/Tizen.Applications.Common/Interop/Interop.Libraries.cs b/src/Tizen.Applications.Common/Interop/Interop.Libraries.cs index e9a8f47..8a417c6 100755 --- a/src/Tizen.Applications.Common/Interop/Interop.Libraries.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.Libraries.cs @@ -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"; } } diff --git a/src/Tizen.Applications.Common/Tizen.Applications/ResourceManager.cs b/src/Tizen.Applications.Common/Tizen.Applications/ResourceManager.cs index dd36f71..c20840a 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications/ResourceManager.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/ResourceManager.cs @@ -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; + } + /// /// Converts resource ID to path name. /// @@ -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) { -- 2.7.4