Bug 1290467 - part9 : remove 'ACTION_REMOVE_CONTROL'. draft
authorAlastor Wu <alwu@mozilla.com>
Thu, 01 Sep 2016 16:46:09 +0800
changeset 408549 a6516f3939f221ef63798c9cd6b816911c13033b
parent 408548 71b8acc832fb2c64ef9bd98d0f7cd8f1ebea82fa
child 408550 3edc3082be9f91dbbfc41273f774e6a33b132665
push id28246
push useralwu@mozilla.com
push dateThu, 01 Sep 2016 09:12:50 +0000
bugs1290467
milestone51.0a1
Bug 1290467 - part9 : remove 'ACTION_REMOVE_CONTROL'. Remove 'ACTION_REMOVE_CONTROL' because it's as same as 'ACTION_STOP'. MozReview-Commit-ID: 6KOj8srEuJA
mobile/android/base/java/org/mozilla/gecko/media/MediaControlService.java
--- a/mobile/android/base/java/org/mozilla/gecko/media/MediaControlService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/media/MediaControlService.java
@@ -32,17 +32,16 @@ import java.lang.ref.WeakReference;
 public class MediaControlService extends Service implements Tabs.OnTabsChangedListener {
     private static final String LOGTAG = "MediaControlService";
 
     public static final String ACTION_INIT           = "action_init";
     public static final String ACTION_START          = "action_start";
     public static final String ACTION_RESUME         = "action_resume";
     public static final String ACTION_PAUSE          = "action_pause";
     public static final String ACTION_STOP           = "action_stop";
-    public static final String ACTION_REMOVE_CONTROL = "action_remove_control";
 
     private static final int MEDIA_CONTROL_ID = 1;
     private static final String MEDIA_CONTROL_PREF = "dom.audiochannel.mediaControl";
 
     private String mActionState = ACTION_STOP;
 
     private MediaSession mSession;
     private MediaController mController;
@@ -133,17 +132,17 @@ public class MediaControlService extends
     }
 
     private void shutdown() {
         if (!mInitialize) {
             return;
         }
 
         Log.d(LOGTAG, "shutdown");
-        notifyControlInterfaceChanged(ACTION_REMOVE_CONTROL);
+        notifyControlInterfaceChanged(ACTION_STOP);
         PrefsHelper.removeObserver(mPrefsObserver);
 
         Tabs.unregisterOnTabsChangedListener(this);
         mInitialize = false;
         stopSelf();
     }
 
     private boolean isAndroidVersionLollopopOrHigher() {
@@ -165,48 +164,42 @@ public class MediaControlService extends
                 break;
             case ACTION_RESUME :
                 mController.getTransportControls().play();
                 break;
             case ACTION_PAUSE :
                 mController.getTransportControls().pause();
                 break;
             case ACTION_STOP :
-                if (!mActionState.equals(ACTION_RESUME)) {
-                    return;
-                }
-                mController.getTransportControls().stop();
-                break;
-            case ACTION_REMOVE_CONTROL :
                 mController.getTransportControls().stop();
                 break;
         }
     }
 
     private void getGeckoPreference() {
         mPrefsObserver = new PrefsHelper.PrefHandlerBase() {
             @Override
             public void prefValue(String pref, boolean value) {
                 if (pref.equals(MEDIA_CONTROL_PREF)) {
                     mIsMediaControlPrefOn = value;
 
                     // If media is playing, we just need to create or remove
                     // the media control interface.
                     if (mActionState.equals(ACTION_RESUME)) {
                         notifyControlInterfaceChanged(mIsMediaControlPrefOn ?
-                            ACTION_PAUSE : ACTION_REMOVE_CONTROL);
+                            ACTION_PAUSE : ACTION_STOP);
                     }
 
                     // If turn off pref during pausing, except removing media
                     // interface, we also need to stop the service and notify
                     // gecko about that.
                     if (mActionState.equals(ACTION_PAUSE) &&
                         !mIsMediaControlPrefOn) {
                         Intent intent = new Intent(getApplicationContext(), MediaControlService.class);
-                        intent.setAction(ACTION_REMOVE_CONTROL);
+                        intent.setAction(ACTION_STOP);
                         handleIntent(intent);
                     }
                 }
             }
         };
         PrefsHelper.addObserver(mPrefs, mPrefsObserver);
     }
 
@@ -257,18 +250,17 @@ public class MediaControlService extends
         });
     }
 
     private void notifyObservers(String topic, String data) {
         GeckoAppShell.notifyObservers(topic, data);
     }
 
     private boolean isNeedToRemoveControlInterface(String action) {
-        return (action.equals(ACTION_STOP) ||
-                action.equals(ACTION_REMOVE_CONTROL));
+        return action.equals(ACTION_STOP);
     }
 
     private void notifyControlInterfaceChanged(final String action) {
         if (!mInitialize) {
             return;
         }
 
         Log.d(LOGTAG, "notifyControlInterfaceChanged, action = " + action);
@@ -354,17 +346,17 @@ public class MediaControlService extends
         Intent intent = new Intent(getApplicationContext(), BrowserApp.class);
         intent.setAction(GeckoApp.ACTION_SWITCH_TAB);
         intent.putExtra("TabId", tabId);
         return PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
     }
 
     private PendingIntent createDeleteIntent() {
         Intent intent = new Intent(getApplicationContext(), MediaControlService.class);
-        intent.setAction(ACTION_REMOVE_CONTROL);
+        intent.setAction(ACTION_STOP);
         return  PendingIntent.getService(getApplicationContext(), 1, intent, 0);
     }
 
     private Bitmap generateCoverArt(Tab tab) {
         final Bitmap favicon = tab.getFavicon();
 
         // If we do not have a favicon or if it's smaller than 72 pixels then just use the default icon.
         if (favicon == null || favicon.getWidth() < 72 || favicon.getHeight() < 72) {