// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String BROADCAST_ACTION = "com.antest1.kcasniffer.broadcast";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final Uri CONTENT_URI = Uri.parse("content://".concat(AUTHORITY).concat(REQUEST_PATH));
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_VPN_ENABLED = "enabled";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String VPN_STOP_REASON = "vpn_stop_from_main";


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.VpnService;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.BROADCAST_ACTION;
import static com.antest1.kcanotify.KcaConstants.CONTENT_URI;
import static com.antest1.kcanotify.KcaConstants.PREF_VPN_ENABLED;
import static com.antest1.kcanotify.KcaConstants.VPN_STOP_REASON;
package com.antest1.kcanotify;




public class KcaAutomationReceiver extends BroadcastReceiver {
    public static final String SNIFFER_ON_ACTION = "sniffer_on";
    public static final String SNIFFER_OFF_ACTION = "sniffer_off";

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action != null) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            switch (action) {
                case SNIFFER_ON_ACTION:
                    try {
                        VpnService.prepare(context);
                        prefs.edit().putBoolean(PREF_VPN_ENABLED, true).apply();
                        KcaVpnService.start("prepared", context);
                    } catch (Throwable ex) {
                        // Prepare failed
                        Log.e("KCA", ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
                    break;

                case SNIFFER_OFF_ACTION:
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String BROADCAST_ACTION = "com.antest1.kcasniffer.broadcast";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final Uri CONTENT_URI = Uri.parse("content://".concat(AUTHORITY).concat(REQUEST_PATH));
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String PREF_VPN_ENABLED = "enabled";
// 
// Path: app/src/main/java/com/antest1/kcanotify/KcaConstants.java
// public static final String VPN_STOP_REASON = "vpn_stop_from_main";


// Path: app/src/main/java/com/antest1/kcanotify/KcaAutomationReceiver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.VpnService;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.antest1.kcanotify.KcaConstants.BROADCAST_ACTION;
import static com.antest1.kcanotify.KcaConstants.CONTENT_URI;
import static com.antest1.kcanotify.KcaConstants.PREF_VPN_ENABLED;
import static com.antest1.kcanotify.KcaConstants.VPN_STOP_REASON;

package com.antest1.kcanotify;




public class KcaAutomationReceiver extends BroadcastReceiver {
    public static final String SNIFFER_ON_ACTION = "sniffer_on";
    public static final String SNIFFER_OFF_ACTION = "sniffer_off";

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action != null) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            switch (action) {
                case SNIFFER_ON_ACTION:
                    try {
                        VpnService.prepare(context);
                        prefs.edit().putBoolean(PREF_VPN_ENABLED, true).apply();
                        KcaVpnService.start("prepared", context);
                    } catch (Throwable ex) {
                        // Prepare failed
                        Log.e("KCA", ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
                    break;

                case SNIFFER_OFF_ACTION:
                    KcaVpnService.stop(VPN_STOP_REASON, context);