aboutsummaryrefslogtreecommitdiff
path: root/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2013-07-25 10:58:31 -0700
committerSiva Velusamy <vsiva@google.com>2013-07-25 11:00:16 -0700
commit8939be83a03659cf31e9109e4c30943c5f052309 (patch)
tree87cccbbcdd5c062f66d8df532cc8b5cc491cbbd6 /eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android
parent50ab1922a3e5cb1f275dc7f49d7fe8bd8e090728 (diff)
downloadsdk-8939be83a03659cf31e9109e4c30943c5f052309.tar.gz
Use systrace html prefix and suffix from platform tools
Parts of the systrace html file were duplicated in the source code (HTML_PREFIX and SUFFIX) as well as in the systrace scripts. This CL picks up that content from data files present in the systrace folder and removes the duplicated content from the source files. Change-Id: I517d23faa14022a666a7f314ffbb34187b1fed1f
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOutputParser.java68
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java13
3 files changed, 39 insertions, 46 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
index b77c34f1a..e08080bf0 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/DdmsPlugin.java
@@ -490,6 +490,10 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL
return sAdbLocation;
}
+ public static File getPlatformToolsFolder() {
+ return new File(sAdbLocation).getParentFile();
+ }
+
public static String getToolsFolder() {
return sToolsFolder;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOutputParser.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOutputParser.java
index a935d7f51..2548edc23 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOutputParser.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOutputParser.java
@@ -29,50 +29,11 @@ import java.util.zip.Inflater;
public class SystraceOutputParser {
private static final String TRACE_START = "TRACE:\n"; //$NON-NLS-1$
- private static final String HTML_PREFIX = "<!DOCTYPE HTML>\n"
- + "<html>\n"
- + "<head i18n-values=\"dir:textdirection;\">\n"
- + "<title>Android System Trace</title>\n"
- + "%s\n"
- + "%s\n"
- + "<script language=\"javascript\">\n"
- + "document.addEventListener('DOMContentLoaded', function() {\n"
- + " if (!linuxPerfData)\n"
- + " return;\n"
- + " var m = new tracing.Model(linuxPerfData);\n"
- + " var timelineViewEl = document.querySelector('.view');\n"
- + " tracing.ui.decorate(timelineViewEl, tracing.TimelineView);\n"
- + " timelineViewEl.model = m;\n"
- + " timelineViewEl.tabIndex = 1;\n"
- + " timelineViewEl.timeline.focusElement = timelineViewEl;\n"
- + "});\n"
- + "</script>\n"
- + "<style>\n"
- + " .view {\n"
- + " overflow: hidden;\n"
- + " position: absolute;\n"
- + " top: 0;\n"
- + " bottom: 0;\n"
- + " left: 0;\n"
- + " right: 0;\n"
- + " }\n"
- + "</style>\n"
- + "</head>\n"
- + "<body>\n"
- + " <div class=\"view\">\n"
- + " </div>\n"
- + " <script>\n"
- + " var linuxPerfData = \"\\\n";
-
- private static final String HTML_SUFFIX =
- " dummy-0000 [000] 0.0: 0: trace_event_clock_sync: parent_ts=0.0\\n\";\n"
- + " </script>\n"
- + "</body>\n"
- + "</html>\n";
-
private final boolean mUncompress;
private final String mJs;
private final String mCss;
+ private final String mHtmlPrefix;
+ private final String mHtmlSuffix;
private byte[] mAtraceOutput;
private int mAtraceLength;
@@ -84,10 +45,13 @@ public class SystraceOutputParser {
* @param systraceJs systrace javascript content
* @param systraceCss systrace css content
*/
- public SystraceOutputParser(boolean compressedStream, String systraceJs, String systraceCss) {
+ public SystraceOutputParser(boolean compressedStream, String systraceJs, String systraceCss,
+ String htmlPrefix, String htmlSuffix) {
mUncompress = compressedStream;
mJs = systraceJs;
mCss = systraceCss;
+ mHtmlPrefix = htmlPrefix;
+ mHtmlSuffix = htmlSuffix;
}
/**
@@ -164,8 +128,8 @@ public class SystraceOutputParser {
// each line should end with the characters \n\ followed by a newline
String html_out = trace.replaceAll("\n", "\\\\n\\\\\n");
- String header = String.format(HTML_PREFIX, mCss, mJs);
- String footer = HTML_SUFFIX;
+ String header = String.format(mHtmlPrefix, mCss, mJs, "");
+ String footer = mHtmlSuffix;
return header + html_out + footer;
}
@@ -186,4 +150,20 @@ public class SystraceOutputParser {
return "";
}
}
+
+ public static String getHtmlPrefix(File assetsFolder) {
+ return getHtmlTemplate(assetsFolder, "prefix.html");
+ }
+
+ public static String getHtmlSuffix(File assetsFolder) {
+ return getHtmlTemplate(assetsFolder, "suffix.html");
+ }
+
+ private static String getHtmlTemplate(File assetsFolder, String htmlFileName) {
+ try {
+ return Files.toString(new File(assetsFolder, htmlFileName), Charsets.UTF_8);
+ } catch (IOException e) {
+ return "";
+ }
+ }
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java
index f4fa214e6..13a4f9969 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java
@@ -568,6 +568,14 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien
};
private void launchSystrace(final IDevice device, final Shell parentShell) {
+ final File systraceAssets = new File(DdmsPlugin.getPlatformToolsFolder(), "systrace"); //$NON-NLS-1$
+ if (!systraceAssets.isDirectory()) {
+ MessageDialog.openError(parentShell, "Systrace",
+ "Updated version of platform-tools (18.0.1 or greater) is required.\n"
+ + "Please update your platform-tools using SDK Manager.");
+ return;
+ }
+
SystraceVersionDetector detector = new SystraceVersionDetector(device);
try {
new ProgressMonitorDialog(parentShell).run(true, false, detector);
@@ -659,11 +667,12 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien
}
monitor.setTaskName("Saving trace information");
- File systraceAssets = new File(DdmsPlugin.getToolsFolder(), "systrace"); //$NON-NLS-1$
SystraceOutputParser parser = new SystraceOutputParser(
COMPRESS_DATA,
SystraceOutputParser.getJs(systraceAssets),
- SystraceOutputParser.getCss(systraceAssets));
+ SystraceOutputParser.getCss(systraceAssets),
+ SystraceOutputParser.getHtmlPrefix(systraceAssets),
+ SystraceOutputParser.getHtmlSuffix(systraceAssets));
parser.parse(task.getAtraceOutput());