Remove generic foreground service condition from Job.

I don't think it actually helps at all, meaning it just adds
complexity.

Fixes #8677
This commit is contained in:
Greyson Parrelli
2019-03-10 20:21:22 -07:00
committed by Alan Evans
parent 278fdebf43
commit 18613e3b6f
4 changed files with 0 additions and 44 deletions

View File

@@ -82,8 +82,6 @@ public abstract class Job extends Worker implements Serializable {
((ContextDependent)this).setContext(getApplicationContext());
}
boolean foregroundRunning = false;
try {
initialize(new SafeData(data));
@@ -102,12 +100,6 @@ public abstract class Job extends Worker implements Serializable {
return retry();
}
if (needsForegroundService(data)) {
Log.i(TAG, "Running a foreground service with description '" + getDescription() + "' to aid in job execution." + logSuffix());
GenericForegroundService.startForegroundTask(getApplicationContext(), getDescription());
foregroundRunning = true;
}
onRun();
log("Successfully completed." + logSuffix());
@@ -119,11 +111,6 @@ public abstract class Job extends Worker implements Serializable {
}
warn("Failing due to an exception." + logSuffix(), e);
return cancel();
} finally {
if (foregroundRunning) {
Log.i(TAG, "Stopping the foreground service." + logSuffix());
GenericForegroundService.stopForegroundTask(getApplicationContext());
}
}
}
@@ -142,14 +129,6 @@ public abstract class Job extends Worker implements Serializable {
onAdded();
}
/**
* @return A string that represents what the task does. Will be shown in a foreground notification
* if necessary.
*/
protected String getDescription() {
return getApplicationContext().getString(R.string.Job_working_in_the_background);
}
/**
* Called after a run has finished and we've determined a retry is required, but before the next
* attempt is run.
@@ -238,13 +217,6 @@ public abstract class Job extends Worker implements Serializable {
return System.currentTimeMillis() < retryUntil;
}
private boolean needsForegroundService(@NonNull Data data) {
NetworkRequirement networkRequirement = new NetworkRequirement(getApplicationContext());
boolean requiresNetwork = data.getBoolean(KEY_REQUIRES_NETWORK, false);
return requiresNetwork && !networkRequirement.isPresent();
}
private void log(@NonNull String message) {
log(message, null);
}

View File

@@ -45,11 +45,6 @@ public class PushNotificationReceiveJob extends PushReceivedJob implements Injec
return dataBuilder.build();
}
@Override
protected String getDescription() {
return context.getString(R.string.PushNotificationReceiveJob_retrieving_a_message);
}
@Override
public void onRun() throws IOException {
pullAndProcessMessages(receiver, TAG, System.currentTimeMillis());

View File

@@ -39,11 +39,6 @@ public abstract class SendJob extends ContextJob {
super(context, parameters);
}
@Override
protected String getDescription() {
return context.getString(R.string.SendJob_sending_a_message);
}
@Override
public final void onRun() throws Exception {
if (Util.getDaysTillBuildExpiry() <= 0) {