aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java10
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java83
3 files changed, 99 insertions, 0 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml
index 3a58d84..f837ee6 100644
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml
@@ -85,4 +85,10 @@
name="Android">
</page>
</extension>
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup
+ class="com.android.ide.eclipse.monitor.MonitorStartup">
+ </startup>
+ </extension>
</plugin>
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java
index 27ba6d7..27fcdd9 100644
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java
@@ -18,6 +18,7 @@ package com.android.ide.eclipse.monitor;
import com.android.ide.eclipse.monitor.SdkToolsLocator.SdkInstallStatus;
import com.android.prefs.AndroidLocation;
+import com.android.sdkstats.SdkStatsService;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -41,10 +42,12 @@ public class MonitorApplication implements IApplication {
public Object start(IApplicationContext context) throws Exception {
Display display = PlatformUI.createDisplay();
+ // set workspace location
Location instanceLoc = Platform.getInstanceLocation();
IPath workspacePath = new Path(AndroidLocation.getFolder()).append(MONITOR_WORKSPACE_PATH);
instanceLoc.set(workspacePath.toFile().toURI().toURL(), true);
+ // figure out path to SDK
String sdkPath = findSdkPath(display);
if (!isValidSdkLocation(sdkPath)) {
// exit with return code -1
@@ -52,6 +55,13 @@ public class MonitorApplication implements IApplication {
}
MonitorPlugin.getDefault().setSdkPath(sdkPath);
+ // If this is the first time using ddms or adt, open up the stats service
+ // opt out dialog, and request user for permissions.
+ // Note that the actual ping is performed in MonitorStartup
+ SdkStatsService stats = new SdkStatsService();
+ stats.checkUserPermissionForPing(new Shell(display));
+
+ // open up RCP
try {
int returnCode = PlatformUI.createAndRunWorkbench(display,
new MonitorWorkbenchAdvisor());
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java
new file mode 100644
index 0000000..2bbe7f4
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java
@@ -0,0 +1,83 @@
+/*
+ * 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.monitor;
+
+import com.android.sdkstats.SdkStatsService;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ui.IStartup;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+public class MonitorStartup implements IStartup {
+ @Override
+ public void earlyStartup() {
+ Job pingJob = new Job("Android SDK Ping") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ SdkStatsService stats = new SdkStatsService();
+ String toolsPath = new Path(MonitorPlugin.getDefault().getSdkPath())
+ .append("tools").toString();
+ ping(stats, toolsPath);
+ return Status.OK_STATUS;
+ }
+ };
+ pingJob.setPriority(Job.DECORATE); // lowest priority
+ pingJob.schedule();
+ }
+
+ private static void ping(SdkStatsService stats, String toolsLocation) {
+ Properties p = new Properties();
+ try{
+ File sourceProp;
+ if (toolsLocation != null && toolsLocation.length() > 0) {
+ sourceProp = new File(toolsLocation, "source.properties"); //$NON-NLS-1$
+ } else {
+ sourceProp = new File("source.properties"); //$NON-NLS-1$
+ }
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(sourceProp);
+ p.load(fis);
+ } finally {
+ if (fis != null) {
+ try {
+ fis.close();
+ } catch (IOException ignore) {
+ }
+ }
+ }
+
+ String revision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$
+ if (revision != null && revision.length() > 0) {
+ stats.ping("ddms", revision); //$NON-NLS-1$
+ }
+ } catch (FileNotFoundException e) {
+ // couldn't find the file? don't ping.
+ } catch (IOException e) {
+ // couldn't find the file? don't ping.
+ }
+ }
+}