Proxy Master v3.4.9版本的 MD5 值为:14d0aa2468d13530c8f6e96bcc114bf5

以下内容为反编译后的 FastVpnService.java 源代码,内容仅作参考


package com.free.vpn.proxy.master.proxy;

import android.app.NotificationManager;
import android.content.Intent;
import android.net.VpnService;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.text.TextUtils;
import com.alibaba.fastjson.JSON;
import com.google.firebase.remoteconfig.FirebaseRemoteConfig;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedSelectorException;
import java.nio.channels.ConnectionPendingException;
import java.nio.channels.NoConnectionPendingException;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import n7.e;
import o.h;
import y4.b;
import y4.c;
import y4.d;
import ye.g0;
public class FastVpnService extends VpnService {
    public static long f6851s;
    public static long f6852t;
    public static final int f6853u = 0;
    public ParcelFileDescriptor f6854b;
    public int f6857e;
    public Thread f6858f;
    public Handler f6859g;
    public d f6860h;
    public byte[] f6862j;
    public int f6863k;
    public SocketChannel f6864l;
    public List<d> f6865m;
    public ConnBean f6867o;
    public Selector f6869q;
    public boolean f6855c = false;
    public boolean f6856d = true;
    public final int f6861i = 8400;
    public String f6866n = "bing.com";
    public int f6868p = 0;
    public final b f6870r = new b();

    public class a implements Runnable {
        public a() {
        }

        @Override
        public final void run() {
            if (c.f36902d == null) {
                c.f36902d = new c();
            }
            c cVar = c.f36902d;
            FastVpnService fastVpnService = FastVpnService.this;
            ((NotificationManager) fastVpnService.getSystemService("notification")).notify(2, cVar.a(fastVpnService));
            fastVpnService.f6859g.postDelayed(this, 1000L);
        }
    }

    public class b implements Runnable {
        public b() {
        }

