diff options
author | Siva Velusamy <vsiva@google.com> | 2013-06-04 08:51:06 -0700 |
---|---|---|
committer | Siva Velusamy <vsiva@google.com> | 2013-06-04 17:30:48 -0700 |
commit | e7479c60dced910efbbe919649c48ff88b5dadc2 (patch) | |
tree | 22b3814c847227881ce958be1088f9387d44c72e | |
parent | ac47eda797d88ec0d59f7eba668b36ba64902169 (diff) | |
download | sdk-e7479c60dced910efbbe919649c48ff88b5dadc2.zip sdk-e7479c60dced910efbbe919649c48ff88b5dadc2.tar.gz sdk-e7479c60dced910efbbe919649c48ff88b5dadc2.tar.bz2 |
systrace: Support for application tracing
Change-Id: I1b936bdd17a8348bd4bf88c4cccfbe90f43f93c0
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOptionsDialogV2.java (renamed from eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/SystraceOptionsDialogV2.java) | 42 | ||||
-rw-r--r-- | eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/DeviceView.java | 21 |
2 files changed, 54 insertions, 9 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/SystraceOptionsDialogV2.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOptionsDialogV2.java index 887e352..104804a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/views/SystraceOptionsDialogV2.java +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOptionsDialogV2.java @@ -14,12 +14,9 @@ * limitations under the License. */ -package com.android.ide.eclipse.ddms.views; +package com.android.ide.eclipse.ddms.systrace; import com.android.ddmuilib.TableHelper; -import com.android.ide.eclipse.ddms.systrace.ISystraceOptions; -import com.android.ide.eclipse.ddms.systrace.ISystraceOptionsDialog; -import com.android.ide.eclipse.ddms.systrace.SystraceTag; import org.eclipse.jface.dialogs.TitleAreaDialog; import org.eclipse.swt.SWT; @@ -30,6 +27,7 @@ import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FileDialog; @@ -54,20 +52,24 @@ public class SystraceOptionsDialogV2 extends TitleAreaDialog implements ISystrac private String mDestinationPath; private Text mTraceDurationText; private Text mTraceBufferSizeText; + private Combo mTraceAppCombo; private static String sSaveToFolder = System.getProperty("user.home"); //$NON-NLS-1$ private static String sTraceDuration = ""; private static String sTraceBufferSize = ""; private static Set<String> sEnabledTags = new HashSet<String>(); + private static String sLastSelectedApp = null; private final List<SystraceTag> mSupportedTags; + private final List<String> mCurrentApps; private final SystraceOptions mOptions = new SystraceOptions(); private Table mTable; - public SystraceOptionsDialogV2(Shell parentShell, List<SystraceTag> tags) { + public SystraceOptionsDialogV2(Shell parentShell, List<SystraceTag> tags, List<String> apps) { super(parentShell); mSupportedTags = tags; + mCurrentApps = apps; } @Override @@ -114,6 +116,24 @@ public class SystraceOptionsDialogV2 extends TitleAreaDialog implements ISystrac mTraceBufferSizeText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); mTraceBufferSizeText.setText(sTraceBufferSize); + Label lblTraceAppName = new Label(c, SWT.NONE); + lblTraceAppName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + lblTraceAppName.setText("Enable Application Traces from: "); + + mTraceAppCombo = new Combo(c, SWT.DROP_DOWN | SWT.READ_ONLY); + mTraceAppCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); + String[] items = new String[mCurrentApps.size() + 1]; + items[0] = "None"; + for (int i = 0; i < mCurrentApps.size(); i++) { + items[i+1] = mCurrentApps.get(i); + } + mTraceAppCombo.setItems(items); + if (sLastSelectedApp != null) { + mTraceAppCombo.setText(sLastSelectedApp); + } else { + mTraceAppCombo.select(0); + } + Label separator = new Label(c, SWT.SEPARATOR | SWT.HORIZONTAL); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 3; @@ -144,6 +164,7 @@ public class SystraceOptionsDialogV2 extends TitleAreaDialog implements ISystrac for (SystraceTag tag : mSupportedTags) { TableItem item = new TableItem(mTable, SWT.NONE); item.setText(tag.info); + item.setChecked(sEnabledTags.contains(tag.tag)); } TableHelper.createTableColumn(mTable, @@ -247,6 +268,10 @@ public class SystraceOptionsDialogV2 extends TitleAreaDialog implements ISystrac mOptions.mTraceBufferSize = Integer.parseInt(sTraceBufferSize); } + if (mTraceAppCombo.getSelectionIndex() != 0) { + mOptions.mTraceApp = sLastSelectedApp = mTraceAppCombo.getText(); + } + sEnabledTags.clear(); for (int i = 0; i < mTable.getItemCount(); i++) { TableItem it = mTable.getItem(i); @@ -271,6 +296,7 @@ public class SystraceOptionsDialogV2 extends TitleAreaDialog implements ISystrac private class SystraceOptions implements ISystraceOptions { private int mTraceBufferSize; private int mTraceDuration; + private String mTraceApp; @Override public String getTags() { @@ -281,6 +307,12 @@ public class SystraceOptionsDialogV2 extends TitleAreaDialog implements ISystrac public String getOptions() { StringBuilder sb = new StringBuilder(5 * mSupportedTags.size()); + if (mTraceApp != null) { + sb.append("-a "); //$NON-NLS-1$ + sb.append(mTraceApp); + sb.append(' '); + } + if (mTraceDuration > 0) { sb.append("-t"); //$NON-NLS-1$ sb.append(mTraceDuration); 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 3322b9c..f4fa214 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 @@ -46,6 +46,7 @@ import com.android.ide.eclipse.ddms.preferences.PreferenceInitializer; import com.android.ide.eclipse.ddms.systrace.ISystraceOptions; import com.android.ide.eclipse.ddms.systrace.ISystraceOptionsDialog; import com.android.ide.eclipse.ddms.systrace.SystraceOptionsDialogV1; +import com.android.ide.eclipse.ddms.systrace.SystraceOptionsDialogV2; import com.android.ide.eclipse.ddms.systrace.SystraceOutputParser; import com.android.ide.eclipse.ddms.systrace.SystraceTask; import com.android.ide.eclipse.ddms.systrace.SystraceVersionDetector; @@ -89,6 +90,8 @@ import org.eclipse.ui.part.ViewPart; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -577,10 +580,20 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien return; } - final ISystraceOptionsDialog dlg = - (detector.getVersion() == SystraceVersionDetector.SYSTRACE_V1) ? - new SystraceOptionsDialogV1(parentShell) : - new SystraceOptionsDialogV2(parentShell, detector.getTags()); + final ISystraceOptionsDialog dlg; + if (detector.getVersion() == SystraceVersionDetector.SYSTRACE_V1) { + dlg = new SystraceOptionsDialogV1(parentShell); + } else { + Client[] clients = device.getClients(); + List<String> apps = new ArrayList<String>(clients.length); + for (int i = 0; i < clients.length; i++) { + String name = clients[i].getClientData().getClientDescription(); + if (name != null && !name.isEmpty()) { + apps.add(name); + } + } + dlg = new SystraceOptionsDialogV2(parentShell, detector.getTags(), apps); + } if (dlg.open() != SystraceOptionsDialogV1.OK) { return; |