Commit 043f5431 authored by torne's avatar torne Committed by Commit bot

Clean up StrictMode.allowThreadDiskReads calls.

allowThreadDiskWrites also allows reads, so it's not necessary to call
both together. Remove all the redundant allowThreadDiskReads calls.

BUG=

Review-Url: https://codereview.chromium.org/2851473007
Cr-Commit-Position: refs/heads/master@{#468050}
parent 4e899699
......@@ -68,8 +68,7 @@ public abstract class PathUtils {
// already finished.
if (sDirPathFetchTask.cancel(false)) {
// Allow disk access here because we have no other choice.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
// sDirPathFetchTask did not complete. We have to run the code it was supposed
// to be responsible for synchronously on the UI thread.
......
......@@ -65,8 +65,7 @@ public class LauncherShortcutActivity extends Activity {
}
// This system call is often modified by OEMs and not actionable. http://crbug.com/619646.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
startActivity(newIntent);
} finally {
......
......@@ -84,8 +84,7 @@ public class BookmarkWidgetService extends RemoteViewsService {
// TODO(crbug.com/635567): Fix this properly.
@SuppressLint("DefaultLocale")
static SharedPreferences getWidgetState(Context context, int widgetId) {
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
return context.getSharedPreferences(
String.format("widgetState-%d", widgetId),
......
......@@ -215,8 +215,7 @@ public class ContextualSearchQuickActionControl extends ViewResourceInflater {
// On KitKat, calling PackageManager#resolveActivity() causes disk reads and writes.
// Temporarily allow this while resolving the intent.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
possibleDefaultActivity = packageManager.resolveActivity(mIntent, 0);
} finally {
......
......@@ -1019,8 +1019,7 @@ public class CustomTabActivity extends ChromeActivity {
intent.putExtra(ChromeLauncherActivity.EXTRA_IS_ALLOWED_TO_RETURN_TO_PARENT, false);
boolean willChromeHandleIntent = getIntentDataProvider().isOpenedByChrome();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
willChromeHandleIntent |= ExternalNavigationDelegateImpl
.willChromeHandleIntent(intent, true);
......@@ -1046,7 +1045,6 @@ public class CustomTabActivity extends ChromeActivity {
tab.detachAndStartReparenting(intent, startActivityOptions, finalizeCallback);
} else {
// Temporarily allowing disk access while fixing. TODO: http://crbug.com/581860
StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
try {
if (mIntentDataProvider.isInfoPage()) {
......
......@@ -77,8 +77,7 @@ public class CustomTabTabPersistencePolicy implements TabPersistencePolicy {
if (sStateDirectory == null) {
sStateDirectory = new File(
TabPersistentStore.getOrCreateBaseStateDirectory(), SAVED_STATE_DIRECTORY);
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
if (!sStateDirectory.exists() && !sStateDirectory.mkdirs()) {
Log.e(TAG, "Failed to create state folder: " + sStateDirectory);
......
......@@ -418,8 +418,7 @@ public class ChromeLauncherActivity extends Activity
}
// This system call is often modified by OEMs and not actionable. http://crbug.com/619646.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
startActivity(newIntent);
} catch (SecurityException ex) {
......
......@@ -262,8 +262,7 @@ public class ExternalAuthUtils {
*/
protected int checkGooglePlayServicesAvailable(final Context context) {
// Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577190
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
long time = SystemClock.elapsedRealtime();
int isAvailable =
......
......@@ -343,7 +343,6 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
boolean activityWasLaunched;
// Only touches disk on Kitkat. See http://crbug.com/617725 for more context.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
StrictMode.allowThreadDiskReads();
try {
forcePdfViewerAsIntentHandlerIfNeeded(intent);
if (proxy) {
......
......@@ -105,8 +105,7 @@ public class CustomNotificationBuilder extends NotificationBuilderBase {
String formattedTime = "";
// Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577185
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
long time = SystemClock.elapsedRealtime();
formattedTime = DateFormat.getTimeFormat(mContext).format(new Date());
......
......@@ -120,8 +120,7 @@ public class ManageSpaceActivity extends AppCompatActivity implements View.OnCli
// Allow reading/writing to disk to check whether the last attempt was successful before
// kicking off the browser process initialization.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
String productVersion = AboutChromePreferences.getApplicationVersion(
this, ChromeVersionInfo.getProductVersion());
......
......@@ -134,8 +134,7 @@ public class TabbedModeTabPersistencePolicy implements TabPersistencePolicy {
if (sStateDirectory == null) {
sStateDirectory = new File(
TabPersistentStore.getOrCreateBaseStateDirectory(), SAVED_STATE_DIRECTORY);
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
if (!sStateDirectory.exists() && !sStateDirectory.mkdirs()) {
Log.e(TAG, "Failed to create state folder: " + sStateDirectory);
......
......@@ -82,10 +82,9 @@ public class VrDaydreamApiImpl implements VrDaydreamApi {
public Boolean isDaydreamCurrentViewer() {
DaydreamApi daydreamApi = DaydreamApi.create(mContext);
if (daydreamApi == null) return false;
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
// If this is the first time any app reads the daydream config file, daydream may create its
// config directory... crbug.com/686104
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
int type = GvrApi.ViewerType.CARDBOARD;
try {
type = daydreamApi.getCurrentViewerType();
......
......@@ -208,8 +208,7 @@ public class WebappActivity extends FullScreenActivity {
File tabFile = new File(activityDirectory, tabFileName);
// Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
long time = SystemClock.elapsedRealtime();
TabState.saveState(tabFile, getActivityTab().getState(), false);
......
......@@ -160,8 +160,7 @@ public class WebappDirectoryManager {
*/
File getWebappDirectory(Context context, String webappId) {
// Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
long time = SystemClock.elapsedRealtime();
File webappDirectory = new File(getBaseWebappDirectory(context), webappId);
......
......@@ -134,8 +134,7 @@ public abstract class CastTestBase extends ChromeActivityTestCaseBase<ChromeActi
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
mOldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
mOldPolicy = StrictMode.allowThreadDiskWrites();
}
});
mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
......
......@@ -81,8 +81,7 @@ public class MediaRouterIntegrationTest extends ChromeActivityTestCaseBase<Chrom
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
mOldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
mOldPolicy = StrictMode.allowThreadDiskWrites();
}
});
mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation().getContext());
......
......@@ -91,8 +91,7 @@ public class ShapeDetectionTest extends ChromeActivityTestCaseBase<ChromeActivit
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
mOldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
mOldPolicy = StrictMode.allowThreadDiskWrites();
}
});
}
......
......@@ -52,8 +52,7 @@ public class MockStorageDelegate extends StorageDelegate {
@Override
public File getStateDirectory() {
// This is a test class, allowing StrictMode violations.
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
if (!mStateDirectory.exists() && !mStateDirectory.mkdirs()) {
Assert.fail("Failed to create state directory. Tests should fail.");
......
......@@ -151,8 +151,7 @@ public class UiUtils {
Context.INPUT_METHOD_SERVICE);
// Third-party touches disk on showSoftInput call. http://crbug.com/619824,
// http://crbug.com/635118
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
StrictMode.allowThreadDiskWrites();
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
try {
imm.showSoftInput(view, 0);
} catch (IllegalArgumentException e) {
......
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