Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NUI.Gadget] Modify loading assembly of NUIGadget #6417

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ internal void Load()
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 + " --");
}
}
Expand Down Expand Up @@ -107,4 +106,4 @@ internal void Unload()
}
}
}
}
}
15 changes: 15 additions & 0 deletions src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,6 +70,15 @@ public string ResourcePath
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>
Expand Down Expand Up @@ -183,6 +193,11 @@ int callback(string key, string value, IntPtr userData)
}

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;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Tizen.NUI.Gadget/Tizen.NUI/NUIGadgetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ private static void Load(NUIGadgetInfo info, bool useDefaultContext)
{
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 + " --");
}
}
}
Expand Down
Loading