// Path: tinkerpatch-sdk/src/main/java/com/tencent/tinker/server/utils/ServerUtils.java
// public final class ServerUtils {
//     public static final String CHARSET             = "UTF-8";
//     public static final int    BUFFER_SIZE         = 4096;
//     public static final String TINKER_SERVER_DIR   = "tinker_server";
//     public static final String TINKER_VERSION_FILE = "version.info";
// 
// 
//     private ServerUtils() {
//         // A TinkerServerUtils Class
//     }
// 
//     public static File readStreamToFile(InputStream inputStream, String filePath) throws IOException {
//         if (inputStream == null) {
//             return null;
//         }
// 
//         File file = new File(filePath);
//         File parent = file.getParentFile();
//         if (!parent.exists() && !parent.mkdirs()) {
//             throw new IOException(String.format("Can't create folder %s", parent.getAbsolutePath()));
//         }
//         FileOutputStream fileOutput = new FileOutputStream(file);
//         try {
//             byte[] buffer = new byte[BUFFER_SIZE];
//             int bufferLength;
//             while ((bufferLength = inputStream.read(buffer)) > 0) {
//                 fileOutput.write(buffer, 0, bufferLength);
//             }
//         } finally {
//             try {
//                 fileOutput.close();
//             } catch (IOException ignored) {
//                 // ignored
//             }
//         }
//         return file;
//     }
// 
//     public static Integer stringToInteger(String string) {
//         if (string == null) {
//             return null;
//         }
//         return Integer.parseInt(string);
//     }
// 
//     public static String readStreamToString(InputStream inputStream, String charset) {
//         if (inputStream == null) {
//             return null;
//         }
//         ByteArrayOutputStream bo = new ByteArrayOutputStream();
//         byte[] buffer = new byte[BUFFER_SIZE];
//         int bufferLength;
// 
//         String result;
//         try {
//             while ((bufferLength = inputStream.read(buffer)) > 0) {
//                 bo.write(buffer, 0, bufferLength);
//             }
//             result = bo.toString(charset);
//         } catch (Throwable e) {
//             result = null;
//         }
//         return result;
//     }
// 
//     public static File getServerDirectory(Context context) {
//         ApplicationInfo applicationInfo = context.getApplicationInfo();
//         if (applicationInfo == null) {
//             // Looks like running on a test Context, so just return without patching.
//             return null;
//         }
//         return new File(applicationInfo.dataDir, TINKER_SERVER_DIR);
//     }
// 
//     public static File getServerFile(Context context, String appVersion, String currentVersion) {
//         return new File(getServerDirectory(context), appVersion + "_" + currentVersion + ".apk");
//     }
// }


import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import com.tencent.tinker.lib.util.TinkerLog;
import com.tencent.tinker.server.utils.ServerUtils;
import org.json.JSONException;
import org.json.JSONObject;
        jsonObject.put("av", appVersion);
        jsonObject.put("pv", patchVersion);
        jsonObject.put("t", platformType);
        return jsonObject;
    }

    protected HashMap<String, String> toEncodeObject() {
        HashMap<String, String> values = new HashMap<>();
        values.put("k", appKey);
        values.put("av", appVersion);
        values.put("pv", patchVersion);
        values.put("t", String.valueOf(platformType));
        return values;
    }

    public String toEncodeForm() {
        return getPostDataString(toEncodeObject());
    }

    private String getPostDataString(HashMap<String, String> params) {
        StringBuilder result = new StringBuilder();

        try {
            boolean first = true;
            for (Map.Entry<String, String> entry : params.entrySet()) {
                if (first) {
                    first = false;
                } else {
                    result.append('&');
                }
// Path: tinkerpatch-sdk/src/main/java/com/tencent/tinker/server/utils/ServerUtils.java
// public final class ServerUtils {
//     public static final String CHARSET             = "UTF-8";
//     public static final int    BUFFER_SIZE         = 4096;
//     public static final String TINKER_SERVER_DIR   = "tinker_server";
//     public static final String TINKER_VERSION_FILE = "version.info";
// 
// 
//     private ServerUtils() {
//         // A TinkerServerUtils Class
//     }
// 
//     public static File readStreamToFile(InputStream inputStream, String filePath) throws IOException {
//         if (inputStream == null) {
//             return null;
//         }
// 
//         File file = new File(filePath);
//         File parent = file.getParentFile();
//         if (!parent.exists() && !parent.mkdirs()) {
//             throw new IOException(String.format("Can't create folder %s", parent.getAbsolutePath()));
//         }
//         FileOutputStream fileOutput = new FileOutputStream(file);
//         try {
//             byte[] buffer = new byte[BUFFER_SIZE];
//             int bufferLength;
//             while ((bufferLength = inputStream.read(buffer)) > 0) {
//                 fileOutput.write(buffer, 0, bufferLength);
//             }
//         } finally {
//             try {
//                 fileOutput.close();
//             } catch (IOException ignored) {
//                 // ignored
//             }
//         }
//         return file;
//     }
// 
//     public static Integer stringToInteger(String string) {
//         if (string == null) {
//             return null;
//         }
//         return Integer.parseInt(string);
//     }
// 
//     public static String readStreamToString(InputStream inputStream, String charset) {
//         if (inputStream == null) {
//             return null;
//         }
//         ByteArrayOutputStream bo = new ByteArrayOutputStream();
//         byte[] buffer = new byte[BUFFER_SIZE];
//         int bufferLength;
// 
//         String result;
//         try {
//             while ((bufferLength = inputStream.read(buffer)) > 0) {
//                 bo.write(buffer, 0, bufferLength);
//             }
//             result = bo.toString(charset);
//         } catch (Throwable e) {
//             result = null;
//         }
//         return result;
//     }
// 
//     public static File getServerDirectory(Context context) {
//         ApplicationInfo applicationInfo = context.getApplicationInfo();
//         if (applicationInfo == null) {
//             // Looks like running on a test Context, so just return without patching.
//             return null;
//         }
//         return new File(applicationInfo.dataDir, TINKER_SERVER_DIR);
//     }
// 
//     public static File getServerFile(Context context, String appVersion, String currentVersion) {
//         return new File(getServerDirectory(context), appVersion + "_" + currentVersion + ".apk");
//     }
// }


// Path: tinkerpatch-sdk/src/main/java/com/tencent/tinker/server/model/request/BaseReport.java
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import com.tencent.tinker.lib.util.TinkerLog;
import com.tencent.tinker.server.utils.ServerUtils;
import org.json.JSONException;
import org.json.JSONObject;

        jsonObject.put("av", appVersion);
        jsonObject.put("pv", patchVersion);
        jsonObject.put("t", platformType);
        return jsonObject;
    }

    protected HashMap<String, String> toEncodeObject() {
        HashMap<String, String> values = new HashMap<>();
        values.put("k", appKey);
        values.put("av", appVersion);
        values.put("pv", patchVersion);
        values.put("t", String.valueOf(platformType));
        return values;
    }

    public String toEncodeForm() {
        return getPostDataString(toEncodeObject());
    }

    private String getPostDataString(HashMap<String, String> params) {
        StringBuilder result = new StringBuilder();

        try {
            boolean first = true;
            for (Map.Entry<String, String> entry : params.entrySet()) {
                if (first) {
                    first = false;
                } else {
                    result.append('&');
                }
                result.append(URLEncoder.encode(entry.getKey(), ServerUtils.CHARSET));