1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
package android.net.wifi;
import android.os.Parcel;
import android.os.Parcelable;
public class ScanInfo implements Parcelable {
private final ScanResult mScanResult;
private final long mBSSID; // The BSSID of the best AP with an SSID matching the OSU
private final int mRSSI; // RSSI of the AP with BSSID
private final String mSSID; // The SSID to connect to for an OSU connection.
private final String mName;
private final String mServiceDescription;
private final String mIconType;
private final byte[] mIconData;
private final int mOSUIdentity;
public ScanInfo(ScanResult scanResult) {
mScanResult = scanResult;
mBSSID = -1;
mRSSI = -1;
mSSID = null;
mName = null;
mServiceDescription = null;
mIconType = null;
mIconData = null;
mOSUIdentity = -1;
}
public ScanInfo(long BSSID, int rssi, String SSID, String name, String serviceDescription,
String iconType, byte[] iconData, int OSUIdentity) {
mBSSID = BSSID;
mRSSI = rssi;
mSSID = SSID;
mName = name;
mServiceDescription = serviceDescription;
mIconType = iconType;
mIconData = iconData;
mOSUIdentity = OSUIdentity;
mScanResult = null;
}
/**
* Get the scan result of this ScanInfo.
* @return The ScanResult, if this ScanInfo contains a one. If the ScanInfo contains
* OSU information getScanResult will return null.
*/
public ScanResult getScanResult() {
return mScanResult;
}
/**
* OSU only: The BSSID of the AP who advertises the OSU SSID. This value is not guaranteed to
* be correct; In the somewhat unlikely case that multiple APs advertise OSU SSIDs that matches
* an OSU information element returned through ANQP and one of those is not related to an OSU
* there is a (slight) risk that the BSSID is for a "spoof" OSU.
* The matching algorithm that produces the ScanInfo objects makes a best effort to get the
* matching right though and since it is (a) fair to assume that the OSU SSID resides on the
* same AP as the one advertising the OSU information, and (b) BSSIDs for multi-SSID APs are
* typically adjacent to each other, matching will prefer the BSSID closest to the advertising
* APs BSSID if multiple SSIDs match.
* @return The BSSID.
*/
public long getBssid() {
return mBSSID;
}
/**
* OSU only.
* @return The signal level of the AP associated with the BSSID from getBSSID.
*/
public int getRssi() {
return mRSSI;
}
/**
* OSU only.
* @return The SSID of the AP to which to associate to establish an OSU connection.
*/
public String getSsid() {
return mSSID;
}
/**
* OSU only.
* @return The name of the Service Provider of the OSU.
*/
public String getName() {
return mName;
}
/**
* OSU only.
* @return The service description of the OSU.
*/
public String getServiceDescription() {
return mServiceDescription;
}
/**
* OSU only.
* Get the type of icon that icon data represents, e.g. JPG, PNG etc. This field is formatted
* using standard MIME encodings per RFC-4288 and IANA MIME media types.
* @return The icon type in icon data.
*/
public String getIconType() {
return mIconType;
}
/**
* OSU only.
* @return The binary data of the icon.
*/
public byte[] getIconData() {
return mIconData;
}
/**
* OSU only.
* @return a unique identity for the OSU. This value is generated by the framework and should
* be used to uniquely identify a specific OSU. Please note that values may be reused after
* a very long time-span (in any normal scenario, likely years) and implementations should make
* sure to not rely on any long term persisted values.
*/
public int getOsuIdentity() {
return mOSUIdentity;
}
private static final int ScanResultMarker = 0;
private static final int OSUMarker = 1;
@Override
public int describeContents() {
return 0;
}
/** Implement the Parcelable interface {@hide} */
public static final Creator<ScanInfo> CREATOR =
new Creator<ScanInfo>() {
@Override
public ScanInfo createFromParcel(Parcel source) {
int marker = source.readInt();
if (marker == ScanResultMarker) {
return new ScanInfo(ScanResult.CREATOR.createFromParcel(source));
}
else if (marker == OSUMarker) {
return new ScanInfo(
source.readLong(),
source.readInt(),
source.readString(),
source.readString(),
source.readString(),
source.readString(),
source.createByteArray(),
source.readInt()
);
}
else {
throw new RuntimeException("Bad ScanInfo data");
}
}
@Override
public ScanInfo[] newArray(int size) {
return new ScanInfo[0];
}
};
@Override
public void writeToParcel(Parcel dest, int flags) {
if (mScanResult != null) {
dest.writeInt(ScanResultMarker);
mScanResult.writeToParcel(dest, flags);
return;
}
dest.writeInt(OSUMarker);
dest.writeLong(mBSSID);
dest.writeInt(mRSSI);
dest.writeString(mSSID);
dest.writeString(mName);
dest.writeString(mServiceDescription);
dest.writeString(mIconType);
dest.writeByteArray(mIconData);
dest.writeInt(mOSUIdentity);
}
}
|