package rc;

import android.app.ActivityManager;
import android.content.ContentResolver;
import android.content.pm.FeatureInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.provider.Settings;
import com.google.firebase.messaging.Constants$ScionAnalytics$MessageType;
import com.pichillilorenzo.flutter_inappwebview_android.credential_database.URLProtectionSpaceContract;
import dd.a0;
import ed.q;
import ed.s;
import ed.t;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import kotlin.text.h;
import kotlin.text.i;
import nb.g;
import xyz.stream.download.config.InnerConstant;

/* JADX INFO: loaded from: classes.dex */
public final class b implements s {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final PackageManager f32533a;

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

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

    public b(PackageManager packageManager, ActivityManager activityManager, ContentResolver contentResolver) {
        this.f32533a = packageManager;
        this.f32534b = activityManager;
        this.f32535c = contentResolver;
    }

    /* JADX WARN: Removed duplicated region for block: B:14:0x00d9  */
    /* JADX WARN: Removed duplicated region for block: B:40:0x0151  */
    @Override // ed.s
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final void onMethodCall(q qVar, t tVar) {
        boolean z10;
        g.i(qVar, "call");
        if (!qVar.f25842a.equals("getDeviceInfo")) {
            ((a0) tVar).notImplemented();
            return;
        }
        HashMap map = new HashMap();
        map.put("board", Build.BOARD);
        map.put("bootloader", Build.BOOTLOADER);
        String str = Build.BRAND;
        map.put("brand", str);
        String str2 = Build.DEVICE;
        map.put("device", str2);
        map.put(Constants$ScionAnalytics$MessageType.DISPLAY_NOTIFICATION, Build.DISPLAY);
        String str3 = Build.FINGERPRINT;
        map.put("fingerprint", str3);
        String str4 = Build.HARDWARE;
        map.put("hardware", str4);
        map.put(URLProtectionSpaceContract.FeedEntry.COLUMN_NAME_HOST, Build.HOST);
        map.put(InnerConstant.Db.f36069id, Build.ID);
        String str5 = Build.MANUFACTURER;
        map.put("manufacturer", str5);
        String str6 = Build.MODEL;
        map.put("model", str6);
        String str7 = Build.PRODUCT;
        map.put("product", str7);
        if (Build.VERSION.SDK_INT >= 25) {
            String string = Settings.Global.getString(this.f32535c, "device_name");
            if (string == null) {
                string = "";
            }
            map.put("name", string);
        }
        String[] strArr = Build.SUPPORTED_32_BIT_ABIS;
        map.put("supported32BitAbis", hb.a.m0(Arrays.copyOf(strArr, strArr.length)));
        String[] strArr2 = Build.SUPPORTED_64_BIT_ABIS;
        map.put("supported64BitAbis", hb.a.m0(Arrays.copyOf(strArr2, strArr2.length)));
        String[] strArr3 = Build.SUPPORTED_ABIS;
        map.put("supportedAbis", hb.a.m0(Arrays.copyOf(strArr3, strArr3.length)));
        map.put("tags", Build.TAGS);
        map.put("type", Build.TYPE);
        g.h(str, "BRAND");
        String serial = "unknown";
        if (h.j0(str, "generic", false)) {
            g.h(str2, "DEVICE");
            if (!h.j0(str2, "generic", false)) {
                g.h(str3, "FINGERPRINT");
                if (h.j0(str3, "generic", false) || h.j0(str3, "unknown", false)) {
                    z10 = true;
                } else {
                    g.h(str4, "HARDWARE");
                    if (!i.l0(str4, "goldfish") && !i.l0(str4, "ranchu")) {
                        g.h(str6, "MODEL");
                        if (!i.l0(str6, "google_sdk") && !i.l0(str6, "Emulator") && !i.l0(str6, "Android SDK built for x86")) {
                            g.h(str5, "MANUFACTURER");
                            if (!i.l0(str5, "Genymotion")) {
                                g.h(str7, "PRODUCT");
                                if (!i.l0(str7, "sdk") && !i.l0(str7, "vbox86p") && !i.l0(str7, "emulator") && !i.l0(str7, "simulator")) {
                                    z10 = false;
                                }
                            }
                        }
                    }
                }
            }
        }
        map.put("isPhysicalDevice", Boolean.valueOf(!z10));
        FeatureInfo[] systemAvailableFeatures = this.f32533a.getSystemAvailableFeatures();
        g.h(systemAvailableFeatures, "getSystemAvailableFeatures(...)");
        ArrayList arrayList = new ArrayList();
        for (FeatureInfo featureInfo : systemAvailableFeatures) {
            if (featureInfo.name != null) {
                arrayList.add(featureInfo);
            }
        }
        ArrayList arrayList2 = new ArrayList(kotlin.collections.i.Z0(10, arrayList));
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            arrayList2.add(((FeatureInfo) it.next()).name);
        }
        map.put("systemFeatures", arrayList2);
        StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
        map.put("freeDiskSize", Long.valueOf(statFs.getFreeBytes()));
        map.put("totalDiskSize", Long.valueOf(statFs.getTotalBytes()));
        HashMap map2 = new HashMap();
        int i10 = Build.VERSION.SDK_INT;
        map2.put("baseOS", Build.VERSION.BASE_OS);
        map2.put("previewSdkInt", Integer.valueOf(Build.VERSION.PREVIEW_SDK_INT));
        map2.put("securityPatch", Build.VERSION.SECURITY_PATCH);
        map2.put("codename", Build.VERSION.CODENAME);
        map2.put("incremental", Build.VERSION.INCREMENTAL);
        map2.put("release", Build.VERSION.RELEASE);
        map2.put("sdkInt", Integer.valueOf(i10));
        map.put("version", map2);
        ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
        this.f32534b.getMemoryInfo(memoryInfo);
        map.put("isLowRamDevice", Boolean.valueOf(memoryInfo.lowMemory));
        map.put("physicalRamSize", Long.valueOf(memoryInfo.totalMem / 1048576));
        map.put("availableRamSize", Long.valueOf(memoryInfo.availMem / 1048576));
        if (i10 >= 26) {
            try {
                serial = Build.getSerial();
            } catch (SecurityException unused) {
            }
            map.put("serialNumber", serial);
        } else {
            map.put("serialNumber", Build.SERIAL);
        }
        ((a0) tVar).success(map);
    }
}
