simplify code
This commit is contained in:
parent
865c9668a1
commit
02b9b87612
2 changed files with 2 additions and 23 deletions
|
@ -104,11 +104,6 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
private OsmandPreference<Boolean> USE_MAGNETIC_FIELD_SENSOR_COMPASS;
|
||||
private OsmandPreference<Boolean> USE_FILTER_FOR_COMPASS;
|
||||
private static final long AGPS_TO_REDOWNLOAD = 16 * 60 * 60 * 1000; // 16 hours
|
||||
public boolean agpsDownloaded = false;
|
||||
|
||||
public boolean agpsDownloaded() {
|
||||
return agpsDownloaded;
|
||||
}
|
||||
|
||||
|
||||
public class SimulationProvider {
|
||||
|
@ -226,17 +221,10 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
public void resumeAllUpdates() {
|
||||
final LocationManager service = (LocationManager) app.getSystemService(Context.LOCATION_SERVICE);
|
||||
if(app.getSettings().isInternetConnectionAvailable()) {
|
||||
long time = System.currentTimeMillis();
|
||||
if(time - app.getSettings().AGPS_DATA_LAST_TIME_DOWNLOADED.get() > AGPS_TO_REDOWNLOAD) {
|
||||
if(System.currentTimeMillis() - app.getSettings().AGPS_DATA_LAST_TIME_DOWNLOADED.get() > AGPS_TO_REDOWNLOAD) {
|
||||
//force an updated check for internet connectivity here before destroying A-GPS-data
|
||||
if(app.getSettings().isInternetConnectionAvailable(true)) {
|
||||
redownloadAGPS();
|
||||
if(agpsDownloaded == true) {
|
||||
app.getSettings().AGPS_DATA_LAST_TIME_DOWNLOADED.set(time);
|
||||
//for debugging only: try catch issue here where A-GPS data sometimes seems destroyed but not reloaded
|
||||
//} else {
|
||||
// app.getSettings().AGPS_DATA_LAST_TIME_DOWNLOADED.set(0L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -264,14 +252,13 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
}
|
||||
|
||||
public void redownloadAGPS() {
|
||||
agpsDownloaded = false;
|
||||
try {
|
||||
final LocationManager service = (LocationManager) app.getSystemService(Context.LOCATION_SERVICE);
|
||||
service.sendExtraCommand(LocationManager.GPS_PROVIDER,"delete_aiding_data", null);
|
||||
Bundle bundle = new Bundle();
|
||||
service.sendExtraCommand("gps", "force_xtra_injection", bundle);
|
||||
service.sendExtraCommand("gps", "force_time_injection", bundle);
|
||||
agpsDownloaded = true;
|
||||
app.getSettings().AGPS_DATA_LAST_TIME_DOWNLOADED.set(System.currentTimeMillis());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -114,14 +114,6 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
|||
public boolean onPreferenceClick(Preference preference) {
|
||||
if(getMyApplication().getSettings().isInternetConnectionAvailable(true)) {
|
||||
getMyApplication().getLocationProvider().redownloadAGPS();
|
||||
if(getMyApplication().getLocationProvider().agpsDownloaded() == true) {
|
||||
getMyApplication().getSettings().AGPS_DATA_LAST_TIME_DOWNLOADED.set(System.currentTimeMillis());
|
||||
SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
pref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get())));
|
||||
//for debugging only: try catch issue here where A-GPS data sometimes seems destroyed but not reloaded
|
||||
//} else {
|
||||
// getMyApplication().getSettings().AGPS_DATA_LAST_TIME_DOWNLOADED.set(0L);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue