package com.appsflyer.internal;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.os.Build;
import android.telephony.TelephonyManager;
import com.appsflyer.AFLogger;
import com.appsflyer.AppsFlyerLib;
import com.appsflyer.AppsFlyerLibCore;
import com.appsflyer.AppsFlyerProperties;
import com.appsflyer.FirebaseMessagingServiceListener;
import com.appsflyer.internal.d;
import com.facebook.places.model.PlaceFields;

public final class s {

    public static final class e {

        /* renamed from: ॱ  reason: contains not printable characters */
        public static final s f2121 = new s();
    }

    /* renamed from: ॱ  reason: contains not printable characters */
    public static d m1240(Context context) {
        String str;
        Throwable th;
        String str2 = "unknown";
        String str3 = null;
        try {
            ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
            if (connectivityManager != null) {
                int i = Build.VERSION.SDK_INT;
                Network[] allNetworks = connectivityManager.getAllNetworks();
                int length = allNetworks.length;
                int i2 = 0;
                while (true) {
                    if (i2 >= length) {
                        break;
                    }
                    NetworkInfo networkInfo = connectivityManager.getNetworkInfo(allNetworks[i2]);
                    if (!(networkInfo != null && networkInfo.isConnectedOrConnecting())) {
                        i2++;
                    } else if (1 == networkInfo.getType()) {
                        str2 = "WIFI";
                    } else if (networkInfo.getType() == 0) {
                        str2 = "MOBILE";
                    }
                }
            }
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(PlaceFields.PHONE);
            str = telephonyManager.getSimOperatorName();
            try {
                str3 = telephonyManager.getNetworkOperatorName();
                if ((str3 == null || str3.isEmpty()) && 2 == telephonyManager.getPhoneType()) {
                    str3 = "CDMA";
                }
            } catch (Throwable th2) {
                th = th2;
                AFLogger.afErrorLog("Exception while collecting network info. ", th);
                return new d(str2, str3, str);
            }
        } catch (Throwable th3) {
            th = th3;
            str = null;
            AFLogger.afErrorLog("Exception while collecting network info. ", th);
            return new d(str2, str3, str);
        }
        return new d(str2, str3, str);
    }

    public static final class d {

        /* renamed from: ˋ  reason: contains not printable characters */
        public final String f2118;

        /* renamed from: ˎ  reason: contains not printable characters */
        public final String f2119;

        /* renamed from: ॱ  reason: contains not printable characters */
        public final String f2120;

        public d(String str, String str2, String str3) {
            this.f2118 = str;
            this.f2119 = str2;
            this.f2120 = str3;
        }

        /* renamed from: ˋ  reason: contains not printable characters */
        public static void m1241(Context context, String str) {
            String str2;
            if (str != null) {
                AFLogger.afInfoLog("updateServerUninstallToken called with: ".concat(str));
                d.C0329d.C0330d r0 = d.C0329d.C0330d.m1223(AppsFlyerProperties.getInstance().getString("afUninstallToken"));
                SharedPreferences r2 = AppsFlyerLibCore.m1100(context);
                if (!r2.getBoolean("sentRegisterRequestToAF", false) || (str2 = r0.f2072) == null || !str2.equals(str)) {
                    AppsFlyerProperties.getInstance().set("afUninstallToken", str);
                    if (AppsFlyerLibCore.m1137(r2)) {
                        AppsFlyerLibCore.getInstance().m1143(context, str);
                    }
                }
            }
        }

        /* renamed from: ॱ  reason: contains not printable characters */
        public static boolean m1242(Context context) {
            if (AppsFlyerLib.getInstance().isTrackingStopped()) {
                return false;
            }
            try {
                Class.forName("com.google.firebase.messaging.FirebaseMessagingService");
                if (context.getPackageManager().queryIntentServices(new Intent("com.google.firebase.MESSAGING_EVENT", null, context, FirebaseMessagingServiceListener.class), 0).size() > 0) {
                    return true;
                }
                AFLogger.afWarnLog("Cannot verify existence of our InstanceID Listener Service in the manifest. Please refer to documentation.");
                return false;
            } catch (ClassNotFoundException unused) {
            } catch (Throwable th) {
                AFLogger.afErrorLog("An error occurred while trying to verify manifest declarations: ", th);
            }
        }

        public d() {
        }
    }
}
