Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2688)

Unified Diff: android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java

Issue 2846963005: Allow disk writes while checking webview version pref. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
diff --git a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
index 2cc39b97ca69acee6a4ae5f7b6d975c90e36661c..6d8e29188ba6a08852315c37d1e0a5293714121e 100644
--- a/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
+++ b/android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java
@@ -16,6 +16,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Looper;
import android.os.Process;
+import android.os.StrictMode;
import android.os.UserManager;
import android.provider.Settings;
import android.util.Log;
@@ -247,8 +248,15 @@ public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider {
System.loadLibrary("webviewchromium_plat_support");
// Use shared preference to check for package downgrade.
- mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
- CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE);
+ // Since N, getSharedPreferences creates the preference dir if it doesn't exist,
+ // causing a disk write.
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
+ try {
+ mWebViewPrefs = ContextUtils.getApplicationContext().getSharedPreferences(
+ CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE);
+ } finally {
+ StrictMode.setThreadPolicy(oldPolicy);
+ }
int lastVersion = mWebViewPrefs.getInt(VERSION_CODE_PREF, 0);
int currentVersion = packageInfo.versionCode;
if (!versionCodeGE(currentVersion, lastVersion)) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698