package c.n;

import android.annotation.SuppressLint;
import android.app.usage.StorageStatsManager;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.hardware.usb.UsbEndpoint;
import android.hardware.usb.UsbInterface;
import android.os.Environment;
import android.os.Parcelable;
import android.os.StatFs;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import c.n.c.r;
import com.cvte.vman.VmanMiddleWare;
import com.ifpdos.debugmenu.DebugMenuApplication;
import com.ifpdos.debugmenu.R;
import com.ifpdos.debugmenu.entity.ValueBody;
import com.ifpdos.debugmenu.event.ActivityEvent;
import com.ifpdos.debugmenu.upgrades.entrties.Progress;
import com.seewo.sdk.SDKConfigureHelper;
import com.seewo.sdk.model.SDKUpgradeResult;
import com.seewo.sdk.model.SDKUpgradeType;
import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;
import d.f.a.r2.g;
import d.f.a.r2.j3.e;
import d.f.a.r2.j3.f;
import d.f.a.r2.s2;
import f.a.i;
import f.a.w.d.d;
import g.a0;
import g.h0.c.l;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Array;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import jxl.SheetSettings;
import k.c.a.c;
import okhttp3.internal.ws.RealWebSocket;

/* JADX INFO: loaded from: classes.dex */
public final class a {
    public static long a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public static Method f1811b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public static Integer f1812c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public static Integer f1813d;

    public static String A() {
        String str = SystemProperties.get("ro.cvte.flash", "");
        if (!TextUtils.isEmpty(str) && !"".equals(str.trim())) {
            d.b.a.a.a.N("getTotalSize: getFlashTotalSizeFrom[ro.cvte.flash], totalSize = ", str, "DiskSizeUtil");
            return str;
        }
        StatFs statFs = new StatFs(Environment.getDataDirectory().getPath());
        long blockSize = statFs.getBlockSize();
        long blockCount = statFs.getBlockCount();
        double dLog = Math.log(blockCount / 800000) / Math.log(2.0d);
        int i2 = 0;
        while (true) {
            if (i2 >= 31) {
                i2 = 0;
                break;
            }
            if (dLog < i2) {
                break;
            }
            i2++;
        }
        String strQ = q(((long) Math.pow(2.0d, i2)) * 1048576 * blockSize);
        Log.d("DiskSizeUtil", String.format(Locale.US, "getTotalSize: getFlashTotalSizeFrom[DiskSizeUtil.getTotalSize()], blockSize = %d, totalCount = %d, index = %d, totalSize = %s", Long.valueOf(blockSize), Long.valueOf(blockCount), Integer.valueOf(i2), strQ));
        return strQ;
    }

    public static String B(Context context) {
        long jLongValue = 0;
        try {
            StorageManager storageManager = (StorageManager) context.getSystemService("storage");
            StorageStatsManager storageStatsManager = (StorageStatsManager) context.getSystemService("storagestats");
            Class<?> cls = Class.forName("android.os.storage.StorageManager");
            Class<?> cls2 = Class.forName("android.app.usage.StorageStatsManager");
            Method method = cls.getMethod("getVolumes", new Class[0]);
            Method method2 = cls2.getMethod("getTotalBytes", String.class);
            List<VolumeInfo> list = (List) method.invoke(storageManager, new Object[0]);
            Class<?> cls3 = Class.forName("android.os.storage.VolumeInfo");
            Method method3 = cls3.getMethod("getType", new Class[0]);
            Method method4 = cls3.getMethod("getFsUuid", new Class[0]);
            Method method5 = cls3.getMethod("isMountedReadable", new Class[0]);
            if (list == null) {
                return q(0L);
            }
            for (VolumeInfo volumeInfo : list) {
                int iIntValue = ((Integer) method3.invoke(volumeInfo, new Object[0])).intValue();
                boolean zBooleanValue = ((Boolean) method5.invoke(volumeInfo, new Object[0])).booleanValue();
                if (1 == iIntValue && zBooleanValue) {
                    jLongValue += ((Long) method2.invoke(storageStatsManager, (String) method4.invoke(volumeInfo, new Object[0]))).longValue();
                }
            }
            return jLongValue < 999000 ? q((jLongValue / 1000) * RealWebSocket.DEFAULT_MINIMUM_DEFLATE_SIZE) : jLongValue < 999000000 ? q((jLongValue / 1000000) * 1048576) : jLongValue < 999000000000L ? q((jLongValue / 1000000000) * 1073741824) : jLongValue < 999000000000000L ? q((jLongValue / 1000000000000L) * 1099511627776L) : jLongValue < 999000000000000000L ? q((jLongValue / 1000000000000000L) * 1125899906842624L) : q(jLongValue);
        } catch (Exception e2) {
            Log.e("FlashHelper", "getTotalSize: ", e2);
            return q(0L);
        }
    }

