// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
//     StringBuilder sb = new StringBuilder();
//     for (final byte b : a)
//         sb.append(KcaUtils.format("%02x ", b & 0xff));
//     return sb.toString();
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
//     SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
//     return pref.getBoolean(key, false);
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
//     StringWriter errors = new StringWriter();
//     ex.printStackTrace(new PrintWriter(errors));
//     return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
//     ByteArrayOutputStream out = new ByteArrayOutputStream();
//     try {
//         ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
//     } catch (IOException e) {
//         throw new RuntimeException(e);
//     }
//     return out.toByteArray();
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
//     byte[] unchunkedData = null;
//     byte[] buffer = new byte[1024];
//     ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
//     ChunkedInputStream cis = new ChunkedInputStream(bis);
//     ByteArrayOutputStream bos = new ByteArrayOutputStream();
// 
//     int read = -1;
//     while ((read = cis.read(buffer)) != -1) {
//         bos.write(buffer, 0, read);
//     }
//     unchunkedData = bos.toByteArray();
//     bos.close();
// 
//     return unchunkedData;
// }


import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata;
                        if (checkKcApi(requestUri)) {
                            KcaHandler k = new KcaHandler(handler, requestUri, requestBody, responseBody);
                            executorService.execute(k);
                        }
                        portToUri.delete(tport);
                        portToRequestData.delete(tport);
                        portToResponseData.delete(tport);
                        portToResponseHeaderLength.delete(tport);
                        portToLength.delete(tport);
                        portToGzipped.delete(tport);
                        isreadyflag = false;
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
            String error_uri = KCA_API_VPN_DATA_ERROR;
            String empty_request = "";
            JsonObject error_data = new JsonObject();
            error_data.addProperty("error", getStringFromException(e));
            error_data.addProperty("uri", requestUri);
            error_data.addProperty("request", requestData.toString());
            String responseDataStr = byteArrayToHex(responseData);
            if (responseDataStr.length() > 240) {
                error_data.addProperty("response", responseDataStr.substring(0, 240));
            } else {
                error_data.addProperty("response", responseDataStr);
            }
            KcaHandler k = new KcaHandler(handler, error_uri, empty_request.getBytes(), error_data.toString().getBytes());
            executorService.execute(k);
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_RESOURCE_URL = "/kca_api/resource_url";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String KCA_API_VPN_DATA_ERROR = "/kca_api/vpn_data_error";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String byteArrayToHex(byte[] a) {
//     StringBuilder sb = new StringBuilder();
//     for (final byte b : a)
//         sb.append(KcaUtils.format("%02x ", b & 0xff));
//     return sb.toString();
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static Boolean getBooleanPreferences(Context ctx, String key) {
//     SharedPreferences pref = ctx.getSharedPreferences("pref", Context.MODE_PRIVATE);
//     return pref.getBoolean(key, false);
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static String getStringFromException(Exception ex) {
//     StringWriter errors = new StringWriter();
//     ex.printStackTrace(new PrintWriter(errors));
//     return errors.toString().replaceAll("\n", " / ").replaceAll("\t", "");
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] gzipdecompress(byte[] contentBytes) {
//     ByteArrayOutputStream out = new ByteArrayOutputStream();
//     try {
//         ByteStreams.copy(new GZIPInputStream(new ByteArrayInputStream(contentBytes)), out);
//     } catch (IOException e) {
//         throw new RuntimeException(e);
//     }
//     return out.toByteArray();
// }
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaUtils.java
// public static byte[] unchunkdata(byte[] contentBytes) throws IOException {
//     byte[] unchunkedData = null;
//     byte[] buffer = new byte[1024];
//     ByteArrayInputStream bis = new ByteArrayInputStream(contentBytes);
//     ChunkedInputStream cis = new ChunkedInputStream(bis);
//     ByteArrayOutputStream bos = new ByteArrayOutputStream();
// 
//     int read = -1;
//     while ((read = cis.read(buffer)) != -1) {
//         bos.write(buffer, 0, read);
//     }
//     unchunkedData = bos.toByteArray();
//     bos.close();
// 
//     return unchunkedData;
// }


// Path: app/src/main/java/com/antest1/kcanotify/KcaVpnData.java
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import com.google.common.collect.EvictingQueue;
import com.google.common.primitives.Bytes;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.ArrayUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.KCA_API_RESOURCE_URL;
import static com.antest1.kcanotify.KcaConstants.KCA_API_VPN_DATA_ERROR;
import static com.antest1.kcanotify.KcaUtils.byteArrayToHex;
import static com.antest1.kcanotify.KcaUtils.getBooleanPreferences;
import static com.antest1.kcanotify.KcaUtils.getStringFromException;
import static com.antest1.kcanotify.KcaUtils.gzipdecompress;
import static com.antest1.kcanotify.KcaUtils.unchunkdata;

                        if (checkKcApi(requestUri)) {
                            KcaHandler k = new KcaHandler(handler, requestUri, requestBody, responseBody);
                            executorService.execute(k);
                        }
                        portToUri.delete(tport);
                        portToRequestData.delete(tport);
                        portToResponseData.delete(tport);
                        portToResponseHeaderLength.delete(tport);
                        portToLength.delete(tport);
                        portToGzipped.delete(tport);
                        isreadyflag = false;
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
            String error_uri = KCA_API_VPN_DATA_ERROR;
            String empty_request = "";
            JsonObject error_data = new JsonObject();
            error_data.addProperty("error", getStringFromException(e));
            error_data.addProperty("uri", requestUri);
            error_data.addProperty("request", requestData.toString());
            String responseDataStr = byteArrayToHex(responseData);
            if (responseDataStr.length() > 240) {
                error_data.addProperty("response", responseDataStr.substring(0, 240));
            } else {
                error_data.addProperty("response", responseDataStr);
            }
            KcaHandler k = new KcaHandler(handler, error_uri, empty_request.getBytes(), error_data.toString().getBytes());
            executorService.execute(k);
            Log.e("KCA", getStringFromException(e));