Fing.apk(点击下载) / h.java


package com.overlook.android.fing.engine.services.htc;

import android.text.TextUtils;
import android.util.Log;
import com.huawei.hms.android.HwBuildEx;
import com.overlook.android.fing.engine.j.h.b;
import com.overlook.android.fing.engine.j.h.d;
import com.overlook.android.fing.engine.j.h.f;
import com.overlook.android.fing.engine.model.net.Ip4Address;
import com.overlook.android.fing.engine.model.net.IpAddress;
import com.overlook.android.fing.engine.model.net.w;
import e.a.a.a.a;
import h.c0;
import h.e0;
import h.i0;
import h.k0;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
import okhttp3.internal.connection.e;
import org.w3c.dom.Element;

/* compiled from: RouterUPnPService */
public class h {

    /* renamed from: a  reason: collision with root package name */
    private String f16223a;
    private int b;

    /* renamed from: c  reason: collision with root package name */
    private String f16224c;

    /* renamed from: d  reason: collision with root package name */
    private String f16225d;

    /* renamed from: e  reason: collision with root package name */
    private String f16226e;

    /* renamed from: f  reason: collision with root package name */
    private String f16227f;

    /* renamed from: g  reason: collision with root package name */
    private SortedSet<String> f16228g = new TreeSet();

    /* renamed from: h  reason: collision with root package name */
    private String f16229h;

