Bug 1084423 - Fix guards to limit wifi and cellular data per location. r=vng, a=lsblakk
authorGarvan Keeley <gkeeley@mozilla.com>
Fri, 17 Oct 2014 16:02:45 -0700
changeset 225655 c75229ca139e01a6c41cf1e3a026583a7fd95015
parent 225654 c4b405e8f11278ce853c4f0c7b65742c96fb1533
child 225656 6727bcfd4f865719929a6e85498f288eb2e611e8
push id7144
push userryanvm@gmail.com
push dateThu, 23 Oct 2014 00:06:09 +0000
treeherdermozilla-aurora@1d9623f1fdee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvng, lsblakk
bugs1084423
milestone35.0a2
Bug 1084423 - Fix guards to limit wifi and cellular data per location. r=vng, a=lsblakk Without these size guards in place, can result in excessively large collections for a single location.
mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/Reporter.java
--- a/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/Reporter.java
+++ b/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/Reporter.java
@@ -137,30 +137,37 @@ public final class Reporter extends Broa
 
     private void putWifiResults(List<ScanResult> results) {
         if (mBundle == null) {
             return;
         }
 
         Map<String, ScanResult> currentWifiData = mBundle.getWifiData();
         for (ScanResult result : results) {
+            if (currentWifiData.size() > MAX_WIFIS_PER_LOCATION) {
+                return;
+            }
+
             String key = result.BSSID;
             if (!currentWifiData.containsKey(key)) {
                 currentWifiData.put(key, result);
             }
         }
     }
 
     private void putCellResults(List<CellInfo> cells) {
         if (mBundle == null) {
             return;
         }
 
         Map<String, CellInfo> currentCellData = mBundle.getCellData();
         for (CellInfo result : cells) {
+            if (currentCellData.size() > MAX_CELLS_PER_LOCATION) {
+                return;
+            }
             String key = result.getCellIdentity();
             if (!currentCellData.containsKey(key)) {
                 currentCellData.put(key, result);
             }
         }
     }
 
     private void reportCollectedLocation() {
@@ -186,17 +193,19 @@ public final class Reporter extends Broa
             Log.w(LOG_TAG, "Failed to convert bundle to JSON: " + e);
             return;
         }
 
         if (AppGlobals.isDebug) {
             Log.d(LOG_TAG, "Received bundle: " + mlsObj.toString());
         }
 
-        AppGlobals.guiLogInfo(mlsObj.toString());
+        if (wifiCount + cellCount < 1) {
+            return;
+        }
 
         try {
             DataStorageManager.getInstance().insert(mlsObj.toString(), wifiCount, cellCount);
         } catch (IOException e) {
             Log.w(LOG_TAG, e.toString());
         }
     }
 }