summaryrefslogtreecommitdiff
path: root/android/src/org/rockbox/RockboxService.java
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2011-02-26 19:54:03 +0000
committerThomas Martitz <kugel@rockbox.org>2011-02-26 19:54:03 +0000
commiteb016648045abdb80ee4e98cde405eb0c62b724c (patch)
tree3b14be88d4201b1de382e5cb481745429b95455e /android/src/org/rockbox/RockboxService.java
parent75aa83526f4410eaddafc0c9188b9d885d05302f (diff)
Android: Simplify media button intent generation in the widget and cleanup RockboxService accordingly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29404 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'android/src/org/rockbox/RockboxService.java')
-rw-r--r--android/src/org/rockbox/RockboxService.java40
1 files changed, 13 insertions, 27 deletions
diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java
index 4f0caa7704..5465152aa8 100644
--- a/android/src/org/rockbox/RockboxService.java
+++ b/android/src/org/rockbox/RockboxService.java
@@ -105,8 +105,8 @@ public class RockboxService extends Service
private void do_start(Intent intent)
{
- LOG("Start Service");
- if (intent != null && intent.hasExtra("callback"))
+ LOG("Start RockboxService (Intent: " + intent.getAction() + ")");
+ if (intent.hasExtra("callback"))
resultReceiver = (ResultReceiver) intent.getParcelableExtra("callback");
if (!rockbox_running)
@@ -114,32 +114,18 @@ public class RockboxService extends Service
if (resultReceiver != null)
resultReceiver.send(RESULT_LIB_LOADED, null);
-
- if (intent != null && intent.getAction() != null)
- {
- if (!rockbox_running)
- { /* give it a bit of time so we can register button presses
- * sleeping longer doesn't work here, apparently Android
- * surpresses long sleeps during intent handling */
- try {
- Thread.sleep(50);
- }
- catch (InterruptedException e) { }
- }
+ if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON))
+ {
+ /* give it a bit of time so we can register button presses
+ * sleeping longer doesn't work here, apparently Android
+ * surpresses long sleeps during intent handling */
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) { }
- if (intent.getAction().equals(Intent.ACTION_MEDIA_BUTTON))
- {
- KeyEvent kev = (KeyEvent)intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
- RockboxFramebuffer.buttonHandler(kev.getKeyCode(), kev.getAction() == KeyEvent.ACTION_DOWN);
- }
- else if (intent.getAction().equals("org.rockbox.PlayPause"))
- RockboxFramebuffer.buttonHandler(KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE, false);
- else if (intent.getAction().equals("org.rockbox.Prev"))
- RockboxFramebuffer.buttonHandler(KeyEvent.KEYCODE_MEDIA_PREVIOUS, false);
- else if (intent.getAction().equals("org.rockbox.Next"))
- RockboxFramebuffer.buttonHandler(KeyEvent.KEYCODE_MEDIA_NEXT, false);
- else if (intent.getAction().equals("org.rockbox.Stop"))
- RockboxFramebuffer.buttonHandler(KeyEvent.KEYCODE_MEDIA_STOP, false);
+ KeyEvent kev = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
+ RockboxFramebuffer.buttonHandler(kev.getKeyCode(),
+ kev.getAction() == KeyEvent.ACTION_DOWN);
}
/* (Re-)attach the media button receiver, in case it has been lost */