package com.urbanairship.push.embedded;

import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import com.flurry.android.AdCreative;
import com.urbanairship.Logger;
import com.urbanairship.UAirship;

/* loaded from: /storage/emulated/0/Documents/jadec/sources/com.UBI.A90.WW/dex-files/2.dex */
public class Network {
    private static ConnectivityManager connMan() {
        return (ConnectivityManager) UAirship.shared().getApplicationContext().getSystemService("connectivity");
    }

    /* JADX WARN: Removed duplicated region for block: B:6:0x000b A[Catch: SocketException -> 0x004f, TryCatch #1 {SocketException -> 0x004f, blocks: (B:4:0x0005, B:6:0x000b, B:7:0x0015, B:9:0x001b, B:12:0x0029), top: B:25:0x0005 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public static java.lang.String getActiveIPAddress() {
        /*
            r1 = 0
            java.util.Enumeration r2 = java.net.NetworkInterface.getNetworkInterfaces()     // Catch: java.net.SocketException -> L47
        L5:
            boolean r0 = r2.hasMoreElements()     // Catch: java.net.SocketException -> L4f
            if (r0 == 0) goto L2f
            java.lang.Object r0 = r2.nextElement()     // Catch: java.net.SocketException -> L4f
            java.net.NetworkInterface r0 = (java.net.NetworkInterface) r0     // Catch: java.net.SocketException -> L4f
            java.util.Enumeration r3 = r0.getInetAddresses()     // Catch: java.net.SocketException -> L4f
        L15:
            boolean r0 = r3.hasMoreElements()     // Catch: java.net.SocketException -> L4f
            if (r0 == 0) goto L5
            java.lang.Object r0 = r3.nextElement()     // Catch: java.net.SocketException -> L4f
            java.net.InetAddress r0 = (java.net.InetAddress) r0     // Catch: java.net.SocketException -> L4f
            boolean r4 = r0.isLoopbackAddress()     // Catch: java.net.SocketException -> L4f
            if (r4 != 0) goto L52
            if (r1 != 0) goto L52
            java.lang.String r0 = r0.getHostAddress()     // Catch: java.net.SocketException -> L4f
        L2d:
            r1 = r0
            goto L15
        L2f:
            r0 = r1
        L30:
            java.lang.StringBuilder r1 = new java.lang.StringBuilder
            r1.<init>()
            java.lang.String r2 = "Detected active IP address as: "
            java.lang.StringBuilder r1 = r1.append(r2)
            java.lang.StringBuilder r1 = r1.append(r0)
            java.lang.String r1 = r1.toString()
            com.urbanairship.Logger.verbose(r1)
            return r0
        L47:
            r0 = move-exception
            r0 = r1
        L49:
            java.lang.String r1 = "Error fetching IP address information"
            com.urbanairship.Logger.error(r1)
            goto L30
        L4f:
            r0 = move-exception
            r0 = r1
            goto L49
        L52:
            r0 = r1
            goto L2d
        */
        throw new UnsupportedOperationException("Method not decompiled: com.urbanairship.push.embedded.Network.getActiveIPAddress():java.lang.String");
    }

    private static NetworkInfo info() {
        ConnectivityManager connMan = connMan();
        if (connMan != null) {
            return connMan.getActiveNetworkInfo();
        }
        Logger.error("Error fetching network info.");
        return null;
    }

    public static boolean isConnected() {
        NetworkInfo info = info();
        if (info == null) {
            return false;
        }
        return info.isConnected();
    }

    public static String typeName() {
        NetworkInfo info = info();
        return info == null ? AdCreative.kFixNone : info.getTypeName();
    }
}