    public static int C(Class<?> cls) {
        if (cls == Byte.TYPE || cls == Byte.class) {
            return 1;
        }
        if (cls == Short.TYPE || cls == Short.class) {
            return 2;
        }
        if (cls == Integer.TYPE || cls == Integer.class) {
            return 3;
        }
        if (cls == Long.TYPE || cls == Long.class) {
            return 4;
        }
        if (cls == Float.TYPE || cls == Float.class) {
            return 5;
        }
        if (cls == Double.TYPE || cls == Double.class) {
            return 6;
        }
        if (cls == Boolean.TYPE || cls == Boolean.class) {
            return 7;
        }
        if (cls == Character.TYPE || cls == Character.class) {
            return 8;
        }
        if (cls == byte[].class) {
            return 9;
        }
        if (cls == short[].class) {
            return 10;
        }
        if (cls == int[].class) {
            return 11;
        }
        if (cls == long[].class) {
            return 12;
        }
        if (cls == float[].class) {
            return 13;
        }
        if (cls == double[].class) {
            return 14;
        }
        if (cls == boolean[].class) {
            return 15;
        }
        if (cls == char[].class) {
            return 16;
        }
        if (cls == String.class) {
            return 17;
        }
        if (cls == String[].class) {
            return 18;
        }
        if (cls == CharSequence.class) {
            return 19;
        }
        if (cls == CharSequence[].class) {
            return 20;
        }
        if (Parcelable.class.isAssignableFrom(cls)) {
            return 21;
        }
        if (Parcelable[].class.isAssignableFrom(cls)) {
            return 22;
        }
        if (List.class.isAssignableFrom(cls)) {
            return 23;
        }
        return Map.class.isAssignableFrom(cls) ? 24 : 0;
    }

    public static String D(Context context, SDKUpgradeResult sDKUpgradeResult, String str) {
        if (SDKUpgradeType.MSB9100.name().equals(str) && sDKUpgradeResult == SDKUpgradeResult.SUCCESS) {
            return context.getResources().getString(R.string.str_debug_upgrade_9100_succeed);
        }
        switch (sDKUpgradeResult) {
            case SUCCESS:
                return context.getString(R.string.str_debug_upgrade_succeed, str);
            case INVALID_MACHINE:
                return context.getString(R.string.str_debug_upgrade_machine_not_support, str);
            case BIN_NOT_FOUND:
                return context.getString(R.string.str_debug_upgrade_file_not_exist_hint, str);
            case COPY_BIN_ERROR:
                return context.getString(R.string.str_debug_upgrade_file_copy_fail, str);
            case CONNECT_DEVICE_ERROR:
                return context.getString(R.string.str_debug_upgrade_connect_device_fail);
            case SWITCH_BOOTLOADER_ERROR:
                return context.getString(R.string.str_debug_upgrade_bootloader_not_found);
            case CHECKING_MD5_ERROR:
                return context.getString(R.string.str_debug_upgrade_md5_check_fail, str);
            case CHECK_BOOT_VERSION_ERROR:
                return context.getString(R.string.str_debug_upgrade_boot_version_check_fail);
            case RECEIVE_DATA_ERROR:
            case READ_BIN_ERROR:
            case UPGRADE_ERROR:
            case UNKNOWN_ERROR:
                return context.getString(R.string.str_debug_upgrade_unknown_error, str);
            default:
                return context.getString(R.string.str_debug_upgrade_unknown_error, str);
        }
    }

    public static String E() {
        ValueBody valueBody = (ValueBody) e.a.b("/v1/system/data/YIDONG_CMEI", ValueBody.class);
        return valueBody == null ? "" : (String) valueBody.getValue();
    }

