Skip to content

Commit

Permalink
Update the Benchmarks.Droid app to use built in Android GetExternalFi…
Browse files Browse the repository at this point in the history
…lesDir (#25015)

* Update the Benchmarks.Droid app to use built in Android GetExternalFilesDir as a location to save tests to.

* Update src/Core/tests/Benchmarks.Droid/MainInstrumentation.cs

---------

Co-authored-by: Jonathan Peppers <jonathan.peppers@gmail.com>
  • Loading branch information
2 people authored and rmarinho committed Oct 16, 2024
1 parent 931d69e commit 3634c7a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Core/tests/Benchmarks.Droid/MainInstrumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class MainInstrumentation : Instrumentation
const string Tag = "MAUI";

public static MainInstrumentation? Instance { get; private set; }
public static string ExternalDataDirectory { get; private set; } = string.Empty;

protected MainInstrumentation(IntPtr handle, JniHandleOwnership transfer)
: base(handle, transfer) { }
Expand All @@ -18,6 +19,13 @@ public override void OnCreate(Bundle? arguments)
base.OnCreate(arguments);

Instance = this;
ExternalDataDirectory = Context?.GetExternalFilesDir(null)?.ToString() ?? string.Empty;
if (string.IsNullOrEmpty(ExternalDataDirectory))
{
Log.Error(Tag, "ExternalDataDirectory is failed to be set");
return;
}
Log.Debug(Tag, $"ExternalDataDirectory: {ExternalDataDirectory}");

Start();
}
Expand All @@ -40,7 +48,7 @@ public async override void OnStart()
Environment.SetEnvironmentVariable("PERFLAB_QUEUE", "REPLACE_PERFLAB_QUEUE");
Environment.SetEnvironmentVariable("PERFLAB_BUILDARCH", "REPLACE_PERFLAB_BUILDARCH");
Environment.SetEnvironmentVariable("PERFLAB_LOCALE", "REPLACE_PERFLAB_LOCALE");
Directory.CreateDirectory("/storage/emulated/0/Android/data/com.microsoft.maui.benchmarks/files");
Directory.CreateDirectory(ExternalDataDirectory);
#endif

var success = await Task.Factory.StartNew(Run);
Expand Down

0 comments on commit 3634c7a

Please sign in to comment.