    public h(String str, String str2) {
        this.f16224c = str;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:50:0x01c7, code lost:
        r5 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:51:0x01c8, code lost:
        if (r2 != null) goto L_0x01ca;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:53:?, code lost:
        r2.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:54:0x01ce, code lost:
        r2 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:55:0x01cf, code lost:
        r4.addSuppressed(r2);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:56:0x01d2, code lost:
        throw r5;
     */
    public void a(PortMapping portMapping) throws RouterUPnPException {
        Element c2;
        Element c3;
        Element a2;
        Log.d("fing:router-upnp-srv", "Deleting UPnP port mapping: " + portMapping);
        try {
            StringBuilder sb = new StringBuilder();
            sb.append("<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:DeletePortMapping xmlns:u=\"");
            sb.append(this.f16224c);
            sb.append("\"><NewRemoteHost>");
            String str = "";
            sb.append(portMapping.j() != null ? portMapping.j().toString() : str);
            sb.append("</NewRemoteHost><NewExternalPort>");
            sb.append(portMapping.d());
            sb.append("</NewExternalPort><NewProtocol>");
            sb.append(portMapping.h().name());
            sb.append("</NewProtocol></u:DeletePortMapping></s:Body></s:Envelope>");
            String sb2 = sb.toString();
            e0.a aVar = new e0.a();
            aVar.a("Accept", "*/*");
            aVar.a("Accept-Encoding", "identity");
            aVar.a("Connection", "close");
            aVar.a("Content-Type", "text/xml");
            aVar.a("SOAPACTION", "\"" + this.f16224c + "#DeletePortMapping\"");
            aVar.a("User-Agent", "FingDroid");
            aVar.h(new f(this.f16223a, this.f16226e, this.b).d());
            aVar.f(d.a(d.b, sb2));
            e0 b2 = aVar.b();
            c0.a b3 = b.b();
            TimeUnit timeUnit = TimeUnit.SECONDS;
            b3.b(5, timeUnit);
            b3.I(5, timeUnit);
            try {
                k0 b4 = ((e) new c0(b3).A(b2)).k().b();
                if (b4 != null) {
                    byte[] b5 = b4.b();
                    b4.close();
                    try {
                        com.overlook.android.fing.engine.l.c0 c0Var = new com.overlook.android.fing.engine.l.c0(new ByteArrayInputStream(b5));
                        Element e2 = c0Var.e();
                        if (!"s:Envelope".equals(e2.getTagName()) || (c2 = c0Var.c(e2, "s:Body")) == null || (c3 = c0Var.c(c2, "s:Fault")) == null || (a2 = c0Var.a(c3, "UPnPError")) == null) {
                            Log.d("fing:router-upnp-srv", "UPnP port mapping deleted: " + portMapping);
                            return;
                        }
                        String f2 = c0Var.f(a2, "errorCode");
                        int i2 = Integer.MIN_VALUE;
                        if (f2 != null) {
                            try {
                                i2 = Integer.parseInt(f2);
                            } catch (NumberFormatException unused) {
                            }
                        }
                        String f3 = c0Var.f(a2, "errorDescription");
                        if (f3 != null) {
                            str = f3;
                        }
                        throw new RouterUPnPException(i2, str);
                    } catch (RouterUPnPException e3) {
                        if (e3.a() == 714) {
                            Log.d("fing:router-upnp-srv", "Port mapping not found: " + portMapping);
                            return;
                        }
                        throw e3;
                    } catch (Exception e4) {
                        Log.e("fing:router-upnp-srv", "Failed to parse SOAP response for \"" + this.f16224c + "#DeletePortMapping\"", e4);
                        StringBuilder sb3 = new StringBuilder();
                        sb3.append("Browse SCPD at ");
                        sb3.append(new f(this.f16223a, this.f16225d, this.b).d());
                        Log.i("fing:router-upnp-srv", sb3.toString());
                        throw new RouterUPnPException(901, e4);
                    }
                } else {
                    throw new IOException("HTTP response body is empty!");
                }
            } catch (IOException e5) {
                Log.e("fing:router-upnp-srv", "SOAP call failed: \"" + this.f16224c + "#DeletePortMapping\"", e5);
                StringBuilder sb4 = new StringBuilder();
                sb4.append("Browse SCPD at ");
                sb4.append(new f(this.f16223a, this.f16225d, this.b).d());
                Log.i("fing:router-upnp-srv", sb4.toString());
                throw new RouterUPnPException(902, e5);
            }
        } catch (RouterUPnPException e6) {
            Log.e("fing:router-upnp-srv", "Cannot delete UPnP port mapping: " + portMapping, e6);
            throw e6;
        }
    }

    public String b() {
        return this.f16226e;
    }

    public String c() {
        return this.f16227f;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:40:0x017f, code lost:
        r5 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:41:0x0180, code lost:
        if (r3 != null) goto L_0x0182;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:43:?, code lost:
        r3.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:44:0x0186, code lost:
        r3 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:45:0x0187, code lost:
        r4.addSuppressed(r3);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:46:0x018a, code lost:
        throw r5;
     */
    public IpAddress d() throws RouterUPnPException {
        Element c2;
        Log.d("fing:router-upnp-srv", "Retrieving UPnP external IP address...");
        try {
            e0.a aVar = new e0.a();
            aVar.a("Accept", "*/*");
            aVar.a("Accept-Encoding", "identity");
            aVar.a("Connection", "close");
            aVar.a("Content-Type", "text/xml");
            aVar.a("SOAPACTION", "\"" + this.f16224c + "#GetExternalIPAddress\"");
            aVar.a("User-Agent", "FingDroid");
            aVar.h(new f(this.f16223a, this.f16226e, this.b).d());
            aVar.f(d.a(d.b, "<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetExternalIPAddress xmlns:u=\"" + this.f16224c + "\"></u:GetExternalIPAddress></s:Body></s:Envelope>"));
            e0 b2 = aVar.b();
            c0.a b3 = b.b();
            TimeUnit timeUnit = TimeUnit.SECONDS;
            b3.b(5, timeUnit);
            b3.I(5, timeUnit);
            try {
                i0 k = ((e) new c0(b3).A(b2)).k();
                if (k.i() == 402 || k.i() == 501) {
                    throw new RouterUPnPException(k.i(), k.y());
                }
                k0 b4 = k.b();
                if (b4 != null) {
                    byte[] b5 = b4.b();
                    b4.close();
                    try {
                        com.overlook.android.fing.engine.l.c0 c0Var = new com.overlook.android.fing.engine.l.c0(new ByteArrayInputStream(b5));
                        Element e2 = c0Var.e();
                        if (!"s:Envelope".equals(e2.getTagName()) || (c2 = c0Var.c(e2, "s:Body")) == null) {
                            throw new RouterUPnPException(901, "UPnP external IP address not found");
                        }
                        String b6 = c0Var.b(c2, "NewExternalIPAddress");
                        if (!TextUtils.isEmpty(b6)) {
                            Ip4Address A = Ip4Address.A(b6);
                            if (A != null) {
                                Log.d("fing:router-upnp-srv", "UPnP external IP address: " + A);
                                return A;
                            }
                            throw new RouterUPnPException(901, "NewExternalIPAddress is not a valid IP4 address: " + b6);
                        }
                        throw new RouterUPnPException(901, "NewExternalIPAddress found but empty");
                    } catch (RouterUPnPException e3) {
                        throw e3;
                    } catch (Exception e4) {
                        Log.e("fing:router-upnp-srv", "Failed to parse SOAP response for \"" + this.f16224c + "#GetExternalIPAddress\"", e4);
                        StringBuilder sb = new StringBuilder();
                        sb.append("Browse SCPD at ");
                        sb.append(new f(this.f16223a, this.f16225d, this.b).d());
                        Log.i("fing:router-upnp-srv", sb.toString());
                        throw new RouterUPnPException(901, e4);
                    }
                } else {
                    throw new IOException("HTTP response body is empty!");
                }
            } catch (IOException e5) {
                Log.e("fing:router-upnp-srv", "SOAP call failed: \"" + this.f16224c + "#GetExternalIPAddress\"", e5);
                StringBuilder sb2 = new StringBuilder();
                sb2.append("Browse SCPD at ");
                sb2.append(new f(this.f16223a, this.f16225d, this.b).d());
                Log.i("fing:router-upnp-srv", sb2.toString());
                throw new RouterUPnPException(902, e5);
            }
        } catch (RouterUPnPException e6) {
            Log.e("fing:router-upnp-srv", "Cannot retrieve UPnP external IP address", e6);
            throw e6;
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:112:0x02b0, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:114:0x02b2, code lost:
        if (r10 != null) goto L_0x02b4;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:116:?, code lost:
        r10.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:117:0x02b8, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:118:0x02b9, code lost:
        r0.addSuppressed(r0);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:119:0x02bd, code lost:
        throw r0;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:62:0x01b3, code lost:
        if (java.lang.Integer.parseInt(r13) != 0) goto L_0x01b5;
     */
    /* JADX WARNING: Removed duplicated region for block: B:129:0x0177 A[SYNTHETIC] */
    /* JADX WARNING: Removed duplicated region for block: B:29:0x0134  */
    /* JADX WARNING: Removed duplicated region for block: B:32:0x0140 A[SYNTHETIC, Splitter:B:32:0x0140] */
    /* JADX WARNING: Removed duplicated region for block: B:37:0x014a  */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x0159  */
    /* JADX WARNING: Removed duplicated region for block: B:44:0x0165  */
    /* JADX WARNING: Removed duplicated region for block: B:49:0x017c  */
    /* JADX WARNING: Removed duplicated region for block: B:52:0x0189  */
    /* JADX WARNING: Removed duplicated region for block: B:55:0x019c  */
    /* JADX WARNING: Removed duplicated region for block: B:58:0x01a6  */
    /* JADX WARNING: Removed duplicated region for block: B:68:0x01cc A[SYNTHETIC, Splitter:B:68:0x01cc] */
    /* JADX WARNING: Removed duplicated region for block: B:74:0x01d8  */
    /* JADX WARNING: Removed duplicated region for block: B:77:0x01e3  */
    /* JADX WARNING: Removed duplicated region for block: B:90:0x0212  */
    public List<PortMapping> e(int i2) throws RouterUPnPException {
        Element c2;
        Element a2;
        int i3;
        String f2;
        int i4;
        String f3;
        int i5;
        String f4;
        int i6;
        w wVar;
        String f5;
        String str;
        String f6;
        boolean z;
        String f7;
        int i7;
        ArrayList arrayList = new ArrayList();
        Log.d("fing:router-upnp-srv", "Retrieving UPnP port mappings (maxPorts=" + i2 + ")...");
        c0.a b2 = b.b();
        TimeUnit timeUnit = TimeUnit.SECONDS;
        b2.b(5, timeUnit);
        b2.I(5, timeUnit);
        c0 c0Var = new c0(b2);
        int i8 = 0;
        while (true) {
            int i9 = i8 + 1;
            try {
                e0.a aVar = new e0.a();
                aVar.a("Accept", "*/*");
                aVar.a("Accept-Encoding", "identity");
                aVar.a("Connection", "close");
                aVar.a("Content-Type", "text/xml");
                aVar.a("SOAPACTION", "\"" + this.f16224c + "#GetGenericPortMappingEntry\"");
                aVar.a("User-Agent", "FingDroid");
                aVar.h(new f(this.f16223a, this.f16226e, this.b).d());
                aVar.f(d.a(d.b, "<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:GetGenericPortMappingEntry xmlns:u=\"" + this.f16224c + "\"><NewPortMappingIndex>" + i8 + "</NewPortMappingIndex></u:GetGenericPortMappingEntry></s:Body></s:Envelope>"));
                try {
                    k0 b3 = ((e) c0Var.A(aVar.b())).k().b();
                    if (b3 != null) {
                        byte[] b4 = b3.b();
                        b3.close();
                        try {
                            com.overlook.android.fing.engine.l.c0 c0Var2 = new com.overlook.android.fing.engine.l.c0(new ByteArrayInputStream(b4));
                            Element e2 = c0Var2.e();
                            if ("s:Envelope".equals(e2.getTagName()) && (c2 = c0Var2.c(e2, "s:Body")) != null) {
                                Element c3 = c0Var2.c(c2, "u:GetGenericPortMappingEntryResponse");
                                if (c3 != null) {
                                    PortMapping portMapping = new PortMapping();
                                    portMapping.m(true);
                                    String f8 = c0Var2.f(c3, "NewRemoteHost");
                                    IpAddress ipAddress = null;
                                    portMapping.x(f8 != null ? IpAddress.p(f8) : null);
                                    String f9 = c0Var2.f(c3, "NewExternalPort");
                                    if (f9 != null) {
                                        try {
                                            i4 = Integer.parseInt(f9);
                                        } catch (NumberFormatException unused) {
                                        }
                                        if (i4 == Integer.MIN_VALUE) {
                                            i4 = -1;
                                        }
                                        portMapping.r(i4);
                                        f3 = c0Var2.f(c3, "NewInternalPort");
                                        if (f3 != null) {
                                            try {
                                                i5 = Integer.parseInt(f3);
                                            } catch (NumberFormatException unused2) {
                                            }
                                            if (i5 == Integer.MIN_VALUE) {
                                                i5 = -1;
                                            }
                                            portMapping.u(i5);
                                            f4 = c0Var2.f(c3, "NewProtocol");
                                            if (f4 == null) {
                                                f4 = "TCP";
                                            }
                                            w wVar2 = w.TCP;
                                            w[] values = w.values();
                                            i6 = 0;
                                            while (true) {
                                                if (i6 >= 2) {
                                                    wVar = null;
                                                    break;
                                                }
                                                wVar = values[i6];
                                                if (wVar.name().equalsIgnoreCase(f4)) {
                                                    break;
                                                }
                                                i6++;
                                            }
                                            if (wVar == null) {
                                                wVar = wVar2;
                                            }
                                            portMapping.w(wVar);
                                            f5 = c0Var2.f(c3, "NewInternalClient");
                                            if (f5 != null) {
                                                ipAddress = IpAddress.p(f5);
                                            }
                                            portMapping.t(ipAddress);
                                            str = "0";
                                            f6 = c0Var2.f(c3, "NewEnabled");
                                            if (f6 != null) {
                                                str = f6;
                                            }
                                            if (!"true".equalsIgnoreCase(str)) {
                                                if (!"false".equalsIgnoreCase(str)) {
                                                }
                                                z = false;
                                                portMapping.q(z);
                                                portMapping.o(c0Var2.f(c3, "NewPortMappingDescription"));
                                                f7 = c0Var2.f(c3, "NewLeaseDuration");
                                                if (f7 != null) {
                                                    try {
                                                        i7 = Integer.parseInt(f7);
                                                    } catch (NumberFormatException unused3) {
                                                    }
                                                    if (i7 == Integer.MIN_VALUE) {
                                                        i7 = 0;
                                                    }
                                                    portMapping.v((long) i7);
                                                    if (portMapping.f() != null) {
                                                        arrayList.add(portMapping);
                                                    }
                                                }
                                                i7 = Integer.MIN_VALUE;
                                                if (i7 == Integer.MIN_VALUE) {
                                                }
                                                portMapping.v((long) i7);
                                                if (portMapping.f() != null) {
                                                }
                                            }
                                            z = true;
                                            portMapping.q(z);
                                            portMapping.o(c0Var2.f(c3, "NewPortMappingDescription"));
                                            f7 = c0Var2.f(c3, "NewLeaseDuration");
                                            if (f7 != null) {
                                            }
                                            i7 = Integer.MIN_VALUE;
                                            if (i7 == Integer.MIN_VALUE) {
                                            }
                                            portMapping.v((long) i7);
                                            if (portMapping.f() != null) {
                                            }
                                        }
                                        i5 = Integer.MIN_VALUE;
                                        if (i5 == Integer.MIN_VALUE) {
                                        }
                                        portMapping.u(i5);
                                        f4 = c0Var2.f(c3, "NewProtocol");
                                        if (f4 == null) {
                                        }
                                        w wVar22 = w.TCP;
                                        w[] values2 = w.values();
                                        i6 = 0;
                                        while (true) {
                                            if (i6 >= 2) {
                                            }
                                            i6++;
                                        }
                                        if (wVar == null) {
                                        }
                                        portMapping.w(wVar);
                                        f5 = c0Var2.f(c3, "NewInternalClient");
                                        if (f5 != null) {
                                        }
                                        portMapping.t(ipAddress);
                                        str = "0";
                                        f6 = c0Var2.f(c3, "NewEnabled");
                                        if (f6 != null) {
                                        }
                                        if (!"true".equalsIgnoreCase(str)) {
                                        }
                                        z = true;
                                        portMapping.q(z);
                                        portMapping.o(c0Var2.f(c3, "NewPortMappingDescription"));
                                        f7 = c0Var2.f(c3, "NewLeaseDuration");
                                        if (f7 != null) {
                                        }
                                        i7 = Integer.MIN_VALUE;
                                        if (i7 == Integer.MIN_VALUE) {
                                        }
                                        portMapping.v((long) i7);
                                        if (portMapping.f() != null) {
                                        }
                                    }
                                    i4 = Integer.MIN_VALUE;
                                    if (i4 == Integer.MIN_VALUE) {
                                    }
                                    portMapping.r(i4);
                                    f3 = c0Var2.f(c3, "NewInternalPort");
                                    if (f3 != null) {
                                    }
                                    i5 = Integer.MIN_VALUE;
                                    if (i5 == Integer.MIN_VALUE) {
                                    }
                                    portMapping.u(i5);
                                    f4 = c0Var2.f(c3, "NewProtocol");
                                    if (f4 == null) {
                                    }
                                    w wVar222 = w.TCP;
                                    w[] values22 = w.values();
                                    i6 = 0;
                                    while (true) {
                                        if (i6 >= 2) {
                                        }
                                        i6++;
                                    }
                                    if (wVar == null) {
                                    }
                                    portMapping.w(wVar);
                                    f5 = c0Var2.f(c3, "NewInternalClient");
                                    if (f5 != null) {
                                    }
                                    portMapping.t(ipAddress);
                                    str = "0";
                                    f6 = c0Var2.f(c3, "NewEnabled");
                                    if (f6 != null) {
                                    }
                                    if (!"true".equalsIgnoreCase(str)) {
                                    }
                                    z = true;
                                    portMapping.q(z);
                                    portMapping.o(c0Var2.f(c3, "NewPortMappingDescription"));
                                    f7 = c0Var2.f(c3, "NewLeaseDuration");
                                    if (f7 != null) {
                                    }
                                    i7 = Integer.MIN_VALUE;
                                    if (i7 == Integer.MIN_VALUE) {
                                    }
                                    portMapping.v((long) i7);
                                    if (portMapping.f() != null) {
                                    }
                                } else {
                                    Element c4 = c0Var2.c(c2, "s:Fault");
                                    if (!(c4 == null || (a2 = c0Var2.a(c4, "UPnPError")) == null)) {
                                        String f10 = c0Var2.f(a2, "errorCode");
                                        if (f10 != null) {
                                            try {
                                                i3 = Integer.parseInt(f10);
                                            } catch (NumberFormatException unused4) {
                                            }
                                            String str2 = "";
                                            f2 = c0Var2.f(a2, "errorDescription");
                                            if (f2 != null) {
                                                str2 = f2;
                                            }
                                            throw new RouterUPnPException(i3, str2);
                                        }
                                        i3 = Integer.MIN_VALUE;
                                        String str22 = "";
                                        f2 = c0Var2.f(a2, "errorDescription");
                                        if (f2 != null) {
                                        }
                                        throw new RouterUPnPException(i3, str22);
                                    }
                                }
                            }
                            if (arrayList.size() == i2) {
                                break;
                            }
                            i8 = i9;
                        } catch (RouterUPnPException e3) {
                            if (e3.a() == 713) {
                                Log.d("fing:router-upnp-srv", "Port mappings query terminated on item " + i8);
                            } else {
                                throw e3;
                            }
                        } catch (Exception e4) {
                            Log.e("fing:router-upnp-srv", "Failed to parse SOAP response (" + i8 + ") for \"" + this.f16224c + "#GetGenericPortMappingEntry\"", e4);
                            StringBuilder sb = new StringBuilder();
                            sb.append("Browse SCPD at ");
                            sb.append(new f(this.f16223a, this.f16225d, this.b).d());
                            Log.i("fing:router-upnp-srv", sb.toString());
                            throw new RouterUPnPException(901, e4);
                        }
                    } else {
                        throw new IOException("HTTP response body is empty!");
                    }
                } catch (IOException e5) {
                    Log.e("fing:router-upnp-srv", "SOAP call failed: \"" + this.f16224c + "#GetGenericPortMappingEntry\"", e5);
                    StringBuilder sb2 = new StringBuilder();
                    sb2.append("Browse SCPD at ");
                    sb2.append(new f(this.f16223a, this.f16225d, this.b).d());
                    Log.i("fing:router-upnp-srv", sb2.toString());
                    throw new RouterUPnPException(902, e5);
                }
            } catch (RouterUPnPException e6) {
                Log.e("fing:router-upnp-srv", "Cannot retrieve UPnP port mappings", e6);
                throw e6;
            }
        }
        Log.d("fing:router-upnp-srv", "UPnP port mappings: " + arrayList);
        return Collections.unmodifiableList(arrayList);
    }

    public String f() {
        return this.f16225d;
    }

    public String g() {
        return this.f16224c;
    }

    public boolean h() throws RouterUPnPException {
        SortedSet<String> sortedSet;
        Element c2;
        Log.d("fing:router-upnp-srv", "Checking whether ports can be opened via UPnP...");
        SortedSet<String> sortedSet2 = this.f16228g;
        if (sortedSet2 == null || sortedSet2.isEmpty()) {
            String str = this.f16229h;
            if (str == null) {
                f fVar = new f(this.f16223a, this.f16225d, this.b);
                StringBuilder E = a.E("Retrieving SCPD from ");
                E.append(fVar.d());
                Log.d("fing:router-upnp-srv", E.toString());
                try {
                    this.f16229h = new com.overlook.android.fing.engine.j.h.e(fVar, (int) HwBuildEx.VersionCodes.CUR_DEVELOPMENT).a();
                    Log.d("fing:router-upnp-srv", "SCPD document retrieved");
                    str = this.f16229h;
                } catch (IOException e2) {
                    Log.e("fing:router-upnp-srv", "Cannot retrieve SCPD document", e2);
                    this.f16229h = null;
                    throw new RouterUPnPException(900, e2);
                }
            }
            Log.d("fing:router-upnp-srv", "Retrieving UPnP actions...");
            this.f16228g = new TreeSet();
            try {
                com.overlook.android.fing.engine.l.c0 c0Var = new com.overlook.android.fing.engine.l.c0(new ByteArrayInputStream(str.getBytes()));
                Element e3 = c0Var.e();
                if ("scpd ".equals(e3.getTagName()) && (c2 = c0Var.c(e3, "actionList")) != null) {
                    for (Element element : c0Var.d(c2, "action")) {
                        String f2 = c0Var.f(element, "name");
                        if (!TextUtils.isEmpty(f2)) {
                            this.f16228g.add(f2);
                        }
                    }
                }
                StringBuilder E2 = a.E("Retrieved UPnP actions: ");
                E2.append(TextUtils.join(", ", this.f16228g));
                Log.d("fing:router-upnp-srv", E2.toString());
                sortedSet = this.f16228g;
            } catch (Exception e4) {
                Log.e("fing:router-upnp-srv", "Failed to parse SCPD document", e4);
                Log.i("fing:router-upnp-srv", "Browse SCPD at " + new f(this.f16223a, this.f16225d, this.b).d());
                throw new RouterUPnPException(901, e4);
            }
        } else {
            sortedSet = this.f16228g;
        }
        if (sortedSet.contains("AddPortMapping")) {
            Log.d("fing:router-upnp-srv", "Opening ports via UPnP is supported by this router");
            return true;
        }
        Log.d("fing:router-upnp-srv", "Ports cannot be opened via UPnP");
        return false;
    }

    public void i(String str) {
        this.f16226e = str;
    }

    public void j(String str) {
        this.f16227f = str;
    }

    public void k(String str) {
        this.f16223a = str;
    }

    public void l(int i2) {
        this.b = i2;
    }

    public void m(String str) {
        this.f16225d = str;
    }
}