Fix the opt-in window for usage stat so that it works when running from ADT.

This commit is contained in:
Xavier Ducrohet
2009-04-27 14:58:09 -07:00
parent aa8c266ed0
commit fe3af81580
5 changed files with 104 additions and 116 deletions

View File

@@ -5,7 +5,7 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="lib" path="jarutils.jar"/>
<classpathentry kind="lib" path="androidprefs.jar"/>
<classpathentry kind="lib" path="sdkstats.jar"/>
<classpathentry kind="lib" path="sdkstats.jar" sourcepath="/SdkStatsService"/>
<classpathentry kind="lib" path="kxml2-2.3.0.jar"/>
<classpathentry kind="lib" path="layoutlib_api.jar"/>
<classpathentry kind="lib" path="layoutlib_utils.jar"/>

View File

@@ -31,7 +31,6 @@ import com.android.ide.eclipse.adt.sdk.Sdk;
import com.android.ide.eclipse.adt.sdk.Sdk.ITargetChangeListener;
import com.android.ide.eclipse.adt.ui.EclipseUiHelper;
import com.android.ide.eclipse.common.AndroidConstants;
import com.android.ide.eclipse.common.SdkStatsHelper;
import com.android.ide.eclipse.common.StreamHelper;
import com.android.ide.eclipse.common.project.BaseProjectHelper;
import com.android.ide.eclipse.common.project.ExportHelper;
@@ -51,6 +50,7 @@ import com.android.ide.eclipse.editors.resources.manager.ResourceMonitor.IFileLi
import com.android.ide.eclipse.editors.xml.XmlEditor;
import com.android.sdklib.IAndroidTarget;
import com.android.sdklib.SdkConstants;
import com.android.sdkstats.SdkStatsService;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -983,13 +983,7 @@ public class AdtPlugin extends AbstractUIPlugin {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
// get the version of the plugin
String versionString = (String) getBundle().getHeaders().get(
Constants.BUNDLE_VERSION);
Version version = new Version(versionString);
SdkStatsHelper.pingUsageServer("adt", version); //$NON-NLS-1$
pingUsageServer(); //$NON-NLS-1$
return Status.OK_STATUS;
} catch (Throwable t) {
@@ -1389,4 +1383,22 @@ public class AdtPlugin extends AbstractUIPlugin {
public static synchronized OutputStream getErrorStream() {
return sPlugin.mAndroidConsoleErrorStream;
}
/**
* Pings the usage start server.
* @param pluginName the name of the plugin to appear in the stats
* @param pluginVersion the {@link Version} of the plugin.
*/
private void pingUsageServer() {
// get the version of the plugin
String versionString = (String) getBundle().getHeaders().get(
Constants.BUNDLE_VERSION);
Version version = new Version(versionString);
versionString = String.format("%1$d.%2$d.%3$d", version.getMajor(), //$NON-NLS-1$
version.getMinor(), version.getMicro());
SdkStatsService.ping("adt", versionString, getDisplay()); //$NON-NLS-1$
}
}

View File

@@ -1,39 +0,0 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
*
* 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.common;
import com.android.sdkstats.SdkStatsService;
import org.osgi.framework.Version;
/**
* Helper class to access the ping usage stat server.
*/
public class SdkStatsHelper {
/**
* Pings the usage start server.
* @param pluginName the name of the plugin to appear in the stats
* @param pluginVersion the {@link Version} of the plugin.
*/
public static void pingUsageServer(String pluginName, Version pluginVersion) {
String versionString = String.format("%1$d.%2$d.%3$d", pluginVersion.getMajor(),
pluginVersion.getMinor(), pluginVersion.getMicro());
SdkStatsService.ping(pluginName, versionString);
}
}