use of org.thoughtcrime.securesms.messages.RestStrategy in project Signal-Android by WhisperSystems.
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;
}
use of org.thoughtcrime.securesms.messages.RestStrategy in project Signal-Android by signalapp.
the class FcmFetchService method retrieveMessages.
static void retrieveMessages(@NonNull Context context) {
BackgroundMessageRetriever retriever = ApplicationDependencies.getBackgroundMessageRetriever();
boolean success = retriever.retrieveMessages(context, new RestStrategy(), new RestStrategy());
if (success) {
Log.i(TAG, "Successfully retrieved messages.");
} else {
if (Build.VERSION.SDK_INT >= 26) {
Log.w(TAG, "Failed to retrieve messages. Scheduling on the system JobScheduler (API " + Build.VERSION.SDK_INT + ").");
FcmJobService.schedule(context);
} else {
Log.w(TAG, "Failed to retrieve messages. Scheduling on JobManager (API " + Build.VERSION.SDK_INT + ").");
ApplicationDependencies.getJobManager().add(new PushNotificationReceiveJob());
}
}
}
use of org.thoughtcrime.securesms.messages.RestStrategy in project Signal-Android by signalapp.
the class PushNotificationReceiveJob method onRun.
@Override
public void onRun() throws IOException {
BackgroundMessageRetriever retriever = ApplicationDependencies.getBackgroundMessageRetriever();
boolean result = retriever.retrieveMessages(context, foregroundServiceDelayMs, new RestStrategy());
if (result) {
Log.i(TAG, "Successfully pulled messages.");
} else {
throw new PushNetworkException("Failed to pull messages.");
}
}
use of org.thoughtcrime.securesms.messages.RestStrategy in project Signal-Android by WhisperSystems.
the class FcmFetchService method retrieveMessages.
static void retrieveMessages(@NonNull Context context) {
BackgroundMessageRetriever retriever = ApplicationDependencies.getBackgroundMessageRetriever();
boolean success = retriever.retrieveMessages(context, new RestStrategy(), new RestStrategy());
if (success) {
Log.i(TAG, "Successfully retrieved messages.");
} else {
if (Build.VERSION.SDK_INT >= 26) {
Log.w(TAG, "Failed to retrieve messages. Scheduling on the system JobScheduler (API " + Build.VERSION.SDK_INT + ").");
FcmJobService.schedule(context);
} else {
Log.w(TAG, "Failed to retrieve messages. Scheduling on JobManager (API " + Build.VERSION.SDK_INT + ").");
ApplicationDependencies.getJobManager().add(new PushNotificationReceiveJob());
}
}
}
use of org.thoughtcrime.securesms.messages.RestStrategy in project Signal-Android by WhisperSystems.
the class PushNotificationReceiveJob method onRun.
@Override
public void onRun() throws IOException {
BackgroundMessageRetriever retriever = ApplicationDependencies.getBackgroundMessageRetriever();
boolean result = retriever.retrieveMessages(context, foregroundServiceDelayMs, new RestStrategy());
if (result) {
Log.i(TAG, "Successfully pulled messages.");
} else {
throw new PushNetworkException("Failed to pull messages.");
}
}
Aggregations