89 lines
4.1 KiB
Java
89 lines
4.1 KiB
Java
package com.discord.workers;
|
|
|
|
import android.content.Context;
|
|
import androidx.work.Data;
|
|
import androidx.work.ListenableWorker;
|
|
import androidx.work.Worker;
|
|
import androidx.work.WorkerParameters;
|
|
import com.discord.app.AppLog;
|
|
import com.discord.utilities.fcm.NotificationClient;
|
|
import com.discord.utilities.io.NetworkUtils;
|
|
import com.discord.utilities.logging.Logger;
|
|
import com.discord.utilities.rest.RestAPI;
|
|
import d0.z.d.m;
|
|
import j0.m.b;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import rx.Observable;
|
|
/* compiled from: CallActionWorker.kt */
|
|
public final class CallActionWorker extends Worker {
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public CallActionWorker(Context context, WorkerParameters workerParameters) {
|
|
super(context, workerParameters);
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(workerParameters, "params");
|
|
}
|
|
|
|
@Override // androidx.work.Worker
|
|
public ListenableWorker.Result doWork() {
|
|
long j;
|
|
long j2;
|
|
Throwable th;
|
|
AppLog appLog = AppLog.g;
|
|
String simpleName = CallActionWorker.class.getSimpleName();
|
|
m.checkNotNullExpressionValue(simpleName, "javaClass.simpleName");
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Starting for [");
|
|
Data inputData = getInputData();
|
|
m.checkNotNullExpressionValue(inputData, "inputData");
|
|
sb.append(inputData.getKeyValueMap());
|
|
sb.append(']');
|
|
Logger.i$default(appLog, simpleName, sb.toString(), null, 4, null);
|
|
if (!NotificationClient.INSTANCE.isAuthed()) {
|
|
String simpleName2 = CallActionWorker.class.getSimpleName();
|
|
m.checkNotNullExpressionValue(simpleName2, "javaClass.simpleName");
|
|
Logger.d$default(appLog, simpleName2, "Not authenticated. Aborting job request.", null, 4, null);
|
|
ListenableWorker.Result failure = ListenableWorker.Result.failure();
|
|
m.checkNotNullExpressionValue(failure, "Result.failure()");
|
|
return failure;
|
|
}
|
|
NetworkUtils networkUtils = NetworkUtils.INSTANCE;
|
|
Context applicationContext = getApplicationContext();
|
|
m.checkNotNullExpressionValue(applicationContext, "applicationContext");
|
|
if (!NetworkUtils.isDeviceConnected$default(networkUtils, applicationContext, null, null, 6, null)) {
|
|
ListenableWorker.Result retry = ListenableWorker.Result.retry();
|
|
m.checkNotNullExpressionValue(retry, "Result.retry()");
|
|
return retry;
|
|
}
|
|
long j3 = getInputData().getLong("com.discord.intent.extra.EXTRA_CHANNEL_ID", -1);
|
|
long j4 = getInputData().getLong("com.discord.intent.extra.EXTRA_MESSAGE_ID", -1);
|
|
try {
|
|
Observable<Void> stopRinging = RestAPI.Companion.getApi().stopRinging(j3, j4, (List<Long>) null);
|
|
Objects.requireNonNull(stopRinging);
|
|
new b(stopRinging).a();
|
|
String simpleName3 = getClass().getSimpleName();
|
|
m.checkNotNullExpressionValue(simpleName3, "javaClass.simpleName");
|
|
j = j4;
|
|
j2 = j3;
|
|
try {
|
|
Logger.d$default(appLog, simpleName3, "Call declined: " + j3 + '-' + j4, null, 4, null);
|
|
ListenableWorker.Result success = ListenableWorker.Result.success();
|
|
m.checkNotNullExpressionValue(success, "Result.success()");
|
|
return success;
|
|
} catch (Throwable th2) {
|
|
th = th2;
|
|
}
|
|
} catch (Throwable th3) {
|
|
th = th3;
|
|
j = j4;
|
|
j2 = j3;
|
|
AppLog appLog2 = AppLog.g;
|
|
String simpleName4 = CallActionWorker.class.getSimpleName();
|
|
m.checkNotNullExpressionValue(simpleName4, "javaClass.simpleName");
|
|
appLog2.w(simpleName4, "Call declined failure: " + j2 + '-' + j, th);
|
|
ListenableWorker.Result retry2 = getRunAttemptCount() < 3 ? ListenableWorker.Result.retry() : ListenableWorker.Result.failure();
|
|
m.checkNotNullExpressionValue(retry2, "if (runAttemptCount < MA…y() else Result.failure()");
|
|
return retry2;
|
|
}
|
|
}
|
|
}
|