From 114be912894a344748a010a212abf09b274defd1 Mon Sep 17 00:00:00 2001 From: Brett Chabot <> Date: Tue, 24 Mar 2009 17:42:09 -0700 Subject: [PATCH 001/127] Automated import from //branches/donutburger/...@140465,140465 --- .../plugins/com.android.ide.eclipse.adt/plugin.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml b/tools/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml index c18c72f05..2ab64256f 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml @@ -506,7 +506,7 @@ delegateDescription="Removes the Android JAR from the Bootstrap Classpath" id="com.android.ide.eclipse.adt.launch.JUnitLaunchConfigDelegate.launchAndroidJunit" modes="run,debug" - name="Android JUnit" + name="Android JUnit Test" type="org.eclipse.jdt.junit.launchconfig"> @@ -516,7 +516,7 @@ delegate="com.android.ide.eclipse.adt.launch.junit.AndroidJUnitLaunchConfigDelegate" id="com.android.ide.eclipse.adt.junit.launchConfigurationType" modes="run,debug" - name="Android Instrumentation" + name="Android JUnit Test" public="true" sourceLocatorId="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector" sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer"> @@ -534,7 +534,7 @@ point="org.eclipse.debug.ui.launchConfigurationTabGroups"> @@ -544,7 +544,7 @@ class="com.android.ide.eclipse.adt.launch.junit.AndroidJUnitLaunchShortcut" icon="icons/android.png" id="com.android.ide.eclipse.adt.junit.launchShortcut" - label="Android Instrumentation" + label="Android JUnit Test" modes="run,debug"> From 1d0652bf7b68f1e404976a4a5d02184553c71dbb Mon Sep 17 00:00:00 2001 From: Brett Chabot <> Date: Tue, 24 Mar 2009 17:42:42 -0700 Subject: [PATCH 002/127] Automated import from //branches/donutburger/...@140466,140466 --- .../AndroidJUnitLaunchConfigDelegate.java | 60 ++++++++++++++++++- .../AndroidJUnitLaunchConfigurationTab.java | 8 +++ .../junit/AndroidJUnitLaunchShortcut.java | 30 ++++++++-- .../ide/eclipse/common/AndroidConstants.java | 3 + .../common/project/AndroidManifestParser.java | 32 +++++++--- 5 files changed, 117 insertions(+), 16 deletions(-) diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchConfigDelegate.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchConfigDelegate.java index 05cc6ae73..a624b0001 100755 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchConfigDelegate.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchConfigDelegate.java @@ -18,10 +18,11 @@ package com.android.ide.eclipse.adt.launch.junit; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.launch.AndroidLaunch; +import com.android.ide.eclipse.adt.launch.AndroidLaunchConfiguration; import com.android.ide.eclipse.adt.launch.AndroidLaunchController; import com.android.ide.eclipse.adt.launch.IAndroidLaunchAction; import com.android.ide.eclipse.adt.launch.LaunchConfigDelegate; -import com.android.ide.eclipse.adt.launch.AndroidLaunchConfiguration; +import com.android.ide.eclipse.common.AndroidConstants; import com.android.ide.eclipse.common.project.AndroidManifestParser; import com.android.ide.eclipse.common.project.BaseProjectHelper; @@ -31,6 +32,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.internal.junit.launcher.JUnitLaunchConfigurationConstants; import org.eclipse.jdt.internal.junit.launcher.TestKindRegistry; @@ -46,6 +48,7 @@ public class AndroidJUnitLaunchConfigDelegate extends LaunchConfigDelegate { /** Launch config attribute that stores instrumentation runner */ static final String ATTR_INSTR_NAME = AdtPlugin.PLUGIN_ID + ".instrumentation"; //$NON-NLS-1$ + static final String INSTRUMENTATION_OK = null; private static final String EMPTY_STRING = ""; //$NON-NLS-1$ @Override @@ -87,7 +90,8 @@ public class AndroidJUnitLaunchConfigDelegate extends LaunchConfigDelegate { * Helper method to return the set of instrumentations for the Android project * * @param project the {@link IProject} to get instrumentations for - * @return null if no error occurred parsing instrumentations + * @return null if error occurred parsing instrumentations, otherwise returns array of + * instrumentation class names */ static String[] getInstrumentationsForProject(IProject project) { if (project != null) { @@ -117,4 +121,56 @@ public class AndroidJUnitLaunchConfigDelegate extends LaunchConfigDelegate { config.setAttribute(JUnitLaunchConfigurationConstants.ATTR_TEST_RUNNER_KIND, TestKindRegistry.JUNIT3_TEST_KIND_ID); } + + /** + * Helper method to determine if specified instrumentation can be used as a test runner + * + * @param project the {@link IJavaProject} to validate + * @param instrumentation the instrumentation class name to validate + * @return INSTRUMENTATION_OK if valid, otherwise returns error message + */ + static String validateInstrumentationRunner(IJavaProject project, String instrumentation) { + AndroidManifestParser manifestParser; + try { + manifestParser = AndroidManifestParser.parse( + project, null /* errorListener */, + true /* gatherData */, false /* markErrors */); + // check if this instrumentation is the standard test runner + if (!instrumentation.equals(AndroidConstants.CLASS_INSTRUMENTATION_RUNNER)) { + // check if it extends the standard test runner + String result = BaseProjectHelper.testClassForManifest(project, + instrumentation, AndroidConstants.CLASS_INSTRUMENTATION_RUNNER, true); + if (result != BaseProjectHelper.TEST_CLASS_OK) { + return String.format("The instrumentation runner must be of type %s", + AndroidConstants.CLASS_INSTRUMENTATION_RUNNER); + } + } + if (!hasTestRunnerLibrary(manifestParser)) { + return String.format("%s does not not use the %s library", + project.getProject().getName(), AndroidConstants.LIBRARY_TEST_RUNNER); + } + } catch (CoreException e) { + String err = String.format("Error parsing AndroidManifest for %s", + project.getProject().getName()); + AdtPlugin.log(e, err); + return err; + } + return INSTRUMENTATION_OK; + } + + /** + * Helper method to determine if given manifest has a AndroidConstants.LIBRARY_TEST_RUNNER + * library reference + * + * @param manifestParser the {@link AndroidManifestParser} to search + * @return true if test runner library found, false otherwise + */ + static boolean hasTestRunnerLibrary(AndroidManifestParser manifestParser) { + for (String lib : manifestParser.getUsesLibraries()) { + if (lib.equals(AndroidConstants.LIBRARY_TEST_RUNNER)) { + return true; + } + } + return false; + } } diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchConfigurationTab.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchConfigurationTab.java index 5fbda983d..aa59a5157 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchConfigurationTab.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchConfigurationTab.java @@ -691,10 +691,18 @@ public class AndroidJUnitLaunchConfigurationTab extends AbstractLaunchConfigurat private void validateInstrumentation(IJavaProject javaProject) { if (mInstrumentations == null || mInstrumentations.length < 1) { setErrorMessage("Specified project has no defined instrumentations"); + return; } String instrumentation = getSelectedInstrumentation(); if (instrumentation == null) { setErrorMessage("Instrumentation not specified"); + return; + } + String result = AndroidJUnitLaunchConfigDelegate.validateInstrumentationRunner( + javaProject, instrumentation); + if (result != AndroidJUnitLaunchConfigDelegate.INSTRUMENTATION_OK) { + setErrorMessage(result); + return; } } diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchShortcut.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchShortcut.java index e03f2822b..30649e2e8 100755 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchShortcut.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchShortcut.java @@ -16,6 +16,9 @@ package com.android.ide.eclipse.adt.launch.junit; +import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.common.AndroidConstants; + import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -34,7 +37,7 @@ public class AndroidJUnitLaunchShortcut extends JUnitLaunchShortcut { /** * Creates a default Android JUnit launch configuration. Sets the instrumentation runner to the - * first instrumentation found in the AndroidManifest. + * first instrumentation found in the AndroidManifest. */ @Override protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(IJavaElement element) @@ -43,10 +46,27 @@ public class AndroidJUnitLaunchShortcut extends JUnitLaunchShortcut { IProject project = element.getResource().getProject(); String[] instrumentations = AndroidJUnitLaunchConfigDelegate.getInstrumentationsForProject(project); - if (instrumentations != null && instrumentations.length > 0) { - // just pick the first runner - config.setAttribute(AndroidJUnitLaunchConfigDelegate.ATTR_INSTR_NAME, - instrumentations[0]); + boolean runnerFound = false; + if (instrumentations != null) { + // just pick the first valid runner + for (String instr : instrumentations) { + if (AndroidJUnitLaunchConfigDelegate.validateInstrumentationRunner( + element.getJavaProject(), instr) == + AndroidJUnitLaunchConfigDelegate.INSTRUMENTATION_OK) { + + config.setAttribute(AndroidJUnitLaunchConfigDelegate.ATTR_INSTR_NAME, + instr); + runnerFound = true; + break; + } + } + } + if (!runnerFound) { + // TODO: put this in a string properties + String msg = String.format("ERROR: Application does not specify a %s instrumentation or does not declare uses-library %s", + AndroidConstants.CLASS_INSTRUMENTATION_RUNNER, + AndroidConstants.LIBRARY_TEST_RUNNER); + AdtPlugin.printErrorToConsole(project, msg); } AndroidJUnitLaunchConfigDelegate.setJUnitDefaults(config); diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/AndroidConstants.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/AndroidConstants.java index 5abfd811d..1da753c7b 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/AndroidConstants.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/AndroidConstants.java @@ -180,6 +180,8 @@ public class AndroidConstants { public final static String CLASS_BROADCASTRECEIVER = "android.content.BroadcastReceiver"; //$NON-NLS-1$ public final static String CLASS_CONTENTPROVIDER = "android.content.ContentProvider"; //$NON-NLS-1$ public final static String CLASS_INSTRUMENTATION = "android.app.Instrumentation"; //$NON-NLS-1$ + public final static String CLASS_INSTRUMENTATION_RUNNER = + "android.test.InstrumentationTestRunner"; //$NON-NLS-1$ public final static String CLASS_BUNDLE = "android.os.Bundle"; //$NON-NLS-1$ public final static String CLASS_R = "android.R"; //$NON-NLS-1$ public final static String CLASS_MANIFEST_PERMISSION = "android.Manifest$permission"; //$NON-NLS-1$ @@ -215,4 +217,5 @@ public class AndroidConstants { /** The base URL where to find the Android class & manifest documentation */ public static final String CODESITE_BASE_URL = "http://code.google.com/android"; //$NON-NLS-1$ + public static final String LIBRARY_TEST_RUNNER = "android.test.runner"; // $NON-NLS-1$ } diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java index 42c881b15..fe11e694c 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java @@ -255,12 +255,8 @@ public class AndroidManifestParser { } catch (NumberFormatException e) { handleError(e, -1 /* lineNumber */); } - } else if (NODE_INSTRUMENTATION.equals(localName)) { - value = getAttributeValue(attributes, ATTRIBUTE_NAME, - true /* hasNamespace */); - if (value != null) { - mInstrumentations.add(value); - } + } else if (NODE_INSTRUMENTATION.equals(localName)) { + processInstrumentationNode(attributes); } break; case LEVEL_ACTIVITY: @@ -449,6 +445,25 @@ public class AndroidManifestParser { addProcessName(processName); } } + + /** + * Processes the instrumentation nodes. + * @param attributes the attributes for the activity node. + * node is representing + */ + private void processInstrumentationNode(Attributes attributes) { + // lets get the class name, and check it if required. + String instrumentationName = getAttributeValue(attributes, ATTRIBUTE_NAME, + true /* hasNamespace */); + if (instrumentationName != null) { + String instrClassName = combinePackageAndClassName(mPackage, instrumentationName); + mInstrumentations.add(instrClassName); + if (mMarkErrors) { + checkClass(instrClassName, AndroidConstants.CLASS_INSTRUMENTATION, + true /* testVisibility */); + } + } + } /** * Checks that a class is valid and can be used in the Android Manifest. @@ -484,8 +499,7 @@ public class AndroidManifestParser { } catch (CoreException e) { } } - } - + } } /** @@ -583,7 +597,7 @@ public class AndroidManifestParser { return null; } - + /** * Parses the Android Manifest, and returns an object containing the result of the parsing. *

