From 18613e3b6fdb3d9dfbd53278381339d5e6b14fe8 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Sun, 10 Mar 2019 20:21:22 -0700 Subject: [PATCH] Remove generic foreground service condition from Job. I don't think it actually helps at all, meaning it just adds complexity. Fixes #8677 --- res/values/strings.xml | 6 ---- .../securesms/jobmanager/Job.java | 28 ------------------- .../jobs/PushNotificationReceiveJob.java | 5 ---- .../thoughtcrime/securesms/jobs/SendJob.java | 5 ---- 4 files changed, 44 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 91f30fcc43..b0594efb4c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -536,9 +536,6 @@ The version of Google Play Services you have installed is not functioning correctly. Please reinstall Google Play Services and try again. - - Retrieving a message... - Rate this app If you enjoy using this app, please take a moment to help us by rating it. @@ -627,9 +624,6 @@ Contacts Messages - - Sending a message... - Add to Contacts Invite to Signal diff --git a/src/org/thoughtcrime/securesms/jobmanager/Job.java b/src/org/thoughtcrime/securesms/jobmanager/Job.java index 6fbbea1b80..a68d2a8b47 100644 --- a/src/org/thoughtcrime/securesms/jobmanager/Job.java +++ b/src/org/thoughtcrime/securesms/jobmanager/Job.java @@ -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); } diff --git a/src/org/thoughtcrime/securesms/jobs/PushNotificationReceiveJob.java b/src/org/thoughtcrime/securesms/jobs/PushNotificationReceiveJob.java index e1d1ac9486..524e42b6c9 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushNotificationReceiveJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushNotificationReceiveJob.java @@ -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()); diff --git a/src/org/thoughtcrime/securesms/jobs/SendJob.java b/src/org/thoughtcrime/securesms/jobs/SendJob.java index cb0456b23f..b29f41b0d6 100644 --- a/src/org/thoughtcrime/securesms/jobs/SendJob.java +++ b/src/org/thoughtcrime/securesms/jobs/SendJob.java @@ -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) {