<commit_before>package com.couchbase.lite.android;

import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;

import com.couchbase.lite.AsyncTask;
import com.couchbase.lite.Context;
import com.couchbase.lite.Database;
import com.couchbase.lite.NetworkReachabilityManager;
import com.couchbase.lite.replicator.Replication;
import com.couchbase.lite.util.Log;

public class AndroidNetworkReachabilityManager extends NetworkReachabilityManager {

    private Context context;
    private boolean listening;
    private android.content.Context wrappedContext;
    private ConnectivityBroadcastReceiver receiver;
    private State state;

    public enum State {
        UNKNOWN,

        /** This state is returned if there is connectivity to any network **/
        CONNECTED,
        /**
         * This state is returned if there is no connectivity to any network. This is set to true
         * under two circumstances:
         * <ul>
         * <li>When connectivity is lost to one network, and there is no other available network to
         * attempt to switch to.</li>
         * <li>When connectivity is lost to one network, and the attempt to switch to another
         * network fails.</li>
         */
        NOT_CONNECTED
    }

    public AndroidNetworkReachabilityManager(AndroidContext context) {
        this.context = context;
        this.wrappedContext = context.getWrappedContext();
        this.receiver = new ConnectivityBroadcastReceiver();
    }


    public void startListening() {
        synchronized (this) {
            if (!listening) {
                IntentFilter filter = new IntentFilter();
                filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
                wrappedContext.registerReceiver(receiver, filter);
                listening = true;
            }
        }
    }

    public void stopListening() {
        synchronized (this) {
            if (listening) {
                wrappedContext.unregisterReceiver(receiver);
                context = null;
                listening = false;
            }
        }
    }

    private class ConnectivityBroadcastReceiver extends BroadcastReceiver {
<commit_msg>Issue #224 - use synchronized keyword rather than synchronized block<commit_after>package com.couchbase.lite.android;

import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;

import com.couchbase.lite.AsyncTask;
import com.couchbase.lite.Context;
import com.couchbase.lite.Database;
import com.couchbase.lite.NetworkReachabilityManager;
import com.couchbase.lite.replicator.Replication;
import com.couchbase.lite.util.Log;

public class AndroidNetworkReachabilityManager extends NetworkReachabilityManager {

    private Context context;
    private boolean listening;
    private android.content.Context wrappedContext;
    private ConnectivityBroadcastReceiver receiver;
    private State state;

    public enum State {
        UNKNOWN,

        /** This state is returned if there is connectivity to any network **/
        CONNECTED,
        /**
         * This state is returned if there is no connectivity to any network. This is set to true
         * under two circumstances:
         * <ul>
         * <li>When connectivity is lost to one network, and there is no other available network to
         * attempt to switch to.</li>
         * <li>When connectivity is lost to one network, and the attempt to switch to another
         * network fails.</li>
         */
        NOT_CONNECTED
    }

    public AndroidNetworkReachabilityManager(AndroidContext context) {
        this.context = context;
        this.wrappedContext = context.getWrappedContext();
        this.receiver = new ConnectivityBroadcastReceiver();
    }


    public synchronized void startListening() {
        if (!listening) {
            IntentFilter filter = new IntentFilter();
            filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
            wrappedContext.registerReceiver(receiver, filter);
            listening = true;
        }
    }

    public synchronized void stopListening() {
        if (listening) {
            wrappedContext.unregisterReceiver(receiver);
            context = null;
            listening = false;
        }
    }

    private class ConnectivityBroadcastReceiver extends BroadcastReceiver {

{'fraction_non_alphanumeric': 0.07045707915273133, 'fraction_numerical': 0.0006688963210702341, 'mean_word_length': 2.7166528583264293, 'pattern_counts': {'":': 0, '<': 13, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6275440', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1102, 'n_words': 322}