From 04179ddb85a3b5b093bed2974cb0805c9c7a4d3a Mon Sep 17 00:00:00 2001 From: Sean Boyer Date: Fri, 6 Jan 2017 14:00:26 -0400 Subject: [PATCH] Restore missing timestamp scan result, and add the three new fields for >= Marshmallow: centerFreq0, centerFreq1 and channelWidth --- .../com/pylonproducts/wifiwizard/WifiWizard.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/android/src/com/pylonproducts/wifiwizard/WifiWizard.java b/src/android/src/com/pylonproducts/wifiwizard/WifiWizard.java index 2c4ac8f..bdc4688 100644 --- a/src/android/src/com/pylonproducts/wifiwizard/WifiWizard.java +++ b/src/android/src/com/pylonproducts/wifiwizard/WifiWizard.java @@ -30,6 +30,7 @@ import android.net.wifi.SupplicantState; import android.content.Context; import android.util.Log; +import android.os.Build.VERSION; public class WifiWizard extends CordovaPlugin { @@ -46,6 +47,7 @@ public class WifiWizard extends CordovaPlugin { private static final String IS_WIFI_ENABLED = "isWifiEnabled"; private static final String SET_WIFI_ENABLED = "setWifiEnabled"; private static final String TAG = "WifiWizard"; + private static final int API_VERSION = VERSION.SDK_INT; private WifiManager wifiManager; private CallbackContext callbackContext; @@ -429,7 +431,17 @@ private boolean getScanResults(CallbackContext callbackContext, JSONArray data) lvl.put("BSSID", scan.BSSID); lvl.put("frequency", scan.frequency); lvl.put("capabilities", scan.capabilities); - // lvl.put("timestamp", scan.timestamp); + lvl.put("timestamp", scan.timestamp); + + if (API_VERSION >= 23) { // Marshmallow + lvl.put("channelWidth", scan.channelWidth); + lvl.put("centerFreq0", scan.centerFreq0); + lvl.put("centerFreq1", scan.centerFreq1); + } else { + lvl.put("channelWidth", null); + lvl.put("centerFreq0", null); + lvl.put("centerFreq1", null); + } returnList.put(lvl); } catch (JSONException e) { e.printStackTrace();