Merge pull request #9186 from nextcloud/strictMode

Enable StrictMode during development
This commit is contained in:
Álvaro Brey 2021-11-09 09:59:03 +01:00 committed by GitHub
commit f0ee7d719e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -244,6 +244,8 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
@SuppressFBWarnings("ST") @SuppressFBWarnings("ST")
@Override @Override
public void onCreate() { public void onCreate() {
enableStrictMode();
setAppTheme(preferences.getDarkThemeMode()); setAppTheme(preferences.getDarkThemeMode());
super.onCreate(); 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( public static void initSyncOperations(
final AppPreferences preferences, final AppPreferences preferences,
final UploadsStorageManager uploadsStorageManager, final UploadsStorageManager uploadsStorageManager,
@ -433,7 +451,7 @@ public class MainApp extends MultiDexApplication implements HasAndroidInjector {
final PowerManagementService powerManagementService, final PowerManagementService powerManagementService,
final BackgroundJobManager backgroundJobManager, final BackgroundJobManager backgroundJobManager,
final Clock clock final Clock clock
) { ) {
updateToAutoUpload(); updateToAutoUpload();
cleanOldEntries(clock); cleanOldEntries(clock);
updateAutoUploadEntries(clock); updateAutoUploadEntries(clock);