Search in sources :

Example 6 with RestStrategy

use of org.thoughtcrime.securesms.messages.RestStrategy in project Signal-Android by signalapp.

the class FcmJobService method onStartJob.

@Override
public boolean onStartJob(JobParameters params) {
    Log.d(TAG, "onStartJob()");
    if (BackgroundMessageRetriever.shouldIgnoreFetch()) {
        Log.i(TAG, "App is foregrounded. No need to run.");
        return false;
    }
    SignalExecutors.UNBOUNDED.execute(() -> {
        Context context = getApplicationContext();
        BackgroundMessageRetriever retriever = ApplicationDependencies.getBackgroundMessageRetriever();
        boolean success = retriever.retrieveMessages(context, new RestStrategy(), new RestStrategy());
        if (success) {
            Log.i(TAG, "Successfully retrieved messages.");
            jobFinished(params, false);
        } else {
            Log.w(TAG, "Failed to retrieve messages. Scheduling a retry.");
            jobFinished(params, true);
        }
    });
    return true;
}
Also used : Context(android.content.Context) BackgroundMessageRetriever(org.thoughtcrime.securesms.messages.BackgroundMessageRetriever) RestStrategy(org.thoughtcrime.securesms.messages.RestStrategy)

Aggregations

BackgroundMessageRetriever (org.thoughtcrime.securesms.messages.BackgroundMessageRetriever)6 RestStrategy (org.thoughtcrime.securesms.messages.RestStrategy)6 Context (android.content.Context)2 PushNotificationReceiveJob (org.thoughtcrime.securesms.jobs.PushNotificationReceiveJob)2 PushNetworkException (org.whispersystems.signalservice.api.push.exceptions.PushNetworkException)2