    public static boolean F(Type type) {
        if (type instanceof Class) {
            return false;
        }
        if (type instanceof ParameterizedType) {
            for (Type type2 : ((ParameterizedType) type).getActualTypeArguments()) {
                if (F(type2)) {
                    return true;
                }
            }
            return false;
        }
        if (type instanceof GenericArrayType) {
            return F(((GenericArrayType) type).getGenericComponentType());
        }
        if ((type instanceof TypeVariable) || (type instanceof WildcardType)) {
            return true;
        }
        throw new IllegalArgumentException("Expected a Class, ParameterizedType, or GenericArrayType, but <" + type + "> is of type " + (type == null ? "null" : type.getClass().getName()));
    }

    public static final void G(View view) {
        l.f(view, "<this>");
        view.setVisibility(8);
    }

    public static long H(String str) {
        Log.i("TAG", "getName " + str);
        Matcher matcher = Pattern.compile("[0-9]+(?=[^0-9]*$)").matcher(str);
        if (!matcher.find()) {
            return 0L;
        }
        long j2 = Long.parseLong(matcher.group());
        StringBuilder sbB = d.b.a.a.a.B("bin文件名匹配结果：");
        sbB.append(matcher.group());
        Log.i("TAG", sbB.toString());
        return j2;
    }

    public static boolean I(int i2) {
        return i2 == 9 || i2 == 10 || i2 == 11 || i2 == 12 || i2 == 13 || i2 == 14 || i2 == 15 || i2 == 16 || i2 == 18 || i2 == 20 || i2 == 22;
    }

    public static boolean J(byte[] bArr) {
        boolean z;
        for (int i2 = 0; i2 < bArr.length; i2++) {
            long jC = c(Byte.valueOf(bArr[i2]));
            if (jC != 0 && jC != 255) {
                StringBuilder sbB = d.b.a.a.a.B("not null:");
                sbB.append(c(Byte.valueOf(bArr[i2])));
                Log.i("isEmptyByte", sbB.toString());
            } else if (c(Byte.valueOf(bArr[0])) != c(Byte.valueOf(bArr[i2]))) {
                Log.i("isEmptyByte", c(Byte.valueOf(bArr[0])) + " not equals :" + c(Byte.valueOf(bArr[i2])));
            }
            z = false;
        }
        z = true;
        Log.i("isEmptyByte", c(Byte.valueOf(bArr[0])) + " result :" + z);
        return z;
    }

    @SuppressLint({"NewApi"})
    public static boolean K() {
        try {
            if (f1811b == null) {
                return Trace.isEnabled();
            }
        } catch (NoClassDefFoundError | NoSuchMethodError unused) {
        }
        try {
            if (f1811b == null) {
                a = Trace.class.getField("TRACE_TAG_APP").getLong(null);
                f1811b = Trace.class.getMethod("isTagEnabled", Long.TYPE);
            }
            return ((Boolean) f1811b.invoke(null, Long.valueOf(a))).booleanValue();
        } catch (Exception e2) {
            if (!(e2 instanceof InvocationTargetException)) {
                Log.v("Trace", "Unable to call isTagEnabled via reflection", e2);
                return false;
            }
            Throwable cause = e2.getCause();
            if (cause instanceof RuntimeException) {
                throw ((RuntimeException) cause);
            }
            throw new RuntimeException(cause);
        }
    }

    public static boolean L(String str) {
        return str == null || str.trim().length() == 0;
    }

    public static void M(final View view, final long j2, final g.h0.b.l lVar, int i2) {
        if ((i2 & 1) != 0) {
            j2 = 500;
        }
        l.f(view, "<this>");
        l.f(lVar, "onclick");
        view.setOnClickListener(new View.OnClickListener() { // from class: d.f.a.r2.b
            @Override // android.view.View.OnClickListener
            public final void onClick(View view2) {
                View view3 = view;
                long j3 = j2;
                g.h0.b.l lVar2 = lVar;
                g.h0.c.l.f(view3, "$this_oneClick");
                g.h0.c.l.f(lVar2, "$onclick");
                Object tag = view3.getTag(R.id.button_click);
                Long l2 = tag instanceof Long ? (Long) tag : null;
                long jLongValue = l2 != null ? l2.longValue() : 0L;
                long jCurrentTimeMillis = System.currentTimeMillis();
                if (jCurrentTimeMillis - jLongValue > j3) {
                    g.h0.c.l.e(view2, "it");
                    lVar2.invoke(view2);
                    view3.setTag(R.id.button_click, Long.valueOf(jCurrentTimeMillis));
                }
            }
        });
    }

