Commit 0a9044e7 authored by Sami Kyostila's avatar Sami Kyostila Committed by Commit Bot

TracingControllerAndroidImpl: Ignore strict mode violation

Ignore a strict mode violation from reading external storage state. We
could do this on a background thread, but since this code path is used for
early startup tracing, we want to minimize how much tracing changes the
normal control flow of the program.

TBR=dtrainor@chromium.org

Bug: 869794
Change-Id: I179a155a2560868839b0610d078e070da3cdfce1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845712Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Commit-Queue: Sami Kyöstilä <skyostil@chromium.org>
Auto-Submit: Sami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704142}
parent a14af81d
......@@ -14,6 +14,7 @@ import android.util.Pair;
import org.chromium.base.Callback;
import org.chromium.base.Log;
import org.chromium.base.StrictModeContext;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
......@@ -123,21 +124,21 @@ public class TracingControllerAndroidImpl implements TracingControllerAndroid {
*/
@CalledByNative
private static String generateTracingFilePath() {
String state = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(state)) {
return null;
}
try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
String state = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(state)) {
return null;
}
// Generate a hopefully-unique filename using the UTC timestamp.
// (Not a huge problem if it isn't unique, we'll just append more data.)
SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd-HHmmss", Locale.US);
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
File dir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_DOWNLOADS);
File file = new File(
dir, "chrome-profile-results-" + formatter.format(new Date()));
return file.getPath();
// Generate a hopefully-unique filename using the UTC timestamp.
// (Not a huge problem if it isn't unique, we'll just append more data.)
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HHmmss", Locale.US);
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
File dir =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File file = new File(dir, "chrome-profile-results-" + formatter.format(new Date()));
return file.getPath();
}
}
/**
......
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