Skip to content

Commit 6fee0a4

Browse files
author
Moritz Hofmann
committed
Merge branch 'master'
2 parents 86acb1a + eee0db8 commit 6fee0a4

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

app/src/main/java/de/morihofi/wifidb/services/WiFiCollectorService.java

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ public IBinder onBind(Intent intent) {
350350
return null;
351351
}
352352

353+
354+
355+
353356
@Override
354357
public void onLocationChanged(Location location) {
355358
//txtLat = (TextView) findViewById(R.id.textview1);
@@ -363,6 +366,11 @@ public void onLocationChanged(Location location) {
363366
@Override
364367
public void onProviderDisabled(String provider) {
365368
Log.d("Latitude","disable");
369+
370+
//GPS is probably lost, so clear variables
371+
loc_lat = 0d;
372+
loc_lon = 0d;
373+
loc_radius = 0;
366374
}
367375

368376
@Override
@@ -398,35 +406,33 @@ public void onReceive(Context c, Intent intent) {
398406

399407
jobj.put("contributor", contributor);
400408

401-
JSONArray arrnetworks = new JSONArray();
409+
JSONArray arrNetworks = new JSONArray();
402410

403411

404412
for (ScanResult res : mScanResults) {
405413
System.out.println(res);
406-
JSONObject netobj = new JSONObject();
414+
JSONObject netObj = new JSONObject();
407415

408416

409-
netobj.put("bssid", res.BSSID);
410-
netobj.put("essid", res.SSID);
411-
netobj.put("signalstrenght", res.level);
412-
netobj.put("frequency", res.frequency);
413-
netobj.put("capabilities", res.capabilities);
417+
netObj.put("bssid", res.BSSID);
418+
netObj.put("essid", res.SSID);
419+
netObj.put("signalstrenght", res.level);
420+
netObj.put("frequency", res.frequency);
421+
netObj.put("capabilities", res.capabilities);
414422

415-
arrnetworks.put(netobj);
423+
arrNetworks.put(netObj);
416424

417425
}
418426

419-
jobj.put("networks", arrnetworks);
420-
421-
427+
jobj.put("networks", arrNetworks);
422428

423429
if(loc_lat == 0 || loc_lon == 0){
424430
//No Position found
425431
}else{
426432
if(wsclient.isOpen()){
427433
wsclient.send(jobj.toString());
428-
}
429-
if(offlinemode){
434+
}else if(!wsclient.isOpen() || offlinemode){
435+
//Append to offline records, even if there is currently no connection
430436
libfile.appendWifiRecord(getApplicationContext(), jobj);
431437
}
432438
}

0 commit comments

Comments
 (0)