Commit e8b4ccb4 authored by gogerald's avatar gogerald Committed by Commit Bot

[StartSurface] Allow disk reads for strict mode

Bug: 1019777
Change-Id: I9e7a2520b588dd0c993fff3a95386d37cee077fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1890793Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711012}
parent eb98d044
......@@ -8,6 +8,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import org.chromium.base.ContextUtils;
import org.chromium.base.StrictModeContext;
/**
* This is a utility class for managing the start surface when returning to Chrome.
......@@ -36,7 +37,11 @@ public final class ReturnToStartSurfaceUtil {
}
private static SharedPreferences getSharedPreferences() {
return ContextUtils.getApplicationContext().getSharedPreferences(
START_SURFACE_PREF_FILE_NAME, Context.MODE_PRIVATE);
// On some versions of Android, creating the Preferences object involves a disk read (to
// check if the Preferences directory exists, not even to read the actual Preferences).
try (StrictModeContext ignored = StrictModeContext.allowDiskReads()) {
return ContextUtils.getApplicationContext().getSharedPreferences(
START_SURFACE_PREF_FILE_NAME, Context.MODE_PRIVATE);
}
}
}
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