diff --git a/src/org/mozilla/mozstumbler/Reporter.java b/src/org/mozilla/mozstumbler/Reporter.java index a4e52f342..a0b6f80b0 100644 --- a/src/org/mozilla/mozstumbler/Reporter.java +++ b/src/org/mozilla/mozstumbler/Reporter.java @@ -41,7 +41,7 @@ final class Reporter extends BroadcastReceiver { private static final int RECORD_BATCH_SIZE = 100; private static final int REPORTER_WINDOW = 60000; //ms private static final int WIFI_COUNT_WATERMARK = 500; - private static final int CELLS_COUNT_WATERMARK = 500; + private static final int CELLS_COUNT_WATERMARK = 50; private static String MOZSTUMBLER_USER_AGENT_STRING; @@ -53,7 +53,6 @@ final class Reporter extends BroadcastReceiver { private URL mURL; private ReentrantLock mReportsLock; - private boolean mIsGpsPositionKnown = false; private final Location mGpsPosition = new Location(""); private long mGpsPositionTime; @@ -87,11 +86,15 @@ final class Reporter extends BroadcastReceiver { mContext.registerReceiver(this, new IntentFilter(ScannerService.MESSAGE_TOPIC)); } + private boolean isGpsPositionKnown() { + return (mGpsPositionTime > 0); + } + private void resetData() { mWifiData.clear(); mCellData.clear(); mGpsPosition.reset(); - mIsGpsPositionKnown = false; + mGpsPositionTime = 0; } void shutdown() { @@ -115,10 +118,10 @@ public void onReceive(Context context, Intent intent) { return; } - long time = intent.getLongExtra("time", 0); + long time = intent.getLongExtra("time", System.currentTimeMillis()); String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT); - if (mIsGpsPositionKnown && Math.abs(time - mGpsPositionTime) > REPORTER_WINDOW) { + if (isGpsPositionKnown() && Math.abs(time - mGpsPositionTime) > REPORTER_WINDOW) { reportCollectedLocation(); } @@ -132,10 +135,9 @@ public void onReceive(Context context, Intent intent) { reportCollectedLocation(); Location l = intent.getParcelableExtra(GPSScanner.GPS_SCANNER_ARG_LOCATION); if (l == null) { - mIsGpsPositionKnown = false; + mGpsPositionTime = 0; } else { mGpsPosition.set(l); - mIsGpsPositionKnown = true; mGpsPositionTime = time; } } else { @@ -143,8 +145,8 @@ public void onReceive(Context context, Intent intent) { return; // Intent not aimed at the Reporter (it is possibly for UI instead) } - if (mIsGpsPositionKnown && ((mWifiData.keySet().size() > WIFI_COUNT_WATERMARK) - || (mCellData.keySet().size() > CELLS_COUNT_WATERMARK))) { + if (isGpsPositionKnown() && ((mWifiData.size() > WIFI_COUNT_WATERMARK) + || (mCellData.size() > CELLS_COUNT_WATERMARK))) { reportCollectedLocation(); } } @@ -253,7 +255,7 @@ public void run() { } private void putWifiResults(List results) { - if (!mIsGpsPositionKnown) { + if (!isGpsPositionKnown()) { return; } for (ScanResult result : results) { @@ -265,7 +267,7 @@ private void putWifiResults(List results) { } private void putCellResults(List cells) { - if (!mIsGpsPositionKnown) { + if (!isGpsPositionKnown()) { return; } for (CellInfo result : cells) { @@ -274,7 +276,8 @@ private void putCellResults(List cells) { + " " + result.getMcc() + " " + result.getMnc() + " " + result.getLac() - + " " + result.getCid(); + + " " + result.getCid() + + " " + result.getPsc(); if (!mCellData.containsKey(key)) { mCellData.put(key, result); @@ -283,7 +286,7 @@ private void putCellResults(List cells) { } private void reportCollectedLocation() { - if (!mIsGpsPositionKnown) { + if (!isGpsPositionKnown()) { return; } @@ -337,8 +340,8 @@ void reportLocation(Location gpsPosition, Collection wifiInfo, Strin locInfo.put("lat", gpsPosition.getLatitude()); locInfo.put("lon", gpsPosition.getLongitude()); locInfo.put("time", DateTimeUtils.formatTime(time)); - if (gpsPosition.hasAccuracy()) locInfo.put("accuracy", (int)gpsPosition.getAccuracy()); - if (gpsPosition.hasAltitude()) locInfo.put("altitude", (int)gpsPosition.getAltitude()); + locInfo.put("accuracy", (int)gpsPosition.getAccuracy()); + locInfo.put("altitude", (int)gpsPosition.getAltitude()); if (!cellInfo.isEmpty()) { JSONArray cellJSON=new JSONArray(); diff --git a/src/org/mozilla/mozstumbler/cellscanner/CellInfo.java b/src/org/mozilla/mozstumbler/cellscanner/CellInfo.java index d2d2d6cc9..3c93c3d48 100644 --- a/src/org/mozilla/mozstumbler/cellscanner/CellInfo.java +++ b/src/org/mozilla/mozstumbler/cellscanner/CellInfo.java @@ -90,6 +90,10 @@ public int getLac() { return mLac; } + public int getPsc() { + return mPsc; + } + public JSONObject toJSONObject() { final JSONObject obj = new JSONObject();