    public static void N(long j2) {
        i.B(j2, TimeUnit.MILLISECONDS).u(new g(""), f.a.w.b.a.f3727d, f.a.w.b.a.f3725b, f.a.w.b.a.f3726c);
    }

    public static void O(Closeable closeable) {
        if (closeable == null) {
            return;
        }
        try {
            closeable.close();
        } catch (Exception unused) {
            Log.e("CommonUtils", "An exception has occurred in CommonUtils.safeClose");
        }
    }

    public static void P(long j2) {
        try {
            Thread.sleep(j2);
        } catch (Exception unused) {
            Log.e("CommonUtils", "An exception has occurred in CommonUtils.safeSleep");
        }
    }

    public static boolean Q(String str) {
        HashMap map = new HashMap();
        map.put("value", str);
        e.a.c("/v1/system/data/DIANXIN_CTEI", map, new f());
        return true;
    }

    public static final void R(TextView textView, Progress progress) {
        l.f(textView, "<this>");
        l.f(progress, "progress");
        String progress2 = progress.getProgress();
        if (progress2 == null) {
            progress2 = "";
        }
        textView.setText(progress2);
        textView.setTextColor(DebugMenuApplication.f1956b.getResources().getColor(progress.getFinish() ? progress.getResult() ? R.color.green : R.color.red : R.color.white));
    }

    public static boolean S(String str) {
        HashMap map = new HashMap();
        map.put("value", str);
        e.a.c("/v1/system/data/YIDONG_CMEI", map, new f());
        return true;
    }

    public static final void T(View view) {
        l.f(view, "<this>");
        view.setVisibility(0);
    }

    public static void U(int i2, int i3, d.f.a.s1.e eVar, DialogInterface.OnCancelListener onCancelListener) {
        c.c().g(new ActivityEvent.ShowCenterDebugMenuDialog(i2, i3, eVar, onCancelListener));
    }

    public static void V(int i2, int i3, final d.f.a.s1.e eVar) {
        c.c().g(new ActivityEvent.ShowDebugMenuDialog(i2, i3, new d.f.a.s1.e() { // from class: d.f.a.r2.k
            @Override // d.f.a.s1.e
            public final void call() {
                d.f.a.s1.e eVar2 = eVar;
                if (eVar2 != null) {
                    eVar2.call();
                }
            }
        }));
    }

    public static void W(int i2, int i3, final d.f.a.s1.e eVar, final d.f.a.s1.e eVar2) {
        c.c().g(new ActivityEvent.ShowDebugMenuDialog(i2, i3, new d.f.a.s1.e() { // from class: d.f.a.r2.o
            @Override // d.f.a.s1.e
            public final void call() {
                d.f.a.s1.e eVar3 = eVar;
                if (eVar3 != null) {
                    eVar3.call();
                }
            }
        }, new DialogInterface.OnCancelListener() { // from class: d.f.a.r2.l
            @Override // android.content.DialogInterface.OnCancelListener
            public final void onCancel(DialogInterface dialogInterface) {
                d.f.a.s1.e eVar3 = eVar2;
                if (eVar3 != null) {
                    eVar3.call();
                }
            }
        }));
    }

    public static void X(int i2, int i3, final d.f.a.s1.f fVar) {
        c.c().g(new ActivityEvent.ShowDebugMenuDialog(i2, i3, new d.f.a.s1.f() { // from class: d.f.a.r2.m
            @Override // d.f.a.s1.f
            public final void a(String str) {
                d.f.a.s1.f fVar2 = fVar;
                if (fVar2 != null) {
                    fVar2.a(str);
                }
            }
        }));
    }

    public static void Y(String str, String str2) {
        c.c().g(new ActivityEvent.ShowUpgradeErrorDialog(str, str2));
    }

    public static void Z(boolean z) {
        d.b.a.a.a.Y(z, c.c());
    }

    public static void a(int i2) {
        c.c().g(new ActivityEvent.UpgradeDialogAddItem(i2));
    }

    public static void a0(int i2) {
        c.c().g(new ActivityEvent.ShowUpgradeDialog(i2));
    }

