f.java 源代码


package o2;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import androidx.core.content.FileProvider;
import androidx.exifinterface.media.ExifInterface;
import com.blankj.utilcode.util.Utils;
import com.blankj.utilcode.util.i;
import com.mbridge.msdk.playercommon.exoplayer2.source.chunk.ChunkedTrackBlacklistUtil;
import com.umeng.analytics.pro.bx;
import com.x8zs.ds2.R;
import com.x8zs.model.ServerApi;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.channels.FileChannel;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.json.JSONArray;
import org.json.JSONException;

public class f {

    private static ServerApi.h0 f24613a;

    public static String A(Context context, String str) {
        try {
            return context.getPackageManager().getPackageInfo(str, 0).versionName;
        } catch (PackageManager.NameNotFoundException unused) {
            return "";
        }
    }

    public static synchronized ServerApi.h0 B(Context context) {
        ServerApi.h0 h0Var;
        String str;
        synchronized (f.class) {
            SharedPreferences sharedPreferences = context.getSharedPreferences("uuid", 0);
            String string = sharedPreferences.getString("uuid", "");
            if (TextUtils.isEmpty(string)) {
                string = UUID.randomUUID().toString();
                sharedPreferences.edit().putString("uuid", string).commit();
            }
            if (f24613a == null) {
                ServerApi.h0 h0Var2 = new ServerApi.h0();
                f24613a = h0Var2;
                h0Var2.f21626a = string;
                h0Var2.f21627b = "Android " + Build.VERSION.RELEASE + " " + Build.DISPLAY + " " + Build.VERSION.SDK_INT;
                f24613a.f21628c = Build.BRAND;
                f24613a.f21629d = Build.MODEL;
                f24613a.f21630e = Build.FINGERPRINT;
                f24613a.f21631f = C();
                f24613a.f21632g = K(context);
                f24613a.f21633h = L(context);
                ServerApi.h0 h0Var3 = f24613a;
                if (Q()) {
                    str = "64";
                } else {
                    str = "32";
                }
                h0Var3.f21634i = str;
                f24613a.f21639n = com.x8zs.app.a.b().f21547a;
                try {
                    f24613a.f21635j = i.b();
                    f24613a.f21636k = i.c();
                    f24613a.f21638m = i.a();
                    f24613a.f21637l = com.blankj.utilcode.util.b.b();
                } catch (Throwable th) {
                    th.printStackTrace();
                    ServerApi.h0 h0Var4 = f24613a;
                    h0Var4.f21635j = "";
                    h0Var4.f21636k = "";
                    h0Var4.f21638m = "";
                    h0Var4.f21637l = "";
                }
            }
            h0Var = f24613a;
        }
        return h0Var;
    }

    public static String C() {
        BufferedReader bufferedReader;
        Throwable th;
        FileReader fileReader;
        String readLine;
        try {
            fileReader = new FileReader("/proc/cpuinfo");
            try {
                bufferedReader = new BufferedReader(fileReader);
            } catch (Throwable th2) {
                bufferedReader = null;
                th = th2;
            }
        } catch (Throwable th3) {
            bufferedReader = null;
            th = th3;
            fileReader = null;
        }
        do {
            try {
                readLine = bufferedReader.readLine();
            } catch (Throwable th4) {
                th = th4;
                try {
                    th.printStackTrace();
                    c(bufferedReader);
                    c(fileReader);
                    return "";
                } finally {
                    c(bufferedReader);
                    c(fileReader);
                }
            }
            if (readLine == null) {
                bufferedReader.close();
                c(bufferedReader);
                c(fileReader);
                return "";
            }
        } while (!readLine.contains("Hardware"));
        return readLine.split(":")[1];
    }

    public static String D(String str) {
        try {
            return M(MessageDigest.getInstance("MD5").digest(str.getBytes()));
        } catch (Throwable th) {
            th.printStackTrace();
            return "";
        }
    }

    public static String E(byte[] bArr) {
        try {
            return M(MessageDigest.getInstance("MD5").digest(bArr));
        } catch (Throwable th) {
            th.printStackTrace();
            return "";
        }
    }

