mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
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:
parent
278fdebf43
commit
18613e3b6f
@ -536,9 +536,6 @@
|
|||||||
<!-- PlayServicesProblemFragment -->
|
<!-- PlayServicesProblemFragment -->
|
||||||
<string name="PlayServicesProblemFragment_the_version_of_google_play_services_you_have_installed_is_not_functioning">The version of Google Play Services you have installed is not functioning correctly. Please reinstall Google Play Services and try again.</string>
|
<string name="PlayServicesProblemFragment_the_version_of_google_play_services_you_have_installed_is_not_functioning">The version of Google Play Services you have installed is not functioning correctly. Please reinstall Google Play Services and try again.</string>
|
||||||
|
|
||||||
<!-- PushNotificationReceiveJob -->
|
|
||||||
<string name="PushNotificationReceiveJob_retrieving_a_message">Retrieving a message...</string>
|
|
||||||
|
|
||||||
<!-- RatingManager -->
|
<!-- RatingManager -->
|
||||||
<string name="RatingManager_rate_this_app">Rate this app</string>
|
<string name="RatingManager_rate_this_app">Rate this app</string>
|
||||||
<string name="RatingManager_if_you_enjoy_using_this_app_please_take_a_moment">If you enjoy using this app, please take a moment to help us by rating it.</string>
|
<string name="RatingManager_if_you_enjoy_using_this_app_please_take_a_moment">If you enjoy using this app, please take a moment to help us by rating it.</string>
|
||||||
@ -627,9 +624,6 @@
|
|||||||
<string name="SearchFragment_header_contacts">Contacts</string>
|
<string name="SearchFragment_header_contacts">Contacts</string>
|
||||||
<string name="SearchFragment_header_messages">Messages</string>
|
<string name="SearchFragment_header_messages">Messages</string>
|
||||||
|
|
||||||
<!-- SendJob -->
|
|
||||||
<string name="SendJob_sending_a_message">Sending a message...</string>
|
|
||||||
|
|
||||||
<!-- SharedContactDetailsActivity -->
|
<!-- SharedContactDetailsActivity -->
|
||||||
<string name="SharedContactDetailsActivity_add_to_contacts">Add to Contacts</string>
|
<string name="SharedContactDetailsActivity_add_to_contacts">Add to Contacts</string>
|
||||||
<string name="SharedContactDetailsActivity_invite_to_signal">Invite to Signal</string>
|
<string name="SharedContactDetailsActivity_invite_to_signal">Invite to Signal</string>
|
||||||
|
@ -82,8 +82,6 @@ public abstract class Job extends Worker implements Serializable {
|
|||||||
((ContextDependent)this).setContext(getApplicationContext());
|
((ContextDependent)this).setContext(getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean foregroundRunning = false;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
initialize(new SafeData(data));
|
initialize(new SafeData(data));
|
||||||
|
|
||||||
@ -102,12 +100,6 @@ public abstract class Job extends Worker implements Serializable {
|
|||||||
return retry();
|
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();
|
onRun();
|
||||||
|
|
||||||
log("Successfully completed." + logSuffix());
|
log("Successfully completed." + logSuffix());
|
||||||
@ -119,11 +111,6 @@ public abstract class Job extends Worker implements Serializable {
|
|||||||
}
|
}
|
||||||
warn("Failing due to an exception." + logSuffix(), e);
|
warn("Failing due to an exception." + logSuffix(), e);
|
||||||
return cancel();
|
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();
|
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
|
* Called after a run has finished and we've determined a retry is required, but before the next
|
||||||
* attempt is run.
|
* attempt is run.
|
||||||
@ -238,13 +217,6 @@ public abstract class Job extends Worker implements Serializable {
|
|||||||
return System.currentTimeMillis() < retryUntil;
|
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) {
|
private void log(@NonNull String message) {
|
||||||
log(message, null);
|
log(message, null);
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,6 @@ public class PushNotificationReceiveJob extends PushReceivedJob implements Injec
|
|||||||
return dataBuilder.build();
|
return dataBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getDescription() {
|
|
||||||
return context.getString(R.string.PushNotificationReceiveJob_retrieving_a_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRun() throws IOException {
|
public void onRun() throws IOException {
|
||||||
pullAndProcessMessages(receiver, TAG, System.currentTimeMillis());
|
pullAndProcessMessages(receiver, TAG, System.currentTimeMillis());
|
||||||
|
@ -39,11 +39,6 @@ public abstract class SendJob extends ContextJob {
|
|||||||
super(context, parameters);
|
super(context, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getDescription() {
|
|
||||||
return context.getString(R.string.SendJob_sending_a_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onRun() throws Exception {
|
public final void onRun() throws Exception {
|
||||||
if (Util.getDaysTillBuildExpiry() <= 0) {
|
if (Util.getDaysTillBuildExpiry() <= 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user