diff options
author | Siva Velusamy <vsiva@google.com> | 2012-09-11 19:20:39 -0700 |
---|---|---|
committer | Siva Velusamy <vsiva@google.com> | 2012-09-17 10:10:28 -0700 |
commit | a117eae7f5299afc95fcd81804293f5786b62b0f (patch) | |
tree | 1a00f7c2433223f3b45745156414723703079a70 /eclipse/plugins | |
parent | 540e10ad7bf3596de762537f11ea71e497935e48 (diff) | |
download | sdk-a117eae7f5299afc95fcd81804293f5786b62b0f.zip sdk-a117eae7f5299afc95fcd81804293f5786b62b0f.tar.gz sdk-a117eae7f5299afc95fcd81804293f5786b62b0f.tar.bz2 |
gltrace: Allow fully qualified activity names
Add a separate checkbox to allow the user to indicate whether
the input activity name is fully qualified. In such a case, don't
prefix the activity name with a period.
Also fixes a formatting issue with the trace file size.
Change-Id: Ib4bf2b716e218e86a273200748fbd06c86918ce3
Diffstat (limited to 'eclipse/plugins')
4 files changed, 43 insertions, 10 deletions
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 9acff50..5e97305 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 @@ -126,7 +126,8 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { try { if (!SYSTEM_APP.equals(traceOptions.appToTrace)) { - startActivity(device, traceOptions.appToTrace, traceOptions.activityToTrace); + startActivity(device, traceOptions.appToTrace, traceOptions.activityToTrace, + traceOptions.isActivityNameFullyQualified); } } catch (Exception e) { MessageDialog.openError(shell, "Setup GL Trace", @@ -272,19 +273,24 @@ public class CollectTraceAction implements IWorkbenchWindowActionDelegate { } } - private void startActivity(IDevice device, String appPackage, String activity) + private void startActivity(IDevice device, String appPackage, String activity, + boolean isActivityNameFullyQualified) throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException, IOException, InterruptedException { killApp(device, appPackage); // kill app if it is already running waitUntilAppKilled(device, appPackage, KILL_TIMEOUT); - String activityPath = appPackage; + StringBuilder activityPath = new StringBuilder(appPackage); if (!activity.isEmpty()) { - activityPath = String.format("%s/.%s", appPackage, activity); //$NON-NLS-1$ + activityPath.append('/'); + if (!isActivityNameFullyQualified) { + activityPath.append('.'); + } + activityPath.append(activity); } String startAppCmd = String.format( "am start --opengl-trace %s -a android.intent.action.MAIN -c android.intent.category.LAUNCHER", //$NON-NLS-1$ - activityPath); + activityPath.toString()); Semaphore launchCompletionSempahore = new Semaphore(0); StartActivityOutputReceiver receiver = new StartActivityOutputReceiver( diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceCollectorDialog.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceCollectorDialog.java index 4dfcafa..56dc8e9 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceCollectorDialog.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/GLTraceCollectorDialog.java @@ -35,11 +35,13 @@ import org.eclipse.swt.widgets.ProgressBar; import org.eclipse.swt.widgets.Shell; import java.io.IOException; +import java.text.DecimalFormat; /** Dialog displayed while the trace is being streamed from device to host. */ public class GLTraceCollectorDialog extends TitleAreaDialog { private static final String TITLE = "OpenGL ES Trace"; private static final String DEFAULT_MESSAGE = "Trace collection in progress."; + private static final DecimalFormat SIZE_FORMATTER = new DecimalFormat("#.##"); //$NON-NLS-1$ private TraceOptions mTraceOptions; private final TraceFileWriter mTraceFileWriter; @@ -194,7 +196,7 @@ public class GLTraceCollectorDialog extends TitleAreaDialog { double fileSize = mTraceFileWriter.getCurrentFileSize(); fileSize /= (1024 * 1024); // convert to size in MB - final String frameSize = String.format("%.2g MB", fileSize); //$NON-NLS-1$ + final String frameSize = SIZE_FORMATTER.format(fileSize) + " MB"; Display.getDefault().syncExec(new Runnable() { @Override 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 1ddb6d8..e18427e 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 @@ -64,6 +64,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { private Combo mDeviceCombo; private Text mAppPackageToTraceText; private Text mActivityToTraceText; + private Button mIsActivityFullyQualifiedButton; private Text mTraceFilePathText; private String mSelectedDevice = ""; @@ -74,6 +75,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { private static boolean sCollectFbOnEglSwap = true; private static boolean sCollectFbOnGlDraw = false; private static boolean sCollectTextureData = false; + private static boolean sIsActivityFullyQualified = false; private IDevice[] mDevices; public GLTraceOptionsDialog(Shell parentShell) { @@ -95,12 +97,20 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { mDevices = AndroidDebugBridge.getBridge().getDevices(); createDeviceDropdown(c, mDevices); + createSeparator(c); + createLabel(c, "Application Package:"); createAppToTraceText(c, "e.g. com.example.package"); createLabel(c, "Activity to launch:"); createActivityToTraceText(c, "Leave blank to launch default activity"); + createLabel(c, ""); + createIsFullyQualifedActivityButton(c, + "Activity name is fully qualified, do not prefix with package name"); + + createSeparator(c); + createLabel(c, "Data Collection Options:"); createCaptureImageOptions(c); @@ -245,6 +255,15 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { return mActivityToTraceText; } + private Button createIsFullyQualifedActivityButton(Composite parent, String message) { + mIsActivityFullyQualifiedButton = new Button(parent, SWT.CHECK); + mIsActivityFullyQualifiedButton.setText(message); + mIsActivityFullyQualifiedButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + mIsActivityFullyQualifiedButton.setSelection(sIsActivityFullyQualified); + + return mIsActivityFullyQualifiedButton; + } + private void validateAndSetMessage() { DialogStatus status = validateDialog(); mOkButton.setEnabled(status.valid); @@ -324,6 +343,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { if (mActivityToTrace.startsWith(".")) { //$NON-NLS-1$ mActivityToTrace = mActivityToTrace.substring(1); } + sIsActivityFullyQualified = mIsActivityFullyQualifiedButton.getSelection(); mTraceFilePath = mTraceFilePathText.getText().trim(); mSelectedDevice = mDeviceCombo.getText(); @@ -333,7 +353,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { } private void savePreferences() { - IEclipsePreferences prefs = new InstanceScope().getNode(GlTracePlugin.PLUGIN_ID); + IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(GlTracePlugin.PLUGIN_ID); prefs.put(PREF_APP_PACKAGE, mAppPackageToTrace); prefs.put(PREF_ACTIVITY, mActivityToTrace); prefs.put(PREF_TRACEFILE, mTraceFilePath); @@ -346,7 +366,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { } private void loadPreferences() { - IEclipsePreferences prefs = new InstanceScope().getNode(GlTracePlugin.PLUGIN_ID); + IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(GlTracePlugin.PLUGIN_ID); mAppPackageToTrace = prefs.get(PREF_APP_PACKAGE, ""); mActivityToTrace = prefs.get(PREF_ACTIVITY, ""); mTraceFilePath = prefs.get(PREF_TRACEFILE, ""); @@ -355,6 +375,7 @@ public class GLTraceOptionsDialog extends TitleAreaDialog { public TraceOptions getTraceOptions() { return new TraceOptions(mSelectedDevice, mAppPackageToTrace, mActivityToTrace, - mTraceFilePath, sCollectFbOnEglSwap, sCollectFbOnGlDraw, sCollectTextureData); + sIsActivityFullyQualified, mTraceFilePath, sCollectFbOnEglSwap, + sCollectFbOnGlDraw, sCollectTextureData); } } diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/TraceOptions.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/TraceOptions.java index e7ad17e..ac9fb6b 100644 --- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/TraceOptions.java +++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/TraceOptions.java @@ -26,6 +26,8 @@ public class TraceOptions { /** Activity to trace. */ public final String activityToTrace; + public final boolean isActivityNameFullyQualified; + /** Path where the trace file should be saved. */ public final String traceDestination; @@ -38,11 +40,13 @@ public class TraceOptions { /** Flag indicating whether texture data should be captured on glTexImage*() */ public final boolean collectTextureData; - public TraceOptions(String device, String appPackage, String activity, String destinationPath, + public TraceOptions(String device, String appPackage, String activity, + boolean isActivityNameFullyQualified, String destinationPath, boolean collectFbOnEglSwap, boolean collectFbOnGlDraw, boolean collectTextureData) { this.device = device; this.appToTrace = appPackage; this.activityToTrace = activity; + this.isActivityNameFullyQualified = isActivityNameFullyQualified; this.traceDestination = destinationPath; this.collectFbOnEglSwap = collectFbOnEglSwap; this.collectFbOnGlDraw = collectFbOnGlDraw; |