Merge pull request #3199 from jas14/fix-3197
Fix scheduling tasks on shutdown executor
This commit is contained in:
commit
0f79fc4d9d
|
@ -228,6 +228,15 @@ public class PlaybackServiceTaskManagerTest {
|
|||
pstm.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStartWidgetUpdaterAfterShutdown() {
|
||||
// Should not throw.
|
||||
final Context c = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
PlaybackServiceTaskManager pstm = new PlaybackServiceTaskManager(c, defaultPSTM);
|
||||
pstm.shutdown();
|
||||
pstm.startWidgetUpdater();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsWidgetUpdaterActive() {
|
||||
final Context c = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
|
|
@ -165,7 +165,7 @@ public class PlaybackServiceTaskManager {
|
|||
* Starts the widget updater task. If the widget updater is already active, nothing will happen.
|
||||
*/
|
||||
public synchronized void startWidgetUpdater() {
|
||||
if (!isWidgetUpdaterActive()) {
|
||||
if (!isWidgetUpdaterActive() && !schedExecutor.isShutdown()) {
|
||||
Runnable widgetUpdater = callback::onWidgetUpdaterTick;
|
||||
widgetUpdater = useMainThreadIfNecessary(widgetUpdater);
|
||||
widgetUpdaterFuture = schedExecutor.scheduleWithFixedDelay(widgetUpdater, WIDGET_UPDATER_NOTIFICATION_INTERVAL,
|
||||
|
|
Loading…
Reference in New Issue