Enable StrictMode during development

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2021-11-01 09:25:41 +01:00
parent f9bfb044dc
commit 9b0db8a355
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7

View file

@ -244,6 +244,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
@SuppressFBWarnings("ST")
@Override
public void onCreate() {
enableStrictMode();
setAppTheme(preferences.getDarkThemeMode());
super.onCreate();
@ -425,6 +427,22 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
}
}
private void enableStrictMode() {
if (BuildConfig.DEBUG) {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectAll()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.build());
}
}
public static void initSyncOperations(
final AppPreferences preferences,
final UploadsStorageManager uploadsStorageManager,