From 44046e24c6ee1cd1c2eaa171d73ad9e4358881ef Mon Sep 17 00:00:00 2001 From: vikrama Date: Sat, 17 Sep 2011 19:43:25 +0000 Subject: [PATCH] Adding minor comments git-svn-id: https://zxing.googlecode.com/svn/trunk@1917 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../google/zxing/client/android/wifi/WifiReceiver.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/android/src/com/google/zxing/client/android/wifi/WifiReceiver.java b/android/src/com/google/zxing/client/android/wifi/WifiReceiver.java index 0c230997f..5e095ecf6 100644 --- a/android/src/com/google/zxing/client/android/wifi/WifiReceiver.java +++ b/android/src/com/google/zxing/client/android/wifi/WifiReceiver.java @@ -50,13 +50,16 @@ final class WifiReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) { + // Wifi supplicant (WPA client software) changed state. handleChange( (SupplicantState) intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE), intent.hasExtra(WifiManager.EXTRA_SUPPLICANT_ERROR)); } else if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)){ + // The network state changed. handleNetworkStateChanged((NetworkInfo) intent.getParcelableExtra( WifiManager.EXTRA_NETWORK_INFO)); } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { + // We might be connected. ConnectivityManager con = (ConnectivityManager) parent.getSystemService( Context.CONNECTIVITY_SERVICE); NetworkInfo[] s = con.getAllNetworkInfo(); @@ -66,6 +69,9 @@ final class WifiReceiver extends BroadcastReceiver { String ssid = mWifiManager.getConnectionInfo().getSSID(); if (state == NetworkInfo.State.CONNECTED && ssid != null){ + // Yes, we connected to the network specified in the barcode. + // Let's save the configuration, since we know it works. Then, + // we stop this application by calling the killer. mWifiManager.saveConfiguration(); String label = parent.getString(R.string.wifi_connected); statusView.setText(label + '\n' + ssid); @@ -73,6 +79,8 @@ final class WifiReceiver extends BroadcastReceiver { delayKill.run(); } if (state == NetworkInfo.State.DISCONNECTED){ + // We couldn't connect to the specified network. Let the parent + // know that we were unsuccessful. Log.d(TAG, "Got state Disconnected for ssid: " + ssid); parent.gotError(); } @@ -95,4 +103,4 @@ final class WifiReceiver extends BroadcastReceiver { parent.gotError(); } } -} +} \ No newline at end of file