diff options
Diffstat (limited to 'eclipse')
10 files changed, 432 insertions, 101 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.properties b/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.properties index f4eb2b0..0593679 100644 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.properties +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.properties @@ -17,4 +17,5 @@ page.name.LogCat = LogCat extension-point.name.Tools_Locator = Tools Locator extension-point.name.Debugger_Connector = Debugger Connector extension-point.name.Source_Revealer = Source Revealer -extension-point.name.TreeView_Laucher = TraceView Launcher
\ No newline at end of file +extension-point.name.TreeView_Laucher = TraceView Launcher +extension-point.name.ClientAction = Client Specific Actions
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml index 4738ba9..43d10cf 100644 --- a/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/plugin.xml @@ -5,6 +5,7 @@ <extension-point id="debuggerConnector" name="%extension-point.name.Debugger_Connector" schema="schema/debuggerConnector.exsd"/> <extension-point id="sourceRevealer" name="%extension-point.name.Source_Revealer" schema="schema/sourceRevealer.exsd"/> <extension-point id="traceviewLauncher" name="%extension-point.name.TreeView_Laucher" schema="schema/traceviewLauncher.exsd"/> + <extension-point id="clientAction" name="%extension-point.name.ClientAction" schema="schema/clientAction.exsd"/> <extension point="org.eclipse.ui.views"> diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/schema/clientAction.exsd b/eclipse/plugins/com.android.ide.eclipse.ddms/schema/clientAction.exsd new file mode 100644 index 0000000..f277bb0 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/schema/clientAction.exsd @@ -0,0 +1,94 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="com.android.ide.eclipse.ddms" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="com.android.ide.eclipse.ddms" id="clientAction" name="%extension-point.name.ClientAction"/> + </appInfo> + <documentation> + Extension point that allows adding custom actions to the DDMS Device Panel to act on the currently selected client (Dalvik VM). + </documentation> + </annotation> + + <element name="clientAction"> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":com.android.ide.eclipse.ddms.IClientAction"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <sequence> + <element ref="clientAction"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + 21.1.0 + </documentation> + </annotation> + + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + Extensions must implement com.android.ide.ddms.IClientAction + </documentation> + </annotation> + + + <annotation> + <appInfo> + <meta.section type="copyright"/> + </appInfo> + <documentation> + Copyright (C) 2012 The Android Open Source Project + </documentation> + </annotation> + +</schema> 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 fe8c709..b77c34f 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 @@ -16,6 +16,7 @@ package com.android.ide.eclipse.ddms; +import com.android.annotations.NonNull; import com.android.ddmlib.AndroidDebugBridge; import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener; import com.android.ddmlib.Client; @@ -61,6 +62,8 @@ import org.osgi.framework.BundleContext; import java.io.File; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collections; +import java.util.List; /** * The activator class controls the plug-in life cycle @@ -86,7 +89,7 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL */ private IDebuggerConnector[] mDebuggerConnectors; private ITraceviewLauncher[] mTraceviewLaunchers; - + private List<IClientAction> mClientSpecificActions = null; /** Console for DDMS log message */ private MessageConsole mDdmsConsole; @@ -426,6 +429,29 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL return list.toArray(new ITraceviewLauncher[list.size()]); } + /** + * Returns the classes that implement {@link IClientAction} in each of the extensions that + * extend clientAction extension point. + * @throws CoreException + */ + private List<IClientAction> instantiateClientSpecificActions(IConfigurationElement[] elements) + throws CoreException { + if (elements == null || elements.length == 0) { + return Collections.emptyList(); + } + + List<IClientAction> extensions = new ArrayList<IClientAction>(1); + + for (IConfigurationElement e : elements) { + Object o = e.createExecutableExtension("class"); //$NON-NLS-1$ + if (o instanceof IClientAction) { + extensions.add((IClientAction) o); + } + } + + return extensions; + } + public static Display getDisplay() { IWorkbench bench = sPlugin.getWorkbench(); if (bench != null) { @@ -811,6 +837,25 @@ public final class DdmsPlugin extends AbstractUIPlugin implements IDeviceChangeL return false; } + /** + * Returns the list of clients that extend the clientAction extension point. + */ + @NonNull + public synchronized List<IClientAction> getClientSpecificActions() { + if (mClientSpecificActions == null) { + // get available client specific action extensions + IConfigurationElement[] elements = + findConfigElements("com.android.ide.eclipse.ddms.clientAction"); //$NON-NLS-1$ + try { + mClientSpecificActions = instantiateClientSpecificActions(elements); + } catch (CoreException e) { + mClientSpecificActions = Collections.emptyList(); + } + } + + return mClientSpecificActions; + } + private LogCatMonitor mLogCatMonitor; public void startLogCatMonitor(IDevice device) { if (mLogCatMonitor == null) { diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IClientAction.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IClientAction.java new file mode 100644 index 0000000..c231975 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/IClientAction.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ide.eclipse.ddms; + +import com.android.ddmlib.Client; + +import org.eclipse.jface.action.Action; + +public interface IClientAction { + Action getAction(); + void selectedClientChanged(Client c); +} 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 e9cafce..3322b9c 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 @@ -38,6 +38,7 @@ import com.android.ddmuilib.SyncProgressHelper.SyncRunnable; import com.android.ddmuilib.handler.BaseFileHandler; import com.android.ddmuilib.handler.MethodProfilingHandler; import com.android.ide.eclipse.ddms.DdmsPlugin; +import com.android.ide.eclipse.ddms.IClientAction; import com.android.ide.eclipse.ddms.IDebuggerConnector; import com.android.ide.eclipse.ddms.editors.UiAutomatorViewer; import com.android.ide.eclipse.ddms.i18n.Messages; @@ -767,6 +768,10 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien mTracingAction.setToolTipText(Messages.DeviceView_Start_Method_Profiling_Tooltip); mTracingAction.setText(Messages.DeviceView_Start_Method_Profiling); } + + for (IClientAction a : DdmsPlugin.getDefault().getClientSpecificActions()) { + a.selectedClientChanged(selectedClient); + } } private void doSelectionChanged(IDevice selectedDevice) { @@ -804,6 +809,9 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien menuManager.add(mSystraceAction); menuManager.add(new Separator()); menuManager.add(mResetAdbAction); + for (IClientAction a : DdmsPlugin.getDefault().getClientSpecificActions()) { + menuManager.add(a.getAction()); + } // and then in the toolbar IToolBarManager toolBarManager = actionBars.getToolBarManager(); @@ -824,6 +832,9 @@ public class DeviceView extends ViewPart implements IUiSelectionListener, IClien toolBarManager.add(mViewUiAutomatorHierarchyAction); toolBarManager.add(new Separator()); toolBarManager.add(mSystraceAction); + for (IClientAction a : DdmsPlugin.getDefault().getClientSpecificActions()) { + toolBarManager.add(a.getAction()); + } } @Override diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.gldebugger/plugin.xml index 6c25822..5806b3c 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/plugin.xml +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/plugin.xml @@ -1,93 +1,99 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<plugin>
-
- <extension
- point="org.eclipse.ui.views">
- <category
- id="com.android.ide.eclipse.gltrace"
- name="Tracer for OpenGL ES">
- </category>
- <view
- category="com.android.ide.eclipse.gltrace"
- class="com.android.ide.eclipse.gltrace.views.FrameSummaryView"
- icon="icons/opengl.png"
- id="com.android.ide.eclipse.gltrace.views.FrameBuffer"
- name="Frame Summary"
- restorable="true">
- </view>
- <view
- category="com.android.ide.eclipse.gltrace"
- class="com.android.ide.eclipse.gltrace.views.StateView"
- icon="icons/opengl.png"
- id="com.android.ide.eclipse.gltrace.views.State"
- name="GL State"
- restorable="true">
- </view>
- <view
- category="com.android.ide.eclipse.gltrace"
- class="com.android.ide.eclipse.gltrace.views.detail.DetailsView"
- icon="icons/opengl.png"
- id="com.android.ide.eclipse.gltrace.views.Details"
- name="Details"
- restorable="true">
- </view>
- </extension>
- <extension
- point="org.eclipse.ui.editors">
- <editor
- class="com.android.ide.eclipse.gltrace.editors.GLFunctionTraceViewer"
- default="true"
- extensions="gltrace"
- icon="icons/opengl.png"
- id="com.android.ide.eclipse.gltrace.GLFunctionTrace"
- name="GL Function Trace">
- </editor>
- </extension>
- <extension
- point="org.eclipse.ui.actionSets">
- <actionSet
- description="OpenGL Trace Actions"
- id="com.android.ide.eclipse.gltrace.actionset"
- label="OpenGL Trace Actions"
- visible="false">
- <action
- class="com.android.ide.eclipse.gltrace.CollectTraceAction"
- icon="icons/connect.png"
- id="gltrace.action.connect"
- label="Collects OpenGL trace from device"
- style="push"
- toolbarPath="Normal/additions"
- tooltip="Connects to the device and collects OpenGL trace information">
- </action>
- <action
- class="com.android.ide.eclipse.gltrace.OpenGLTraceAction"
- icon="icons/opengl.png"
- id="gltrace.action.open"
- label="Open GL Trace File"
- style="push"
- toolbarPath="Normal/additions"
- tooltip="Open a saved OpenGL Trace File">
- </action>
- </actionSet>
- </extension>
- <extension
- point="org.eclipse.ui.perspectives">
- <perspective
- class="com.android.ide.eclipse.gltrace.GLTracePerspective"
- icon="icons/opengl.png"
- id="com.android.ide.eclipse.gltrace.perspective"
- name="Tracer for OpenGL ES">
- </perspective>
- </extension>
- <extension
- point="org.eclipse.ui.perspectiveExtensions">
- <perspectiveExtension
- targetID="com.android.ide.eclipse.gltrace.perspective">
- <actionSet
- id="com.android.ide.eclipse.gltrace.actionset">
- </actionSet>
- </perspectiveExtension>
- </extension>
-
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<plugin> + + <extension + point="org.eclipse.ui.views"> + <category + id="com.android.ide.eclipse.gltrace" + name="Tracer for OpenGL ES"> + </category> + <view + category="com.android.ide.eclipse.gltrace" + class="com.android.ide.eclipse.gltrace.views.FrameSummaryView" + icon="icons/opengl.png" + id="com.android.ide.eclipse.gltrace.views.FrameBuffer" + name="Frame Summary" + restorable="true"> + </view> + <view + category="com.android.ide.eclipse.gltrace" + class="com.android.ide.eclipse.gltrace.views.StateView" + icon="icons/opengl.png" + id="com.android.ide.eclipse.gltrace.views.State" + name="GL State" + restorable="true"> + </view> + <view + category="com.android.ide.eclipse.gltrace" + class="com.android.ide.eclipse.gltrace.views.detail.DetailsView" + icon="icons/opengl.png" + id="com.android.ide.eclipse.gltrace.views.Details" + name="Details" + restorable="true"> + </view> + </extension> + <extension + point="org.eclipse.ui.editors"> + <editor + class="com.android.ide.eclipse.gltrace.editors.GLFunctionTraceViewer" + default="true" + extensions="gltrace" + icon="icons/opengl.png" + id="com.android.ide.eclipse.gltrace.GLFunctionTrace" + name="GL Function Trace"> + </editor> + </extension> + <extension + point="org.eclipse.ui.actionSets"> + <actionSet + description="OpenGL Trace Actions" + id="com.android.ide.eclipse.gltrace.actionset" + label="OpenGL Trace Actions" + visible="false"> + <action + class="com.android.ide.eclipse.gltrace.CollectTraceAction" + icon="icons/connect.png" + id="gltrace.action.connect" + label="Collects OpenGL trace from device" + style="push" + toolbarPath="Normal/additions" + tooltip="Connects to the device and collects OpenGL trace information"> + </action> + <action + class="com.android.ide.eclipse.gltrace.OpenGLTraceAction" + icon="icons/opengl.png" + id="gltrace.action.open" + label="Open GL Trace File" + style="push" + toolbarPath="Normal/additions" + tooltip="Open a saved OpenGL Trace File"> + </action> + </actionSet> + </extension> + <extension + point="org.eclipse.ui.perspectives"> + <perspective + class="com.android.ide.eclipse.gltrace.GLTracePerspective" + icon="icons/opengl.png" + id="com.android.ide.eclipse.gltrace.perspective" + name="Tracer for OpenGL ES"> + </perspective> + </extension> + <extension + point="org.eclipse.ui.perspectiveExtensions"> + <perspectiveExtension + targetID="com.android.ide.eclipse.gltrace.perspective"> + <actionSet + id="com.android.ide.eclipse.gltrace.actionset"> + </actionSet> + </perspectiveExtension> + </extension> + <extension + point="com.android.ide.eclipse.ddms.clientAction"> + <clientAction + class="com.android.ide.eclipse.gltrace.DeviceViewAction"> + </clientAction> + </extension> + +</plugin> diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/CollectTraceAction.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/CollectTraceAction.java index 5e97305..f28e0f0 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/CollectTraceAction.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/CollectTraceAction.java @@ -25,6 +25,7 @@ import com.android.ddmlib.IShellOutputReceiver; import com.android.ddmlib.ShellCommandUnresponsiveException; import com.android.ddmlib.TimeoutException; import com.android.ide.eclipse.gltrace.editors.GLFunctionTraceViewer; +import com.google.common.io.Closeables; import com.google.common.util.concurrent.SimpleTimeLimiter; import org.eclipse.core.filesystem.EFS; @@ -45,6 +46,7 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.WorkbenchException; import org.eclipse.ui.ide.IDE; import java.io.DataInputStream; @@ -122,6 +124,7 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { } catch (Exception e) { MessageDialog.openError(shell, "Setup GL Trace", "Error while setting up port forwarding: " + e.getMessage()); + return; } try { @@ -146,7 +149,7 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { openInEditor(shell, traceOptions.traceDestination); } - private void openInEditor(Shell shell, String traceFilePath) { + public static void openInEditor(Shell shell, String traceFilePath) { final IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(traceFilePath)); if (!fileStore.fetchInfo().exists()) { return; @@ -163,6 +166,11 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { return; } + try { + workbench.showPerspective("com.android.ide.eclipse.gltrace.perspective", window); + } catch (WorkbenchException e) { + } + // if there is a editor already open, then refresh its model GLFunctionTraceViewer viewer = getOpenTraceViewer(page, traceFilePath); if (viewer != null) { @@ -186,7 +194,8 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { * @return if given trace file is already open, then a reference to that editor part, * null otherwise */ - private GLFunctionTraceViewer getOpenTraceViewer(IWorkbenchPage page, String traceFilePath) { + private static GLFunctionTraceViewer getOpenTraceViewer(IWorkbenchPage page, + String traceFilePath) { IEditorReference[] editorRefs = page.getEditorReferences(); for (IEditorReference ref : editorRefs) { String id = ref.getId(); @@ -213,7 +222,8 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { return null; } - private void startTracing(Shell shell, TraceOptions traceOptions, int port) { + @SuppressWarnings("resource") // Closeables.closeQuietly + public static void startTracing(Shell shell, TraceOptions traceOptions, int port) { FileOutputStream fos = null; try { fos = new FileOutputStream(traceOptions.traceDestination, false); @@ -233,6 +243,7 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { MessageDialog.openError(shell, "OpenGL Trace", "Unable to connect to remote GL Trace Server: " + e.getMessage()); + Closeables.closeQuietly(fos); return; } @@ -247,6 +258,7 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { "OpenGL Trace", "Unexpected error while setting trace options: " + e.getMessage()); closeSocket(socket); + Closeables.closeQuietly(fos); return; } @@ -265,7 +277,7 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { closeSocket(socket); } - private void closeSocket(Socket socket) { + private static void closeSocket(Socket socket) { try { socket.close(); } catch (IOException e) { @@ -362,12 +374,12 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { } } - private void setupForwarding(IDevice device, int i) + public static void setupForwarding(IDevice device, int i) throws TimeoutException, AdbCommandRejectedException, IOException { device.createForward(i, GLTRACE_UDS, DeviceUnixSocketNamespace.ABSTRACT); } - private void disablePortForwarding(IDevice device, int port) { + public static void disablePortForwarding(IDevice device, int port) { try { device.removeForward(port, GLTRACE_UDS, DeviceUnixSocketNamespace.ABSTRACT); } catch (Exception e) { diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/DeviceViewAction.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/DeviceViewAction.java new file mode 100644 index 0000000..7d912ba --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/DeviceViewAction.java @@ -0,0 +1,113 @@ +package com.android.ide.eclipse.gltrace; + +import com.android.ddmlib.Client; +import com.android.ddmlib.ClientData; +import com.android.ide.eclipse.ddms.IClientAction; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import java.lang.reflect.InvocationTargetException; + +public class DeviceViewAction implements IClientAction { + private static final class StartTraceAction extends Action { + private static final int LOCAL_FORWARDED_PORT = 6049; + + private Client mClient; + + public StartTraceAction() { + super("Start OpenGL Trace"); + setImageDescriptor(GlTracePlugin.getImageDescriptor("/icons/connect.png")); //$NON-NLS-1$ + setClient(null); + } + + public void setClient(Client c) { + mClient = c; + clientChanged(); + } + + private void clientChanged() { + if (mClient == null) { + setEnabled(false); + return; + } + + ClientData cd = mClient.getClientData(); + if (cd.hasFeature(ClientData.FEATURE_OPENGL_TRACING)) { + setEnabled(true); + setToolTipText("Trace OpenGL calls"); + } else { + setEnabled(false); + setToolTipText("Selected VM does not support tracing OpenGL calls"); + } + } + + @Override + public void run() { + if (mClient == null) { + return; + } + + Shell shell = Display.getDefault().getActiveShell(); + GLTraceOptionsDialog dlg = new GLTraceOptionsDialog(shell, false, + mClient.getClientData().getClientDescription()); + if (dlg.open() != Window.OK) { + return; + } + + // start tracing on the client + mClient.startOpenGlTracing(); + + try { + CollectTraceAction.setupForwarding(mClient.getDevice(), LOCAL_FORWARDED_PORT); + } catch (Exception e) { + MessageDialog.openError(shell, "Setup GL Trace", + "Error while setting up port forwarding: " + e.getMessage()); + return; + } + + // wait for a few seconds for the client to start the trace server + try { + new ProgressMonitorDialog(shell).run(true, true, new IRunnableWithProgress() { + @Override + public void run(IProgressMonitor monitor) + throws InvocationTargetException, InterruptedException { + Thread.sleep(3000); + } + }); + } catch (Exception e) { + } + + // retrieve the trace from the device + TraceOptions traceOptions = dlg.getTraceOptions(); + CollectTraceAction.startTracing(shell, traceOptions, LOCAL_FORWARDED_PORT); + + // inform the client that it doesn't need to be traced anymore + mClient.stopOpenGlTracing(); + + // remove port forwarding + CollectTraceAction.disablePortForwarding(mClient.getDevice(), LOCAL_FORWARDED_PORT); + + // and finally open the editor to view the file + CollectTraceAction.openInEditor(shell, traceOptions.traceDestination); + } + } + + private static final StartTraceAction sAction = new StartTraceAction(); + + @Override + public Action getAction() { + return sAction; + } + + @Override + public void selectedClientChanged(Client c) { + sAction.setClient(c); + } +} diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java index 764ba98..b4de3d1 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceOptionsDialog.java @@ -71,6 +71,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { private String mAppPackageToTrace = ""; private String mActivityToTrace = ""; private String mTraceFilePath = ""; + private boolean mAllowAppSelection; private static boolean sCollectFbOnEglSwap = true; private static boolean sCollectFbOnGlDraw = false; @@ -79,8 +80,23 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { private IDevice[] mDevices; public GLTraceOptionsDialog(Shell parentShell) { + this(parentShell, true, null); + } + + /** + * Constructs a dialog displaying options for the tracer. + * @param allowAppSelection true if user can change the application to trace + * @param appToTrace default application package to trace + */ + public GLTraceOptionsDialog(Shell parentShell, boolean allowAppSelection, + String appToTrace) { super(parentShell); loadPreferences(); + + mAllowAppSelection = allowAppSelection; + if (appToTrace != null) { + mAppPackageToTrace = appToTrace; + } } @Override @@ -109,6 +125,12 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { createIsFullyQualifedActivityButton(c, "Activity name is fully qualified, do not prefix with package name"); + if (!mAllowAppSelection) { + mAppPackageToTraceText.setEnabled(false); + mActivityToTraceText.setEnabled(false); + mIsActivityFullyQualifiedButton.setEnabled(false); + } + createSeparator(c); createLabel(c, "Data Collection Options:"); |