aboutsummaryrefslogtreecommitdiffstats
path: root/wpadebug
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-05-12 18:06:59 (GMT)
committerJouni Malinen <j@w1.fi>2013-05-12 18:06:59 (GMT)
commit53aafe75e09f81c4ed384439055056579200dea8 (patch)
treea345822b49c83551d2e5f9087659119b8756f444 /wpadebug
parente679f140b9a5219e07dae415489b861f0661bfcf (diff)
downloadhostap-53aafe75e09f81c4ed384439055056579200dea8.zip
hostap-53aafe75e09f81c4ed384439055056579200dea8.tar.gz
hostap-53aafe75e09f81c4ed384439055056579200dea8.tar.bz2
wpadebug: Add broadcast intent receiver for Wi-Fi events
This makes it easier to debug Android framework actions with all the related broadcast intents being logged. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpadebug')
-rw-r--r--wpadebug/AndroidManifest.xml10
-rw-r--r--wpadebug/src/w1/fi/wpadebug/WifiReceiver.java95
2 files changed, 105 insertions, 0 deletions
diff --git a/wpadebug/AndroidManifest.xml b/wpadebug/AndroidManifest.xml
index e939d24..9f3ca68 100644
--- a/wpadebug/AndroidManifest.xml
+++ b/wpadebug/AndroidManifest.xml
@@ -53,5 +53,15 @@
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
+ <receiver android:name="w1.fi.wpadebug.WifiReceiver">
+ <intent-filter>
+ <action android:name="android.net.wifi.STATE_CHANGE" />
+ <action android:name="android.net.wifi.RSSI_CHANGED" />
+ <action android:name="android.net.wifi.SCAN_RESULTS" />
+ <action android:name="android.net.wifi.supplicant.CONNECTION_CHANGE" />
+ <action android:name="android.net.wifi.supplicant.STATE_CHANGE" />
+ <action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
+ </intent-filter>
+ </receiver>
</application>
</manifest>
diff --git a/wpadebug/src/w1/fi/wpadebug/WifiReceiver.java b/wpadebug/src/w1/fi/wpadebug/WifiReceiver.java
new file mode 100644
index 0000000..d69e05d
--- /dev/null
+++ b/wpadebug/src/w1/fi/wpadebug/WifiReceiver.java
@@ -0,0 +1,95 @@
+/*
+ * wpadebug - wpa_supplicant and Wi-Fi debugging app for Android
+ * Copyright (c) 2013, Jouni Malinen <j@w1.fi>
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+package w1.fi.wpadebug;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.NetworkInfo;
+import android.net.wifi.SupplicantState;
+import android.net.wifi.WifiInfo;
+import android.os.Bundle;
+import android.util.Log;
+
+public class WifiReceiver extends BroadcastReceiver
+{
+ private static final String TAG = "wpadebug";
+
+ @Override
+ public void onReceive(Context c, Intent intent)
+ {
+ String act = intent.getAction();
+ Log.d(TAG, "Received broadcast intent: action=" + act);
+
+ Bundle bundles = intent.getExtras();
+ if (bundles == null)
+ return;
+
+ if (bundles.containsKey("bssid")) {
+ String val;
+ val = intent.getStringExtra("bssid");
+ if (val != null)
+ Log.d(TAG, " bssid: " + val);
+ }
+
+ if (bundles.containsKey("networkInfo")) {
+ NetworkInfo info;
+ info = (NetworkInfo) intent.getParcelableExtra("networkInfo");
+ if (info != null)
+ Log.d(TAG, " networkInfo: " + info);
+ }
+
+ if (bundles.containsKey("newRssi")) {
+ int val;
+ val = intent.getIntExtra("newRssi", -1);
+ Log.d(TAG, " newRssi: " + val);
+ }
+
+ if (bundles.containsKey("newState")) {
+ SupplicantState state;
+ state = (SupplicantState) intent.getParcelableExtra("newState");
+ if (state != null)
+ Log.d(TAG, " newState: " + state);
+ }
+
+ if (bundles.containsKey("previous_wifi_state")) {
+ int wifi_state;
+ wifi_state = intent.getIntExtra("previous_wifi_state", -1);
+ if (wifi_state != -1)
+ Log.d(TAG, " previous_wifi_state: " + wifi_state);
+ }
+
+ if (bundles.containsKey("connected")) {
+ boolean connected;
+ connected = intent.getBooleanExtra("connected", false);
+ Log.d(TAG, " connected: " + connected);
+ }
+
+ if (bundles.containsKey("supplicantError")) {
+ int error;
+ error = intent.getIntExtra("supplicantError", -1);
+ if (error != -1)
+ Log.d(TAG, " supplicantError: " + error);
+ }
+
+ if (bundles.containsKey("wifiInfo")) {
+ WifiInfo info;
+ info = (WifiInfo) intent.getParcelableExtra("wifiInfo");
+ if (info != null)
+ Log.d(TAG, " wifiInfo: " + info);
+ }
+
+ if (bundles.containsKey("wifi_state")) {
+ int wifi_state;
+ wifi_state = intent.getIntExtra("wifi_state", -1);
+ if (wifi_state != -1)
+ Log.d(TAG, " wifi_state: " + wifi_state);
+ }
+ }
+}