aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/app
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2011-08-22 14:10:57 -0700
committerSiva Velusamy <vsiva@google.com>2011-08-22 14:39:35 -0700
commitbbd4f1dff7c6940bf4439569f19e8705cd2c3818 (patch)
treea1a5b893f74e3463b8e079f529176f428cf002c9 /ddms/app
parent3bf8ed5b35d7e4b905bf372b73f0f6ef7b88cbaa (diff)
downloadsdk-bbd4f1dff7c6940bf4439569f19e8705cd2c3818.zip
sdk-bbd4f1dff7c6940bf4439569f19e8705cd2c3818.tar.gz
sdk-bbd4f1dff7c6940bf4439569f19e8705cd2c3818.tar.bz2
Open SDK stats dialog from an existing shell.
This patch addresses Issue #15267. The primary issue is that the SDK stats permission dialog was opened from a separate Job, and this dialog shows up when the user opens the preference page for the first time. Since both of them happen to be modal dialogs, the behavior is inconsistent, and many times results in a blocked UI. The patch fixes this issue by opening up the stats dialog as a child of the preference page dialog within ADT, and as a child of a new shell within DDMS. Change-Id: I8c9ed9e9bbfac855435690f287b4f60975f336fb
Diffstat (limited to 'ddms/app')
-rw-r--r--ddms/app/src/com/android/ddms/Main.java15
-rw-r--r--ddms/app/src/com/android/ddms/PrefsDialog.java7
-rw-r--r--ddms/app/src/com/android/ddms/UIThread.java2
3 files changed, 17 insertions, 7 deletions
diff --git a/ddms/app/src/com/android/ddms/Main.java b/ddms/app/src/com/android/ddms/Main.java
index c8bab66..b538ba9 100644
--- a/ddms/app/src/com/android/ddms/Main.java
+++ b/ddms/app/src/com/android/ddms/Main.java
@@ -21,6 +21,9 @@ import com.android.ddmlib.DebugPortManager;
import com.android.ddmlib.Log;
import com.android.sdkstats.SdkStatsService;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -71,10 +74,16 @@ public class Main {
Log.d("ddms", "Initializing");
+ // if this is the first time using ddms or adt, open up the stats service
+ // opt out dialog, and request user for permissions.
+ if (!SdkStatsService.pingPermissionsSet()) {
+ SdkStatsService.getUserPermissionForPing(new Shell(Display.getDefault()));
+ }
+
// the "ping" argument means to check in with the server and exit
// the application name and version number must also be supplied
if (args.length >= 3 && args[0].equals("ping")) {
- SdkStatsService.ping(args[1], args[2], null);
+ SdkStatsService.ping(args[1], args[2]);
return;
} else if (args.length > 0) {
Log.e("ddms", "Unknown argument: " + args[0]);
@@ -122,7 +131,7 @@ public class Main {
return System.getProperty("os.name").startsWith("Mac OS"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public static void ping(String ddmsParentLocation) {
+ private static void ping(String ddmsParentLocation) {
Properties p = new Properties();
try{
File sourceProp;
@@ -134,7 +143,7 @@ public class Main {
p.load(new FileInputStream(sourceProp));
sRevision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$
if (sRevision != null && sRevision.length() > 0) {
- SdkStatsService.ping("ddms", sRevision, null); //$NON-NLS-1$
+ SdkStatsService.ping("ddms", sRevision); //$NON-NLS-1$
}
} catch (FileNotFoundException e) {
// couldn't find the file? don't ping.
diff --git a/ddms/app/src/com/android/ddms/PrefsDialog.java b/ddms/app/src/com/android/ddms/PrefsDialog.java
index e34a63f..9b79886 100644
--- a/ddms/app/src/com/android/ddms/PrefsDialog.java
+++ b/ddms/app/src/com/android/ddms/PrefsDialog.java
@@ -24,6 +24,7 @@ import com.android.ddmlib.Log.LogLevel;
import com.android.ddmuilib.DdmUiPreferences;
import com.android.ddmuilib.PortFieldEditor;
import com.android.ddmuilib.logcat.LogCatPanel;
+import com.android.sdkstats.SdkStatsPermissionDialog;
import com.android.sdkstats.SdkStatsService;
import org.eclipse.jface.preference.BooleanFieldEditor;
@@ -529,17 +530,17 @@ public final class PrefsDialog {
Link text = new Link(mTop, SWT.WRAP);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- text.setText(SdkStatsService.BODY_TEXT);
+ text.setText(SdkStatsPermissionDialog.BODY_TEXT);
text.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- SdkStatsService.openUrl(event.text);
+ SdkStatsPermissionDialog.openUrl(event.text);
}
});
mOptInCheckbox = new BooleanFieldEditor(SdkStatsService.PING_OPT_IN,
- SdkStatsService.CHECKBOX_TEXT, mTop);
+ SdkStatsPermissionDialog.CHECKBOX_TEXT, mTop);
mOptInCheckbox.setPage(this);
mOptInCheckbox.setPreferenceStore(getPreferenceStore());
mOptInCheckbox.load();
diff --git a/ddms/app/src/com/android/ddms/UIThread.java b/ddms/app/src/com/android/ddms/UIThread.java
index dfe1b9a..27a66d1 100644
--- a/ddms/app/src/com/android/ddms/UIThread.java
+++ b/ddms/app/src/com/android/ddms/UIThread.java
@@ -437,7 +437,7 @@ public class UIThread implements IUiSelectionListener, IClientChangeListener {
*/
public void runUI(String ddmsParentLocation) {
Display.setAppName(APP_NAME);
- mDisplay = new Display();
+ mDisplay = Display.getDefault();
final Shell shell = new Shell(mDisplay);
// create the image loaders for DDMS and DDMUILIB