[Android] Correctly filter broadcasted intents to avoid unwanted actions

Ludovic Fauvet git at videolan.org
Thu Nov 1 16:06:06 CET 2012


vlc-ports/android | branch: master | Ludovic Fauvet <etix at videolan.org> | Thu Nov  1 15:35:55 2012 +0100| [9af711cff0de71b5128701eeb4d017b300c19976] | committer: Ludovic Fauvet

Correctly filter broadcasted intents to avoid unwanted actions

... like an unexpected start of VLC.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=9af711cff0de71b5128701eeb4d017b300c19976
---

 vlc-android/src/org/videolan/vlc/AudioService.java |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index fb30bf7..2c9f419 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -60,6 +60,7 @@ public class AudioService extends Service {
 
     private static final int SHOW_PROGRESS = 0;
     public static final String START_FROM_NOTIFICATION = "from_notification";
+    public static final String ACTION_REMOTE_GENERIC = "org.videolan.vlc.remote.";
     public static final String ACTION_REMOTE_BACKWARD = "org.videolan.vlc.remote.Backward";
     public static final String ACTION_REMOTE_PLAY = "org.videolan.vlc.remote.Play";
     public static final String ACTION_REMOTE_PLAYPAUSE = "org.videolan.vlc.remote.PlayPause";
@@ -263,7 +264,10 @@ public class AudioService extends Service {
             if (telManager != null && telManager.getCallState() != TelephonyManager.CALL_STATE_IDLE)
                 return;
 
-            if (!mLibVLC.isPlaying() && mCurrentMedia == null) {
+            /*
+             * Launch the activity if needed
+             */
+            if (action.startsWith(ACTION_REMOTE_GENERIC) && !mLibVLC.isPlaying() && mCurrentMedia == null) {
                 Intent iVlc = new Intent(context, MainActivity.class);
                 iVlc.putExtra(START_FROM_NOTIFICATION, true);
                 iVlc.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);



More information about the Android mailing list