        @Override
        public final void run() {
            FastVpnService fastVpnService;
            String str;
            int i10;
            while (true) {
                fastVpnService = FastVpnService.this;
                if (fastVpnService.f6856d) {
                    break;
                }
                try {
                    if (fastVpnService.f6865m == null) {
                        fastVpnService.f6865m = new ArrayList();
                    }
                    fastVpnService.f6865m.clear();
                    if (fastVpnService.f6867o == null) {
                        break;
                    }
                    d dVar = new d();
                    dVar.f36906a = fastVpnService.f6867o.getIp();
                    dVar.f36907b = fastVpnService.f6867o.getCountry();
                    dVar.f36908c = fastVpnService.f6867o.getPort();
                    fastVpnService.f6867o.getIp();
                    fastVpnService.f6867o.getPort();
                    SimpleDateFormat simpleDateFormat = e.f28649f;
                    fastVpnService.f6865m.add(dVar);
                    break;
                } catch (Exception e10) {
                    e10.printStackTrace();
                }
            }
            if (fastVpnService.f6856d) {
                return;
            }
            fastVpnService.f6862j = new byte[fastVpnService.f6861i];
            fastVpnService.f6863k = 0;
            FastVpnService.f6851s = 0L;
            FastVpnService.f6852t = 0L;
            if (y4.b.f36895e == null) {
                y4.b.f36895e = new y4.b();
            }
            y4.b bVar = y4.b.f36895e;
            bVar.getClass();
            bVar.f36896a = FastVpnService.f6852t;
            bVar.f36897b = FastVpnService.f6851s;
            bVar.f36898c = new Date().getTime();
            b.a aVar = bVar.f36899d;
            aVar.f36900a = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
            aVar.f36901b = FirebaseRemoteConfig.DEFAULT_VALUE_FOR_DOUBLE;
            try {
            } catch (IOException e11) {
                e = e11;
                "OnRead".concat(e.getClass().getSimpleName());
                SimpleDateFormat simpleDateFormat2 = e.f28649f;
                String message = e.getMessage();
                y4.a.c().b(e.getMessage());
                e.printStackTrace();
                str = message;
                fastVpnService.a();
                if (!fastVpnService.f6856d) {
                }
                Objects.toString(fastVpnService.f6860h);
                SimpleDateFormat simpleDateFormat3 = e.f28649f;
                i10 = fastVpnService.f6868p + 1;
                fastVpnService.f6868p = i10;
                if (i10 >= 3) {
                }
                fastVpnService.f6856d = true;
                y4.a.c().f36892f = str;
                if (fastVpnService.f6860h != null) {
                }
            } catch (ArrayIndexOutOfBoundsException e12) {
                e = e12;
                "OnRead".concat(e.getClass().getSimpleName());
                SimpleDateFormat simpleDateFormat22 = e.f28649f;
                String message2 = e.getMessage();
                y4.a.c().b(e.getMessage());
                e.printStackTrace();
                str = message2;
                fastVpnService.a();
                if (!fastVpnService.f6856d) {
                }
                Objects.toString(fastVpnService.f6860h);
                SimpleDateFormat simpleDateFormat32 = e.f28649f;
                i10 = fastVpnService.f6868p + 1;
                fastVpnService.f6868p = i10;
                if (i10 >= 3) {
                }
                fastVpnService.f6856d = true;
                y4.a.c().f36892f = str;
                if (fastVpnService.f6860h != null) {
                }
            } catch (ClosedSelectorException e13) {
                e = e13;
                "OnRead".concat(e.getClass().getSimpleName());
                SimpleDateFormat simpleDateFormat222 = e.f28649f;
                String message22 = e.getMessage();
                y4.a.c().b(e.getMessage());
                e.printStackTrace();
                str = message22;
                fastVpnService.a();
                if (!fastVpnService.f6856d) {
                }
                Objects.toString(fastVpnService.f6860h);
                SimpleDateFormat simpleDateFormat322 = e.f28649f;
                i10 = fastVpnService.f6868p + 1;
                fastVpnService.f6868p = i10;
                if (i10 >= 3) {
                }
                fastVpnService.f6856d = true;
                y4.a.c().f36892f = str;
                if (fastVpnService.f6860h != null) {
                }
            } catch (ConnectionPendingException e14) {
                e = e14;
                "OnRead".concat(e.getClass().getSimpleName());
                SimpleDateFormat simpleDateFormat2222 = e.f28649f;
                String message222 = e.getMessage();
                y4.a.c().b(e.getMessage());
                e.printStackTrace();
                str = message222;
                fastVpnService.a();
                if (!fastVpnService.f6856d) {
                }
                Objects.toString(fastVpnService.f6860h);
                SimpleDateFormat simpleDateFormat3222 = e.f28649f;
                i10 = fastVpnService.f6868p + 1;
                fastVpnService.f6868p = i10;
                if (i10 >= 3) {
                }
                fastVpnService.f6856d = true;
                y4.a.c().f36892f = str;
                if (fastVpnService.f6860h != null) {
                }
            } catch (NoConnectionPendingException e15) {
                e = e15;
                "OnRead".concat(e.getClass().getSimpleName());
                SimpleDateFormat simpleDateFormat22222 = e.f28649f;
                String message2222 = e.getMessage();
                y4.a.c().b(e.getMessage());
                e.printStackTrace();
                str = message2222;
                fastVpnService.a();
                if (!fastVpnService.f6856d) {
                }
                Objects.toString(fastVpnService.f6860h);
                SimpleDateFormat simpleDateFormat32222 = e.f28649f;
                i10 = fastVpnService.f6868p + 1;
                fastVpnService.f6868p = i10;
                if (i10 >= 3) {
                }
                fastVpnService.f6856d = true;
                y4.a.c().f36892f = str;
                if (fastVpnService.f6860h != null) {
                }
            }
            if (fastVpnService.f6856d) {
                return;
            }
            Selector selector = fastVpnService.f6869q;
            if (selector != null && selector.isOpen()) {
                fastVpnService.f6869q.close();
            }
            fastVpnService.f6869q = Selector.open();
            if (!fastVpnService.b()) {
                SimpleDateFormat simpleDateFormat4 = e.f28649f;
                throw new IOException("close on connecting");
            }
            VpnService.Builder addDnsServer = new VpnService.Builder(fastVpnService).setBlocking(true).addAddress(InetAddress.getByAddress(BigInteger.valueOf(fastVpnService.f6857e).toByteArray()), 16).addRoute("0.0.0.0", 0).setMtu(1400).addDnsServer("8.8.8.8");
            Iterator it = e.d().iterator();
            while (it.hasNext()) {
                addDnsServer.addDnsServer((String) it.next());
            }
            FastVpnService.d(addDnsServer);
            if (Build.VERSION.SDK_INT >= 29) {
                addDnsServer.setMetered(false);
            }
            FastVpnService.f6851s = 0L;
            FastVpnService.f6852t = 0L;
            ParcelFileDescriptor establish = addDnsServer.establish();
            fastVpnService.f6854b = establish;
            if (establish == null) {
                fastVpnService.f6856d = true;
                d dVar2 = fastVpnService.f6860h;
                String.format("connect_fatal_error,%s,%s", dVar2.f36907b, dVar2.f36906a);
                SimpleDateFormat simpleDateFormat5 = e.f28649f;
                fastVpnService.a();
                y4.a c10 = y4.a.c();
                d dVar3 = fastVpnService.f6860h;
                c10.e(0, dVar3.f36906a, dVar3.f36908c, fastVpnService.f6867o);
                return;
            }
            y4.a c11 = y4.a.c();
            d dVar4 = fastVpnService.f6860h;
            c11.e(1, dVar4.f36906a, dVar4.f36908c, fastVpnService.f6867o);
            SimpleDateFormat simpleDateFormat6 = e.f28649f;
            fastVpnService.f();
            fastVpnService.e();
            str = "";
            fastVpnService.a();
            if (!fastVpnService.f6856d) {
                if (fastVpnService.f6860h != null) {
                    y4.a c12 = y4.a.c();
                    d dVar5 = fastVpnService.f6860h;
                    c12.e(2, dVar5.f36906a, dVar5.f36908c, fastVpnService.f6867o);
                } else {
                    y4.a.c().d(2);
                }
                try {
                    Thread.sleep(1000L);
                } catch (InterruptedException e16) {
                    e16.printStackTrace();
                }
            }
            Objects.toString(fastVpnService.f6860h);
            SimpleDateFormat simpleDateFormat322222 = e.f28649f;
            i10 = fastVpnService.f6868p + 1;
            fastVpnService.f6868p = i10;
            if (i10 >= 3 && !fastVpnService.f6856d) {
                Thread thread = new Thread(fastVpnService.f6870r);
                fastVpnService.f6858f = thread;
                thread.start();
                return;
            }
            fastVpnService.f6856d = true;
            y4.a.c().f36892f = str;
            if (fastVpnService.f6860h != null) {
                y4.a.c().d(0);
                return;
            }
            y4.a c13 = y4.a.c();
            d dVar6 = fastVpnService.f6860h;
            c13.e(0, dVar6.f36906a, dVar6.f36908c, fastVpnService.f6867o);
        }
    }

