From d171a7ccc65fd284fe7e81ea3ff11d38360387bb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 19 Jan 2013 05:45:29 +0100 Subject: Fix ActivityLauncher/MainLauncher .. and make adb-launch-main more suitable - ActivityLauncher - no finish() from onDestroy() - MainLauncher - finish activity after returning 'main()' returns - no finish() from onDestroy() - adb-launch-main: - Clear logcat - Wait until activity is stopped - Dump logcat to local logfile --- make/scripts/adb-launch-main.sh | 13 ++++--- .../jogamp/android/launcher/ActivityLauncher.java | 1 - src/java/jogamp/android/launcher/MainLauncher.java | 40 +++++++++------------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/make/scripts/adb-launch-main.sh b/make/scripts/adb-launch-main.sh index 039e2e8..bb2d008 100644 --- a/make/scripts/adb-launch-main.sh +++ b/make/scripts/adb-launch-main.sh @@ -24,10 +24,11 @@ TSTCLASS=com.jogamp.common.GlueGenVersion LOGFILE=`basename $0 .sh`.log -adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall jogamp.android.launcher -adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall com.jogamp.common -adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jogamp-android-launcher.apk -adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/gluegen-rt-android-armeabi.apk +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall jogamp.android.launcher +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jogamp-android-launcher.apk + +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall com.jogamp.common +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/gluegen-rt-android-armeabi.apk SHELL_CMD="\ cd /sdcard ; \ @@ -35,9 +36,11 @@ if [ -e $TARGET_ROOT ] ; then rm -r $TARGET_ROOT ; fi ; \ mkdir $TARGET_ROOT ; cd $TARGET_ROOT ; \ setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \ am kill-all ; \ -am start -S -a android.intent.action.MAIN -n jogamp.android.launcher/jogamp.android.launcher.MainLauncher -d launch://jogamp.org/$TSTCLASS/?pkg=com.jogamp.common \ +am start -W -S -a android.intent.action.MAIN -n jogamp.android.launcher/jogamp.android.launcher.MainLauncher -d launch://jogamp.org/$TSTCLASS/?pkg=com.jogamp.common \ " adb connect $TARGET_IP:$TARGET_ADB_PORT +adb -s $TARGET_IP:$TARGET_ADB_PORT logcat -c adb -s $TARGET_IP:$TARGET_ADB_PORT shell $SHELL_CMD 2>&1 | tee $LOGFILE +adb -s $TARGET_IP:$TARGET_ADB_PORT logcat -d 2>&1 | tee $LOGFILE diff --git a/src/java/jogamp/android/launcher/ActivityLauncher.java b/src/java/jogamp/android/launcher/ActivityLauncher.java index 6620b59..0ac940e 100644 --- a/src/java/jogamp/android/launcher/ActivityLauncher.java +++ b/src/java/jogamp/android/launcher/ActivityLauncher.java @@ -139,7 +139,6 @@ public class ActivityLauncher extends Activity { data = null; } super.onDestroy(); - finish(); Log.d(TAG, "onDestroy - X"); } diff --git a/src/java/jogamp/android/launcher/MainLauncher.java b/src/java/jogamp/android/launcher/MainLauncher.java index c146668..d4ac4ca 100644 --- a/src/java/jogamp/android/launcher/MainLauncher.java +++ b/src/java/jogamp/android/launcher/MainLauncher.java @@ -113,27 +113,25 @@ public class MainLauncher extends Activity { Log.d(TAG, "onRestart - X"); } - private volatile Thread mainThread = null; - @Override public void onResume() { - Log.d(TAG, "onResume - S"); + Log.d(TAG, "onResume - S - "+Thread.currentThread().getName()); super.onResume(); - if(null == mainThread) { - mainThread = new Thread("Main") { - public void run() { - try { - mainClazzMain.invoke(null, new Object[] { mainClassArgs } ); - } catch (InvocationTargetException ite) { - ite.getTargetException().printStackTrace(); - } catch (Throwable t) { - t.printStackTrace(); - } - mainThread = null; - } }; - mainThread.start(); - } - Log.d(TAG, "onResume - X"); + final Thread mainThread = new Thread("Main") { + public void run() { + try { + Log.d(TAG, "onResume - main.0 - "+Thread.currentThread().getName()); + mainClazzMain.invoke(null, new Object[] { mainClassArgs } ); + } catch (InvocationTargetException ite) { + ite.getTargetException().printStackTrace(); + } catch (Throwable t) { + t.printStackTrace(); + } + Log.d(TAG, "onResume - main.X -> finish() - "+Thread.currentThread().getName()); + finish(); + } }; + mainThread.start(); + Log.d(TAG, "onResume - X - "+Thread.currentThread().getName()); } @Override @@ -159,18 +157,12 @@ public class MainLauncher extends Activity { } callMethod(null, mStaticContextClear); super.onDestroy(); - finish(); Log.d(TAG, "onDestroy - X"); } @Override public void finish() { Log.d(TAG, "finish - S"); - if(null != mainThread) { - // FIXME: No means to trigger an exit a main class, or do we ? - // mainThread.destroy(); // n/a on Android - mainThread = null; - } super.finish(); Log.d(TAG, "finish - X"); } -- cgit v1.2.3