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; ...@@ -14,6 +14,7 @@ import android.util.Pair;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.base.StrictModeContext;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods; import org.chromium.base.annotations.NativeMethods;
...@@ -123,6 +124,7 @@ public class TracingControllerAndroidImpl implements TracingControllerAndroid { ...@@ -123,6 +124,7 @@ public class TracingControllerAndroidImpl implements TracingControllerAndroid {
*/ */
@CalledByNative @CalledByNative
private static String generateTracingFilePath() { private static String generateTracingFilePath() {
try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
String state = Environment.getExternalStorageState(); String state = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(state)) { if (!Environment.MEDIA_MOUNTED.equals(state)) {
return null; return null;
...@@ -130,15 +132,14 @@ public class TracingControllerAndroidImpl implements TracingControllerAndroid { ...@@ -130,15 +132,14 @@ public class TracingControllerAndroidImpl implements TracingControllerAndroid {
// Generate a hopefully-unique filename using the UTC timestamp. // Generate a hopefully-unique filename using the UTC timestamp.
// (Not a huge problem if it isn't unique, we'll just append more data.) // (Not a huge problem if it isn't unique, we'll just append more data.)
SimpleDateFormat formatter = new SimpleDateFormat( SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HHmmss", Locale.US);
"yyyy-MM-dd-HHmmss", Locale.US);
formatter.setTimeZone(TimeZone.getTimeZone("UTC")); formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
File dir = Environment.getExternalStoragePublicDirectory( File dir =
Environment.DIRECTORY_DOWNLOADS); Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
File file = new File( File file = new File(dir, "chrome-profile-results-" + formatter.format(new Date()));
dir, "chrome-profile-results-" + formatter.format(new Date()));
return file.getPath(); return file.getPath();
} }
}
/** /**
* Start profiling to a new file in the Downloads directory. * Start profiling to a new file in the Downloads directory.
......
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