99import android .content .pm .PackageManager ;
1010import android .content .res .AssetManager ;
1111import android .os .Bundle ;
12+ import android .os .Looper ;
1213import android .util .Log ;
1314import android .view .View ;
1415import android .app .Activity ;
@@ -32,6 +33,7 @@ public class MonoRunner extends Instrumentation
3233 }
3334
3435 static String entryPointLibName = "%EntryPointLibName%" ;
36+ static Bundle result = new Bundle ();
3537
3638 @ Override
3739 public void onCreate (Bundle arguments ) {
@@ -62,33 +64,32 @@ public static int initialize(String entryPointLibName, Context context) {
6264 // unzip libs and test files to filesDir
6365 unzipAssets (context , filesDir , "assets.zip" );
6466
65- Log .i ("DOTNET" , "initRuntime , entryPointLibName=" + entryPointLibName );
67+ Log .i ("DOTNET" , "MonoRunner initialize , entryPointLibName=" + entryPointLibName );
6668 return initRuntime (filesDir , cacheDir , docsDir , entryPointLibName );
6769 }
6870
6971 @ Override
7072 public void onStart () {
71- super . onStart ();
73+ Looper . prepare ();
7274
7375 if (entryPointLibName == "" ) {
7476 Log .e ("DOTNET" , "Missing entryPointLibName argument, pass '-e entryPointLibName <name.dll>' to adb to specify which program to run." );
7577 finish (1 , null );
7678 return ;
7779 }
7880 int retcode = initialize (entryPointLibName , getContext ());
79- runOnMainSync (new Runnable () {
80- public void run () {
81- Bundle result = new Bundle ();
82- result .putInt ("return-code" , retcode );
83-
84- // Xharness cli expects "test-results-path" with test results
85- File testResults = new File (getDocsDir (getContext ()) + "/testResults.xml" );
86- if (testResults .exists ()) {
87- result .putString ("test-results-path" , testResults .getAbsolutePath ());
88- }
89- finish (retcode , result );
90- }
91- });
81+
82+ Log .i ("DOTNET" , "MonoRunner finished, return-code=" + retcode );
83+ result .putInt ("return-code" , retcode );
84+
85+ // Xharness cli expects "test-results-path" with test results
86+ File testResults = new File (getDocsDir (getContext ()) + "/testResults.xml" );
87+ if (testResults .exists ()) {
88+ Log .i ("DOTNET" , "MonoRunner finished, test-results-path=" + testResults .getAbsolutePath ());
89+ result .putString ("test-results-path" , testResults .getAbsolutePath ());
90+ }
91+
92+ finish (retcode , result );
9293 }
9394
9495 static void unzipAssets (Context context , String toPath , String zipName ) {
0 commit comments