diff --git a/BmwDeepObd/ActivityCommon.cs b/BmwDeepObd/ActivityCommon.cs
index 9cdfb6496..bd5fe61ae 100644
--- a/BmwDeepObd/ActivityCommon.cs
+++ b/BmwDeepObd/ActivityCommon.cs
@@ -10912,7 +10912,7 @@ public static string GetAssetEcuFilename()
try
{
Regex regex = new Regex(@"^Ecu.*\.bin$", RegexOptions.IgnoreCase);
- AssetManager assets = ActivityCommon.GetPackageContext()?.Assets;
+ AssetManager assets = GetPackageContext()?.Assets;
if (assets != null)
{
string[] assetFiles = assets.List(string.Empty);
@@ -11055,7 +11055,30 @@ public static void ExtractZipFile(AssetManager assetManager, Assembly resourceAs
}
else
{
- if (resourceAssembly != null)
+ if (assetManager != null)
+ {
+ AssetFileDescriptor assetFile = null;
+ try
+ {
+ assetFile = assetManager.OpenFd(archiveFilenameIn);
+ using (Stream inputStream = assetFile.CreateInputStream())
+ {
+ if (inputStream == null)
+ {
+ throw new IOException("Opening asset stream failed");
+ }
+
+ fs = new MemoryStream();
+ inputStream.CopyTo(fs);
+ fs.Seek(0, SeekOrigin.Begin);
+ }
+ }
+ finally
+ {
+ assetFile?.Close();
+ }
+ }
+ else if (resourceAssembly != null)
{
fs = resourceAssembly.GetManifestResourceStream(archiveFilenameIn);
}
diff --git a/BmwDeepObd/Sample/Sample.zip b/BmwDeepObd/Assets/Sample.zip
similarity index 100%
rename from BmwDeepObd/Sample/Sample.zip
rename to BmwDeepObd/Assets/Sample.zip
diff --git a/BmwDeepObd/BmwDeepObd.csproj b/BmwDeepObd/BmwDeepObd.csproj
index a481244c1..5f29c98fa 100644
--- a/BmwDeepObd/BmwDeepObd.csproj
+++ b/BmwDeepObd/BmwDeepObd.csproj
@@ -34,6 +34,7 @@
+
@@ -44,7 +45,6 @@
-
@@ -76,7 +76,6 @@
-
diff --git a/BmwDeepObd/MainActivity.cs b/BmwDeepObd/MainActivity.cs
index 98608e434..24504f9e2 100644
--- a/BmwDeepObd/MainActivity.cs
+++ b/BmwDeepObd/MainActivity.cs
@@ -6453,7 +6453,26 @@ private bool ExtractSampleFiles(bool force = false)
return false;
}
- string resourceName = VehicleInfoBmw.FindResourceName("Sample.zip");
+ AssetManager assets = ActivityCommon.GetPackageContext()?.Assets;
+ if (assets == null)
+ {
+ return false;
+ }
+
+ string resourceName = null;
+ string[] assetFiles = assets.List(string.Empty);
+ if (assetFiles != null)
+ {
+ foreach (string fileName in assetFiles)
+ {
+ if (fileName.EndsWith("Sample.zip", StringComparison.OrdinalIgnoreCase))
+ {
+ resourceName = fileName;
+ break;
+ }
+ }
+ }
+
if (string.IsNullOrEmpty(resourceName))
{
return false;
@@ -6518,8 +6537,7 @@ private bool ExtractSampleFiles(bool force = false)
}
}
- Assembly assembly = Assembly.GetExecutingAssembly();
- ActivityCommon.ExtractZipFile(null, assembly, resourceName, sampleDir, null, null, null, null);
+ ActivityCommon.ExtractZipFile(assets, null, resourceName, sampleDir, null, null, null, null);
XElement xmlInfo = new XElement("Info");
xmlInfo.Add(new XAttribute("Name", resourceName));