    public static double F(double d6) {
        return Math.round(d6 * 100.0d) / 100.0d;
    }

    public static long G() {
        try {
            StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
            return statFs.getAvailableBlocks() * statFs.getBlockSize();
        } catch (Throwable th) {
            th.printStackTrace();
            return -1L;
        }
    }

    public static int H() {
        WindowManager windowManager = (WindowManager) Utils.c().getSystemService("window");
        if (windowManager == null) {
            return -1;
        }
        Point point = new Point();
        windowManager.getDefaultDisplay().getRealSize(point);
        return point.x;
    }

    public static String I(String str) {
        Random random = new Random(System.currentTimeMillis());
        StringBuilder sb = new StringBuilder("com.x8zs.");
        for (int i6 = 0; i6 < 4; i6++) {
            sb.append((char) (random.nextInt(26) + 97));
        }
        return sb.toString();
    }

    public static String J(String str, String str2) {
        try {
            return (String) Class.forName("android.os.SystemProperties").getMethod("get", String.class, String.class).invoke(null, str, str2);
        } catch (Exception e6) {
            e6.printStackTrace();
            return str2;
        }
    }

    public static String K(Context context) {
        try {
            return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode + "";
        } catch (PackageManager.NameNotFoundException e6) {
            e6.printStackTrace();
            return "";
        }
    }

    public static String L(Context context) {
        try {
            return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException e6) {
            e6.printStackTrace();
            return "";
        }
    }

    public static String M(byte[] bArr) {
        char[] cArr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
        char[] cArr2 = new char[bArr.length * 2];
        for (int i6 = 0; i6 < bArr.length; i6++) {
            byte b6 = bArr[i6];
            int i7 = i6 * 2;
            cArr2[i7] = cArr[(b6 >> 4) & 15];
            cArr2[i7 + 1] = cArr[b6 & bx.f20591m];
        }
        return new String(cArr2);
    }

    public static void N(Context context, View view) {
        ((InputMethodManager) context.getSystemService("input_method")).hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    public static boolean O(Activity activity) {
        if (activity == null || activity.isFinishing() || activity.isDestroyed()) {
            return true;
        }
        return false;
    }

    public static boolean P(PackageInfo packageInfo) {
        if (!"com.x8zs.shell.ProxyApplication".equals(packageInfo.applicationInfo.className) && !"com.x8zs.sandbox.app.SandboxApplication".equals(packageInfo.applicationInfo.className)) {
            return "08C424D49777D5A45AFB89A06DA6F798".equals(w(packageInfo));
        }
        return true;
    }

    private static boolean Q() {
        FileInputStream fileInputStream;
        BufferedReader bufferedReader;
        File file = new File("/proc/cpuinfo");
        if (file.exists()) {
            BufferedReader bufferedReader2 = null;
            try {
                fileInputStream = new FileInputStream(file);
                try {
                    bufferedReader = new BufferedReader(new InputStreamReader(fileInputStream), 512);
                } catch (Throwable unused) {
                }
                try {
                    String readLine = bufferedReader.readLine();
                    if (readLine != null && readLine.length() > 0) {
                        if (readLine.toLowerCase(Locale.US).contains("arch64")) {
                            try {
                                bufferedReader.close();
                            } catch (Exception e6) {
                                e6.printStackTrace();
                            }
                            try {
                                fileInputStream.close();
                                return true;
                            } catch (Exception e7) {
                                e7.printStackTrace();
                                return true;
                            }
                        }
                    }
                    try {
                        bufferedReader.close();
                    } catch (Exception e8) {
                        e8.printStackTrace();
                    }
                    try {
                        fileInputStream.close();
                    } catch (Exception e9) {
                        e9.printStackTrace();
                    }
                    return false;
                } catch (Throwable unused2) {
                    bufferedReader2 = bufferedReader;
                    if (bufferedReader2 != null) {
                        try {
                            bufferedReader2.close();
                        } catch (Exception e10) {
                            e10.printStackTrace();
                        }
                    }
                    if (fileInputStream != null) {
                        try {
                            fileInputStream.close();
                        } catch (Exception e11) {
                            e11.printStackTrace();
                        }
                    }
                    return false;
                }
            } catch (Throwable unused3) {
                fileInputStream = null;
            }
        }
        return false;
    }

    public static boolean R(Context context) {
        try {
            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService("phone");
            String networkCountryIso = telephonyManager.getNetworkCountryIso();
            String simCountryIso = telephonyManager.getSimCountryIso();
            if (!TextUtils.isEmpty(networkCountryIso) || !TextUtils.isEmpty(simCountryIso)) {
                if (!"cn".equalsIgnoreCase(networkCountryIso)) {
                    if (!"cn".equalsIgnoreCase(simCountryIso)) {
                        return false;
                    }
                }
                return true;
            }
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return "cn".equalsIgnoreCase(Locale.getDefault().getCountry());
    }

    public static boolean S(String str) {
        return Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$").matcher(str).matches();
    }

    public static boolean T(List<?> list) {
        if (list != null && list.size() != 0) {
            return false;
        }
        return true;
    }

    public static boolean U(List<?> list, List<?> list2) {
        if (list == null) {
            if (list2 == null) {
                return true;
            }
            return false;
        }
        if (list2 == null || list.size() != list2.size()) {
            return false;
        }
        int size = list.size();
        for (int i6 = 0; i6 < size; i6++) {
            Object obj = list.get(i6);
            Object obj2 = list2.get(i6);
            if (obj != null || obj2 != null) {
                if (obj == null && obj2 != null) {
                    return false;
                }
                if ((obj != null && obj2 == null) || !obj.equals(obj2)) {
                    return false;
                }
            }
        }
        return true;
    }

    public static boolean V(Context context, String str) {
        try {
            context.getPackageManager().getPackageInfo(str, 0);
            return true;
        } catch (Throwable unused) {
            return false;
        }
    }

    public static boolean W(Context context) {
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
            if (Math.abs(packageInfo.firstInstallTime - packageInfo.lastUpdateTime) <= ChunkedTrackBlacklistUtil.DEFAULT_TRACK_BLACKLIST_MS) {
                return false;
            }
            return true;
        } catch (Exception e6) {
            e6.printStackTrace();
            return false;
        }
    }

    public static boolean X(Context context) {
        NetworkInfo activeNetworkInfo;
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService("connectivity");
        if (connectivityManager == null || (activeNetworkInfo = connectivityManager.getActiveNetworkInfo()) == null || activeNetworkInfo.getType() != 1) {
            return false;
        }
        return true;
    }

    public static String Y(List<String> list, String str) {
        StringBuilder sb = new StringBuilder();
        for (int i6 = 0; i6 < list.size(); i6++) {
            sb.append(list.get(i6));
            if (i6 != list.size() - 1) {
                sb.append(str);
            }
        }
        return sb.toString();
    }

    public static boolean Z(Context context) {
        Intent intent = new Intent();
        intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3DuBu4kcrLUHUdPw-hIiCbWSeDb8HMQ2s4"));
        try {
            if (!(context instanceof Activity)) {
                intent.addFlags(268435456);
            }
            context.startActivity(intent);
            return true;
        } catch (Throwable unused) {
            e.a(context, R.string.no_qq_installed, 0);
            return false;
        }
    }

    public static String a(File file) {
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            FileInputStream fileInputStream = new FileInputStream(file);
            byte[] bArr = new byte[8192];
            while (true) {
                try {
                    try {
                        int read = fileInputStream.read(bArr);
                        if (read <= 0) {
                            break;
                        }
                        messageDigest.update(bArr, 0, read);
                    } catch (IOException e6) {
                        throw new RuntimeException("Unable to process file for MD5", e6);
                    }
                } catch (Throwable th) {
                    try {
                        fileInputStream.close();
                    } catch (IOException unused) {
                    }
                    throw th;
                }
            }
            String replace = String.format("%32s", new BigInteger(1, messageDigest.digest()).toString(16)).replace(' ', '0');
            try {
                fileInputStream.close();
            } catch (IOException unused2) {
            }
            return replace;
        } catch (FileNotFoundException | NoSuchAlgorithmException unused3) {
            return null;
        }
    }