    public static long b(byte[] bArr) {
        long jC = 0;
        for (int i2 = 0; i2 < bArr.length && i2 < 8; i2++) {
            jC |= c(Byte.valueOf(bArr[i2])) << (i2 * 8);
        }
        return jC;
    }

    public static void b0(String str, Context context, boolean z) {
        Intent intent = new Intent(str);
        if (z) {
            intent.setFlags(268435456);
        }
        try {
            context.startActivity(intent);
        } catch (ActivityNotFoundException e2) {
            Log.e("IntentUtils", d.i.f.g.c.a(e2));
        }
    }

    public static long c(Byte b2) {
        return ((long) b2.byteValue()) & 255;
    }

    public static i c0(i iVar, Context context, com.trello.rxlifecycle3.android.ActivityEvent activityEvent, int i2) {
        com.trello.rxlifecycle3.android.ActivityEvent activityEvent2 = (i2 & 2) != 0 ? com.trello.rxlifecycle3.android.ActivityEvent.STOP : null;
        l.f(iVar, "<this>");
        l.f(context, "context");
        l.f(activityEvent2, "event");
        i iVarN = iVar.w(f.a.z.a.f4044c).n(f.a.s.b.a.a());
        if (!(context instanceof RxAppCompatActivity)) {
            l.e(iVarN, "observable");
            return iVarN;
        }
        i iVarG = iVarN.g(((RxAppCompatActivity) context).bindUntilEvent(activityEvent2));
        l.e(iVarG, "observable.compose(context.bindUntilEvent(event))");
        return iVarG;
    }

    public static String d(long j2) {
        if (j2 < RealWebSocket.DEFAULT_MINIMUM_DEFLATE_SIZE) {
            return p(j2) + " byte";
        }
        if (j2 < 1048576) {
            return p(j2 / RealWebSocket.DEFAULT_MINIMUM_DEFLATE_SIZE) + "KB";
        }
        if (j2 < 1073741824) {
            return p(j2 / 1048576) + "MB";
        }
        if (j2 < 1099511627776L) {
            return p(j2 / 1073741824) + "GB";
        }
        if (j2 < 1125899906842624L) {
            return p(j2 / 1099511627776L) + "TB";
        }
        if (j2 < 1152921504606846976L) {
            return p(j2 / 1125899906842624L) + "Pb";
        }
        return p(j2 / 1152921504606846976L) + " Eb";
    }

    public static void d0(int i2) {
        d.b.a.a.a.J(i2, c.c());
    }

    public static boolean e(Class<?> cls) {
        return (cls.isPrimitive() || cls == Byte.class || cls == Short.class || cls == Integer.class || cls == Long.class || cls == Float.class || cls == Double.class || cls == Boolean.class || cls == Character.class) || cls == String.class || cls == CharSequence.class;
    }

    public static void e0(String str) {
        c.c().g(new ActivityEvent.ShowToast(str));
    }

    public static boolean f(String str) {
        if (str == null) {
            return false;
        }
        for (char c2 : str.toCharArray()) {
            if (String.valueOf(c2).getBytes().length > 1) {
                return false;
            }
        }
        return str.length() >= 5;
    }

    public static void f0(int i2, boolean z) {
        c.c().g(new ActivityEvent.UpgradeDialogUpdateResult(i2, z));
    }

    public static int g(RecyclerView.v vVar, r rVar, View view, View view2, RecyclerView.m mVar, boolean z) {
        if (mVar.x() == 0 || vVar.b() == 0 || view == null || view2 == null) {
            return 0;
        }
        if (!z) {
            return Math.abs(mVar.L(view) - mVar.L(view2)) + 1;
        }
        return Math.min(rVar.l(), rVar.b(view2) - rVar.e(view));
    }

    public static <T> void g0(Class<T> cls) {
        if (!cls.isInterface()) {
            throw new IllegalArgumentException("API declarations must be interfaces.");
        }
        if (cls.getInterfaces().length > 0) {
            throw new IllegalArgumentException("API interfaces must not extend other interfaces.");
        }
    }

