<commit_before>package net.opencurlybraces.android.projects.wifihandler.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.util.Log;

import net.opencurlybraces.android.projects.wifihandler.util.WifiUtils;

import java.util.List;

/**
 * {@link BroadcastReceiver} filtered on {@link android.net.wifi
 * .WifiManager#SCAN_RESULTS_AVAILABLE_ACTION}
 * system action.
 *
 * @author <NAME>
 */
public class WifiScanResultsReceiver extends BroadcastReceiver {
    private static final String TAG = WifiScanResultsReceiver.class.getSimpleName();
    WifiManager mWifiManager = null;
    private static final int SIGNAL_STRENGH_THRESHOLD = -80;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (mWifiManager == null) {
            mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        }
        Log.d(TAG, "SCAN_RESULTS received");
        new ScanResultAsyncHandler(mWifiManager).execute();
    }


    private static class ScanResultAsyncHandler extends AsyncTask<Void, Void, Void> {

        private WifiManager mWifiManager = null;

        private ScanResultAsyncHandler(WifiManager wifiManager) {
            mWifiManager = wifiManager;
        }

        @Override
        protected Void doInBackground(Void... params) {
            handleScanResults();
            return null;
        }

        private void handleScanResults() {
            try {
                List<ScanResult> availableWifiNetworks = mWifiManager
                        .getScanResults();
                List<WifiConfiguration> configuredWifiNetworks = WifiUtils.getConfiguredWifis
                        (mWifiManager);

                if (configuredWifiNetworks == null || availableWifiNetworks == null) {
                    return;
                }
                for (ScanResult wifiNetwork : availableWifiNetworks) {
                    for (WifiConfiguration wifiConfig : configuredWifiNetworks) {
                        String quoteStripped = wifiConfig.SSID.replace("\"", "");
                        if (quoteStripped.equals(wifiNetwork.SSID)) {
                            Log.d(TAG, "Signal Strength=" + wifiNetwork.level + " SSID=" +
                                    wifiNetwork
                                            .SSID);
                            if (wifiNetwork.level > SIGNAL_STRENGH_THRESHOLD) {
                                mWifiManager.setWifiEnabled(true);
                            } else {
                                mWifiManager.setWifiEnabled(false);
                            }
                        }
                    }
                }
            } catch (InterruptedException e) {
                Log.d(TAG, "Could not retrieve user's configured networks");
            }
        }


    }
}<commit_msg>ScanResultHandlerService removed as it was making the app process crash for some reason..result handling done in an asynctask<commit_after>package net.opencurlybraces.android.projects.wifihandler.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.util.Log;

import net.opencurlybraces.android.projects.wifihandler.util.WifiUtils;

import java.util.List;

/**
 * {@link BroadcastReceiver} filtered on {@link android.net.wifi
 * .WifiManager#SCAN_RESULTS_AVAILABLE_ACTION}
 * system action.
 *
 * @author <NAME>
 */
public class WifiScanResultsReceiver extends BroadcastReceiver {
    private static final String TAG = WifiScanResultsReceiver.class.getSimpleName();
    WifiManager mWifiManager = null;
    private static final int SIGNAL_STRENGTH_THRESHOLD = -80;

    @Override
    public void onReceive(Context context, Intent intent) {
        if (mWifiManager == null) {
            mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        }
        Log.d(TAG, "SCAN_RESULTS received");
        new ScanResultAsyncHandler(mWifiManager).execute();
    }


    private static class ScanResultAsyncHandler extends AsyncTask<Void, Void, Void> {

        private WifiManager mWifiManager = null;

        private ScanResultAsyncHandler(WifiManager wifiManager) {
            mWifiManager = wifiManager;
        }

        @Override
        protected Void doInBackground(Void... params) {
            handleScanResults();
            return null;
        }

        private void handleScanResults() {
            try {
                List<ScanResult> availableWifiNetworks = mWifiManager
                        .getScanResults();
                List<WifiConfiguration> configuredWifiNetworks = WifiUtils.getConfiguredWifis
                        (mWifiManager);

                if (configuredWifiNetworks == null || availableWifiNetworks == null) {
                    return;
                }
                for (ScanResult wifiNetwork : availableWifiNetworks) {
                    for (WifiConfiguration wifiConfig : configuredWifiNetworks) {
                        String quoteStripped = wifiConfig.SSID.replace("\"", "");
                        if (quoteStripped.equals(wifiNetwork.SSID)) {
                            Log.d(TAG, "Signal Strength=" + wifiNetwork.level + " SSID=" +
                                    wifiNetwork
                                            .SSID);
                            if (wifiNetwork.level > SIGNAL_STRENGTH_THRESHOLD) {
                                mWifiManager.setWifiEnabled(true);
                            } else {
                                mWifiManager.setWifiEnabled(false);
                            }
                        }
                    }
                }
            } catch (InterruptedException e) {
                Log.d(TAG, "Could not retrieve user's configured networks");
            }
        }


    }
}
{'fraction_non_alphanumeric': 0.08045234248788369, 'fraction_numerical': 0.0006462035541195477, 'mean_word_length': 1.9230406043437205, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2567641', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1566, 'n_words': 317}