move receivers to the top of music service
This commit is contained in:
parent
69e636e446
commit
2fd95ce432
1 changed files with 32 additions and 32 deletions
|
|
@ -86,7 +86,6 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
public static final String APP_WIDGET_UPDATE = PHONOGRAPH_PACKAGE_NAME + ".appwidgetupdate";
|
public static final String APP_WIDGET_UPDATE = PHONOGRAPH_PACKAGE_NAME + ".appwidgetupdate";
|
||||||
public static final String EXTRA_APP_WIDGET_NAME = PHONOGRAPH_PACKAGE_NAME + "app_widget_name";
|
public static final String EXTRA_APP_WIDGET_NAME = PHONOGRAPH_PACKAGE_NAME + "app_widget_name";
|
||||||
|
|
||||||
// do not change these three strings as it will break support with other apps like last.fm
|
|
||||||
public static final String META_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".metachanged";
|
public static final String META_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".metachanged";
|
||||||
public static final String QUEUE_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".queuechanged";
|
public static final String QUEUE_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".queuechanged";
|
||||||
public static final String PLAY_STATE_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".playstatechanged";
|
public static final String PLAY_STATE_CHANGED = PHONOGRAPH_PACKAGE_NAME + ".playstatechanged";
|
||||||
|
|
@ -118,9 +117,9 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
|
|
||||||
public boolean pendingQuit = false;
|
public boolean pendingQuit = false;
|
||||||
|
|
||||||
private AppWidgetAlbum appWidgetAlbum = AppWidgetAlbum.getInstance();
|
private final AppWidgetAlbum appWidgetAlbum = AppWidgetAlbum.getInstance();
|
||||||
private AppWidgetCard appWidgetCard = AppWidgetCard.getInstance();
|
private final AppWidgetCard appWidgetCard = AppWidgetCard.getInstance();
|
||||||
private AppWidgetClassic appWidgetClassic = AppWidgetClassic.getInstance();
|
private final AppWidgetClassic appWidgetClassic = AppWidgetClassic.getInstance();
|
||||||
|
|
||||||
private Playback playback;
|
private Playback playback;
|
||||||
|
|
||||||
|
|
@ -132,20 +131,16 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
|
|
||||||
private int shuffleMode;
|
private int shuffleMode;
|
||||||
private int repeatMode;
|
private int repeatMode;
|
||||||
|
|
||||||
|
private boolean notHandledMetaChangedForCurrentTrack;
|
||||||
private boolean queuesRestored;
|
private boolean queuesRestored;
|
||||||
private boolean pausedByTransientLossOfFocus;
|
private boolean pausedByTransientLossOfFocus;
|
||||||
|
|
||||||
private PlayingNotification playingNotification;
|
private PlayingNotification playingNotification;
|
||||||
private AudioManager audioManager;
|
private AudioManager audioManager;
|
||||||
private MediaSessionCompat mediaSession;
|
private MediaSessionCompat mediaSession;
|
||||||
private PowerManager.WakeLock wakeLock;
|
private PowerManager.WakeLock wakeLock;
|
||||||
|
|
||||||
private final AudioManager.OnAudioFocusChangeListener audioFocusListener = new AudioManager.OnAudioFocusChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onAudioFocusChange(final int focusChange) {
|
|
||||||
playerHandler.obtainMessage(FOCUS_CHANGE, focusChange, 0).sendToTarget();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private PlaybackHandler playerHandler;
|
private PlaybackHandler playerHandler;
|
||||||
private Handler uiThreadHandler;
|
private Handler uiThreadHandler;
|
||||||
private ThrottledSeekHandler throttledSeekHandler;
|
private ThrottledSeekHandler throttledSeekHandler;
|
||||||
|
|
@ -164,7 +159,32 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private boolean notHandledMetaChangedForCurrentTrack;
|
private final BroadcastReceiver widgetIntentReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(final Context context, final Intent intent) {
|
||||||
|
final String command = intent.getStringExtra(EXTRA_APP_WIDGET_NAME);
|
||||||
|
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
||||||
|
|
||||||
|
switch (command) {
|
||||||
|
case AppWidgetClassic.NAME:
|
||||||
|
appWidgetClassic.performUpdate(MusicService.this, ids);
|
||||||
|
break;
|
||||||
|
case AppWidgetAlbum.NAME:
|
||||||
|
appWidgetAlbum.performUpdate(MusicService.this, ids);
|
||||||
|
break;
|
||||||
|
case AppWidgetCard.NAME:
|
||||||
|
appWidgetCard.performUpdate(MusicService.this, ids);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final AudioManager.OnAudioFocusChangeListener audioFocusListener = new AudioManager.OnAudioFocusChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onAudioFocusChange(final int focusChange) {
|
||||||
|
playerHandler.obtainMessage(FOCUS_CHANGE, focusChange, 0).sendToTarget();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private static final long MEDIA_SESSION_ACTIONS = PlaybackStateCompat.ACTION_PLAY
|
private static final long MEDIA_SESSION_ACTIONS = PlaybackStateCompat.ACTION_PLAY
|
||||||
| PlaybackStateCompat.ACTION_PAUSE
|
| PlaybackStateCompat.ACTION_PAUSE
|
||||||
|
|
@ -1157,26 +1177,6 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final BroadcastReceiver widgetIntentReceiver = new BroadcastReceiver() {
|
|
||||||
@Override
|
|
||||||
public void onReceive(final Context context, final Intent intent) {
|
|
||||||
final String command = intent.getStringExtra(EXTRA_APP_WIDGET_NAME);
|
|
||||||
final int[] ids = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);
|
|
||||||
|
|
||||||
switch (command) {
|
|
||||||
case AppWidgetClassic.NAME:
|
|
||||||
appWidgetClassic.performUpdate(MusicService.this, ids);
|
|
||||||
break;
|
|
||||||
case AppWidgetAlbum.NAME:
|
|
||||||
appWidgetAlbum.performUpdate(MusicService.this, ids);
|
|
||||||
break;
|
|
||||||
case AppWidgetCard.NAME:
|
|
||||||
appWidgetCard.performUpdate(MusicService.this, ids);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private class ThrottledSeekHandler implements Runnable {
|
private class ThrottledSeekHandler implements Runnable {
|
||||||
// milliseconds to throttle before calling run to aggregate events
|
// milliseconds to throttle before calling run to aggregate events
|
||||||
private static final long THROTTLE = 500;
|
private static final long THROTTLE = 500;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue