apk(点击下载) / a.java


package com.vdog;

import android.content.Context;
import android.os.Build;
import com.android.app.utils.d;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarFile;

public class a {
    public static String a = null;

    public static void a(Context context) {
        try {
            Defines.context = context;
            a = context.getApplicationInfo().dataDir + "/";
            a(a + Defines.XDATA);
            a(a + Defines.YDATA);
            a(a + Defines.MDATA);
            String soName = b(Defines.SO_ARM);
            String soPath = a + Defines.XDATA + Defines.SO_ARM;
            String soSqliteName = b(Defines.SO_SQLITE_ARM);
            String soSqilitePath = a + Defines.XDATA + Defines.SO_SQLITE_ARM;
            String soNmgName = b(Defines.SO_NMG_ARM);
            String soNmgPath = a + Defines.XDATA + Defines.SO_NMG_ARM;
            String _main_data = a + Defines.XDATA + Defines.MAIN_DATA;
            String _data_rc = a + Defines.XDATA + Defines.DATARC;
            String _res_data = a + Defines.XDATA + Defines.RES_DATA;
            String _cert0 = a + Defines.XDATA + Defines.CERT0;
            String _enc_mf = a + Defines.MDATA + Defines.ENC_MF;
            String tablePath = a + Defines.XDATA + Defines.TABLE;
            String screenTable = a + Defines.XDATA + Defines.SCREEN_TABLE;
            if (b(context) || !new File(soPath).exists() || !new File(a + Defines.XDATA, "classes.dex").exists()) {
                c(a + Defines.XDATA);
                c(a + Defines.YDATA);
                c(a + Defines.MDATA);
                a(_main_data, "main000/main.data", context);
                a(_data_rc, "main000/datarc", context);
                a(_res_data, "main000/res.data", context);
                a(_cert0, "main000/cert0", context);
                a(_enc_mf, "meta-inf/enc.mf", context);
                a(tablePath, context);
                a(screenTable, "main000/scrtable.dat", context);
                a(soPath, Defines.SUB_ASSETS + soName.substring(0, soName.length() - 3), context);
                a(soSqilitePath, Defines.SUB_ASSETS + soSqliteName.substring(0, soSqliteName.length() - 3), context);
                a(soNmgPath, Defines.SUB_ASSETS + soNmgName.substring(0, soNmgName.length() - 3), context);
                a(context, a + Defines.XDATA);
                c(context);
            }
            try {
                System.loadLibrary(Defines.SO_ARM.substring(3, Defines.SO_ARM.length() - 3));
            } catch (Throwable th) {
                System.load(soPath);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void a(String dir) {
        File file = new File(dir);
        if (!file.exists()) {
            file.mkdir();
        }
    }

    public static List<File> a(Context context, String dir) {
        List<File> files = new ArrayList<>();
        JarFile jarFile = new JarFile(context.getApplicationInfo().publicSourceDir);
        int count = 1;
        while (true) {
            String num = count == 1 ? "" : Integer.toString(count);
            String assetsDex = "main000/classes" + num + Defines._DEX;
            String path = dir + ("classes" + num + Defines._DEX);
            if (jarFile.getEntry("assets/" + assetsDex) != null) {
                a(path, assetsDex, context);
                files.add(new File(path));
                count++;
            } else {
                jarFile.close();
                return files;
            }
        }
    }

    public static boolean b(Context context) {
        if (d.a(new File(context.getApplicationInfo().sourceDir)) != context.getSharedPreferences("update", 0).getLong("crc", 0)) {
            return true;
        }
        return false;
    }

    private static boolean c(Context context) {
        context.getSharedPreferences("update", 0).edit().putLong("crc", d.a(new File(context.getApplicationInfo().sourceDir))).commit();
        return false;
    }

    private static void c(String dir) {
        File[] files = new File(dir).listFiles();
        if (files != null) {
            for (File f : files) {
                f.delete();
            }
        }
    }

    private static void a(String output, Context context) {
        String[] split = a().split(";");
        int length = split.length;
        for (int i = 0; i < length; i++) {
            a(output, Defines.SUB_ASSETS + split[i], context);
        }
    }

    private static void a(String output, String input, Context context) {
        try {
            InputStream inputStream = context.getAssets().open(input);
            File localFile = new File(output);
            byte[] bytes = new byte[65536];
            BufferedInputStream bufferedInput = new BufferedInputStream(inputStream);
            BufferedOutputStream bufferedOutput = new BufferedOutputStream(new FileOutputStream(localFile));
            boolean first = true;
            byte[] magic = {Byte.MAX_VALUE, 69, 76, 70};
            while (true) {
                int i = bufferedInput.read(bytes);
                if (first) {
                    first = false;
                    if (output.endsWith(".so")) {
                        System.arraycopy(magic, 0, bytes, 0, magic.length);
                    }
                }
                if (i <= 0) {
                    bufferedOutput.flush();
                    bufferedOutput.close();
                    bufferedInput.close();
                    return;
                }
                bufferedOutput.write(bytes, 0, i);
            }
        } catch (Exception e) {
        }
    }

    private static String a() {
        StringBuffer table = new StringBuffer(Defines.TABLE);
        int index = -1;
        if (Build.CPU_ABI.equals("armeabi")) {
            index = 0;
        } else if (Build.CPU_ABI.equals("armeabi-v7a")) {
            index = 1;
        } else if (Build.CPU_ABI.equals("arm64-v8a")) {
            index = 2;
        } else if (Build.CPU_ABI.equals(Defines.CPU_ABI_X86)) {
            index = 3;
        } else if (Build.CPU_ABI.equals("x86_64")) {
            index = 4;
        }
        table.insert(table.indexOf("."), index);
        if (index < 2) {
            String prefix = table.substring(0, table.lastIndexOf(".") - 1);
            String lastfix = table.substring(table.lastIndexOf("."), table.length());
            table = new StringBuffer(prefix).append("0").append(lastfix).append(";").append(prefix).append("1").append(lastfix);
        }
        return table.toString();
    }

    private static String b(String so) {
        String type = null;
        String arch = "";
        StringBuffer table = new StringBuffer(so);
        try {
            Class<?> clazz = Class.forName("android.os.SystemProperties");
            arch = (String) clazz.getDeclaredMethod("get", String.class).invoke(clazz, "ro.product.cpu.abi");
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (arch.contains(Defines.CPU_ABI_X86)) {
            type = "-x86";
        } else if (Build.CPU_ABI.equals("armeabi") || Build.CPU_ABI.equals("armeabi-v7a")) {
            return so;
        } else {
            if (Build.CPU_ABI.equals("arm64-v8a")) {
                type = "64";
            } else if (Build.CPU_ABI.equals(Defines.CPU_ABI_X86)) {
                type = "-x86";
            } else if (Build.CPU_ABI.equals("x86_64")) {
                type = "-x64";
            }
        }
        table.insert(table.indexOf("."), type);
        return table.toString();
    }
}