From 02c11da47f8916cf50095b10c16478a136a21aa5 Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet <> Date: Tue, 24 Mar 2009 18:14:09 -0700 Subject: [PATCH 003/127] Automated import from //branches/donutburger/...@140696,140696 --- .../editors/layout/GraphicalLayoutEditor.java | 154 ++++++++++++------ 1 file changed, 102 insertions(+), 52 deletions(-) diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/layout/GraphicalLayoutEditor.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/layout/GraphicalLayoutEditor.java index 9c529e5da..12d49fe27 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/layout/GraphicalLayoutEditor.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/editors/layout/GraphicalLayoutEditor.java @@ -61,8 +61,10 @@ import com.android.ide.eclipse.editors.wizards.ConfigurationSelector.LanguageReg import com.android.ide.eclipse.editors.wizards.ConfigurationSelector.MobileCodeVerifier; import com.android.layoutlib.api.ILayoutLog; import com.android.layoutlib.api.ILayoutResult; +import com.android.layoutlib.api.IProjectCallback; import com.android.layoutlib.api.IResourceValue; import com.android.layoutlib.api.IStyleResourceValue; +import com.android.layoutlib.api.IXmlPullParser; import com.android.layoutlib.api.ILayoutResult.ILayoutViewInfo; import com.android.sdklib.IAndroidTarget; @@ -222,7 +224,7 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor // updateUiFromFramework will reset language/region combo, so we must call // setConfiguration after, or the settext on language/region will be lost. if (mEditedConfig != null) { - setConfiguration(mEditedConfig); + setConfiguration(mEditedConfig, false /*force*/); } // make sure we remove the custom view loader, since its parent class loader is the @@ -867,7 +869,7 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor @Override void editNewFile(FolderConfiguration configuration) { // update the configuration UI - setConfiguration(configuration); + setConfiguration(configuration, true /*force*/); // enable the create button if the current and edited config are not equals mCreateButton.setEnabled(mEditedConfig.equals(mCurrentConfig) == false); @@ -975,18 +977,14 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor int themeIndex = mThemeCombo.getSelectionIndex(); if (themeIndex != -1) { String theme = mThemeCombo.getItem(themeIndex); - - // change the string if it's a custom theme to make sure we can - // differentiate them - if (themeIndex >= mPlatformThemeCount) { - theme = "*" + theme; //$NON-NLS-1$ - } // Render a single object as described by the ViewElementDescriptor. WidgetPullParser parser = new WidgetPullParser(descriptor); - ILayoutResult result = bridge.bridge.computeLayout(parser, + ILayoutResult result = computeLayout(bridge, parser, null /* projectKey */, - 300 /* width */, 300 /* height */, theme, + 300 /* width */, 300 /* height */, 160 /*density*/, + 160.f /*xdpi*/, 160.f /*ydpi*/, theme, + themeIndex >= mPlatformThemeCount /*isProjectTheme*/, configuredProjectResources, frameworkResources, projectCallback, null /* logger */); @@ -1073,11 +1071,14 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor /** * Update the UI controls state with a given {@link FolderConfiguration}. - *

If a qualifier is not present in the {@link FolderConfiguration} object, the UI control - * is not modified. However if the value in the control is not the default value, a warning - * icon is showed. + *

