summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinit Deshpande <vinitd@google.com>2014-06-09 15:39:22 -0700
committerVinit Deshpande <vinitd@google.com>2014-06-12 08:34:44 -0700
commitdaf215cf95fe5464d67465d9a6540c6296ca90bd (patch)
tree764311db888879a4907ae1e5c2f0412c6394104f
parente344cb226885b071c0aad5dd034518fca5002841 (diff)
downloadframeworks_base-daf215cf95fe5464d67465d9a6540c6296ca90bd.zip
frameworks_base-daf215cf95fe5464d67465d9a6540c6296ca90bd.tar.gz
frameworks_base-daf215cf95fe5464d67465d9a6540c6296ca90bd.tar.bz2
Support scanning using band specification instead of channels
This change enables scanning with band specification instead of channels, this should ease app development. Also includes a bug fix for parcel serialization/deserialization. Change-Id: Idbffce4805b403bf8fe1efae999cb828e09c2420
-rw-r--r--wifi/java/android/net/wifi/WifiScanner.java64
1 files changed, 41 insertions, 23 deletions
diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java
index a145d67..21b700d 100644
--- a/wifi/java/android/net/wifi/WifiScanner.java
+++ b/wifi/java/android/net/wifi/WifiScanner.java
@@ -153,12 +153,17 @@ public class WifiScanner {
dest.writeInt(band);
dest.writeInt(periodInMs);
dest.writeInt(reportEvents);
- dest.writeInt(channels.length);
- for (int i = 0; i < channels.length; i++) {
- dest.writeInt(channels[i].frequency);
- dest.writeInt(channels[i].dwellTimeMS);
- dest.writeInt(channels[i].passive ? 1 : 0);
+ if (channels != null) {
+ dest.writeInt(channels.length);
+
+ for (int i = 0; i < channels.length; i++) {
+ dest.writeInt(channels[i].frequency);
+ dest.writeInt(channels[i].dwellTimeMS);
+ dest.writeInt(channels[i].passive ? 1 : 0);
+ }
+ } else {
+ dest.writeInt(0);
}
}
@@ -211,10 +216,14 @@ public class WifiScanner {
/** Implement the Parcelable interface {@hide} */
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mResults.length);
- for (int i = 0; i < mResults.length; i++) {
- ScanResult result = mResults[i];
- result.writeToParcel(dest, flags);
+ if (mResults != null) {
+ dest.writeInt(mResults.length);
+ for (int i = 0; i < mResults.length; i++) {
+ ScanResult result = mResults[i];
+ result.writeToParcel(dest, flags);
+ }
+ } else {
+ dest.writeInt(0);
}
}
@@ -324,13 +333,17 @@ public class WifiScanner {
dest.writeInt(unchangedSampleSize);
dest.writeInt(minApsBreachingThreshold);
dest.writeInt(periodInMs);
- dest.writeInt(hotspotInfos.length);
- for (int i = 0; i < hotspotInfos.length; i++) {
- HotspotInfo info = hotspotInfos[i];
- dest.writeString(info.bssid);
- dest.writeInt(info.low);
- dest.writeInt(info.high);
- dest.writeInt(info.frequencyHint);
+ if (hotspotInfos != null) {
+ dest.writeInt(hotspotInfos.length);
+ for (int i = 0; i < hotspotInfos.length; i++) {
+ HotspotInfo info = hotspotInfos[i];
+ dest.writeString(info.bssid);
+ dest.writeInt(info.low);
+ dest.writeInt(info.high);
+ dest.writeInt(info.frequencyHint);
+ }
+ } else {
+ dest.writeInt(0);
}
}
@@ -456,13 +469,18 @@ public class WifiScanner {
/** Implement the Parcelable interface {@hide} */
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(apLostThreshold);
- dest.writeInt(hotspotInfos.length);
- for (int i = 0; i < hotspotInfos.length; i++) {
- HotspotInfo info = hotspotInfos[i];
- dest.writeString(info.bssid);
- dest.writeInt(info.low);
- dest.writeInt(info.high);
- dest.writeInt(info.frequencyHint);
+
+ if (hotspotInfos != null) {
+ dest.writeInt(hotspotInfos.length);
+ for (int i = 0; i < hotspotInfos.length; i++) {
+ HotspotInfo info = hotspotInfos[i];
+ dest.writeString(info.bssid);
+ dest.writeInt(info.low);
+ dest.writeInt(info.high);
+ dest.writeInt(info.frequencyHint);
+ }
+ } else {
+ dest.writeInt(0);
}
}