    public static int h(RecyclerView.v vVar, r rVar, View view, View view2, RecyclerView.m mVar, boolean z, boolean z2) {
        if (mVar.x() == 0 || vVar.b() == 0 || view == null || view2 == null) {
            return 0;
        }
        int iMax = z2 ? Math.max(0, (vVar.b() - Math.max(mVar.L(view), mVar.L(view2))) - 1) : Math.max(0, Math.min(mVar.L(view), mVar.L(view2)));
        if (z) {
            return Math.round((iMax * (Math.abs(rVar.b(view2) - rVar.e(view)) / (Math.abs(mVar.L(view) - mVar.L(view2)) + 1))) + (rVar.k() - rVar.e(view)));
        }
        return iMax;
    }

    public static byte[] h0(int i2) throws IOException {
        return new byte[]{(byte) (i2 & SheetSettings.DEFAULT_DEFAULT_ROW_HEIGHT), (byte) ((65280 & i2) >> 8), (byte) ((16711680 & i2) >> 16), (byte) ((i2 & (-16777216)) >> 24)};
    }

    public static int i(RecyclerView.v vVar, r rVar, View view, View view2, RecyclerView.m mVar, boolean z) {
        if (mVar.x() == 0 || vVar.b() == 0 || view == null || view2 == null) {
            return 0;
        }
        if (!z) {
            return vVar.b();
        }
        return (int) (((rVar.b(view2) - rVar.e(view)) / (Math.abs(mVar.L(view) - mVar.L(view2)) + 1)) * vVar.b());
    }

    public static byte[] i0(short s) throws IOException {
        return new byte[]{(byte) (s & 255), (byte) ((s & 65280) >> 8)};
    }

    public static String j(byte[] bArr) {
        int[] iArr = new int[6];
        if (bArr == null || bArr.length != 6) {
            return "00:00:00:00:00:00";
        }
        for (int i2 = 0; i2 < 6; i2++) {
            iArr[i2] = bArr[i2] & 255;
        }
        StringBuilder sb = new StringBuilder();
        for (int i3 = 0; i3 < 6; i3++) {
            if (iArr[i3] < 16) {
                StringBuilder sbB = d.b.a.a.a.B("0");
                sbB.append(Integer.toHexString(iArr[i3]));
                sbB.append(":");
                sb.append(sbB.toString());
            } else {
                sb.append(Integer.toHexString(iArr[i3]) + ":");
            }
        }
        return sb.substring(0, sb.length() - 1);
    }

    public static boolean k(InputStream inputStream, OutputStream outputStream) {
        try {
            byte[] bArr = new byte[1024];
            while (true) {
                int i2 = inputStream.read(bArr);
                if (i2 == -1) {
                    return true;
                }
                outputStream.write(bArr, 0, i2);
            }
        } catch (Exception unused) {
            Log.e("CommonUtils", "An exception has occurred in CommonUtils.copyStream");
            return false;
        }
    }

    public static final <T> f.a.t.b l(i<T> iVar, g.h0.b.l<? super s2<T>, a0> lVar) {
        l.f(iVar, "<this>");
        l.f(lVar, "block");
        s2 s2Var = new s2();
        lVar.invoke(s2Var);
        f.a.v.c<? super T> cVar = s2Var.a;
        if (cVar == null) {
            cVar = f.a.w.b.a.f3726c;
        }
        f.a.v.c<? super Throwable> cVar2 = s2Var.f3319b;
        if (cVar2 == null) {
            cVar2 = f.a.w.b.a.f3726c;
        }
        f.a.v.a aVar = s2Var.f3320c;
        if (aVar == null) {
            aVar = f.a.w.b.a.f3725b;
        }
        d dVar = new d(cVar, cVar2, aVar, f.a.w.b.a.f3726c);
        iVar.d(dVar);
        return dVar;
    }

    public static boolean m(String str) {
        String str2 = File.separator;
        if (!str.endsWith(str2)) {
            str = d.b.a.a.a.p(str, str2);
        }
        File file = new File(str);
        if (!file.exists() || !file.isDirectory()) {
            return false;
        }
        File[] fileArrListFiles = file.listFiles();
        boolean zM = true;
        for (int i2 = 0; i2 < fileArrListFiles.length; i2++) {
            if (fileArrListFiles[i2].isFile()) {
                zM = n(fileArrListFiles[i2].getAbsolutePath());
                if (!zM) {
                    break;
                }
            } else {
                zM = m(fileArrListFiles[i2].getAbsolutePath());
                if (!zM) {
                    break;
                }
            }
        }
        if (zM) {
            return file.delete();
        }
        return false;
    }

