Skip to content

Commit

Permalink
Merge pull request #1793 from crankycoder/features/api_17_timestamps
Browse files Browse the repository at this point in the history
put an API 17 guard around grabbing the age for wifi signals
  • Loading branch information
crankycoder committed May 11, 2016
2 parents c22bd17 + c8e01e0 commit 3fcf26a
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,12 @@ public MLSJSONObject toMLSGeosubmit() throws JSONException {

if (mWifiData.size() > 0) {
JSONArray wifis = new JSONArray();
long gpsTimeSinceBootInMS = 0;

if (Build.VERSION.SDK_INT >= 17) {
gpsTimeSinceBootInMS = (mGpsPosition.getElapsedRealtimeNanos() / 1000000);
}

long gpsTimeSinceBootInMS = (mGpsPosition.getElapsedRealtimeNanos()/1000000);
for (ScanResult scanResult : mWifiData.values()) {
JSONObject wifiEntry = new JSONObject();
wifiEntry.put("macAddress", scanResult.BSSID);
Expand All @@ -137,9 +141,12 @@ public MLSJSONObject toMLSGeosubmit() throws JSONException {
wifiEntry.put("signalStrength", scanResult.level);
}

long wifiTimeSinceBootInMS = (scanResult.timestamp / 1000);
long ageMS = wifiTimeSinceBootInMS - gpsTimeSinceBootInMS;
wifiEntry.put("age", ageMS);
if (Build.VERSION.SDK_INT >= 17) {
long wifiTimeSinceBootInMS = (scanResult.timestamp / 1000);
long ageMS = wifiTimeSinceBootInMS - gpsTimeSinceBootInMS;
wifiEntry.put("age", ageMS);
}

wifis.put(wifiEntry);
}
headerFields.put(DataStorageConstants.ReportsColumns.WIFI, wifis);
Expand Down

0 comments on commit 3fcf26a

Please sign in to comment.