    public static String c(byte[] bArr) {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        messageDigest.update(bArr);
        byte[] digest = messageDigest.digest();
        StringBuilder sb2 = new StringBuilder();
        for (byte b6 : digest) {
            String hexString = Integer.toHexString(b6 & 255);
            while (hexString.length() < 2) {
                hexString = "0".concat(hexString);
            }
            sb2.append(hexString);
        }
        String sb3 = sb2.toString();
        String str = "";
        for (int i10 = 0; i10 != sb3.length(); i10++) {
            if (sb3.charAt(i10) >= '0' && sb3.charAt(i10) <= '9') {
                StringBuilder b10 = h.b(str);
                b10.append(sb3.charAt(i10));
                str = b10.toString();
            }
        }
        return str.length() == 0 ? "0" : str.length() <= 5 ? str : str.substring(0, 5);
    }

    public static void d(VpnService.Builder builder) {
        if (e.b()) {
            for (String str : g0.P()) {
                try {
                    builder.addDisallowedApplication(str);
                } catch (Exception e10) {
                    e10.printStackTrace();
                }
            }
            return;
        }
        Iterator it = g0.M().iterator();
        while (it.hasNext()) {
            try {
                builder.addAllowedApplication((String) it.next());
            } catch (Exception e11) {
                e11.printStackTrace();
            }
        }
    }

