Skip to content

Commit 8c8e72f

Browse files
author
Doug Turner
committed
Merge pull request #89 from cpeterso/cpeterso/skip-empty-scanresults
Don't upload report if we have no WiFi scan results or cell info
2 parents f551585 + 4f29c91 commit 8c8e72f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Diff for: src/org/mozilla/mozstumbler/Scanner.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ class Scanner implements LocationListener {
4949
private long mWifiScanResultsTime;
5050
private Collection<ScanResult> mWifiScanResults;
5151

52-
private GpsStatus.Listener mGPSListener;
52+
private GpsStatus.Listener mGPSListener;
53+
private final int mRadioType;
5354

5455
Scanner(Context context, Reporter reporter) {
5556
mContext = context;
5657
mReporter = reporter;
58+
59+
TelephonyManager tm = getTelephonyManager();
60+
mRadioType = (tm != null) ? tm.getPhoneType() : TelephonyManager.PHONE_TYPE_NONE;
5761
}
5862

5963
private class WifiReceiver extends BroadcastReceiver {
@@ -219,15 +223,18 @@ public void onLocationChanged(Location location) {
219223
} else {
220224
Log.d(LOGTAG, "New location: " + location);
221225

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);
226234
}
227235
}
228236

229237
private Collection<ScanResult> getWifiInfo() {
230-
231238
Log.d(LOGTAG, "getWifiInfo() called at " + System.currentTimeMillis());
232239
if (System.currentTimeMillis() - mWifiScanResultsTime < 5000 && mWifiScanResults != null) {
233240
return mWifiScanResults;
@@ -236,13 +243,6 @@ private Collection<ScanResult> getWifiInfo() {
236243
return null;
237244
}
238245

239-
private int getRadioType() {
240-
TelephonyManager tm = getTelephonyManager();
241-
if (tm == null)
242-
return TelephonyManager.PHONE_TYPE_NONE;
243-
return tm.getPhoneType();
244-
}
245-
246246
private JSONArray getCellInfo() {
247247
JSONArray cellInfo = new JSONArray();
248248

0 commit comments

Comments
 (0)