package com.google.android.gms.internal.ads;

import android.content.Context;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.Callable;

/* JADX INFO: loaded from: classes2.dex */
public final /* synthetic */ class y61 implements Callable {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ int f18670a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ Object f18671b;

    public /* synthetic */ y61(Object obj, int i10) {
        this.f18670a = i10;
        this.f18671b = obj;
    }

    @Override // java.util.concurrent.Callable
    public final Object call() throws PackageManager.NameNotFoundException {
        int i10;
        Object obj;
        Object objApply;
        File file;
        boolean zIsActiveNetworkMetered = false;
        switch (this.f18670a) {
            case 0:
                Context context = ((z61) this.f18671b).f19099b;
                TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
                String networkOperator = telephonyManager.getNetworkOperator();
                int phoneType = telephonyManager.getPhoneType();
                m7.n nVar = m7.n.C;
                p7.r0 r0Var = nVar.f30464c;
                int iOrdinal = -1;
                if (p7.r0.b(context, "android.permission.ACCESS_NETWORK_STATE")) {
                    ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
                    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
                    if (activeNetworkInfo != null) {
                        int type = activeNetworkInfo.getType();
                        iOrdinal = activeNetworkInfo.getDetailedState().ordinal();
                        i10 = type;
                    } else {
                        i10 = -1;
                    }
                    zIsActiveNetworkMetered = connectivityManager.isActiveNetworkMetered();
                } else {
                    i10 = -2;
                }
                return new x61(networkOperator, i10, nVar.f30467f.f(context), phoneType, zIsActiveNetworkMetered, iOrdinal);
            case 1:
                return new f31(((s71) this.f18671b).f16336b, 5);
            case 2:
                ((uc1) this.f18671b).zza();
                return null;
            case 3:
                Context context2 = ((nh1) this.f18671b).f14610a;
                return ih1.g(context2, context2.getPackageName(), Integer.toString(context2.getPackageManager().getPackageInfo(context2.getPackageName(), 0).versionCode));
            case 4:
                al1 al1Var = (al1) this.f18671b;
                synchronized (al1Var) {
                    try {
                        try {
                            try {
                                FileInputStream fileInputStream = new FileInputStream(al1Var.f8731a);
                                try {
                                    objApply = ((ru) al1Var.f8733c).i(fileInputStream);
                                    fileInputStream.close();
                                } catch (Throwable th) {
                                    try {
                                        fileInputStream.close();
                                        break;
                                    } catch (Throwable th2) {
                                        th.addSuppressed(th2);
                                    }
                                    throw th;
                                }
                            } catch (IOException e10) {
                                objApply = al1Var.f8734d.apply(new zzgcw(e10));
                            }
                        } catch (zzgcw e11) {
                            objApply = al1Var.f8734d.apply(e11);
                        }
                    } catch (FileNotFoundException unused) {
                        ru ruVar = (ru) al1Var.f8733c;
                        int i11 = ruVar.f16224a;
                        Object obj2 = ruVar.f16225b;
                        switch (i11) {
                            case 2:
                                obj = (byte[]) obj2;
                                break;
                            default:
                                obj = (wb2) obj2;
                                break;
                        }
                        objApply = obj;
                    }
                }
                return objApply;
            case 5:
                am1 am1Var = (am1) this.f18671b;
                ((gm1) am1Var.f8745c.zzb()).a();
                ((lm1) am1Var.f8744b.zzb()).a();
                return null;
            case 6:
                return ((gg2) this.f18671b).zzb();
            case 7:
                oo1 oo1Var = (oo1) this.f18671b;
                jp1 jp1Var = oo1Var.f15131i;
                al1 al1Var2 = oo1Var.f15124b;
                al1 al1Var3 = oo1Var.f15126d;
                gg2 gg2Var = oo1Var.f15128f;
                try {
                    File file2 = al1Var2.f8731a;
                    boolean zExists = file2.exists();
                    File file3 = al1Var2.f8731a;
                    if (zExists) {
                        File file4 = ((al1) gg2Var.zzb()).f8731a;
                        File file5 = ((al1) oo1Var.f15127e.zzb()).f8731a;
                        try {
                            if (file4.exists()) {
                                File parentFile = file5.getParentFile();
                                if (parentFile != null) {
                                    ih1.M0(parentFile);
                                }
                                ih1.d0(file5);
                                ih1.t0(file4, file5);
                            }
                            File file6 = al1Var3.f8731a;
                            File file7 = oo1Var.f15125c.f8731a;
                            try {
                                if (file6.exists()) {
                                    ih1.d0(file7);
                                    ih1.t0(file6, file7);
                                }
                                File file8 = oo1Var.f15123a.f8731a;
                                try {
                                    if (file2.exists()) {
                                        ih1.d0(file8);
                                        ih1.t0(file2, file8);
                                    }
                                    file3.delete();
                                    ((al1) gg2Var.zzb()).f8731a.delete();
                                    file6.delete();
                                    zIsActiveNetworkMetered = true;
                                } catch (IOException | SecurityException e12) {
                                    jp1Var.d(15313, e12);
                                    file3.delete();
                                    file = ((al1) gg2Var.zzb()).f8731a;
                                    file.delete();
                                    file6.delete();
                                }
                            } catch (IOException | SecurityException e13) {
                                jp1Var.d(15312, e13);
                                file3.delete();
                                file = ((al1) gg2Var.zzb()).f8731a;
                            }
                            break;
                        } catch (IOException e14) {
                            e = e14;
                            jp1Var.d(15311, e);
                            file3.delete();
                            ((al1) gg2Var.zzb()).f8731a.delete();
                            al1Var3.f8731a.delete();
                        } catch (SecurityException e15) {
                            e = e15;
                            jp1Var.d(15311, e);
                            file3.delete();
                            ((al1) gg2Var.zzb()).f8731a.delete();
                            al1Var3.f8731a.delete();
                        }
                        return new Boolean(zIsActiveNetworkMetered);
                    }
                    file3.delete();
                    ((al1) gg2Var.zzb()).f8731a.delete();
                    al1Var3.f8731a.delete();
                    return new Boolean(zIsActiveNetworkMetered);
                } catch (Throwable th3) {
                    al1Var2.f8731a.delete();
                    ((al1) gg2Var.zzb()).f8731a.delete();
                    al1Var3.f8731a.delete();
                    throw th3;
                }
            case 8:
                cp1 cp1Var = (cp1) this.f18671b;
                cp1Var.getClass();
                qz qzVar = new qz(cp1Var, 14);
                synchronized (cp1Var) {
                    jp1 jp1Var2 = cp1Var.f10020c;
                    ku1 ku1VarH1 = ih1.h1(kotlinx.coroutines.y.y(new uz0(cp1Var.f10019b, cp1Var.f10022e, 9)), qzVar, cp1Var.f10021d);
                    jp1Var2.e(52, ku1VarH1);
                    cp1Var.f10024g = ku1VarH1;
                    break;
                }
                return "";
            case 9:
                Context context3 = ((cp1) this.f18671b).f10019b;
                try {
                    return ih1.g(context3, context3.getPackageName(), Integer.toString(context3.getPackageManager().getPackageInfo(context3.getPackageName(), 0).versionCode));
                } catch (Throwable unused2) {
                    return null;
                }
            default:
                zzgnw zzgnwVar = (zzgnw) this.f18671b;
                zzgnwVar.getClass();
                IntentFilter intentFilter = new IntentFilter();
                intentFilter.addAction("android.intent.action.USER_PRESENT");
                intentFilter.addAction("android.intent.action.SCREEN_OFF");
                zzgnwVar.f19744a.registerReceiver(zzgnwVar, intentFilter);
                return null;
        }
    }
}
