diff options
Diffstat (limited to 'android/src/org/rockbox')
-rw-r--r-- | android/src/org/rockbox/RockboxActivity.java | 3 | ||||
-rw-r--r-- | android/src/org/rockbox/RockboxService.java | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/android/src/org/rockbox/RockboxActivity.java b/android/src/org/rockbox/RockboxActivity.java index 2e601cf041..cae0510229 100644 --- a/android/src/org/rockbox/RockboxActivity.java +++ b/android/src/org/rockbox/RockboxActivity.java @@ -81,6 +81,9 @@ public class RockboxActivity extends Activity case RockboxService.RESULT_ERROR_OCCURED: Toast.makeText(RockboxActivity.this, resultData.getString("error"), Toast.LENGTH_LONG); break; + case RockboxService.RESULT_ROCKBOX_EXIT: + finish(); + break; } } }); diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java index 3d7d7908c0..d078fe83b6 100644 --- a/android/src/org/rockbox/RockboxService.java +++ b/android/src/org/rockbox/RockboxService.java @@ -75,6 +75,7 @@ public class RockboxService extends Service public static final int RESULT_SERVICE_RUNNING = 3; public static final int RESULT_ERROR_OCCURED = 4; public static final int RESULT_LIB_LOADED = 5; + public static final int RESULT_ROCKBOX_EXIT = 6; @Override public void onCreate() @@ -270,7 +271,12 @@ public class RockboxService extends Service resultReceiver.send(RESULT_INVOKING_MAIN, null); main(); - throw new IllegalStateException("native main() returned!"); + + if (resultReceiver != null) + resultReceiver.send(RESULT_ROCKBOX_EXIT, null); + + LOG("Stop service: main() returned"); + stopSelf(); /* serivce is of no use anymore */ } }, "Rockbox thread"); rb.setDaemon(false); @@ -353,5 +359,11 @@ public class RockboxService extends Service stopForeground(); instance = null; rockbox_running = false; + System.runFinalization(); + /* exit() seems unclean but is needed in order to get the .so file garbage + * collected, otherwise Android caches this Service and librockbox.so + * The library must be reloaded to zero the bss and reset data + * segment */ + System.exit(0); } } |