Fix scheduler NPE in DownloadService

PiperOrigin-RevId: 230260266
This commit is contained in:
olly 2019-01-21 23:52:18 +00:00 committed by Oliver Woodman
parent 29711b922d
commit de3a749b97
2 changed files with 2 additions and 2 deletions

View File

@ -65,7 +65,7 @@ public class DemoDownloadService extends DownloadService {
@Override @Override
protected void onDownloadStateChanged(DownloadState downloadState) { protected void onDownloadStateChanged(DownloadState downloadState) {
Notification notification = null; Notification notification;
if (downloadState.state == DownloadState.STATE_COMPLETED) { if (downloadState.state == DownloadState.STATE_COMPLETED) {
notification = notification =
DownloadNotificationUtil.buildDownloadCompletedNotification( DownloadNotificationUtil.buildDownloadCompletedNotification(

View File

@ -462,7 +462,7 @@ public abstract class DownloadService extends Service {
public void detachService(DownloadService downloadService, boolean unschedule) { public void detachService(DownloadService downloadService, boolean unschedule) {
Assertions.checkState(this.downloadService == downloadService); Assertions.checkState(this.downloadService == downloadService);
this.downloadService = null; this.downloadService = null;
if (unschedule) { if (scheduler != null && unschedule) {
scheduler.cancel(); scheduler.cancel();
} }
} }