package o0;

import android.content.Context;
import android.os.Build;
import android.os.Trace;
import android.text.PrecomputedText;
import android.text.StaticLayout;
import android.text.TextUtils;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.Callable;

/* JADX INFO: loaded from: classes.dex */
public final class d implements Callable {

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

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

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Object f31271c;

    public /* synthetic */ d(Object obj, Object obj2, int i10) {
        this.f31269a = i10;
        this.f31270b = obj;
        this.f31271c = obj2;
    }

    @Override // java.util.concurrent.Callable
    public final Object call() {
        f fVar;
        PrecomputedText.Params params;
        Object obj = this.f31271c;
        Object obj2 = this.f31270b;
        switch (this.f31269a) {
            case 0:
                CharSequence charSequence = (CharSequence) obj;
                c cVar = (c) obj2;
                Object obj3 = f.f31272c;
                p0.g.checkNotNull(charSequence);
                p0.g.checkNotNull(cVar);
                try {
                    Trace.beginSection("PrecomputedText");
                    if (Build.VERSION.SDK_INT < 29 || (params = cVar.f31268d) == null) {
                        ArrayList arrayList = new ArrayList();
                        int length = charSequence.length();
                        int i10 = 0;
                        while (i10 < length) {
                            int iIndexOf = TextUtils.indexOf(charSequence, '\n', i10, length);
                            i10 = iIndexOf < 0 ? length : iIndexOf + 1;
                            arrayList.add(Integer.valueOf(i10));
                        }
                        int[] iArr = new int[arrayList.size()];
                        for (int i11 = 0; i11 < arrayList.size(); i11++) {
                            iArr[i11] = ((Integer) arrayList.get(i11)).intValue();
                        }
                        StaticLayout.Builder.obtain(charSequence, 0, charSequence.length(), cVar.f31265a, Integer.MAX_VALUE).setBreakStrategy(cVar.f31266b).setHyphenationFrequency(cVar.f31267c).setTextDirection(cVar.getTextDirection()).build();
                        fVar = new f(charSequence, cVar);
                    } else {
                        fVar = new f(PrecomputedText.create(charSequence, params), cVar);
                    }
                    return fVar;
                } finally {
                    Trace.endSection();
                }
            case 1:
                return ((m7.g) obj2).e((Context) obj);
            case 2:
                return ((com.google.android.gms.ads.nonagon.signalgeneration.a) obj2).getClickSignals((String) obj);
            case 3:
                ((Runnable) obj2).run();
                return null;
            default:
                id.b.g("FlutterLoader initTask");
                try {
                    ((io.flutter.embedding.engine.loader.f) obj).getClass();
                    try {
                        ((io.flutter.embedding.engine.loader.f) obj).f27991d.loadLibrary((Context) obj2);
                        ((io.flutter.embedding.engine.loader.f) obj).f27991d.updateRefreshRate();
                        ((io.flutter.embedding.engine.loader.f) obj).f27992e.execute(new y.a(this, 26));
                        Context context = (Context) obj2;
                        File filesDir = context.getFilesDir();
                        if (filesDir == null) {
                            filesDir = new File(context.getDataDir().getPath(), "files");
                        }
                        String path = filesDir.getPath();
                        Context context2 = (Context) obj2;
                        File codeCacheDir = context2.getCodeCacheDir();
                        if (codeCacheDir == null) {
                            codeCacheDir = context2.getCacheDir();
                        }
                        if (codeCacheDir == null) {
                            codeCacheDir = new File(context2.getDataDir().getPath(), "cache");
                        }
                        String path2 = codeCacheDir.getPath();
                        Context context3 = (Context) obj2;
                        File dir = context3.getDir("flutter", 0);
                        if (dir == null) {
                            dir = new File(context3.getDataDir().getPath(), "app_flutter");
                        }
                        dir.getPath();
                        return new io.flutter.embedding.engine.loader.d(path, path2);
                    } catch (UnsatisfiedLinkError e10) {
                        if (!e10.toString().contains("couldn't find \"libflutter.so\"") && !e10.toString().contains("dlopen failed: library \"libflutter.so\" not found")) {
                            throw e10;
                        }
                        String property = System.getProperty("os.arch");
                        File file = new File(((io.flutter.embedding.engine.loader.f) obj).f27990c.f27978d);
                        String[] list = file.list();
                        StringBuilder sb = new StringBuilder("Could not load libflutter.so this is possibly because the application is running on an architecture that Flutter Android does not support (e.g. x86) see https://docs.flutter.dev/deployment/android#what-are-the-supported-target-architectures for more detail.\nApp is using cpu architecture: ");
                        sb.append(property);
                        sb.append(", and the native libraries directory (with path ");
                        sb.append(file.getAbsolutePath());
                        sb.append(") ");
                        sb.append(file.exists() ? "contains the following files: " + Arrays.toString(list) : "does not exist.");
                        throw new UnsupportedOperationException(sb.toString(), e10);
                    }
                } catch (Throwable th) {
                    try {
                        break;
                    } catch (Throwable th2) {
                        th.addSuppressed(th2);
                    }
                    throw th;
                }
        }
    }

    public /* synthetic */ d(Object obj, Object obj2, int i10, int i11) {
        this.f31269a = i10;
        this.f31270b = obj2;
        this.f31271c = obj;
    }
}
