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

Update the Benchmarks.Droid app to use built in Android GetExternalFilesDir #25015

Merged
Merged
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
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
Loading