StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); final File reportFile = getReportFileName(crashReportData); saveCrashReportFile(reportFile, crashReportData);
static SharedPreferences getWidgetState(Context context, int widgetId) { StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { return context.getSharedPreferences( String.format("widgetState-%d", widgetId), Context.MODE_PRIVATE); } finally { StrictMode.setThreadPolicy(oldPolicy); } }
/** * The folder where the state should be saved to. * @return A file representing the directory that contains TabModelSelector states. */ public static File getOrCreateStateDirectory() { synchronized (DIR_CREATION_LOCK) { if (sStateDirectory == null) { sStateDirectory = new File( BaseStateDirectoryHolder.sDirectory, SAVED_STATE_DIRECTORY); StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { if (!sStateDirectory.exists() && !sStateDirectory.mkdirs()) { Log.e(TAG, "Failed to create state folder: " + sStateDirectory); } } finally { StrictMode.setThreadPolicy(oldPolicy); } } } return sStateDirectory; }
/** * Returns the directory for a web app, creating it if necessary. * @param webappId ID for the web app. Used as a subdirectory name. * @return File for storing information about the web app. */ File getWebappDirectory(Context context, String webappId) { // Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { long time = SystemClock.elapsedRealtime(); File webappDirectory = new File(getBaseWebappDirectory(context), webappId); if (!webappDirectory.exists() && !webappDirectory.mkdir()) { Log.e(TAG, "Failed to create web app directory."); } RecordHistogram.recordTimesHistogram("Android.StrictMode.WebappDir", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); return webappDirectory; } finally { StrictMode.setThreadPolicy(oldPolicy); } }
@SuppressLint("InlinedApi") private void launchTabbedMode() { maybePrefetchDnsInBackground(); Intent newIntent = new Intent(getIntent()); String className = MultiWindowUtils.getInstance().getTabbedActivityForIntent( newIntent, this).getName(); newIntent.setClassName(getApplicationContext().getPackageName(), className); newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { newIntent.addFlags(Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS); } Uri uri = newIntent.getData(); if (uri != null && "content".equals(uri.getScheme())) { newIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } if (mIsInLegacyMultiInstanceMode) { MultiWindowUtils.getInstance().makeLegacyMultiInstanceIntent(this, newIntent); } // This system call is often modified by OEMs and not actionable. http://crbug.com/619646. StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { startActivity(newIntent); } finally { StrictMode.setThreadPolicy(oldPolicy); } }
@Override public boolean onCreate() { final Context context = getContext(); StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); mOpenHelper = new DatabaseHelper(context); StrictMode.setThreadPolicy(oldPolicy); LauncherAppState.setLauncherProvider(this); return true; }
/** * Invokes whatever external code is necessary to check if Google Play Services is available * and returns the code produced by the attempt. Subclasses can override to force the behavior * one way or another, or to change the way that the check is performed. * @param context The current context. * @return The code produced by calling the external code */ protected int checkGooglePlayServicesAvailable(final Context context) { // Temporarily allowing disk access. TODO: Fix. See http://crbug.com/577190 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { long time = SystemClock.elapsedRealtime(); int isAvailable = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context); mRegistrationTimeHistogramSample.record(SystemClock.elapsedRealtime() - time); return isAvailable; } finally { StrictMode.setThreadPolicy(oldPolicy); } }
StrictMode.allowThreadDiskWrites(); try { String productVersion = AboutChromePreferences.getApplicationVersion(
/** * Saves the tab data out to a file. */ void saveState(File activityDirectory) { String tabFileName = TabState.getTabStateFilename(getActivityTab().getId(), false); File tabFile = new File(activityDirectory, tabFileName); FileOutputStream foutput = null; // Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); try { long time = SystemClock.elapsedRealtime(); foutput = new FileOutputStream(tabFile); TabState.saveState(foutput, getActivityTab().getState(), false); RecordHistogram.recordTimesHistogram("Android.StrictMode.WebappSaveState", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); } catch (FileNotFoundException exception) { Log.e(TAG, "Failed to save out tab state.", exception); } catch (IOException exception) { Log.e(TAG, "Failed to save out tab state.", exception); } finally { StreamUtil.closeQuietly(foutput); StrictMode.setThreadPolicy(oldPolicy); } }
StrictMode.allowThreadDiskWrites(); try { willChromeHandleIntent |= ExternalNavigationDelegateImpl StrictMode.allowThreadDiskWrites(); try { startActivity(intent, startActivityOptions);
try { StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); switch (method) { case "getHooks":
@Override public boolean startActivityIfNeeded(Intent intent) { boolean activityWasLaunched; // Only touches disk on Kitkat. See http://crbug.com/617725 for more context. StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); StrictMode.allowThreadDiskReads(); try { forcePdfViewerAsIntentHandlerIfNeeded(mApplicationContext, intent); Context context = getAvailableContext(); if (context instanceof Activity) { activityWasLaunched = ((Activity) context).startActivityIfNeeded(intent, -1); } else { activityWasLaunched = false; } if (activityWasLaunched) recordExternalNavigationDispatched(intent); return activityWasLaunched; } catch (RuntimeException e) { logTransactionTooLargeOrRethrow(e, intent); return false; } finally { StrictMode.setThreadPolicy(oldPolicy); } }
try { StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); switch (method) { case "getVersion":
public void saveState() { StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); try { long saveStateStartTime = SystemClock.uptimeMillis();
StrictMode.allowThreadDiskWrites(); try { long time = SystemClock.elapsedRealtime();