Bug 1290467 - part9 : remove 'ACTION_REMOVE_CONTROL'. r=sebastian
authorAlastor Wu <alwu@mozilla.com>
Fri, 09 Sep 2016 09:51:10 +0800
changeset 354575 0ccb80fc769b96d1f342d6fcc5e6a748d1a186f4
parent 354574 9c459f432b365a3c209f150df5864d3299a91e1f
child 354576 52a630b9ed23a9ca199837644a616dfa8407339a
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1290467
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1290467 - part9 : remove 'ACTION_REMOVE_CONTROL'. r=sebastian 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;
@@ -132,17 +131,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);
@@ -355,17 +347,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) {