    public final void a() {
        try {
            ParcelFileDescriptor parcelFileDescriptor = this.f6854b;
            if (parcelFileDescriptor != null) {
                parcelFileDescriptor.close();
            }
            this.f6855c = false;
            Selector selector = this.f6869q;
            if (selector != null && selector.isOpen()) {
                this.f6869q.wakeup();
                this.f6869q.close();
            }
            SocketChannel socketChannel = this.f6864l;
            if (socketChannel != null) {
                socketChannel.close();
            }
        } catch (IOException e10) {
            e10.printStackTrace();
        }
    }

    public final boolean b() {
        boolean z6;
        char c10;
        int indexOf;
        boolean z9;
        String q10 = android.support.v4.media.b.q(new StringBuilder("GET /home HTTP HTTP/1.1\r\nHost: "), this.f6866n, "\r\nAccept-Encoding: deflate\r\n\r\n");
        String q11 = android.support.v4.media.b.q(new StringBuilder("GET /home HTTP HTTP/1.1\r\nHost: "), this.f6866n, "\r\nAccept-Encoding: gzip\r\n\r\n");
        int size = this.f6865m.size();
        SocketChannel[] socketChannelArr = new SocketChannel[size];
        int i10 = 0;
        for (int i11 = 0; i11 != this.f6865m.size(); i11++) {
            d dVar = this.f6865m.get(i11);
            SocketChannel open = SocketChannel.open();
            socketChannelArr[i11] = open;
            open.configureBlocking(false);
            socketChannelArr[i11].register(this.f6869q, 8).attach(Integer.valueOf(i11));
            socketChannelArr[i11].connect(new InetSocketAddress(dVar.f36906a, dVar.f36908c));
            String.format("start_connect,%s,%s", dVar.f36907b, dVar.f36906a);
            SimpleDateFormat simpleDateFormat = e.f28649f;
        }
        HashSet hashSet = new HashSet();
        ?? r62 = 0;
        char c11 = 1;
        int i12 = 2;
        boolean z10 = false;
        while (true) {
            SimpleDateFormat simpleDateFormat2 = e.f28649f;
            i10++;
            if (i10 > 50) {
                for (int i13 = r62; i13 != this.f6865m.size(); i13++) {
                    d dVar2 = this.f6865m.get(i13);
                    Object[] objArr = new Object[i12];
                    objArr[r62] = dVar2.f36907b;
                    objArr[c11] = dVar2.f36906a;
                    String.format("exceed max retry count, connect_failed,%s,%s", objArr);
                    SimpleDateFormat simpleDateFormat3 = e.f28649f;
                }
                y4.a.c().b("exceed max retry count, connect final failed.");
                return r62;
            }
            this.f6869q.select(100L);
            if (this.f6856d) {
                return r62;
            }
            Iterator it = Collections.synchronizedSet(this.f6869q.selectedKeys()).iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                SelectionKey selectionKey = (SelectionKey) it.next();
                if (selectionKey.isConnectable()) {
                    SocketChannel socketChannel = (SocketChannel) selectionKey.channel();
                    Object attachment = selectionKey.attachment();
                    Objects.toString(attachment);
                    SimpleDateFormat simpleDateFormat4 = e.f28649f;
                    try {
                        HashMap hashMap = new HashMap();
                        hashMap.put("attachment", "value_" + attachment);
                        f8.a.c("nut_selection_attachment", hashMap);
                    } catch (Exception e10) {
                        e10.printStackTrace();
                    }
                    int intValue = attachment instanceof Integer ? ((Integer) attachment).intValue() : 0;
                    try {
                        z9 = socketChannel.finishConnect();
                    } catch (IOException unused) {
                        d dVar3 = this.f6865m.get(intValue);
                        y4.a.c().b(String.format("connect_failed,%s,%s", dVar3.f36907b, dVar3.f36906a));
                        SimpleDateFormat simpleDateFormat5 = e.f28649f;
                        socketChannel.close();
                        hashSet.add(Integer.valueOf(intValue));
                        z9 = false;
                    }
                    if (z9) {
                        this.f6864l = socketChannel;
                        this.f6860h = this.f6865m.get(intValue);
                        for (int i14 = 0; i14 != size; i14++) {
                            if (i14 != intValue && socketChannelArr[i14] != null && !hashSet.contains(Integer.valueOf(i14))) {
                                socketChannelArr[i14].close();
                                d dVar4 = this.f6865m.get(i14);
                                if (dVar4 != null) {
                                    String.format("connect_abandon,%s,%s", dVar4.f36907b, dVar4.f36906a);
                                    SimpleDateFormat simpleDateFormat6 = e.f28649f;
                                }
                            }
                        }
                        protect(this.f6864l.socket());
                        z10 = true;
                    }
                }
                it.remove();
            }
            if (z10) {
                this.f6864l.write(ByteBuffer.wrap(q11.getBytes()));
                this.f6864l.register(this.f6869q, 1).attach(0);
                ByteBuffer allocate = ByteBuffer.allocate(2800);
                String str = "";
                int i15 = 0;
                while (true) {
                    this.f6869q.select(100L);
                    this.f6869q.selectedKeys().clear();
                    if (this.f6856d) {
                        break;
                    }
                    int read = this.f6864l.read(allocate);
                    if (read == -1) {
                        d dVar5 = this.f6860h;
                        y4.a.c().b(String.format("wait_server_response_error,%s,%s", dVar5.f36907b, dVar5.f36906a));
                        SimpleDateFormat simpleDateFormat7 = e.f28649f;
                        break;
                    }
                    str = str.concat(new String(allocate.array(), 0, read, StandardCharsets.US_ASCII));
                    if (i15 == 0 && (indexOf = str.indexOf("\r\n\r\n")) >= 0) {
                        Matcher matcher = Pattern.compile("Content-Length: (\\d+)").matcher(str.substring(0, indexOf));
                        if (matcher.find()) {
                            i15 = Integer.parseInt(matcher.group(1));
                            str = str.substring(indexOf + 4);
                        }
                    }
                    if (str.length() >= i15 && i15 > 0) {
                        String substring = str.substring(0, i15);
                        Matcher matcher2 = Pattern.compile("(\\d+),(\\d+),(\\d+)").matcher(substring);
                        if (matcher2.find()) {
                            this.f6857e = Integer.parseInt(matcher2.group(1));
                        }
                        if (this.f6857e == 0) {
                            d dVar6 = this.f6860h;
                            y4.a.c().b(String.format("protocol_error,%s,%s", dVar6.f36907b, dVar6.f36906a));
                            SimpleDateFormat simpleDateFormat8 = e.f28649f;
                        } else {
                            if (substring.length() > i15) {
                                System.arraycopy(str.getBytes(), i15, this.f6862j, 0, str.length() - i15);
                                c10 = 0;
                            } else {
                                c10 = 0;
                            }
                            z6 = true;
                        }
                    }
                }
                if (z6) {
                    this.f6864l.write(ByteBuffer.wrap(q10.getBytes()));
                    return true;
                }
                Object[] objArr2 = new Object[2];
                d dVar7 = this.f6860h;
                objArr2[c10] = dVar7.f36907b;
                objArr2[1] = dVar7.f36906a;
                String.format("initialize_failed,%s,%s", objArr2);
                SimpleDateFormat simpleDateFormat9 = e.f28649f;
                d dVar8 = this.f6860h;
                String.format("connect_failed,%s,%s", dVar8.f36907b, dVar8.f36906a);
                return false;
            }
            r62 = 0;
            i12 = 2;
            c11 = 1;
        }
    }

    public final void e() {
        int read;
        int indexOf;
        Pattern compile = Pattern.compile("Content-Length: (\\d+)");
        ByteBuffer allocate = ByteBuffer.allocate(5600);
        FileOutputStream fileOutputStream = new FileOutputStream(this.f6854b.getFileDescriptor());
        this.f6855c = true;
        Locale locale = Locale.ENGLISH;
        d dVar = this.f6860h;
        g0.X(String.format(locale, "connect_success,0,%s,%s,%d", dVar.f36907b, dVar.f36906a, Integer.valueOf(dVar.f36908c)), new Object[0]);
        int i10 = 0;
        while (this.f6855c) {
            this.f6869q.select(1000L);
            if (!this.f6855c || this.f6856d) {
                return;
            }
            Iterator it = Collections.synchronizedSet(this.f6869q.selectedKeys()).iterator();
            while (true) {
                if (it.hasNext()) {
                    SelectionKey selectionKey = (SelectionKey) it.next();
                    Object attachment = selectionKey.attachment();
                    if ((attachment instanceof Integer ? ((Integer) attachment).intValue() : 0) == 0 && selectionKey.isReadable()) {
                        synchronized ("tcp_lock") {
                            read = this.f6864l.read(allocate);
                        }
                        if (read == -1) {
                            this.f6855c = false;
                            break;
                        } else if (read > 0) {
                            System.arraycopy(allocate.array(), 0, this.f6862j, this.f6863k, read);
                            allocate.clear();
                            f6852t += read;
                            this.f6863k += read;
                            boolean z6 = false;
                            while (!z6) {
                                if (i10 != 0 || (indexOf = new String(this.f6862j, 0, this.f6863k, StandardCharsets.US_ASCII).indexOf("\r\n\r\n")) < 0) {
                                    z6 = true;
                                } else {
                                    Matcher matcher = compile.matcher(new String(this.f6862j, 0, indexOf));
                                    if (matcher.find()) {
                                        i10 = Integer.parseInt(matcher.group(1));
                                    } else {
                                        SimpleDateFormat simpleDateFormat = e.f28649f;
                                    }
                                    int i11 = (this.f6863k - indexOf) - 4;
                                    this.f6863k = i11;
                                    byte[] bArr = this.f6862j;
                                    System.arraycopy(bArr, indexOf + 4, bArr, 0, i11);
                                    z6 = false;
                                }
                                if (i10 > 0 && this.f6863k >= i10) {
                                    fileOutputStream.write(this.f6862j, 0, i10);
                                    int i12 = this.f6863k - i10;
                                    this.f6863k = i12;
                                    byte[] bArr2 = this.f6862j;
                                    System.arraycopy(bArr2, i10, bArr2, 0, i12);
                                    i10 = 0;
                                    z6 = false;
                                }
                            }
                        }
                    }
                    it.remove();
                }
            }
        }
    }

    public final void f() {
        new Thread(new t0.b(3, this, new FileInputStream(this.f6854b.getFileDescriptor()))).start();
    }

    @Override
    public final void onCreate() {
        super.onCreate();
        this.f6859g = new Handler(Looper.getMainLooper());
        y4.a.c().d(0);
    }

    @Override
    public final void onDestroy() {
        super.onDestroy();
    }

    @Override
    public final void onRevoke() {
        this.f6856d = true;
        a();
        y4.a.c().d(0);
        Handler handler = this.f6859g;
        if (handler != null) {
            handler.removeCallbacksAndMessages(null);
        }
        stopForeground(true);
        super.onRevoke();
    }

    @Override
    public final int onStartCommand(Intent intent, int i10, int i11) {
        if (intent != null && intent.hasExtra("service_command")) {
            intent.getIntExtra("service_command", -1);
            SimpleDateFormat simpleDateFormat = e.f28649f;
            int intExtra = intent.getIntExtra("service_command", 1);
            if (intExtra == 1) {
                this.f6856d = false;
                String stringExtra = intent.getStringExtra("service_gateway_json");
                if (!TextUtils.isEmpty(stringExtra)) {
                    ConnBean connBean = (ConnBean) JSON.parseObject(stringExtra, ConnBean.class);
                    this.f6867o = connBean;
                    this.f6866n = connBean.getFakeHost();
                    y4.a.c().f36891e = this.f6867o;
                }
                this.f6868p = 0;
                y4.a.c().f36893g.clear();
                Thread thread = new Thread(this.f6870r);
                this.f6858f = thread;
                thread.start();
                y4.a.c().d(2);
                if (c.f36902d == null) {
                    c.f36902d = new c();
                }
                startForeground(2, c.f36902d.a(this));
                this.f6859g.removeCallbacksAndMessages(null);
                this.f6859g.postDelayed(new a(), 0L);
            } else if (intExtra == 2) {
                d dVar = this.f6860h;
                if (dVar != null) {
                    if (this.f6855c) {
                        String.format("terminate_connect,%s,%s", dVar.f36907b, dVar.f36906a);
                    } else {
                        String.format("stop_on_connecting,%s,%s", dVar.f36907b, dVar.f36906a);
                    }
                }
                this.f6856d = true;
                Handler handler = this.f6859g;
                if (handler != null) {
                    handler.removeCallbacksAndMessages(null);
                }
                stopForeground(true);
                a();
                new Thread(new androidx.activity.d(this, 10)).start();
            }
        }
        return super.onStartCommand(intent, i10, i11);
    }
}