summaryrefslogtreecommitdiffstats
path: root/android/src/org/rockbox
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-03-16 15:17:24 +0000
committerThomas Martitz <kugel@rockbox.org>2011-03-16 15:17:24 +0000
commit8c46ddf9d719fb29f483dc21993167907953f39c (patch)
tree03d99235b88ba6f327db503f65e67061ae5568e3 /android/src/org/rockbox
parent046cec3aa7fd58a9519cad8d693b47a2400e1742 (diff)
downloadrockbox-8c46ddf9d719fb29f483dc21993167907953f39c.tar.gz
rockbox-8c46ddf9d719fb29f483dc21993167907953f39c.tar.bz2
rockbox-8c46ddf9d719fb29f483dc21993167907953f39c.zip
Android: Implement app shutdown and thus, sleep timer.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29602 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android/src/org/rockbox')
-rw-r--r--android/src/org/rockbox/RockboxActivity.java3
-rw-r--r--android/src/org/rockbox/RockboxService.java14
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);
}
}