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,21 +124,21 @@ public class TracingControllerAndroidImpl implements TracingControllerAndroid { ...@@ -123,21 +124,21 @@ public class TracingControllerAndroidImpl implements TracingControllerAndroid {
*/ */
@CalledByNative @CalledByNative
private static String generateTracingFilePath() { private static String generateTracingFilePath() {
String state = Environment.getExternalStorageState(); try (StrictModeContext ignored = StrictModeContext.allowDiskWrites()) {
if (!Environment.MEDIA_MOUNTED.equals(state)) { String state = Environment.getExternalStorageState();
return null; if (!Environment.MEDIA_MOUNTED.equals(state)) {
} return null;
}
// 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 =
File dir = Environment.getExternalStoragePublicDirectory( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
Environment.DIRECTORY_DOWNLOADS); File file = new File(dir, "chrome-profile-results-" + formatter.format(new Date()));
File file = new File( return file.getPath();
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