package he;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import com.google.android.gms.measurement.internal.u1;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import kotlinx.coroutines.flow.h;
import kotlinx.coroutines.y;
import org.drive_hunter.R;
import w4.g;
import xyz.netfly.MyApplication;
import xyz.netfly.SplashActivity;
import xyz.netfly.ads.r;
import xyz.netfly.mobile.MobileMainActivity;
import xyz.netfly.ui.dashboard.DashboardActivity;
import xyz.netfly.ui.main.HomeActivity;
import xyz.stream.api.o;
import xyz.stream.api.q;
import xyz.stream.download.DownloadManager;
import xyz.stream.utils.NativeSecurity;
import xyz.stream.utils.entity.CheckResultEntity;
import xyz.stream.utils.entity.InstallEntity;
import xyz.stream.utils.f0;

/* JADX INFO: loaded from: classes3.dex */
public final /* synthetic */ class b implements Runnable {

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

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

    public /* synthetic */ b(SplashActivity splashActivity, int i10) {
        this.f26468a = i10;
        this.f26469b = splashActivity;
    }

    @Override // java.lang.Runnable
    public final void run() {
        switch (this.f26468a) {
            case 0:
                SplashActivity splashActivity = this.f26469b;
                int i10 = SplashActivity.f34824f;
                splashActivity.getClass();
                String[] strArr = {"APP START", "AndroidVersion: " + Build.VERSION.RELEASE, Build.MODEL + ", " + Build.BRAND, "macAddress: " + h.v(), "AppVersion: 3.0.3", "ChannelName: NETFLY", "AndroidId: " + xyz.stream.utils.e.d().b(), "LocalLanguage: " + splashActivity.getResources().getConfiguration().locale.getLanguage()};
                t4.c cVar = new t4.c(new g(new w4.d(strArr), new fa.h(10)));
                boolean z10 = false;
                int i11 = 0;
                while (true) {
                    v4.b bVar = cVar.f32945a;
                    int i12 = 1;
                    if (!bVar.hasNext()) {
                        t4.e eVar = z10 ? new t4.e(i11) : t4.e.f32948c;
                        int i13 = 4;
                        int i14 = 2;
                        String strL = y.L("", Collections.nCopies(((eVar.f32949a ? eVar.f32950b : 0) + 4) * 2, "*"));
                        StringBuilder sb = new StringBuilder(u1.k("\n\n", strL, "\n"));
                        for (int i15 = 0; i15 < 8; i15++) {
                            String str = strArr[i15];
                            String strL2 = y.L("", Collections.nCopies(5, " "));
                            sb.append("*");
                            sb.append(strL2);
                            sb.append(str);
                            sb.append("\n");
                        }
                        sb.append(strL);
                        sb.append("\n");
                        xyz.stream.utils.f.p().y(null, sb.toString());
                        InstallEntity installEntity = (InstallEntity) f0.o().k(InstallEntity.class, "sp_install_entity");
                        if (installEntity != null && "3.0.3".equals(installEntity.getVersionName())) {
                            f0.o().y("sp_install_entity");
                            String installPath = installEntity.getInstallPath();
                            if (installPath != null) {
                                File file = new File(installPath);
                                if (file.exists() && !file.delete()) {
                                    xyz.stream.utils.h.b("Failed to delete old install file: ".concat(installPath));
                                }
                            }
                            String sourcePath = installEntity.getSourcePath();
                            if (sourcePath != null) {
                                File file2 = new File(sourcePath);
                                if (file2.exists() && !file2.delete()) {
                                    xyz.stream.utils.h.b("Failed to delete old source file: ".concat(sourcePath));
                                }
                            }
                        }
                        o.f35913d = new o("xyz.netfly", "com.netfly", "netfly");
                        CheckResultEntity checkResultEntityC = xyz.stream.utils.e.d().c();
                        int iIntValue = (checkResultEntityC == null || checkResultEntityC.getIsPremium() == null) ? 0 : checkResultEntityC.getIsPremium().intValue();
                        q qVarG = q.g();
                        Context context = MyApplication.f34822a;
                        qVarG.m(context, y.q(context), iIntValue);
                        xyz.netfly.ui.live.epg.q.o().f35391o = xyz.stream.api.database.q.a().e(MyApplication.f34822a);
                        xyz.netfly.api.c cVarB = xyz.netfly.api.c.b();
                        cVarB.getClass();
                        cVarB.f34900a.execute(new xyz.netfly.api.a(cVarB, 2));
                        re.a aVarU = re.a.u();
                        aVarU.getClass();
                        aVarU.f35898a = new ArrayList();
                        xyz.stream.api.d.b().a();
                        o.f().j();
                        Uri uri = Uri.parse("android.resource://xyz.stream/2131755078");
                        xyz.stream.api.d dVarB = xyz.stream.api.d.b();
                        String string = splashActivity.getString(R.string.trending_now);
                        dVarB.a();
                        dVarB.f35773g = uri;
                        dVarB.f35774h = string;
                        dVarB.f35775i = SplashActivity.class;
                        try {
                            dVarB.f35767a = new File(xyz.stream.utils.e.d().f36112a.getFilesDir(), "cms_top.json");
                            dVarB.f35768b = new File(xyz.stream.utils.e.d().f36112a.getFilesDir(), "cms_collections.json");
                            dVarB.g();
                            dVarB.f();
                            new Handler(Looper.getMainLooper()).postDelayed(new b7.a(i13), 5000L);
                        } catch (Exception e10) {
                            xyz.stream.utils.h.c("ApiDataCacheHelper init error: " + e10.getMessage());
                            xyz.stream.utils.e.d().i();
                        }
                        String[] strArr2 = {"default_pic", "mipmap", "default_pic.png"};
                        String str2 = strArr2[0];
                        String str3 = strArr2[1];
                        String str4 = strArr2[2];
                        try {
                            File file3 = new File(xyz.stream.utils.e.d().f36112a.getCacheDir(), str4);
                            if (!file3.exists()) {
                                int identifier = xyz.stream.utils.e.d().f36112a.getResources().getIdentifier(str2, str3, xyz.stream.utils.e.d().f36112a.getPackageName());
                                if (identifier == 0) {
                                    xyz.stream.utils.f.p().x("Resource not found: " + str2 + " in " + str3 + " for package " + xyz.stream.utils.e.d().f36112a.getPackageName());
                                } else {
                                    InputStream inputStreamOpenRawResource = xyz.stream.utils.e.d().f36112a.getResources().openRawResource(identifier);
                                    FileOutputStream fileOutputStream = new FileOutputStream(file3);
                                    byte[] bArr = new byte[1024];
                                    while (true) {
                                        int i16 = inputStreamOpenRawResource.read(bArr);
                                        if (i16 > 0) {
                                            fileOutputStream.write(bArr, 0, i16);
                                        } else {
                                            fileOutputStream.close();
                                            inputStreamOpenRawResource.close();
                                        }
                                    }
                                }
                            }
                        } catch (Exception e11) {
                            xyz.stream.utils.f fVarP = xyz.stream.utils.f.p();
                            StringBuilder sbN = u1.n("Failed to copy image ", str4, ": ");
                            sbN.append(e11.getMessage());
                            fVarP.x(sbN.toString());
                        }
                        if (xyz.stream.utils.e.d().f36119h || xyz.stream.utils.e.d().f36121j) {
                            DownloadManager.getInstance().init(splashActivity, xyz.stream.utils.e.d().f36117f);
                            DownloadManager.getInstance().queryDownloadTask(true);
                        }
                        if (xyz.stream.utils.e.d().f36121j) {
                            r.e().f(splashActivity, new c(splashActivity, i12));
                        } else if (xyz.stream.utils.e.d().f36119h) {
                            r.e().f(splashActivity, new c(splashActivity, i14));
                        } else {
                            splashActivity.K(true);
                        }
                        break;
                    } else {
                        int iA = bVar.a();
                        if (!z10) {
                            i11 = iA;
                            z10 = true;
                        } else if (i11 <= iA) {
                            i11 = iA;
                        }
                    }
                }
                break;
            default:
                int i17 = SplashActivity.f34824f;
                SplashActivity splashActivity2 = this.f26469b;
                boolean zA = NativeSecurity.a(splashActivity2, splashActivity2.getPackageName(), new String[0]);
                boolean zK = y.K(splashActivity2);
                if (zA && zK) {
                    Intent intent = xyz.stream.utils.e.d().f36121j ? new Intent(splashActivity2, (Class<?>) MobileMainActivity.class) : xyz.stream.utils.e.d().f36119h ? new Intent(splashActivity2, (Class<?>) HomeActivity.class) : new Intent(splashActivity2, (Class<?>) DashboardActivity.class);
                    int i18 = splashActivity2.f34825b;
                    if (i18 > 0) {
                        intent.putExtra("videoId", i18);
                        intent.putExtra("sourceType", splashActivity2.f34826c);
                    }
                    splashActivity2.startActivity(intent);
                    splashActivity2.finish();
                } else {
                    splashActivity2.finish();
                }
                break;
        }
    }
}
