Add StrictMode to the entire app, fixes #399

Only enabled on debug builds. With only logs for now, we can move on to more
annoying penalties like dialogs or crashes once we have solved all of them.
This commit is contained in:
Daniel Martí 2015-09-05 23:22:51 -04:00
parent 232ed2229b
commit bd1db5412b

View File

@ -32,6 +32,7 @@ import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Build;
import android.os.StrictMode;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
@ -154,6 +155,17 @@ public class FDroidApp extends Application {
@Override
public void onCreate() {
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.build());
}
updateLanguage(this);
super.onCreate();