Skip to content

Commit

Permalink
Merge pull request #1256 from rantianhua/master
Browse files Browse the repository at this point in the history
Revert "fix: cannot start a foreground service if there is no any wai…
  • Loading branch information
Jacksgong authored Aug 27, 2019
2 parents f8daf9a + 80c9413 commit 77c787c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 32 deletions.
12 changes: 0 additions & 12 deletions demo/src/main/res/layout/activity_notification_entrance.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ IQueuesHandler getQueuesHandler() {
private static final Object INIT_LOST_CONNECTED_HANDLER_LOCK = new Object();
private ILostServiceConnectedHandler mLostConnectedHandler;

public ILostServiceConnectedHandler getLostConnectedHandler() {
ILostServiceConnectedHandler getLostConnectedHandler() {
if (mLostConnectedHandler == null) {
synchronized (INIT_LOST_CONNECTED_HANDLER_LOCK) {
if (mLostConnectedHandler == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,4 @@ public interface ILostServiceConnectedHandler {
* @return {@code true} if the start action was dispatched.
*/
boolean dispatchTaskStart(BaseDownloadTask.IRunningTask task);

/**
* @return {@code true} if there is task in waiting list.
*/
boolean haveWaitingTask();
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ public void taskWorkFine(BaseDownloadTask.IRunningTask task) {
}
}

@Override
public boolean haveWaitingTask() {
synchronized (mWaitingList) {
return !mWaitingList.isEmpty();
}
}

@Override
public boolean dispatchTaskStart(BaseDownloadTask.IRunningTask task) {
if (!FileDownloader.getImpl().isServiceConnected()) {
Expand All @@ -141,12 +134,12 @@ public boolean dispatchTaskStart(BaseDownloadTask.IRunningTask task) {
FileDownloadLog.d(this, "Waiting for connecting with the downloader "
+ "service... %d", task.getOrigin().getId());
}
FileDownloadServiceProxy.getImpl().
bindStartByContext(FileDownloadHelper.getAppContext());
if (!mWaitingList.contains(task)) {
task.free();
mWaitingList.add(task);
}
FileDownloadServiceProxy.getImpl().
bindStartByContext(FileDownloadHelper.getAppContext());
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import android.os.RemoteException;

import com.liulishuo.filedownloader.FileDownloadEventPool;
import com.liulishuo.filedownloader.FileDownloader;
import com.liulishuo.filedownloader.IFileDownloadServiceProxy;
import com.liulishuo.filedownloader.event.DownloadServiceConnectChangedEvent;
import com.liulishuo.filedownloader.util.ExtraKeys;
Expand Down Expand Up @@ -158,10 +157,7 @@ public void bindStartByContext(final Context context, final Runnable connectedRu
bindContexts.add(context);
}

boolean needMakeServiceForeground = FileDownloadUtils.needMakeServiceForeground(context);
boolean haveWaitingTask =
FileDownloader.getImpl().getLostConnectedHandler().haveWaitingTask();
runServiceForeground = needMakeServiceForeground && haveWaitingTask;
runServiceForeground = FileDownloadUtils.needMakeServiceForeground(context);
i.putExtra(ExtraKeys.IS_FOREGROUND, runServiceForeground);
context.bindService(i, this, Context.BIND_AUTO_CREATE);
if (runServiceForeground) {
Expand Down

0 comments on commit 77c787c

Please sign in to comment.