Bug 1290467 - part9 : remove 'ACTION_REMOVE_CONTROL'.
Remove 'ACTION_REMOVE_CONTROL' because it's as same as 'ACTION_STOP'.
MozReview-Commit-ID: 6KOj8srEuJA
--- 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) {