@@ -49,11 +49,15 @@ class Scanner implements LocationListener {
49
49
private long mWifiScanResultsTime ;
50
50
private Collection <ScanResult > mWifiScanResults ;
51
51
52
- private GpsStatus .Listener mGPSListener ;
52
+ private GpsStatus .Listener mGPSListener ;
53
+ private final int mRadioType ;
53
54
54
55
Scanner (Context context , Reporter reporter ) {
55
56
mContext = context ;
56
57
mReporter = reporter ;
58
+
59
+ TelephonyManager tm = getTelephonyManager ();
60
+ mRadioType = (tm != null ) ? tm .getPhoneType () : TelephonyManager .PHONE_TYPE_NONE ;
57
61
}
58
62
59
63
private class WifiReceiver extends BroadcastReceiver {
@@ -219,15 +223,18 @@ public void onLocationChanged(Location location) {
219
223
} else {
220
224
Log .d (LOGTAG , "New location: " + location );
221
225
222
- mReporter .reportLocation (location ,
223
- getWifiInfo (),
224
- getRadioType (),
225
- getCellInfo ());
226
+ Collection <ScanResult > scanResults = getWifiInfo ();
227
+ JSONArray cellInfo = getCellInfo ();
228
+
229
+ if ((scanResults == null || scanResults .size () == 0 ) && cellInfo == null ) {
230
+ return ;
231
+ }
232
+
233
+ mReporter .reportLocation (location , scanResults , mRadioType , cellInfo );
226
234
}
227
235
}
228
236
229
237
private Collection <ScanResult > getWifiInfo () {
230
-
231
238
Log .d (LOGTAG , "getWifiInfo() called at " + System .currentTimeMillis ());
232
239
if (System .currentTimeMillis () - mWifiScanResultsTime < 5000 && mWifiScanResults != null ) {
233
240
return mWifiScanResults ;
@@ -236,13 +243,6 @@ private Collection<ScanResult> getWifiInfo() {
236
243
return null ;
237
244
}
238
245
239
- private int getRadioType () {
240
- TelephonyManager tm = getTelephonyManager ();
241
- if (tm == null )
242
- return TelephonyManager .PHONE_TYPE_NONE ;
243
- return tm .getPhoneType ();
244
- }
245
-
246
246
private JSONArray getCellInfo () {
247
247
JSONArray cellInfo = new JSONArray ();
248
248
0 commit comments