    public static void a0(JSONArray jSONArray, List<String> list) throws JSONException {
        if (jSONArray == null) {
            return;
        }
        for (int i6 = 0; i6 < jSONArray.length(); i6++) {
            list.add(jSONArray.getString(i6));
        }
    }

    public static boolean b() {
        String J = J("ro.dalvik.vm.native.bridge", "0");
        if ((!TextUtils.isEmpty(J) && J.startsWith("libnb")) || new File("/data/dalvik-cache/x86/system@framework@boot.oat").exists()) {
            return true;
        }
        return new File("/x8").exists();
    }

    public static void b0(List<String> list, JSONArray jSONArray) throws JSONException {
        if (T(list)) {
            return;
        }
        for (int i6 = 0; i6 < list.size(); i6++) {
            jSONArray.put(i6, list.get(i6));
        }
    }

    public static void c(Closeable closeable) {
        if (closeable != null) {
            try {
                closeable.close();
            } catch (Throwable unused) {
            }
        }
    }

    public static byte[] c0(String str) throws IOException {
        FileInputStream fileInputStream = null;
        try {
            FileInputStream fileInputStream2 = new FileInputStream(str);
            try {
                byte[] bArr = new byte[1024];
                ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                while (true) {
                    int read = fileInputStream2.read(bArr);
                    if (read != -1) {
                        byteArrayOutputStream.write(bArr, 0, read);
                    } else {
                        byte[] byteArray = byteArrayOutputStream.toByteArray();
                        c(fileInputStream2);
                        return byteArray;
                    }
                }
            } catch (Throwable th) {
                th = th;
                fileInputStream = fileInputStream2;
                c(fileInputStream);
                throw th;
            }
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public static int d(Throwable th) {
        if (th instanceof UnknownHostException) {
            return 2;
        }
        String message = th.getMessage();
        if (TextUtils.isEmpty(message)) {
            return 255;
        }
        if (message.contains("open failed: EACCES (Permission denied)")) {
            return 7;
        }
        if (message.contains("No space left on device")) {
            return 8;
        }
        if (!message.contains("open failed: EBUSY (Device or resource busy)")) {
            return 255;
        }
        return 10;
    }

    public static byte[] d0(InputStream inputStream, boolean z6) throws IOException {
        try {
            byte[] bArr = new byte[1024];
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            while (true) {
                int read = inputStream.read(bArr);
                if (read == -1) {
                    break;
                }
                byteArrayOutputStream.write(bArr, 0, read);
            }
            return byteArrayOutputStream.toByteArray();
        } finally {
            if (z6) {
                c(inputStream);
            }
        }
    }

    public static float e(String str) {
        if (TextUtils.isEmpty(str)) {
            return 0.0f;
        }
        String upperCase = str.toUpperCase();
        if (!upperCase.endsWith("GB") && !upperCase.endsWith("G")) {
            if (!upperCase.endsWith("MB") && !upperCase.endsWith("M")) {
                if (!upperCase.endsWith("KB") && !upperCase.endsWith("K")) {
                    if (upperCase.endsWith("B")) {
                        return Float.parseFloat(upperCase.replace("B", ""));
                    }
                    return Float.parseFloat(upperCase);
                }
                return Float.parseFloat(upperCase.replace("KB", "").replace("K", "")) * 1024.0f;
            }
            return Float.parseFloat(upperCase.replace("MB", "").replace("M", "")) * 1024.0f * 1024.0f;
        }
        return Float.parseFloat(upperCase.replace("GB", "").replace("G", "")) * 1024.0f * 1024.0f * 1024.0f;
    }

    public static void e0(Context context, String str) {
        try {
            context.startActivity(context.getPackageManager().getLaunchIntentForPackage(str));
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static boolean f(File file, File file2) {
        FileOutputStream fileOutputStream;
        FileInputStream fileInputStream = null;
        try {
            FileInputStream fileInputStream2 = new FileInputStream(file);
            try {
                File file3 = new File(file2.getAbsolutePath() + ".tmp");
                fileOutputStream = new FileOutputStream(file3);
                try {
                    FileChannel channel = fileInputStream2.getChannel();
                    FileChannel channel2 = fileOutputStream.getChannel();
                    long size = channel.size();
                    long j6 = 0;
                    while (size > 0) {
                        long transferTo = channel.transferTo(j6, size, channel2);
                        j6 += transferTo;
                        size -= transferTo;
                    }
                    if (channel2.size() != channel.size()) {
                        Log.e("Utils", "[copy] size not match");
                    } else if (!file3.renameTo(file2)) {
                        Log.e("Utils", "[copy] rename failed");
                    } else {
                        c(fileInputStream2);
                        c(fileOutputStream);
                        return true;
                    }
                    c(fileInputStream2);
                } catch (Exception e6) {
                    e = e6;
                    fileInputStream = fileInputStream2;
                    try {
                        e.printStackTrace();
                        c(fileInputStream);
                        c(fileOutputStream);
                        return false;
                    } catch (Throwable th) {
                        th = th;
                        c(fileInputStream);
                        c(fileOutputStream);
                        throw th;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    fileInputStream = fileInputStream2;
                    c(fileInputStream);
                    c(fileOutputStream);
                    throw th;
                }
            } catch (Exception e7) {
                e = e7;
                fileOutputStream = null;
            } catch (Throwable th3) {
                th = th3;
                fileOutputStream = null;
            }
        } catch (Exception e8) {
            e = e8;
            fileOutputStream = null;
        } catch (Throwable th4) {
            th = th4;
            fileOutputStream = null;
        }
        c(fileOutputStream);
        return false;
    }

    public static void f0(Activity activity, int i6) {
        try {
            Intent intent = new Intent();
            intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
            intent.addCategory("android.intent.category.DEFAULT");
            intent.setData(Uri.parse("package:" + activity.getPackageName()));
            intent.addFlags(268435456);
            intent.addFlags(1073741824);
            intent.addFlags(8388608);
            activity.startActivityForResult(intent, i6);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static void g(File file, File file2) throws IOException {
        if (file.isDirectory()) {
            h(file, file2);
        } else {
            i(file, file2);
        }
    }

    public static boolean g0(Activity activity, String str, int i6) {
        try {
            if (Build.VERSION.SDK_INT >= 24) {
                Intent intent = new Intent("android.intent.action.VIEW");
                intent.setDataAndType(FileProvider.getUriForFile(activity, activity.getPackageName() + ".fileprovider", new File(str)), "application/vnd.android.package-archive");
                intent.addFlags(1);
                activity.startActivityForResult(intent, i6);
            } else {
                Intent intent2 = new Intent("android.intent.action.VIEW");
                intent2.setDataAndType(Uri.fromFile(new File(str)), "application/vnd.android.package-archive");
                activity.startActivityForResult(intent2, i6);
            }
            return true;
        } catch (Throwable th) {
            th.printStackTrace();
            return false;
        }
    }

    public static void h(File file, File file2) throws IOException {
        if (!file2.exists()) {
            file2.mkdir();
        }
        for (String str : file.list()) {
            g(new File(file, str), new File(file2, str));
        }
    }

    public static void h0(Activity activity, int i6) {
        try {
            Intent intent = new Intent("android.settings.INTERNAL_STORAGE_SETTINGS");
            activity.startActivity(intent);
            activity.startActivityForResult(intent, i6);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    private static void i(File file, File file2) throws IOException {
        f(file, file2);
    }

    public static void i0(Activity activity, String str, int i6) {
        try {
            activity.startActivityForResult(new Intent("android.intent.action.DELETE", Uri.parse("package:" + str)), i6);
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static void j(String str) {
        if (str != null) {
            File file = new File(str);
            if (file.exists()) {
                file.delete();
            }
        }
    }

    public static byte[] j0(String str) {
        byte[] bArr = null;
        try {
            FileInputStream fileInputStream = new FileInputStream(str);
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            byte[] bArr2 = new byte[8192];
            while (true) {
                int read = fileInputStream.read(bArr2);
                if (read != -1) {
                    byteArrayOutputStream.write(bArr2, 0, read);
                } else {
                    bArr = byteArrayOutputStream.toByteArray();
                    fileInputStream.close();
                    return bArr;
                }
            }
        } catch (IOException e6) {
            e6.printStackTrace();
            return bArr;
        }
    }

    public static boolean k(File file) {
        if (!file.exists()) {
            return false;
        }
        if (file.isFile()) {
            return file.delete();
        }
        for (File file2 : file.listFiles()) {
            k(file2);
        }
        return file.delete();
    }

    public static int k0(File file) {
        if (file.isDirectory()) {
            File[] listFiles = file.listFiles();
            if (listFiles.length == 0) {
                if (file.delete()) {
                    return 1;
                }
            } else if (listFiles.length > 0) {
                int i6 = 0;
                do {
                    File[] listFiles2 = file.listFiles();
                    File file2 = file;
                    do {
                        int length = listFiles2.length;
                        int i7 = 0;
                        while (true) {
                            if (i7 >= length) {
                                break;
                            }
                            File file3 = listFiles2[i7];
                            if (file3.isDirectory()) {
                                listFiles2 = file3.listFiles();
                                file2 = file3;
                                break;
                            }
                            if (!file3.delete()) {
                                break;
                            }
                            i6++;
                            i7++;
                        }
                    } while (!file2.delete());
                    i6++;
                    if (!file.exists()) {
                        return i6;
                    }
                } while (file.exists());
            }
            return 0;
        }
        return -1;
    }

    public static float l(Context context, float f6) {
        return context.getResources().getDisplayMetrics().density * f6;
    }

    public static Uri l0(Context context, int i6) {
        return Uri.parse("android.resource://" + context.getPackageName() + "/" + i6);
    }

    public static boolean m(String str, String str2) {
        try {
            Class<?> cls = Class.forName("android.content.res.AssetManager");
            Object newInstance = cls.getConstructor(null).newInstance(null);
            cls.getDeclaredMethod("addAssetPath", String.class).invoke(newInstance, str);
            c(((AssetManager) newInstance).open(str2));
            return true;
        } catch (Throwable unused) {
            return false;
        }
    }

    public static boolean m0(File file, Bitmap bitmap) {
        FileOutputStream fileOutputStream;
        FileOutputStream fileOutputStream2 = null;
        try {
            try {
                fileOutputStream = new FileOutputStream(file);
            } catch (Exception e6) {
                e = e6;
            }
        } catch (Throwable th) {
            th = th;
        }
        try {
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutputStream);
            c(fileOutputStream);
            return true;
        } catch (Exception e7) {
            e = e7;
            fileOutputStream2 = fileOutputStream;
            e.printStackTrace();
            c(fileOutputStream2);
            return false;
        } catch (Throwable th2) {
            th = th2;
            fileOutputStream2 = fileOutputStream;
            c(fileOutputStream2);
            throw th;
        }
    }

    public static boolean n(String str, String str2, String str3) throws IOException {
        HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
        if (httpURLConnection.getResponseCode() != 200) {
            return false;
        }
        httpURLConnection.getHeaderField("Content-Disposition");
        httpURLConnection.getContentType();
        httpURLConnection.getContentLength();
        InputStream inputStream = httpURLConnection.getInputStream();
        String str4 = str2 + ".tmp";
        FileOutputStream fileOutputStream = new FileOutputStream(str4);
        byte[] bArr = new byte[4096];
        while (true) {
            int read = inputStream.read(bArr);
            if (read == -1) {
                break;
            }
            fileOutputStream.write(bArr, 0, read);
        }
        fileOutputStream.close();
        inputStream.close();
        httpURLConnection.disconnect();
        File file = new File(str4);
        if (!TextUtils.isEmpty(str3) && !str3.equalsIgnoreCase(a(file))) {
            file.delete();
            return false;
        }
        return file.renameTo(new File(str2));
    }

    public static void n0(String str, byte[] bArr) throws IOException {
        FileOutputStream fileOutputStream;
        FileOutputStream fileOutputStream2 = null;
        try {
            fileOutputStream = new FileOutputStream(str);
        } catch (Throwable th) {
            th = th;
        }
        try {
            fileOutputStream.write(bArr);
            c(fileOutputStream);
        } catch (Throwable th2) {
            th = th2;
            fileOutputStream2 = fileOutputStream;
            c(fileOutputStream2);
            throw th;
        }
    }

    public static void o() {
        try {
            Method declaredMethod = Class.class.getDeclaredMethod("forName", String.class);
            Method declaredMethod2 = Class.class.getDeclaredMethod("getDeclaredMethod", String.class, Class[].class);
            Class cls = (Class) declaredMethod.invoke(null, "dalvik.system.VMRuntime");
            ((Method) declaredMethod2.invoke(cls, "setHiddenApiExemptions", new Class[]{String[].class})).invoke(((Method) declaredMethod2.invoke(cls, "getRuntime", null)).invoke(null, new Object[0]), new String[]{"L"});
        } catch (Throwable th) {
            Log.e("[error]", "reflect bootstrap failed:", th);
        }
    }

    public static void o0(Context context, View view) {
        ((InputMethodManager) context.getSystemService("input_method")).showSoftInput(view, 2);
    }

    public static void p(Activity activity) {
        String str;
        try {
            if (activity.getPackageManager().getPackageInfo("com.facebook.katana", 0).versionCode >= 3002850) {
                str = "fb://facewebmodal/f?href=https://www.facebook.com/x8speeder";
            } else {
                str = "fb://page/415580488848418";
            }
        } catch (Throwable unused) {
            str = "https://www.facebook.com/x8speeder";
        }
        try {
            activity.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
        } catch (Throwable th) {
            th.printStackTrace();
        }
    }

    public static List<String> p0(String str, String str2) {
        if (TextUtils.isEmpty(str)) {
            return new ArrayList();
        }
        return Arrays.asList(str.split(str2));
    }

    public static String q(long j6) {
        if (j6 == 0) {
            return "0B";
        }
        String[] strArr = {"B", "K", "M", "G", ExifInterface.GPS_DIRECTION_TRUE, "P", ExifInterface.LONGITUDE_EAST, "Z", "Y"};
        double d6 = j6;
        double d7 = 1024;
        int floor = (int) Math.floor(Math.log(d6) / Math.log(d7));
        return String.format("%.2f%s", Double.valueOf(d6 / Math.pow(d7, floor)), strArr[floor]);
    }

    public static byte[] q0(Serializable serializable) {
        if (serializable == null) {
            return null;
        }
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        try {
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            objectOutputStream.writeObject(serializable);
            objectOutputStream.flush();
            return byteArrayOutputStream.toByteArray();
        } catch (IOException e6) {
            e6.printStackTrace();
            return null;
        } finally {
            c(byteArrayOutputStream);
        }
    }

    public static Serializable r(byte[] bArr) {
        ByteArrayInputStream byteArrayInputStream;
        ByteArrayInputStream byteArrayInputStream2 = null;
        try {
            byteArrayInputStream = new ByteArrayInputStream(bArr);
            try {
                Serializable serializable = (Serializable) new ObjectInputStream(byteArrayInputStream).readObject();
                c(byteArrayInputStream);
                return serializable;
            } catch (Exception unused) {
                c(byteArrayInputStream);
                return null;
            } catch (Throwable th) {
                th = th;
                byteArrayInputStream2 = byteArrayInputStream;
                c(byteArrayInputStream2);
                throw th;
            }
        } catch (Exception unused2) {
            byteArrayInputStream = null;
        } catch (Throwable th2) {
            th = th2;
        }
    }

    public static boolean r0(String str, String str2) {
        try {
            ZipInputStream zipInputStream = new ZipInputStream(new BufferedInputStream(new FileInputStream(str2)));
            byte[] bArr = new byte[1024];
            while (true) {
                ZipEntry nextEntry = zipInputStream.getNextEntry();
                if (nextEntry != null) {
                    String name = nextEntry.getName();
                    File file = new File(str + name);
                    if (nextEntry.isDirectory()) {
                        file.mkdirs();
                    } else {
                        file.getParentFile().mkdirs();
                        FileOutputStream fileOutputStream = new FileOutputStream(str + name);
                        while (true) {
                            int read = zipInputStream.read(bArr);
                            if (read == -1) {
                                break;
                            }
                            fileOutputStream.write(bArr, 0, read);
                        }
                        fileOutputStream.close();
                        zipInputStream.closeEntry();
                    }
                } else {
                    zipInputStream.close();
                    return true;
                }
            }
        } catch (IOException e6) {
            e6.printStackTrace();
            return false;
        }
    }

    public static String s(Context context, String str) {
        PackageInfo packageArchiveInfo = context.getPackageManager().getPackageArchiveInfo(str, 0);
        if (packageArchiveInfo != null) {
            return packageArchiveInfo.packageName;
        }
        return "";
    }

    public static void s0(String str, byte[] bArr) {
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(str);
            fileOutputStream.write(bArr);
            fileOutputStream.close();
        } catch (IOException e6) {
            e6.printStackTrace();
        }
    }

    public static PackageInfo t(Context context, String str) {
        PackageInfo packageArchiveInfo = context.getPackageManager().getPackageArchiveInfo(str, 0);
        if (packageArchiveInfo != null) {
            return packageArchiveInfo;
        }
        return null;
    }

    private static Resources u(Context context, String str) {
        try {
            Class<?> cls = Class.forName("android.content.res.AssetManager");
            Object newInstance = cls.getConstructor(null).newInstance(null);
            cls.getDeclaredMethod("addAssetPath", String.class).invoke(newInstance, str);
            Resources resources = context.getResources();
            return new Resources((AssetManager) newInstance, resources.getDisplayMetrics(), resources.getConfiguration());
        } catch (Throwable unused) {
            return null;
        }
    }

    public static String v(Context context, String str) {
        try {
            return w(context.getPackageManager().getPackageInfo(str, 64));
        } catch (Throwable th) {
            th.printStackTrace();
            return "";
        }
    }

    public static String w(PackageInfo packageInfo) {
        try {
            return M(MessageDigest.getInstance("MD5").digest(packageInfo.signatures[0].toByteArray()));
        } catch (Throwable th) {
            th.printStackTrace();
            return "";
        }
    }

    public static Drawable x(Context context, ApplicationInfo applicationInfo, String str) {
        Bitmap decodeResource;
        Resources u6 = u(context, str);
        if (u6 != null && (decodeResource = BitmapFactory.decodeResource(u6, applicationInfo.icon)) != null) {
            return new BitmapDrawable(decodeResource);
        }
        try {
            PackageManager packageManager = context.getPackageManager();
            applicationInfo.sourceDir = str;
            applicationInfo.publicSourceDir = str;
            return applicationInfo.loadIcon(packageManager);
        } catch (Exception unused) {
            return null;
        }
    }

    public static String y(Context context, ApplicationInfo applicationInfo, String str) {
        PackageManager packageManager = context.getPackageManager();
        try {
            applicationInfo.sourceDir = str;
            applicationInfo.publicSourceDir = str;
            return (String) packageManager.getApplicationLabel(applicationInfo);
        } catch (Exception unused) {
            return "Unknown";
        }
    }

    public static long z(Context context, String str) {
        try {
            return new File(context.getPackageManager().getPackageInfo(str, 0).applicationInfo.sourceDir).length();
        } catch (Throwable unused) {
            return 0L;
        }
    }
}