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