Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f3c5da3 authored by Irfan Sheriff's avatar Irfan Sheriff Committed by Android (Google) Code Review
Browse files

Merge "Split WifiStateMachine from WifiStateTracker"

parents 4668e772 0d25534f
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -526,12 +526,6 @@ public class MobileDataStateTracker implements NetworkStateTracker {
        return -1;
    }

    /**
     * This is not supported.
     */
    public void interpretScanResultsAvailable() {
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer("Mobile data state: ");
+6 −13
Original line number Diff line number Diff line
@@ -27,18 +27,17 @@ package android.net;
public interface NetworkStateTracker {

    public static final int EVENT_STATE_CHANGED = 1;
    public static final int EVENT_SCAN_RESULTS_AVAILABLE = 2;
    /**
     * arg1: 1 to show, 0 to hide
     * arg2: ID of the notification
     * obj: Notification (if showing)
     */
    public static final int EVENT_NOTIFICATION_CHANGED = 3;
    public static final int EVENT_CONFIGURATION_CHANGED = 4;
    public static final int EVENT_ROAMING_CHANGED = 5;
    public static final int EVENT_NETWORK_SUBTYPE_CHANGED = 6;
    public static final int EVENT_RESTORE_DEFAULT_NETWORK = 7;
    public static final int EVENT_CLEAR_NET_TRANSITION_WAKELOCK = 8;
    public static final int EVENT_NOTIFICATION_CHANGED = 2;
    public static final int EVENT_CONFIGURATION_CHANGED = 3;
    public static final int EVENT_ROAMING_CHANGED = 4;
    public static final int EVENT_NETWORK_SUBTYPE_CHANGED = 5;
    public static final int EVENT_RESTORE_DEFAULT_NETWORK = 6;
    public static final int EVENT_CLEAR_NET_TRANSITION_WAKELOCK = 7;

    /**
     * Fetch NetworkInfo for the network
@@ -147,10 +146,4 @@ public interface NetworkStateTracker {
     */
    public int stopUsingNetworkFeature(String feature, int callingPid, int callingUid);

    /**
     * Interprets scan results. This will be called at a safe time for
     * processing, and from a safe thread.
     */
    public void interpretScanResultsAvailable();

}
+3 −18
Original line number Diff line number Diff line
@@ -314,14 +314,14 @@ public class ConnectivityService extends IConnectivityManager.Stub {
            case ConnectivityManager.TYPE_WIFI:
                if (DBG) Slog.v(TAG, "Starting Wifi Service.");
                WifiStateTracker wst = new WifiStateTracker(context, mHandler);
                WifiService wifiService = new WifiService(context, wst);
                WifiService wifiService = new WifiService(context);
                ServiceManager.addService(Context.WIFI_SERVICE, wifiService);
                wifiService.startWifi();
                wifiService.checkAndStartWifi();
                mNetTrackers[ConnectivityManager.TYPE_WIFI] = wst;
                wst.startMonitoring();

                //TODO: as part of WWS refactor, create only when needed
                mWifiWatchdogService = new WifiWatchdogService(context, wst);
                mWifiWatchdogService = new WifiWatchdogService(context);

                break;
            case ConnectivityManager.TYPE_MOBILE:
@@ -1205,16 +1205,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        sendConnectedBroadcast(info);
    }

    private void handleScanResultsAvailable(NetworkInfo info) {
        int networkType = info.getType();
        if (networkType != ConnectivityManager.TYPE_WIFI) {
            if (DBG) Slog.v(TAG, "Got ScanResultsAvailable for " +
                    info.getTypeName() + " network. Don't know how to handle.");
        }

        mNetTrackers[networkType].interpretScanResultsAvailable();
    }

    private void handleNotificationChange(boolean visible, int id,
            Notification notification) {
        NotificationManager notificationManager = (NotificationManager) mContext
@@ -1619,11 +1609,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
                    }
                    break;

                case NetworkStateTracker.EVENT_SCAN_RESULTS_AVAILABLE:
                    info = (NetworkInfo) msg.obj;
                    handleScanResultsAvailable(info);
                    break;

                case NetworkStateTracker.EVENT_NOTIFICATION_CHANGED:
                    handleNotificationChange(msg.arg1 == 1, msg.arg2,
                            (Notification) msg.obj);
+353 −49

File changed.

Preview size limit exceeded, changes collapsed.

+5 −8
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.net.DhcpInfo;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.net.wifi.WifiStateTracker;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -77,7 +76,6 @@ public class WifiWatchdogService {
    
    private Context mContext;
    private ContentResolver mContentResolver;
    private WifiStateTracker mWifiStateTracker;
    private WifiManager mWifiManager;
    
    /**
@@ -108,10 +106,9 @@ public class WifiWatchdogService {
    /** Whether the current AP check should be canceled. */
    private boolean mShouldCancel;
    
    WifiWatchdogService(Context context, WifiStateTracker wifiStateTracker) {
    WifiWatchdogService(Context context) {
        mContext = context;
        mContentResolver = context.getContentResolver();
        mWifiStateTracker = wifiStateTracker;
        mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        
        createThread();
@@ -752,7 +749,7 @@ public class WifiWatchdogService {
        // Black list this "bad" AP, this will cause an attempt to connect to another
        blacklistAp(ap.bssid);
        // Initiate an association to an alternate AP
        mWifiStateTracker.reassociateCommand();
        mWifiManager.reassociate();
    }

    private void blacklistAp(String bssid) {
@@ -763,7 +760,7 @@ public class WifiWatchdogService {
        // Before taking action, make sure we should not cancel our processing
        if (shouldCancel()) return;
        
        mWifiStateTracker.addToBlacklist(bssid);
        mWifiManager.addToBlacklist(bssid);

        if (D) {
            myLogD("Blacklisting " + bssid);
@@ -858,7 +855,7 @@ public class WifiWatchdogService {
             * (and blacklisted them). Clear the blacklist so the AP with best
             * signal is chosen.
             */
            mWifiStateTracker.clearBlacklist();
            mWifiManager.clearBlacklist();
            
            if (V) {
                myLogV("handleSleep: Set state to SLEEP and cleared blacklist");
@@ -929,7 +926,7 @@ public class WifiWatchdogService {
     * should revert anything done by the watchdog monitoring.
     */
    private void handleReset() {
        mWifiStateTracker.clearBlacklist();
        mWifiManager.clearBlacklist();
        setIdleState(true);
    }
    
Loading