If force is set to true the UI will be changed to exactly reflect + * config, otherwise, if a qualifier is not present in config, + * the UI control is not modified. However if the value in the control is not the default value, + * a warning icon is shown. + * @param config The {@link FolderConfiguration} to set. + * @param force Whether the UI should be changed to exactly match the received configuration. */ - void setConfiguration(FolderConfiguration config) { + void setConfiguration(FolderConfiguration config, boolean force) { mDisableUpdates = true; // we do not want to trigger onXXXChange when setting new values in the widgets. mEditedConfig = config; @@ -1088,6 +1089,9 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor if (countryQualifier != null) { mCountry.setText(String.format("%1$d", countryQualifier.getCode())); mCurrentConfig.setCountryCodeQualifier(countryQualifier); + } else if (force) { + mCountry.setText(""); //$NON-NLS-1$ + mCurrentConfig.setCountryCodeQualifier(null); } else if (mCountry.getText().length() > 0) { mCountryIcon.setImage(mWarningImage); } @@ -1097,6 +1101,9 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor if (networkQualifier != null) { mNetwork.setText(String.format("%1$d", networkQualifier.getCode())); mCurrentConfig.setNetworkCodeQualifier(networkQualifier); + } else if (force) { + mNetwork.setText(""); //$NON-NLS-1$ + mCurrentConfig.setNetworkCodeQualifier(null); } else if (mNetwork.getText().length() > 0) { mNetworkIcon.setImage(mWarningImage); } @@ -1106,6 +1113,9 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor if (languageQualifier != null) { mLanguage.setText(languageQualifier.getValue()); mCurrentConfig.setLanguageQualifier(languageQualifier); + } else if (force) { + mLanguage.setText(""); //$NON-NLS-1$ + mCurrentConfig.setLanguageQualifier(null); } else if (mLanguage.getText().length() > 0) { mLanguageIcon.setImage(mWarningImage); } @@ -1115,6 +1125,9 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor if (regionQualifier != null) { mRegion.setText(regionQualifier.getValue()); mCurrentConfig.setRegionQualifier(regionQualifier); + } else if (force) { + mRegion.setText(""); //$NON-NLS-1$ + mCurrentConfig.setRegionQualifier(null); } else if (mRegion.getText().length() > 0) { mRegionIcon.setImage(mWarningImage); } @@ -1125,6 +1138,9 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor mOrientation.select( ScreenOrientation.getIndex(orientationQualifier.getValue()) + 1); mCurrentConfig.setScreenOrientationQualifier(orientationQualifier); + } else if (force) { + mOrientation.select(0); + mCurrentConfig.setScreenOrientationQualifier(null); } else if (mOrientation.getSelectionIndex() != 0) { mOrientationIcon.setImage(mWarningImage); } @@ -1134,6 +1150,9 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor if (densityQualifier != null) { mDensity.setText(String.format("%1$d", densityQualifier.getValue())); mCurrentConfig.setPixelDensityQualifier(densityQualifier); + } else if (force) { + mDensity.setText(""); //$NON-NLS-1$ + mCurrentConfig.setPixelDensityQualifier(null); } else if (mDensity.getText().length() > 0) { mDensityIcon.setImage(mWarningImage); } @@ -1143,6 +1162,9 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor if (touchQualifier != null) { mTouch.select(TouchScreenType.getIndex(touchQualifier.getValue()) + 1); mCurrentConfig.setTouchTypeQualifier(touchQualifier); + } else if (force) { + mTouch.select(0); + mCurrentConfig.setTouchTypeQualifier(null); } else if (mTouch.getSelectionIndex() != 0) { mTouchIcon.setImage(mWarningImage); } @@ -1152,6 +1174,9 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor if (keyboardQualifier != null) { mKeyboard.select(KeyboardState.getIndex(keyboardQualifier.getValue()) + 1); mCurrentConfig.setKeyboardStateQualifier(keyboardQualifier); + } else if (force) { + mKeyboard.select(0); + mCurrentConfig.setKeyboardStateQualifier(null); } else if (mKeyboard.getSelectionIndex() != 0) { mKeyboardIcon.setImage(mWarningImage); } @@ -1161,6 +1186,9 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor if (inputQualifier != null) { mTextInput.select(TextInputMethod.getIndex(inputQualifier.getValue()) + 1); mCurrentConfig.setTextInputMethodQualifier(inputQualifier); + } else if (force) { + mTextInput.select(0); + mCurrentConfig.setTextInputMethodQualifier(null); } else if (mTextInput.getSelectionIndex() != 0) { mTextInputIcon.setImage(mWarningImage); } @@ -1171,6 +1199,9 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor mNavigation.select( NavigationMethod.getIndex(navigationQualifiter.getValue()) + 1); mCurrentConfig.setNavigationMethodQualifier(navigationQualifiter); + } else if (force) { + mNavigation.select(0); + mCurrentConfig.setNavigationMethodQualifier(null); } else if (mNavigation.getSelectionIndex() != 0) { mNavigationIcon.setImage(mWarningImage); } @@ -1181,6 +1212,10 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor mSize1.setText(String.format("%1$d", sizeQualifier.getValue1())); mSize2.setText(String.format("%1$d", sizeQualifier.getValue2())); mCurrentConfig.setScreenDimensionQualifier(sizeQualifier); + } else if (force) { + mSize1.setText(""); //$NON-NLS-1$ + mSize2.setText(""); //$NON-NLS-1$ + mCurrentConfig.setScreenDimensionQualifier(null); } else if (mSize1.getText().length() > 0 && mSize2.getText().length() > 0) { mSizeIcon.setImage(mWarningImage); } @@ -1607,7 +1642,7 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor // at this point, we have not opened a new file. // update the configuration icons with the new edited config. - setConfiguration(mEditedConfig); + setConfiguration(mEditedConfig, false /*force*/); // enable the create button if the current and edited config are not equals mCreateButton.setEnabled(mEditedConfig.equals(mCurrentConfig) == false); @@ -1794,45 +1829,16 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor // Compute the layout UiElementPullParser parser = new UiElementPullParser(getModel()); Rectangle rect = getBounds(); - ILayoutResult result = null; - if (bridge.apiLevel >= 3) { - // call the new api with proper theme differentiator and - // density/dpi support. - boolean isProjectTheme = themeIndex >= mPlatformThemeCount; + boolean isProjectTheme = themeIndex >= mPlatformThemeCount; - // FIXME pass the density/dpi from somewhere (resource config or skin). - result = bridge.bridge.computeLayout(parser, - iProject /* projectKey */, - rect.width, rect.height, 160, 160.f, 160.f, - theme, isProjectTheme, - mConfiguredProjectRes, frameworkResources, mProjectCallback, - mLogger); - } else if (bridge.apiLevel == 2) { - // api with boolean for separation of project/framework theme - boolean isProjectTheme = themeIndex >= mPlatformThemeCount; + // FIXME pass the density/dpi from somewhere (resource config or skin). + ILayoutResult result = computeLayout(bridge, parser, + iProject /* projectKey */, + rect.width, rect.height, 160, 160.f, 160.f, + theme, isProjectTheme, + mConfiguredProjectRes, frameworkResources, mProjectCallback, + mLogger); - result = bridge.bridge.computeLayout(parser, - iProject /* projectKey */, - rect.width, rect.height, theme, isProjectTheme, - mConfiguredProjectRes, frameworkResources, mProjectCallback, - mLogger); - } else { - // oldest api with no density/dpi, and project theme boolean mixed - // into the theme name. - - // change the string if it's a custom theme to make sure we can - // differentiate them - if (themeIndex >= mPlatformThemeCount) { - theme = "*" + theme; //$NON-NLS-1$ - } - - result = bridge.bridge.computeLayout(parser, - iProject /* projectKey */, - rect.width, rect.height, theme, - mConfiguredProjectRes, frameworkResources, mProjectCallback, - mLogger); - } - // update the UiElementNode with the layout info. if (result.getSuccess() == ILayoutResult.SUCCESS) { model.setEditData(result.getImage()); @@ -2383,4 +2389,48 @@ public class GraphicalLayoutEditor extends AbstractGraphicalLayoutEditor return null; } + + /** + * Computes a layout by calling the correct computeLayout method of ILayoutBridge based on + * the implementation API level. + */ + @SuppressWarnings("deprecation") + private ILayoutResult computeLayout(LayoutBridge bridge, + IXmlPullParser layoutDescription, Object projectKey, + int screenWidth, int screenHeight, int density, float xdpi, float ydpi, + String themeName, boolean isProjectTheme, + Map> projectResources, + Map> frameworkResources, + IProjectCallback projectCallback, ILayoutLog logger) { + + if (bridge.apiLevel >= 3) { + // newer api with boolean for separation of project/framework theme, + // and density support. + return bridge.bridge.computeLayout(layoutDescription, + projectKey, screenWidth, screenHeight, density, xdpi, ydpi, + themeName, isProjectTheme, + projectResources, frameworkResources, projectCallback, + logger); + } else if (bridge.apiLevel == 2) { + // api with boolean for separation of project/framework theme + return bridge.bridge.computeLayout(layoutDescription, + projectKey, screenWidth, screenHeight, themeName, isProjectTheme, + mConfiguredProjectRes, frameworkResources, mProjectCallback, + mLogger); + } else { + // oldest api with no density/dpi, and project theme boolean mixed + // into the theme name. + + // change the string if it's a custom theme to make sure we can + // differentiate them + if (isProjectTheme) { + themeName = "*" + themeName; //$NON-NLS-1$ + } + + return bridge.bridge.computeLayout(layoutDescription, + projectKey, screenWidth, screenHeight, themeName, + mConfiguredProjectRes, frameworkResources, mProjectCallback, + mLogger); + } + } } From 9c03440f19481e49cef8142c66b0bda76c59a74d Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet <> Date: Tue, 24 Mar 2009 18:15:02 -0700 Subject: [PATCH 004/127] Automated import from //branches/donutburger/...@140697,140697 --- .../launch/AndroidLaunchConfiguration.java | 31 ++++++++++++++++--- .../adt/launch/AndroidLaunchController.java | 16 ++++++++-- .../adt/launch/LaunchConfigDelegate.java | 3 +- .../com/android/sdklib/avd/AvdManager.java | 20 ++++++++++-- 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/AndroidLaunchConfiguration.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/AndroidLaunchConfiguration.java index 448cda6b5..3e610db08 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/AndroidLaunchConfiguration.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/AndroidLaunchConfiguration.java @@ -32,8 +32,30 @@ public class AndroidLaunchConfiguration { */ public int mLaunchAction = LaunchConfigDelegate.DEFAULT_LAUNCH_ACTION; - public static final boolean AUTO_TARGET_MODE = true; + public enum TargetMode { + AUTO(true), MANUAL(false); + + private boolean mValue; + TargetMode(boolean value) { + mValue = value; + } + + public boolean getValue() { + return mValue; + } + + public static TargetMode getMode(boolean value) { + for (TargetMode mode : values()) { + if (mode.mValue == value) { + return mode; + } + } + + return null; + } + } + /** * Target selection mode. *

    @@ -41,7 +63,7 @@ public class AndroidLaunchConfiguration { *
  • false: manual mode
  • *
*/ - public boolean mTargetMode = LaunchConfigDelegate.DEFAULT_TARGET_MODE; + public TargetMode mTargetMode = LaunchConfigDelegate.DEFAULT_TARGET_MODE; /** * Indicates whether the emulator should be called with -wipe-data @@ -81,8 +103,9 @@ public class AndroidLaunchConfiguration { } try { - mTargetMode = config.getAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE, - mTargetMode); + boolean value = config.getAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE, + mTargetMode.getValue()); + mTargetMode = TargetMode.getMode(value); } catch (CoreException e) { // nothing to be done here, we'll use the default value } diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/AndroidLaunchController.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/AndroidLaunchController.java index 499cca704..5cf966904 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/AndroidLaunchController.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/AndroidLaunchController.java @@ -29,11 +29,13 @@ import com.android.ddmlib.MultiLineReceiver; import com.android.ddmlib.SyncService; import com.android.ddmlib.SyncService.SyncResult; import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.launch.AndroidLaunchConfiguration.TargetMode; import com.android.ide.eclipse.adt.launch.DelayedLaunchInfo.InstallRetryMode; import com.android.ide.eclipse.adt.launch.DeviceChooserDialog.DeviceChooserResponse; import com.android.ide.eclipse.adt.project.ProjectHelper; import com.android.ide.eclipse.adt.sdk.Sdk; import com.android.ide.eclipse.common.project.AndroidManifestParser; +import com.android.prefs.AndroidLocation.AndroidLocationException; import com.android.sdklib.IAndroidTarget; import com.android.sdklib.SdkManager; import com.android.sdklib.avd.AvdManager; @@ -236,7 +238,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener // set default target mode wc.setAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE, - LaunchConfigDelegate.DEFAULT_TARGET_MODE); + LaunchConfigDelegate.DEFAULT_TARGET_MODE.getValue()); // default AVD: None wc.setAttribute(LaunchConfigDelegate.ATTR_AVD_NAME, (String) null); @@ -332,6 +334,16 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener Sdk currentSdk = Sdk.getCurrent(); AvdManager avdManager = currentSdk.getAvdManager(); + // reload the AVDs to make sure we are up to date + try { + avdManager.reloadAvds(); + } catch (AndroidLocationException e1) { + // this happens if the AVD Manager failed to find the folder in which the AVDs are + // stored. This is unlikely to happen, but if it does, we should force to go manual + // to allow using physical devices. + config.mTargetMode = TargetMode.MANUAL; + } + // get the project target final IAndroidTarget projectTarget = currentSdk.getTarget(project); @@ -356,7 +368,7 @@ public final class AndroidLaunchController implements IDebugBridgeChangeListener * If == 1, launch the application on this AVD/device. */ - if (config.mTargetMode == AndroidLaunchConfiguration.AUTO_TARGET_MODE) { + if (config.mTargetMode == TargetMode.AUTO) { // if we are in automatic target mode, we need to find the current devices IDevice[] devices = AndroidDebugBridge.getBridge().getDevices(); diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/LaunchConfigDelegate.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/LaunchConfigDelegate.java index 80f62eaa8..db9a4aceb 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/LaunchConfigDelegate.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/LaunchConfigDelegate.java @@ -18,6 +18,7 @@ package com.android.ide.eclipse.adt.launch; import com.android.ddmlib.AndroidDebugBridge; import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.launch.AndroidLaunchConfiguration.TargetMode; import com.android.ide.eclipse.adt.project.ProjectHelper; import com.android.ide.eclipse.common.AndroidConstants; import com.android.ide.eclipse.common.project.AndroidManifestParser; @@ -51,7 +52,7 @@ public class LaunchConfigDelegate extends LaunchConfigurationDelegate { /** Target mode parameters: true is automatic, false is manual */ public static final String ATTR_TARGET_MODE = AdtPlugin.PLUGIN_ID + ".target"; //$NON-NLS-1$ - public static final boolean DEFAULT_TARGET_MODE = true; //automatic mode + public static final TargetMode DEFAULT_TARGET_MODE = TargetMode.AUTO; /** * Launch action: diff --git a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/avd/AvdManager.java b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/avd/AvdManager.java index 65cbbe356..93577e42b 100644 --- a/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/avd/AvdManager.java +++ b/tools/sdkmanager/libs/sdklib/src/com/android/sdklib/avd/AvdManager.java @@ -177,7 +177,7 @@ public final class AvdManager { public AvdManager(SdkManager sdk, ISdkLog sdkLog) throws AndroidLocationException { mSdk = sdk; mSdkLog = sdkLog; - buildAvdList(); + buildAvdList(mAvdList); } /** @@ -201,6 +201,20 @@ public final class AvdManager { return null; } + + /** + * Reloads the AVD list. + * @throws AndroidLocationException if there was an error finding the location of the + * AVD folder. + */ + public void reloadAvds() throws AndroidLocationException { + // build the list in a temp list first, in case the method throws an exception. + // It's better than deleting the whole list before reading the new one. + ArrayList list = new ArrayList(); + buildAvdList(list); + mAvdList.clear(); + mAvdList.addAll(list); + } /** * Creates a new AVD. It is expected that there is no existing AVD with this name already. @@ -620,7 +634,7 @@ public final class AvdManager { } } - private void buildAvdList() throws AndroidLocationException { + private void buildAvdList(ArrayList list) throws AndroidLocationException { // get the Android prefs location. String avdRoot = AndroidLocation.getFolder() + AndroidLocation.FOLDER_AVD; @@ -664,7 +678,7 @@ public final class AvdManager { for (File avd : avds) { AvdInfo info = parseAvdInfo(avd); if (info != null) { - mAvdList.add(info); + list.add(info); if (avdListDebug) { mSdkLog.printf("[AVD LIST DEBUG] Added AVD '%s'\n", info.getPath()); } From 024d1c2375a09cadf7809c454fb04c190116815d Mon Sep 17 00:00:00 2001 From: Andy McFadden <> Date: Tue, 24 Mar 2009 18:15:56 -0700 Subject: [PATCH 005/127] Automated import from //branches/donutburger/...@140700,140700 --- .../android/ddmlib/AndroidDebugBridge.java | 1 + .../src/com/android/ddmlib/HandleHeap.java | 41 +++++ .../src/com/android/ddmlib/HandleHello.java | 37 +++- .../com/android/ddmlib/HandleProfiling.java | 163 ++++++++++++++++++ 4 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleProfiling.java diff --git a/tools/ddms/libs/ddmlib/src/com/android/ddmlib/AndroidDebugBridge.java b/tools/ddms/libs/ddmlib/src/com/android/ddmlib/AndroidDebugBridge.java index 795bf886a..0957171c6 100644 --- a/tools/ddms/libs/ddmlib/src/com/android/ddmlib/AndroidDebugBridge.java +++ b/tools/ddms/libs/ddmlib/src/com/android/ddmlib/AndroidDebugBridge.java @@ -194,6 +194,7 @@ public final class AndroidDebugBridge { HandleThread.register(monitorThread); HandleHeap.register(monitorThread); HandleWait.register(monitorThread); + HandleProfiling.register(monitorThread); } /** diff --git a/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleHeap.java b/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleHeap.java index 5752b861a..51116387e 100644 --- a/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleHeap.java +++ b/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleHeap.java @@ -32,6 +32,7 @@ final class HandleHeap extends ChunkHandler { public static final int CHUNK_HPEN = type("HPEN"); public static final int CHUNK_HPSG = type("HPSG"); public static final int CHUNK_HPGC = type("HPGC"); + public static final int CHUNK_HPDU = type("HPDU"); public static final int CHUNK_REAE = type("REAE"); public static final int CHUNK_REAQ = type("REAQ"); public static final int CHUNK_REAL = type("REAL"); @@ -98,6 +99,8 @@ final class HandleHeap extends ChunkHandler { client.update(Client.CHANGE_HEAP_DATA); } else if (type == CHUNK_HPSG) { handleHPSG(client, data); + } else if (type == CHUNK_HPDU) { + handleHPDU(client, data); } else if (type == CHUNK_REAQ) { handleREAQ(client, data); client.update(Client.CHANGE_HEAP_ALLOCATION_STATUS); @@ -220,6 +223,44 @@ final class HandleHeap extends ChunkHandler { client.sendAndConsume(packet, mInst); } + /** + * Sends an HPDU request to the client. + * + * We will get an HPDU response when the heap dump has completed. On + * failure we get a generic failure response. + * + * @param fileName name of output file (on device) + */ + public static void sendHPDU(Client client, String fileName) + throws IOException { + ByteBuffer rawBuf = allocBuffer(4 + fileName.length() * 2); + JdwpPacket packet = new JdwpPacket(rawBuf); + ByteBuffer buf = getChunkDataBuf(rawBuf); + + buf.putInt(fileName.length()); + putString(buf, fileName); + + finishChunkPacket(packet, CHUNK_HPDU, buf.position()); + Log.d("ddm-heap", "Sending " + name(CHUNK_HPDU) + " '" + fileName +"'"); + client.sendAndConsume(packet, mInst); + } + + /* + * Handle notification of completion of a HeaP DUmp. + */ + private void handleHPDU(Client client, ByteBuffer data) { + byte result; + + result = data.get(); + + if (result == 0) { + Log.i("ddm-heap", "Heap dump request has finished"); + // TODO: stuff + } else { + Log.w("ddm-heap", "Heap dump request failed (check device log)"); + } + } + /** * Sends a REAE (REcent Allocation Enable) request to the client. */ diff --git a/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleHello.java b/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleHello.java index 5ba5aeb8f..fb9697cce 100644 --- a/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleHello.java +++ b/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleHello.java @@ -20,11 +20,12 @@ import java.io.IOException; import java.nio.ByteBuffer; /** - * Handle the "hello" chunk (HELO). + * Handle the "hello" chunk (HELO) and feature discovery. */ final class HandleHello extends ChunkHandler { public static final int CHUNK_HELO = ChunkHandler.type("HELO"); + public static final int CHUNK_FEAT = ChunkHandler.type("FEAT"); private static final HandleHello mInst = new HandleHello(); @@ -65,6 +66,8 @@ final class HandleHello extends ChunkHandler { if (type == CHUNK_HELO) { assert isReply; handleHELO(client, data); + } else if (type == CHUNK_FEAT) { + handleFEAT(client, data); } else { handleUnknownChunk(client, type, data, isReply, msgId); } @@ -126,5 +129,37 @@ final class HandleHello extends ChunkHandler { + " ID=0x" + Integer.toHexString(packet.getId())); client.sendAndConsume(packet, mInst); } + + /** + * Handle a reply to our FEAT request. + */ + private static void handleFEAT(Client client, ByteBuffer data) { + int featureCount; + int i; + + featureCount = data.getInt(); + for (i = 0; i < featureCount; i++) { + int len = data.getInt(); + String feature = getString(data, len); + + Log.d("ddm-hello", "Feature: " + feature); + } + } + + /** + * Send a FEAT request to the client. + */ + public static void sendFEAT(Client client) throws IOException { + ByteBuffer rawBuf = allocBuffer(0); + JdwpPacket packet = new JdwpPacket(rawBuf); + ByteBuffer buf = getChunkDataBuf(rawBuf); + + // no data + + finishChunkPacket(packet, CHUNK_FEAT, buf.position()); + Log.d("ddm-heap", "Sending " + name(CHUNK_FEAT)); + client.sendAndConsume(packet, mInst); + } + } diff --git a/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleProfiling.java b/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleProfiling.java new file mode 100644 index 000000000..e8e810325 --- /dev/null +++ b/tools/ddms/libs/ddmlib/src/com/android/ddmlib/HandleProfiling.java @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2009 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.ddmlib; + +import java.io.IOException; +import java.nio.ByteBuffer; + +/** + * Handle heap status updates. + */ +final class HandleProfiling extends ChunkHandler { + + public static final int CHUNK_MPRS = type("MPRS"); + public static final int CHUNK_MPRE = type("MPRE"); + public static final int CHUNK_MPRQ = type("MPRQ"); + + private static final HandleProfiling mInst = new HandleProfiling(); + + private HandleProfiling() {} + + /** + * Register for the packets we expect to get from the client. + */ + public static void register(MonitorThread mt) { + mt.registerChunkHandler(CHUNK_MPRE, mInst); + mt.registerChunkHandler(CHUNK_MPRQ, mInst); + } + + /** + * Client is ready. + */ + @Override + public void clientReady(Client client) throws IOException {} + + /** + * Client went away. + */ + @Override + public void clientDisconnected(Client client) {} + + /** + * Chunk handler entry point. + */ + @Override + public void handleChunk(Client client, int type, ByteBuffer data, + boolean isReply, int msgId) { + + Log.d("ddm-prof", "handling " + ChunkHandler.name(type)); + + if (type == CHUNK_MPRE) { + handleMPRE(client, data); + } else if (type == CHUNK_MPRQ) { + handleMPRQ(client, data); + } else { + handleUnknownChunk(client, type, data, isReply, msgId); + } + } + + /** + * Send a MPRS (Method PRofiling Start) request to the client. + * + * @param fileName is the name of the file to which profiling data + * will be written (on the device); it will have ".trace" + * appended if necessary + * @param bufferSize is the desired buffer size in bytes (8MB is good) + * @param flags should be zero + */ + public static void sendMPRS(Client client, String fileName, int bufferSize, + int flags) throws IOException { + + ByteBuffer rawBuf = allocBuffer(3*4 + fileName.length() * 2); + JdwpPacket packet = new JdwpPacket(rawBuf); + ByteBuffer buf = getChunkDataBuf(rawBuf); + + buf.putInt(bufferSize); + buf.putInt(flags); + buf.putInt(fileName.length()); + putString(buf, fileName); + + finishChunkPacket(packet, CHUNK_MPRS, buf.position()); + Log.d("ddm-prof", "Sending " + name(CHUNK_MPRS) + " '" + fileName + + "', size=" + bufferSize + ", flags=" + flags); + client.sendAndConsume(packet, mInst); + } + + /** + * Send a MPRE (Method PRofiling End) request to the client. + */ + public static void sendMPRE(Client client) throws IOException { + ByteBuffer rawBuf = allocBuffer(0); + JdwpPacket packet = new JdwpPacket(rawBuf); + ByteBuffer buf = getChunkDataBuf(rawBuf); + + // no data + + finishChunkPacket(packet, CHUNK_MPRE, buf.position()); + Log.d("ddm-prof", "Sending " + name(CHUNK_MPRE)); + client.sendAndConsume(packet, mInst); + } + + /** + * Handle notification that method profiling has finished writing + * data to disk. + */ + private void handleMPRE(Client client, ByteBuffer data) { + byte result; + + result = data.get(); + + if (result == 0) { + Log.i("ddm-prof", "Method profiling has finished"); + } else { + Log.w("ddm-prof", "Method profiling has failed (check device log)"); + } + + // TODO: stuff + } + + /** + * Send a MPRQ (Method PRofiling Query) request to the client. + */ + public static void sendMPRQ(Client client) throws IOException { + ByteBuffer rawBuf = allocBuffer(0); + JdwpPacket packet = new JdwpPacket(rawBuf); + ByteBuffer buf = getChunkDataBuf(rawBuf); + + // no data + + finishChunkPacket(packet, CHUNK_MPRQ, buf.position()); + Log.d("ddm-prof", "Sending " + name(CHUNK_MPRQ)); + client.sendAndConsume(packet, mInst); + } + + /** + * Receive response to query. + */ + private void handleMPRQ(Client client, ByteBuffer data) { + byte result; + + result = data.get(); + + if (result == 0) { + Log.i("ddm-prof", "Method profiling is not running"); + } else { + Log.i("ddm-prof", "Method profiling is running"); + } + } +} + From 7798a83bdf87605b9e6b9487a41d681872cc6dbc Mon Sep 17 00:00:00 2001 From: Xavier Ducrohet <> Date: Tue, 24 Mar 2009 18:20:02 -0700 Subject: [PATCH 006/127] Automated import from //branches/donutburger/...@140722,140722 --- .../ide/eclipse/adt/launch/EmulatorConfigTab.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/EmulatorConfigTab.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/EmulatorConfigTab.java index b898f63c5..3789153e4 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/EmulatorConfigTab.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/EmulatorConfigTab.java @@ -17,6 +17,7 @@ package com.android.ide.eclipse.adt.launch; import com.android.ide.eclipse.adt.AdtPlugin; +import com.android.ide.eclipse.adt.launch.AndroidLaunchConfiguration.TargetMode; import com.android.ide.eclipse.adt.sdk.Sdk; import com.android.ide.eclipse.common.project.BaseProjectHelper; import com.android.ide.eclipse.ddms.DdmsPlugin; @@ -292,14 +293,15 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab { public void initializeFrom(ILaunchConfiguration configuration) { AvdManager avdManager = Sdk.getCurrent().getAvdManager(); - boolean value = LaunchConfigDelegate.DEFAULT_TARGET_MODE; // true == automatic + TargetMode mode = LaunchConfigDelegate.DEFAULT_TARGET_MODE; // true == automatic try { - value = configuration.getAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE, value); + mode = TargetMode.getMode(configuration.getAttribute( + LaunchConfigDelegate.ATTR_TARGET_MODE, mode.getValue())); } catch (CoreException e) { // let's not do anything here, we'll use the default value } - mAutoTargetButton.setSelection(value); - mManualTargetButton.setSelection(!value); + mAutoTargetButton.setSelection(mode.getValue()); + mManualTargetButton.setSelection(!mode.getValue()); // look for the project name to get its target. String stringValue = ""; @@ -354,7 +356,7 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab { mPreferredAvdSelector.setSelection(null); } - value = LaunchConfigDelegate.DEFAULT_WIPE_DATA; + boolean value = LaunchConfigDelegate.DEFAULT_WIPE_DATA; try { value = configuration.getAttribute(LaunchConfigDelegate.ATTR_WIPE_DATA, value); } catch (CoreException e) { @@ -440,7 +442,7 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab { */ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(LaunchConfigDelegate.ATTR_TARGET_MODE, - LaunchConfigDelegate.DEFAULT_TARGET_MODE); + LaunchConfigDelegate.DEFAULT_TARGET_MODE.getValue()); configuration.setAttribute(LaunchConfigDelegate.ATTR_SPEED, LaunchConfigDelegate.DEFAULT_SPEED); configuration.setAttribute(LaunchConfigDelegate.ATTR_DELAY, From f934a160fdf11489b8a6f7ec6beb55fb0c009cbb Mon Sep 17 00:00:00 2001 From: Dianne Hackborn <> Date: Tue, 24 Mar 2009 18:36:43 -0700 Subject: [PATCH 007/127] Automated import from //branches/donutburger/...@140818,140818 --- apps/CustomLocale/NOTICE | 190 +++++++++++++++++++++++++++++++++++++++ apps/Development/NOTICE | 190 +++++++++++++++++++++++++++++++++++++++ apps/SdkSetup/NOTICE | 190 +++++++++++++++++++++++++++++++++++++++ apps/SpareParts/NOTICE | 190 +++++++++++++++++++++++++++++++++++++++ apps/launchperf/NOTICE | 190 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 950 insertions(+) create mode 100644 apps/CustomLocale/NOTICE create mode 100644 apps/Development/NOTICE create mode 100644 apps/SdkSetup/NOTICE create mode 100644 apps/SpareParts/NOTICE create mode 100644 apps/launchperf/NOTICE diff --git a/apps/CustomLocale/NOTICE b/apps/CustomLocale/NOTICE new file mode 100644 index 000000000..c5b1efa7a --- /dev/null +++ b/apps/CustomLocale/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2005-2008, 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. + + 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. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/apps/Development/NOTICE b/apps/Development/NOTICE new file mode 100644 index 000000000..c5b1efa7a --- /dev/null +++ b/apps/Development/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2005-2008, 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. + + 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. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/apps/SdkSetup/NOTICE b/apps/SdkSetup/NOTICE new file mode 100644 index 000000000..c5b1efa7a --- /dev/null +++ b/apps/SdkSetup/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2005-2008, 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. + + 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. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/apps/SpareParts/NOTICE b/apps/SpareParts/NOTICE new file mode 100644 index 000000000..c5b1efa7a --- /dev/null +++ b/apps/SpareParts/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2005-2008, 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. + + 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. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + diff --git a/apps/launchperf/NOTICE b/apps/launchperf/NOTICE new file mode 100644 index 000000000..c5b1efa7a --- /dev/null +++ b/apps/launchperf/NOTICE @@ -0,0 +1,190 @@ + + Copyright (c) 2005-2008, 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. + + 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. + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + From bbf8acf406c98b1e8a41a4b2c29d2285224ece8b Mon Sep 17 00:00:00 2001 From: Ricky Ng-Adam <> Date: Tue, 24 Mar 2009 20:14:25 -0700 Subject: [PATCH 008/127] Automated import from //branches/donutburger/...@141413,141413 --- .../common/project/AndroidManifestParser.java | 36 ++++++--- .../ide/eclipse/tests/AdtTestData.java | 29 ++++++- .../project/AndroidManifestParserTest.java | 75 ++++++++----------- .../data/AndroidManifest-instrumentation.xml | 18 +++++ .../data/AndroidManifest-testapp.xml | 17 +++++ 5 files changed, 119 insertions(+), 56 deletions(-) create mode 100644 tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/data/AndroidManifest-instrumentation.xml create mode 100644 tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/data/AndroidManifest-testapp.xml diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java index fe11e694c..fa7e9b9f4 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/common/project/AndroidManifestParser.java @@ -16,6 +16,7 @@ package com.android.ide.eclipse.common.project; +import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.common.AndroidConstants; import com.android.ide.eclipse.common.project.XmlErrorHandler.XmlErrorListener; import com.android.sdklib.SdkConstants; @@ -579,7 +580,6 @@ public class AndroidManifestParser { ManifestHandler manifestHandler = new ManifestHandler(manifestFile, errorListener, gatherData, javaProject, markErrors); - parser.parse(new InputSource(manifestFile.getContents()), manifestHandler); // get the result from the handler @@ -590,10 +590,15 @@ public class AndroidManifestParser { manifestHandler.getApiLevelRequirement(), manifestHandler.getInstrumentations(), manifestHandler.getUsesLibraries()); } catch (ParserConfigurationException e) { + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), + "Bad parser configuration for %s", manifestFile.getFullPath()); } catch (SAXException e) { + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), + "Parser exception for %s", manifestFile.getFullPath()); } catch (IOException e) { - } finally { - } + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), + "I/O error for %s", manifestFile.getFullPath()); + } return null; } @@ -633,11 +638,15 @@ public class AndroidManifestParser { manifestHandler.getApiLevelRequirement(), manifestHandler.getInstrumentations(), manifestHandler.getUsesLibraries()); } catch (ParserConfigurationException e) { + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), + "Bad parser configuration for %s", manifestFile.getAbsolutePath()); } catch (SAXException e) { + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), + "Parser exception for %s", manifestFile.getAbsolutePath()); } catch (IOException e) { - } finally { - } - + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), + "I/O error for %s", manifestFile.getAbsolutePath()); + } return null; } @@ -660,10 +669,12 @@ public class AndroidManifestParser { boolean gatherData, boolean markErrors) throws CoreException { + + IFile manifestFile = getManifest(javaProject.getProject()); + try { SAXParser parser = sParserFactory.newSAXParser(); - - IFile manifestFile = getManifest(javaProject.getProject()); + if (manifestFile != null) { ManifestHandler manifestHandler = new ManifestHandler(manifestFile, errorListener, gatherData, javaProject, markErrors); @@ -678,10 +689,15 @@ public class AndroidManifestParser { manifestHandler.getInstrumentations(), manifestHandler.getUsesLibraries()); } } catch (ParserConfigurationException e) { + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), + "Bad parser configuration for %s", manifestFile.getFullPath()); } catch (SAXException e) { + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), + "Parser exception for %s", manifestFile.getFullPath()); } catch (IOException e) { - } finally { - } + AdtPlugin.logAndPrintError(e, AndroidManifestParser.class.getCanonicalName(), + "I/O error for %s", manifestFile.getFullPath()); + } return null; } diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/AdtTestData.java b/tools/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/AdtTestData.java index 262ef65a1..d86d585a3 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/AdtTestData.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/AdtTestData.java @@ -15,7 +15,13 @@ */ package com.android.ide.eclipse.tests; +import com.android.ide.eclipse.common.AndroidConstants; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.Platform; + import java.io.File; +import java.io.IOException; import java.net.URL; import java.util.logging.Logger; @@ -45,12 +51,29 @@ public class AdtTestData { // accessed normally mOsRootDataPath = System.getProperty("test_data"); if (mOsRootDataPath == null) { - sLogger.info("Cannot find test_data directory, init to class loader"); + sLogger.info("Cannot find test_data environment variable, init to class loader"); URL url = this.getClass().getClassLoader().getResource("data"); //$NON-NLS-1$ - mOsRootDataPath = url.getFile(); + + if (Platform.isRunning()) { + sLogger.info("Running as an Eclipse Plug-in JUnit test, using FileLocator"); + try { + mOsRootDataPath = FileLocator.resolve(url).getFile(); + } catch (IOException e) { + sLogger.warning("IOException while using FileLocator, reverting to url"); + mOsRootDataPath = url.getFile(); + } + } else { + sLogger.info("Running as an plain JUnit test, using url as-is"); + mOsRootDataPath = url.getFile(); + } } + + if (mOsRootDataPath.equals(AndroidConstants.WS_SEP + "data")) { + sLogger.warning("Resource data not found using class loader!, Defaulting to no path"); + } + if (!mOsRootDataPath.endsWith(File.separator)) { - sLogger.info("Fixing test_data env variable does not end with path separator"); + sLogger.info("Fixing test_data env variable (does not end with path separator)"); mOsRootDataPath = mOsRootDataPath.concat(File.separator); } } diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/common/project/AndroidManifestParserTest.java b/tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/common/project/AndroidManifestParserTest.java index 516e448e6..7e8b0af10 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/common/project/AndroidManifestParserTest.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/common/project/AndroidManifestParserTest.java @@ -16,17 +16,20 @@ package com.android.ide.eclipse.common.project; -import junit.framework.TestCase; +import com.android.ide.eclipse.tests.AdtTestData; -import com.android.ide.eclipse.mock.FileMock; +import junit.framework.TestCase; /** * Tests for {@link AndroidManifestParser} */ public class AndroidManifestParserTest extends TestCase { - private AndroidManifestParser mManifest; + private AndroidManifestParser mManifestTestApp; + private AndroidManifestParser mManifestInstrumentation; - private static final String PACKAGE_NAME = "com.android.testapp"; //$NON-NLS-1$ + private static final String INSTRUMENTATION_XML = "AndroidManifest-instrumentation.xml"; //$NON-NLS-1$ + private static final String TESTAPP_XML = "AndroidManifest-testapp.xml"; //$NON-NLS-1$ + private static final String PACKAGE_NAME = "com.android.testapp"; //$NON-NLS-1$ private static final String ACTIVITY_NAME = "com.android.testapp.MainActivity"; //$NON-NLS-1$ private static final String LIBRARY_NAME = "android.test.runner"; //$NON-NLS-1$ private static final String INSTRUMENTATION_NAME = "android.test.InstrumentationTestRunner"; //$NON-NLS-1$ @@ -35,60 +38,46 @@ public class AndroidManifestParserTest extends TestCase { protected void setUp() throws Exception { super.setUp(); - // create the test data - StringBuilder sb = new StringBuilder(); - sb.append("\n"); //$NON-NLS-1$ - sb.append("\n"); //$NON-NLS-1$ - sb.append(" \n"); //$NON-NLS-1$ - sb.append(" \n"); //$NON-NLS-1$ - sb.append(" \n"); //$NON-NLS-1$ - sb.append(" \n"); //$NON-NLS-1$ - sb.append(" \"\n"); //$NON-NLS-1$ - sb.append(" \n"); //$NON-NLS-1$ - sb.append(" \n"); //$NON-NLS-1$ - sb.append(" \n"); //$NON-NLS-1$ - sb.append(" \n"); //$NON-NLS-1$ - sb.append(" "); //$NON-NLS-1$ - sb.append(" \n"); - sb.append("\n"); //$NON-NLS-1$ - - FileMock mockFile = new FileMock("AndroidManifest.xml", sb.toString().getBytes()); + String testFilePath = AdtTestData.getInstance().getTestFilePath( + TESTAPP_XML); + mManifestTestApp = AndroidManifestParser.parseForData(testFilePath); + assertNotNull(mManifestTestApp); - mManifest = AndroidManifestParser.parseForData(mockFile); - assertNotNull(mManifest); + testFilePath = AdtTestData.getInstance().getTestFilePath( + INSTRUMENTATION_XML); + mManifestInstrumentation = AndroidManifestParser.parseForData(testFilePath); + assertNotNull(mManifestInstrumentation); } + public void testGetInstrumentationInformation() { + assertEquals(1, mManifestInstrumentation.getInstrumentations().length); + assertEquals(INSTRUMENTATION_NAME, mManifestTestApp.getInstrumentations()[0]); + } + public void testGetPackage() { - assertEquals("com.android.testapp", mManifest.getPackage()); + assertEquals(PACKAGE_NAME, mManifestTestApp.getPackage()); } public void testGetActivities() { - assertEquals(1, mManifest.getActivities().length); - assertEquals(ACTIVITY_NAME, mManifest.getActivities()[0]); + assertEquals(1, mManifestTestApp.getActivities().length); + assertEquals(ACTIVITY_NAME, mManifestTestApp.getActivities()[0]); } public void testGetLauncherActivity() { - assertEquals(ACTIVITY_NAME, mManifest.getLauncherActivity()); + assertEquals(ACTIVITY_NAME, mManifestTestApp.getLauncherActivity()); } public void testGetUsesLibraries() { - assertEquals(1, mManifest.getUsesLibraries().length); - assertEquals(LIBRARY_NAME, mManifest.getUsesLibraries()[0]); + assertEquals(1, mManifestTestApp.getUsesLibraries().length); + assertEquals(LIBRARY_NAME, mManifestTestApp.getUsesLibraries()[0]); } public void testGetInstrumentations() { - assertEquals(1, mManifest.getInstrumentations().length); - assertEquals(INSTRUMENTATION_NAME, mManifest.getInstrumentations()[0]); + assertEquals(1, mManifestTestApp.getInstrumentations().length); + assertEquals(INSTRUMENTATION_NAME, mManifestTestApp.getInstrumentations()[0]); + } + + public void testGetPackageName() { + assertEquals(PACKAGE_NAME, mManifestTestApp.getPackage()); } } diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/data/AndroidManifest-instrumentation.xml b/tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/data/AndroidManifest-instrumentation.xml new file mode 100644 index 000000000..b380f967e --- /dev/null +++ b/tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/data/AndroidManifest-instrumentation.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/data/AndroidManifest-testapp.xml b/tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/data/AndroidManifest-testapp.xml new file mode 100644 index 000000000..8ae70121c --- /dev/null +++ b/tools/eclipse/plugins/com.android.ide.eclipse.tests/unittests/data/AndroidManifest-testapp.xml @@ -0,0 +1,17 @@ + + + + + + + " + + + + + " + + \ No newline at end of file From 8ee14c4a389f1dd488b96d55cb4833ab0db8c71b Mon Sep 17 00:00:00 2001 From: Brett Chabot <> Date: Tue, 24 Mar 2009 20:21:04 -0700 Subject: [PATCH 009/127] Automated import from //branches/donutburger/...@141463,141463 --- .../eclipse/adt/launch/junit/AndroidJUnitLaunchAction.java | 6 +++--- .../{RemoteADTTestRunner.java => RemoteAdtTestRunner.java} | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) rename tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/runtime/{RemoteADTTestRunner.java => RemoteAdtTestRunner.java} (98%) diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchAction.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchAction.java index 4dfe37d1d..b88026329 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchAction.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/AndroidJUnitLaunchAction.java @@ -20,7 +20,7 @@ import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.launch.DelayedLaunchInfo; import com.android.ide.eclipse.adt.launch.IAndroidLaunchAction; import com.android.ide.eclipse.adt.launch.junit.runtime.AndroidJUnitLaunchInfo; -import com.android.ide.eclipse.adt.launch.junit.runtime.RemoteADTTestRunner; +import com.android.ide.eclipse.adt.launch.junit.runtime.RemoteAdtTestRunner; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -166,7 +166,7 @@ class AndroidJUnitLaunchAction implements IAndroidLaunchAction { private final VMRunnerConfiguration mRunConfig; private final ILaunch mLaunch; private final AndroidJUnitLaunchInfo mJUnitInfo; - private RemoteADTTestRunner mTestRunner = null; + private RemoteAdtTestRunner mTestRunner = null; private boolean mIsTerminated = false; TestRunnerProcess(VMRunnerConfiguration runConfig, ILaunch launch, @@ -256,7 +256,7 @@ class AndroidJUnitLaunchAction implements IAndroidLaunchAction { */ @Override public void run() { - mTestRunner = new RemoteADTTestRunner(); + mTestRunner = new RemoteAdtTestRunner(); mTestRunner.runTests(mRunConfig.getProgramArguments(), mJUnitInfo); } } diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/runtime/RemoteADTTestRunner.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/runtime/RemoteAdtTestRunner.java similarity index 98% rename from tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/runtime/RemoteADTTestRunner.java rename to tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/runtime/RemoteAdtTestRunner.java index 6834c089a..0a6a3daee 100755 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/runtime/RemoteADTTestRunner.java +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/launch/junit/runtime/RemoteAdtTestRunner.java @@ -34,7 +34,7 @@ import org.eclipse.jdt.internal.junit.runner.TestReferenceFailure; * @see org.eclipse.jdt.internal.junit.runner.RemoteTestRunner for more details on the protocol */ @SuppressWarnings("restriction") -public class RemoteADTTestRunner extends RemoteTestRunner { +public class RemoteAdtTestRunner extends RemoteTestRunner { private AndroidJUnitLaunchInfo mLaunchInfo; private TestExecution mExecution; @@ -97,6 +97,8 @@ public class RemoteADTTestRunner extends RemoteTestRunner { // error occurred during test collection. reportError(collector.getErrorMessage()); // abort here + notifyTestRunEnded(0); + return; } notifyTestRunStarted(collector.getTestCaseCount()); collector.sendTrees(this); From e818ff0de5215f58aa836d652411ac274a7bb013 Mon Sep 17 00:00:00 2001 From: Raphael Moll <> Date: Tue, 24 Mar 2009 20:23:44 -0700 Subject: [PATCH 010/127] Automated import from //branches/donutburger/...@141482,141482 --- .../META-INF/MANIFEST.MF | 4 +- .../com.android.ide.eclipse.adt/plugin.xml | 44 +- .../extractstring/ExtractStringAction.java | 161 ++++ .../ExtractStringContribution.java | 53 ++ .../ExtractStringDescriptor.java | 71 ++ .../extractstring/ExtractStringInputPage.java | 177 ++++ .../ExtractStringRefactoring.java | 890 ++++++++++++++++++ .../extractstring/ExtractStringWizard.java | 42 + 8 files changed, 1434 insertions(+), 8 deletions(-) create mode 100644 tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/refactorings/extractstring/ExtractStringAction.java create mode 100644 tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/refactorings/extractstring/ExtractStringContribution.java create mode 100644 tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/refactorings/extractstring/ExtractStringDescriptor.java create mode 100644 tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/refactorings/extractstring/ExtractStringInputPage.java create mode 100644 tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/refactorings/extractstring/ExtractStringRefactoring.java create mode 100644 tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/refactorings/extractstring/ExtractStringWizard.java diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF b/tools/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF index 55c18bb26..c0dfcefd5 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF @@ -41,7 +41,9 @@ Require-Bundle: com.android.ide.eclipse.ddms, org.eclipse.wst.xml.core, org.eclipse.wst.xml.ui, org.eclipse.jdt.junit, - org.eclipse.jdt.junit.runtime + org.eclipse.jdt.junit.runtime, + org.eclipse.ltk.core.refactoring, + org.eclipse.ltk.ui.refactoring Eclipse-LazyStart: true Export-Package: com.android.ide.eclipse.adt, com.android.ide.eclipse.adt.build;x-friends:="com.android.ide.eclipse.tests", diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml b/tools/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml index 2ab64256f..2bf633d32 100644 --- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/plugin.xml @@ -470,7 +470,7 @@ point="org.eclipse.ui.actionSets"> - - - - + + + + @@ -565,4 +574,25 @@ + + + + + + + + + + diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/refactorings/extractstring/ExtractStringAction.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/refactorings/extractstring/ExtractStringAction.java new file mode 100644 index 000000000..528701573 --- /dev/null +++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/refactorings/extractstring/ExtractStringAction.java @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2009 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.adt.refactorings.extractstring; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.ITypeRoot; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.ui.JavaUI; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ltk.ui.refactoring.RefactoringWizard; +import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +/* + * Quick Reference Link: + * http://www.eclipse.org/articles/article.php?file=Article-Unleashing-the-Power-of-Refactoring/index.html + * and + * http://www.ibm.com/developerworks/opensource/library/os-ecjdt/ + */ + +/** + * Action executed when the "Extract String" menu item is invoked. + *

+ * The intent of the action is to start a refactoring that extracts a source string and + * replaces it by an Android string resource ID. + *

+ * Workflow: + *