Enable strict mode for > 9 api level

This commit is contained in:
Victor Shcherb 2013-05-23 20:24:15 +02:00
parent 04baf7f15d
commit 5332b4e839
2 changed files with 21 additions and 4 deletions

View file

@ -29,6 +29,7 @@ import net.osmand.plus.api.InternalToDoAPI;
import net.osmand.plus.api.SQLiteAPI;
import net.osmand.plus.api.SQLiteAPIImpl;
import net.osmand.plus.api.SettingsAPI;
import net.osmand.plus.api.ExternalServiceAPI.AudioFocusHelper;
import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.resources.ResourceManager;
@ -105,10 +106,13 @@ public class OsmandApplication extends Application implements ClientContext {
public void onCreate() {
long timeToStart = System.currentTimeMillis();
if (Version.getAppName(this).equals("OsmAnd~")) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskWrites().detectNetwork().detectCustomSlowCalls().
detectDiskReads().
penaltyLog()./*penaltyDeath().*/build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog()./*penaltyDeath().*/build());
if (android.os.Build.VERSION.SDK_INT >= 9) {
try {
Class.forName("net.osmand.plus.base.EnableStrictMode").newInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
}
super.onCreate();

View file

@ -0,0 +1,13 @@
package net.osmand.plus.base;
import android.os.StrictMode;
public class EnableStrictMode {
public EnableStrictMode(){
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskWrites().detectNetwork().detectCustomSlowCalls().
detectDiskReads().
penaltyLog()./*penaltyDeath().*/build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog()./*penaltyDeath().*/build());
}
}