Show logs in english in TracingController for adb_chrome_profiler

if the target is not in english, adb_profiler_chrome can 
not know when the profiler is started and finished.
because adb_profiler_chrome uses only english regex for
parsing the logs. So this is a patch for showing the logs 
in english, however it still shows toasts by following 
the target's locale.

BUG=373505

Review URL: https://codereview.chromium.org/282813002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273035 0039d316-1c4b-4281-b951-d872f2087c98
parent d6cbfe88
...@@ -53,6 +53,11 @@ public class TracingControllerAndroid { ...@@ -53,6 +53,11 @@ public class TracingControllerAndroid {
private static final String DEFAULT_CHROME_CATEGORIES_PLACE_HOLDER = private static final String DEFAULT_CHROME_CATEGORIES_PLACE_HOLDER =
"_DEFAULT_CHROME_CATEGORIES"; "_DEFAULT_CHROME_CATEGORIES";
// These strings must match the ones expected by adb_profile_chrome.
private static final String PROFILER_STARTED_FMT = "Profiler started: %s";
private static final String PROFILER_FINISHED_FMT =
"Profiler finished. Results are in %s.";
private final Context mContext; private final Context mContext;
private final TracingBroadcastReceiver mBroadcastReceiver; private final TracingBroadcastReceiver mBroadcastReceiver;
private final TracingIntentFilter mIntentFilter; private final TracingIntentFilter mIntentFilter;
...@@ -191,7 +196,8 @@ public class TracingControllerAndroid { ...@@ -191,7 +196,8 @@ public class TracingControllerAndroid {
return false; return false;
} }
logAndToastInfo(mContext.getString(R.string.profiler_started_toast) + ": " + categories); logForProfiler(String.format(PROFILER_STARTED_FMT, categories));
showToast(mContext.getString(R.string.profiler_started_toast) + ": " + categories);
mFilename = filename; mFilename = filename;
mIsTracing = true; mIsTracing = true;
return true; return true;
...@@ -217,8 +223,8 @@ public class TracingControllerAndroid { ...@@ -217,8 +223,8 @@ public class TracingControllerAndroid {
return; return;
} }
logAndToastInfo( logForProfiler(String.format(PROFILER_FINISHED_FMT, mFilename));
mContext.getString(R.string.profiler_stopped_toast, mFilename)); showToast(mContext.getString(R.string.profiler_stopped_toast, mFilename));
mIsTracing = false; mIsTracing = false;
mFilename = null; mFilename = null;
} }
...@@ -242,13 +248,17 @@ public class TracingControllerAndroid { ...@@ -242,13 +248,17 @@ public class TracingControllerAndroid {
} }
} }
void logAndToastError(String str) { private void logAndToastError(String str) {
Log.e(TAG, str); Log.e(TAG, str);
if (mShowToasts) Toast.makeText(mContext, str, Toast.LENGTH_SHORT).show(); if (mShowToasts) Toast.makeText(mContext, str, Toast.LENGTH_SHORT).show();
} }
void logAndToastInfo(String str) { // The |str| string needs to match the ones that adb_chrome_profiler looks for.
private void logForProfiler(String str) {
Log.i(TAG, str); Log.i(TAG, str);
}
private void showToast(String str) {
if (mShowToasts) Toast.makeText(mContext, str, Toast.LENGTH_SHORT).show(); if (mShowToasts) Toast.makeText(mContext, str, Toast.LENGTH_SHORT).show();
} }
......
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