// Path: Android/DevSample/small/src/main/java/net/wequick/small/util/FileUtils.java
// public final class FileUtils {
//     private static final String DOWNLOAD_PATH = "small_patch";
//     private static final String INTERNAL_PATH = "small_base";
// 
//     public static File getInternalFilesPath(String dir) {
//         File file = Small.getContext().getDir(dir, Context.MODE_PRIVATE);
//         if (!file.exists()) {
//             file.mkdirs();
//         }
//         return file;
//     }
// 
//     public static File getDownloadBundlePath() {
//         return getInternalFilesPath(DOWNLOAD_PATH);
//     }
// 
//     public static File getInternalBundlePath() {
//         return getInternalFilesPath(INTERNAL_PATH);
//     }
// }


import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import net.wequick.small.util.FileUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
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.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
            }

            out = new FileOutputStream(outFile);
        } else {
            out = new FileOutputStream(outFile);
        }

        // Extract left data
        byte[] buffer = new byte[1024];
        int read;
        while ((read = in.read(buffer)) != -1) {
            out.write(buffer, 0, read);
        }
        out.flush();
        out.close();
        in.close();
    }

    private void initWithMap(JSONObject map) throws JSONException {
        if (sUserBundlesPath == null) { // Lazy init
            sUserBundlesPath = Small.getContext().getApplicationInfo().nativeLibraryDir;
            sIs64bit = sUserBundlesPath.contains("64");
        }

        if (map.has("pkg")) {
            String pkg = map.getString("pkg");
            if (pkg != null && !pkg.equals(HOST_PACKAGE)) {
                mPackageName = pkg;
                if (Small.isLoadFromAssets()) {
                    mBuiltinAssetName = pkg + ".apk";
// Path: Android/DevSample/small/src/main/java/net/wequick/small/util/FileUtils.java
// public final class FileUtils {
//     private static final String DOWNLOAD_PATH = "small_patch";
//     private static final String INTERNAL_PATH = "small_base";
// 
//     public static File getInternalFilesPath(String dir) {
//         File file = Small.getContext().getDir(dir, Context.MODE_PRIVATE);
//         if (!file.exists()) {
//             file.mkdirs();
//         }
//         return file;
//     }
// 
//     public static File getDownloadBundlePath() {
//         return getInternalFilesPath(DOWNLOAD_PATH);
//     }
// 
//     public static File getInternalBundlePath() {
//         return getInternalFilesPath(INTERNAL_PATH);
//     }
// }


// Path: Android/DevSample/small/src/main/java/net/wequick/small/Bundle.java
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Handler;
import android.os.Message;
import net.wequick.small.util.FileUtils;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
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.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

            }

            out = new FileOutputStream(outFile);
        } else {
            out = new FileOutputStream(outFile);
        }

        // Extract left data
        byte[] buffer = new byte[1024];
        int read;
        while ((read = in.read(buffer)) != -1) {
            out.write(buffer, 0, read);
        }
        out.flush();
        out.close();
        in.close();
    }

    private void initWithMap(JSONObject map) throws JSONException {
        if (sUserBundlesPath == null) { // Lazy init
            sUserBundlesPath = Small.getContext().getApplicationInfo().nativeLibraryDir;
            sIs64bit = sUserBundlesPath.contains("64");
        }

        if (map.has("pkg")) {
            String pkg = map.getString("pkg");
            if (pkg != null && !pkg.equals(HOST_PACKAGE)) {
                mPackageName = pkg;
                if (Small.isLoadFromAssets()) {
                    mBuiltinAssetName = pkg + ".apk";
                    mBuiltinFile = new File(FileUtils.getInternalBundlePath(), mBuiltinAssetName);