Enable strict mode in OsmAnd~ version
This commit is contained in:
parent
ad455a43ed
commit
7bd0697b09
6 changed files with 38 additions and 48 deletions
|
@ -319,33 +319,33 @@ public class TileSourceManager {
|
|||
final List<TileSourceTemplate> templates = new ArrayList<TileSourceTemplate>();
|
||||
// FIXME android.os.NetworkOnMainThreadException
|
||||
// at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
|
||||
// try {
|
||||
// URLConnection connection = new URL("http://download.osmand.net//tile_sources.php?" + versionAsUrl).openConnection();
|
||||
// XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
||||
// parser.setInput(connection.getInputStream(), "UTF-8");
|
||||
// int tok;
|
||||
// while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||
// if (tok == XmlPullParser.START_TAG) {
|
||||
// String name = parser.getName();
|
||||
// if (name.equals("tile_source")) {
|
||||
// Map<String, String> attrs = new LinkedHashMap<String, String>();
|
||||
// for(int i=0; i< parser.getAttributeCount(); i++) {
|
||||
// attrs.put(parser.getAttributeName(i), parser.getAttributeValue(i));
|
||||
// }
|
||||
// TileSourceTemplate template = createTileSourceTemplate(attrs);
|
||||
// if (template != null) {
|
||||
// templates.add(template);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// log.error("Exception while downloading tile sources", e);
|
||||
// return null;
|
||||
// } catch (XmlPullParserException e) {
|
||||
// log.error("Exception while downloading tile sources", e);
|
||||
// return null;
|
||||
// }
|
||||
try {
|
||||
URLConnection connection = new URL("http://download.osmand.net//tile_sources.php?" + versionAsUrl).openConnection();
|
||||
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
||||
parser.setInput(connection.getInputStream(), "UTF-8");
|
||||
int tok;
|
||||
while ((tok = parser.next()) != XmlPullParser.END_DOCUMENT) {
|
||||
if (tok == XmlPullParser.START_TAG) {
|
||||
String name = parser.getName();
|
||||
if (name.equals("tile_source")) {
|
||||
Map<String, String> attrs = new LinkedHashMap<String, String>();
|
||||
for(int i=0; i< parser.getAttributeCount(); i++) {
|
||||
attrs.put(parser.getAttributeName(i), parser.getAttributeValue(i));
|
||||
}
|
||||
TileSourceTemplate template = createTileSourceTemplate(attrs);
|
||||
if (template != null) {
|
||||
templates.add(template);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Exception while downloading tile sources", e);
|
||||
return null;
|
||||
} catch (XmlPullParserException e) {
|
||||
log.error("Exception while downloading tile sources", e);
|
||||
return null;
|
||||
}
|
||||
return templates;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ import android.graphics.drawable.BitmapDrawable;
|
|||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.StrictMode;
|
||||
import android.text.format.DateFormat;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -103,7 +104,13 @@ public class OsmandApplication extends Application implements ClientContext {
|
|||
@Override
|
||||
public void onCreate() {
|
||||
long timeToStart = System.currentTimeMillis();
|
||||
if (Version.getAppName(this).equals("OsmAnd~")) {
|
||||
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskWrites().detectNetwork().detectCustomSlowCalls().
|
||||
penaltyLog().penaltyDeath().build());
|
||||
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().penaltyDeath().build());
|
||||
}
|
||||
super.onCreate();
|
||||
|
||||
settingsAPI = new net.osmand.plus.api.SettingsAPIImpl(this);
|
||||
externalServiceAPI = new net.osmand.plus.api.ExternalServiceAPIImpl(this);
|
||||
internalToDoAPI = new net.osmand.plus.api.InternalToDoAPIImpl(this);
|
||||
|
|
|
@ -15,8 +15,6 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.StateChangedListener;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -30,6 +28,7 @@ import net.osmand.plus.api.SettingsAPI.SettingsEditor;
|
|||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.routing.RouteProvider.RouteService;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import android.os.Build;
|
||||
|
||||
public class OsmandSettings {
|
||||
|
||||
|
@ -98,7 +97,6 @@ public class OsmandSettings {
|
|||
// cache variables
|
||||
private long lastTimeInternetConnectionChecked = 0;
|
||||
private boolean internetConnectionAvailable = true;
|
||||
private List<TileSourceTemplate> internetAvailableSourceTemplates = null;
|
||||
|
||||
|
||||
protected OsmandSettings(OsmandApplication clientContext) {
|
||||
|
@ -816,12 +814,6 @@ public class OsmandSettings {
|
|||
public final CommonPreference<String> MAP_TILE_SOURCES = new StringPreference("map_tile_sources",
|
||||
TileSourceManager.getMapnikSource().getName()).makeGlobal();
|
||||
|
||||
public List<TileSourceTemplate> getInternetAvailableSourceTemplates(){
|
||||
if(internetAvailableSourceTemplates == null && isInternetConnectionAvailable()){
|
||||
internetAvailableSourceTemplates = TileSourceManager.downloadTileSourceTemplates(Version.getVersionAsURLParam(ctx));
|
||||
}
|
||||
return internetAvailableSourceTemplates;
|
||||
}
|
||||
|
||||
public CommonPreference<String> PREVIOUS_INSTALLED_VERSION = new StringPreference("previous_installed_version", "").makeGlobal();
|
||||
|
||||
|
@ -868,8 +860,6 @@ public class OsmandSettings {
|
|||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
// try to find among other templates
|
||||
ret = checkAmongAvailableTileSources(dir, getInternetAvailableSourceTemplates());
|
||||
if (ret != null) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -882,18 +872,10 @@ public class OsmandSettings {
|
|||
}
|
||||
if (!TileSourceManager.isTileSourceMetaInfoExist(dir)) {
|
||||
TileSourceTemplate ret = checkAmongAvailableTileSources(dir, knownTemplates);
|
||||
if (ret != null) {
|
||||
t = ret;
|
||||
} else {
|
||||
// try to find among other templates
|
||||
ret = checkAmongAvailableTileSources(dir, getInternetAvailableSourceTemplates());
|
||||
if (ret != null) {
|
||||
t = ret;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.content.DialogInterface.OnClickListener;
|
|||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.hardware.SensorManager;
|
||||
import android.media.AudioManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
@ -114,7 +113,6 @@ public class SettingsGeneralActivity extends SettingsBaseActivity {
|
|||
screen.addPreference(applicationDir);
|
||||
}
|
||||
|
||||
screen.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr));
|
||||
screen.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr));
|
||||
|
||||
registerBooleanPreference(settings.USE_ENGLISH_NAMES, screen);
|
||||
|
|
|
@ -28,6 +28,8 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
|||
R.string.trace_rendering, R.string.trace_rendering_descr);
|
||||
cat.addPreference(dbg);
|
||||
|
||||
cat.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr));
|
||||
|
||||
Preference pref = new Preference(this);
|
||||
pref.setTitle(R.string.test_voice_prompts);
|
||||
pref.setSummary(R.string.play_commands_of_currently_selected_voice);
|
||||
|
|
|
@ -105,6 +105,7 @@ public class HillshadeLayer extends MapTileLayer {
|
|||
}
|
||||
|
||||
} while(cursor.moveToNext());
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue