[NUI.Gadget] Modify loading assembly of NUIGadget (#6417)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Mon, 28 Oct 2024 00:27:21 +0000 (09:27 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 27 Nov 2024 04:59:15 +0000 (13:59 +0900)
* [NUI.Gadget] Modify loading assembly of NUIGadget

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
* [NUI.Gadget] Fix wrong implementation

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
* [NUI.Gadget] Fix resource path

The AllowedResourcePath is added for backward compatibility.

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
---------

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetAssembly.cs
src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetInfo.cs
src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs

index 206bf788be7c913905f5650a2f8faf8ae97894e9..29d67e0a502bc6c8d186f5c9eb45ef62c31951f1 100644 (file)
@@ -62,11 +62,10 @@ namespace Tizen.NUI
                 Log.Warn("Load(): " + _assemblyPath + " ++");
                 NUIGadgetAssemblyLoadContext context = new NUIGadgetAssemblyLoadContext();
                 _assemblyRef = new WeakReference(context);
-                string directoryPath = SystemIO.Path.GetDirectoryName(_assemblyPath);
-                string fileName = SystemIO.Path.GetFileNameWithoutExtension(_assemblyPath);
-                string nativeImagePath = directoryPath + "/.native_image/" + fileName + ".ni.dll";
-                Log.Debug("NativeImagePath=" + nativeImagePath + ", AssemblyPath=" + _assemblyPath);
-                _assembly = context.LoadFromNativeImagePath(nativeImagePath, _assemblyPath);
+                using (FileStream stream = new FileStream(_assemblyPath, FileMode.Open, FileAccess.Read))
+                {
+                    _assembly = context.LoadFromStream(stream);
+                }
                 Log.Warn("Load(): " + _assemblyPath + " --");
             }
         }
@@ -107,4 +106,4 @@ namespace Tizen.NUI
             }
         }
     }
-}
\ No newline at end of file
+}
index c28aaa88a19e4be6839d9bd4671f3e37158df4d3..dac6befa33f7a19cfd309ba27f5fe19f844a32e3 100755 (executable)
@@ -17,6 +17,7 @@
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
+using System.IO;
 using System.Reflection;
 using System.Runtime.InteropServices;
 using Tizen.Applications;
@@ -69,6 +70,15 @@ namespace Tizen.NUI
             get; private set;
         }
 
+        /// <summary>
+        /// Gets the allowed resourced path of the gadget.
+        /// </summary>
+        /// <since_tizen> 12 </since_tizen>
+        public string AllowedResourcePath
+        {
+            get; private set;
+        }
+
         /// <summary>
         /// Gets the executable file of the gadget.
         /// </summary>
@@ -183,6 +193,11 @@ namespace Tizen.NUI
             }
 
             info.ResourcePath = SystemIO.Path.GetDirectoryName(Application.Current.ApplicationInfo.ExecutablePath) + "/";
+            info.AllowedResourcePath = SystemIO.Path.GetDirectoryName(Application.Current.DirectoryInfo.Resource) + "/mount/allowed/" + info.ResourceType + "/";
+            if (!Directory.Exists(info.AllowedResourcePath))
+            {
+                info.AllowedResourcePath = SystemIO.Path.GetDirectoryName(Application.Current.DirectoryInfo.Resource) + "/mount/allowed/";
+            }
             return info;
         }
     }
index e7e277d33df57e8fe2bcaf6f2f42ab25b0f9b45b..c93087b52018c551bf6952320f14ae754dbeb8ae 100755 (executable)
@@ -243,10 +243,10 @@ namespace Tizen.NUI
                     {
                         if (info.NUIGadgetAssembly == null || !info.NUIGadgetAssembly.IsLoaded)
                         {
-                            Log.Warn("NUIGadgetAssembly.Load(): " + info.ResourcePath + info.ExecutableFile + " ++");
-                            info.NUIGadgetAssembly = new NUIGadgetAssembly(info.ResourcePath + info.ExecutableFile);
+                            Log.Warn("NUIGadgetAssembly.Load(): " + info.AllowedResourcePath + info.ExecutableFile + " ++");
+                            info.NUIGadgetAssembly = new NUIGadgetAssembly(info.AllowedResourcePath + info.ExecutableFile);
                             info.NUIGadgetAssembly.Load();
-                            Log.Warn("NUIGadgetAssembly.Load(): " + info.ResourcePath + info.ExecutableFile + " --");
+                            Log.Warn("NUIGadgetAssembly.Load(): " + info.AllowedResourcePath + info.ExecutableFile + " --");
                         }
                     }
                 }