aboutsummaryrefslogtreecommitdiffstats
path: root/eclipse
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2013-07-25 18:39:09 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-07-25 18:39:10 +0000
commiteb2e22567025be7eb1b5cde0eef6c5c0bc947608 (patch)
tree6d31fd74da33f9c8b981d0c2724d1a9089632027 /eclipse
parent46e78a4c146a82afa531b33f8eaf26f28cf53484 (diff)
parent8939be83a03659cf31e9109e4c30943c5f052309 (diff)
downloadsdk-eb2e22567025be7eb1b5cde0eef6c5c0bc947608.zip
sdk-eb2e22567025be7eb1b5cde0eef6c5c0bc947608.tar.gz
sdk-eb2e22567025be7eb1b5cde0eef6c5c0bc947608.tar.bz2
Merge "Use systrace html prefix and suffix from platform tools"
Diffstat (limited to 'eclipse')
-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 b77c34f..e08080b 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 a935d7f..2548edc 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 f4fa214..13a4f99 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());