Commit abba550d authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Fix StrictMode violations in ChromeBackupWatcher

Fixes disk read violations in ChromeBackupWatcher.java by briefly
allowing disk reads when notifying the backup manager that data has
changed.

Bug: 1018401
Change-Id: I220f8f967844a9af847777975595d891fb1201d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1888744Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710824}
parent d80e1fc8
......@@ -9,6 +9,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import org.chromium.base.ContextUtils;
import org.chromium.base.StrictModeContext;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
......@@ -39,7 +40,9 @@ public class ChromeBackupWatcher {
SharedPreferences sharedPrefs = ContextUtils.getAppSharedPreferences();
// If we have never done a backup do one immediately.
if (!sharedPrefs.getBoolean(FIRST_BACKUP_DONE, false)) {
mBackupManager.dataChanged();
try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) {
mBackupManager.dataChanged();
}
sharedPrefs.edit().putBoolean(FIRST_BACKUP_DONE, true).apply();
}
sharedPrefs.registerOnSharedPreferenceChangeListener(
......@@ -61,6 +64,8 @@ public class ChromeBackupWatcher {
@CalledByNative
private void onBackupPrefsChanged() {
mBackupManager.dataChanged();
try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) {
mBackupManager.dataChanged();
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment