aboutsummaryrefslogtreecommitdiff
path: root/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java
diff options
context:
space:
mode:
authorBob Badour <bbadour@google.com>2020-05-06 15:54:00 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-06 15:54:00 +0000
commitc6f9015f6bf1b59f46d6bb87f5e48cbab3cb94de (patch)
treefd845444b59dfc72656b7781596e0b1a0662c4c7 /eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java
parentb96d49b79df68d7cc1d63c15fe7416e27e419151 (diff)
parent9d23b89ef175eab9c26c504e6b6cdf5cd28c0b34 (diff)
downloadsdk-c6f9015f6bf1b59f46d6bb87f5e48cbab3cb94de.tar.gz
Merge "Revert "Remove unused project."" am: fc7cda06f5 am: d3c69fa48e am: d58f8ba3b1 am: f1a59c9833 am: 9d23b89ef1
Change-Id: I463b8ee72ee68d390c4398e5287b6d1003197939
Diffstat (limited to 'eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java')
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java87
1 files changed, 87 insertions, 0 deletions
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 000000000..2de260ee6
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java
@@ -0,0 +1,87 @@
+/*
+ * 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.SdkConstants;
+import com.android.sdkstats.SdkStatsService;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+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();
+ File sdkFolder = MonitorPlugin.getDefault().getSdkFolder();
+ if (sdkFolder == null) {
+ return Status.OK_STATUS;
+ }
+
+ String toolsPath = new File(sdkFolder, SdkConstants.FD_TOOLS).getAbsolutePath();
+ 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.
+ }
+ }
+}