    public static boolean n(String str) {
        File file = new File(str);
        if (file.isFile() && file.exists()) {
            return file.delete();
        }
        return false;
    }

    public static void o() {
        d.b.a.a.a.X(c.c());
    }

    public static String p(double d2) {
        return d.b.a.a.a.s(new StringBuilder(), (int) Math.ceil(d2), "");
    }

    public static String q(long j2) {
        String str;
        float f2 = j2;
        if (f2 == 0.0f) {
            return "0MB";
        }
        if (f2 > 900.0f) {
            f2 /= 1024.0f;
            str = "KB";
        } else {
            str = "B";
        }
        if (f2 > 900.0f) {
            f2 /= 1024.0f;
            str = "MB";
        }
        if (f2 > 900.0f) {
            f2 /= 1024.0f;
            str = "GB";
        }
        if (f2 > 900.0f) {
            f2 /= 1024.0f;
            str = "TB";
        }
        if (f2 > 900.0f) {
            f2 /= 1024.0f;
            str = "PB";
        }
        if (f2 > 900.0f) {
            f2 /= 1024.0f;
            str = "EB";
        }
        return String.format("%s%s", f2 < 1.0f ? String.format(Locale.US, "%.2f", Float.valueOf(f2)) : String.format(Locale.US, "%.0f", Float.valueOf(f2)), str);
    }

    public static String r(byte[] bArr) {
        StringBuilder sb = new StringBuilder();
        for (byte b2 : bArr) {
            sb.append((char) b2);
        }
        return sb.toString();
    }

    public static long s() {
        if (f1812c == null) {
            f1812c = Integer.valueOf(VmanMiddleWare.getInstance().getDevcieCtrl().getDeviceList());
            StringBuilder sbB = d.b.a.a.a.B("firstDeviceList:");
            sbB.append(Integer.toBinaryString(f1812c.intValue()));
            Log.i("HardwareUtils", sbB.toString());
        }
        return f1812c.intValue();
    }

    public static String t() {
        ValueBody valueBody = (ValueBody) e.a.b("/v1/system/data/DIANXIN_CTEI", ValueBody.class);
        return valueBody == null ? "" : (String) valueBody.getValue();
    }

    public static UsbEndpoint u(UsbInterface usbInterface, int i2) {
        if (usbInterface == null) {
            return null;
        }
        for (int i3 = 0; i3 < usbInterface.getEndpointCount(); i3++) {
            UsbEndpoint endpoint = usbInterface.getEndpoint(i3);
            if (endpoint.getType() == 3 && endpoint.getDirection() == i2) {
                return endpoint;
            }
        }
        return null;
    }

    public static final String v(int i2) {
        String string = DebugMenuApplication.f1956b.getString(i2);
        l.e(string, "sApplication.getString(this)");
        return string;
    }

    public static String w(String str) {
        if (!str.startsWith("a0:b0:c0")) {
            return str;
        }
        return "<b><font color=#FF0000>" + str + "</b>";
    }

    public static String x() {
        return SDKConfigureHelper.I.getMachineSN();
    }

    public static Class<?> y(Type type) {
        Objects.requireNonNull(type, "type == null");
        if (type instanceof Class) {
            return (Class) type;
        }
        if (type instanceof ParameterizedType) {
            Type rawType = ((ParameterizedType) type).getRawType();
            if (rawType instanceof Class) {
                return (Class) rawType;
            }
            throw new IllegalArgumentException();
        }
        if (type instanceof GenericArrayType) {
            return Array.newInstance(y(((GenericArrayType) type).getGenericComponentType()), 0).getClass();
        }
        if (type instanceof TypeVariable) {
            return Object.class;
        }
        if (type instanceof WildcardType) {
            return y(((WildcardType) type).getUpperBounds()[0]);
        }
        throw new IllegalArgumentException("Expected a Class, ParameterizedType, or GenericArrayType, but <" + type + "> is of type " + type.getClass().getName());
    }

    public static long z() {
        if (f1813d == null) {
            f1813d = Integer.valueOf(VmanMiddleWare.getInstance().getDevcieCtrl().getSecondDeviceList());
            StringBuilder sbB = d.b.a.a.a.B("secondDeviceList:");
            sbB.append(Integer.toBinaryString(f1813d.intValue()));
            Log.i("HardwareUtils", sbB.toString());
        }
        return f1813d.intValue();
    }
}
