Merge commit '816ba073c618e4f1c2085451d117d463e71680a0' * commit '816ba073c618e4f1c2085451d117d463e71680a0': ADT #1825491: Provide default choices for <uses-library>
This commit is contained in:
@@ -29,6 +29,7 @@ import com.android.layoutlib.api.ILayoutBridge;
|
|||||||
import com.android.sdklib.IAndroidTarget;
|
import com.android.sdklib.IAndroidTarget;
|
||||||
import com.android.sdklib.IAndroidTarget.IOptionalLibrary;
|
import com.android.sdklib.IAndroidTarget.IOptionalLibrary;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -97,6 +98,7 @@ public class AndroidTargetData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an AndroidTargetData object.
|
* Creates an AndroidTargetData object.
|
||||||
|
* @param platformLibraries
|
||||||
* @param optionalLibraries
|
* @param optionalLibraries
|
||||||
*/
|
*/
|
||||||
void setExtraData(IResourceRepository systemResourceRepository,
|
void setExtraData(IResourceRepository systemResourceRepository,
|
||||||
@@ -110,6 +112,7 @@ public class AndroidTargetData {
|
|||||||
String[] broadcastIntentActionValues,
|
String[] broadcastIntentActionValues,
|
||||||
String[] serviceIntentActionValues,
|
String[] serviceIntentActionValues,
|
||||||
String[] intentCategoryValues,
|
String[] intentCategoryValues,
|
||||||
|
String[] platformLibraries,
|
||||||
IOptionalLibrary[] optionalLibraries,
|
IOptionalLibrary[] optionalLibraries,
|
||||||
ProjectResources resources,
|
ProjectResources resources,
|
||||||
LayoutBridge layoutBridge) {
|
LayoutBridge layoutBridge) {
|
||||||
@@ -126,7 +129,7 @@ public class AndroidTargetData {
|
|||||||
setPermissions(permissionValues);
|
setPermissions(permissionValues);
|
||||||
setIntentFilterActionsAndCategories(activityIntentActionValues, broadcastIntentActionValues,
|
setIntentFilterActionsAndCategories(activityIntentActionValues, broadcastIntentActionValues,
|
||||||
serviceIntentActionValues, intentCategoryValues);
|
serviceIntentActionValues, intentCategoryValues);
|
||||||
setOptionalLibraries(optionalLibraries);
|
setOptionalLibraries(platformLibraries, optionalLibraries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DexWrapper getDexWrapper() {
|
public DexWrapper getDexWrapper() {
|
||||||
@@ -276,35 +279,40 @@ public class AndroidTargetData {
|
|||||||
* @param permissionValues the list of permissions
|
* @param permissionValues the list of permissions
|
||||||
*/
|
*/
|
||||||
private void setPermissions(String[] permissionValues) {
|
private void setPermissions(String[] permissionValues) {
|
||||||
setValues("(uses-permission,android:name)", permissionValues); //$NON-NLS-1$
|
setValues("(uses-permission,android:name)", permissionValues); //$NON-NLS-1$
|
||||||
setValues("(application,android:permission)", permissionValues); //$NON-NLS-1$
|
setValues("(application,android:permission)", permissionValues); //$NON-NLS-1$
|
||||||
setValues("(activity,android:permission)", permissionValues); //$NON-NLS-1$
|
setValues("(activity,android:permission)", permissionValues); //$NON-NLS-1$
|
||||||
setValues("(receiver,android:permission)", permissionValues); //$NON-NLS-1$
|
setValues("(receiver,android:permission)", permissionValues); //$NON-NLS-1$
|
||||||
setValues("(service,android:permission)", permissionValues); //$NON-NLS-1$
|
setValues("(service,android:permission)", permissionValues); //$NON-NLS-1$
|
||||||
setValues("(provider,android:permission)", permissionValues); //$NON-NLS-1$
|
setValues("(provider,android:permission)", permissionValues); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setIntentFilterActionsAndCategories(String[] activityIntentActions,
|
private void setIntentFilterActionsAndCategories(String[] activityIntentActions,
|
||||||
String[] broadcastIntentActions, String[] serviceIntentActions,
|
String[] broadcastIntentActions, String[] serviceIntentActions,
|
||||||
String[] intentCategoryValues) {
|
String[] intentCategoryValues) {
|
||||||
setValues("(activity,action,android:name)", activityIntentActions); //$NON-NLS-1$
|
setValues("(activity,action,android:name)", activityIntentActions); //$NON-NLS-1$
|
||||||
setValues("(receiver,action,android:name)", broadcastIntentActions); //$NON-NLS-1$
|
setValues("(receiver,action,android:name)", broadcastIntentActions); //$NON-NLS-1$
|
||||||
setValues("(service,action,android:name)", serviceIntentActions); //$NON-NLS-1$
|
setValues("(service,action,android:name)", serviceIntentActions); //$NON-NLS-1$
|
||||||
setValues("(category,android:name)", intentCategoryValues); //$NON-NLS-1$
|
setValues("(category,android:name)", intentCategoryValues); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setOptionalLibraries(IOptionalLibrary[] optionalLibraries) {
|
private void setOptionalLibraries(String[] platformLibraries,
|
||||||
String[] values;
|
IOptionalLibrary[] optionalLibraries) {
|
||||||
|
|
||||||
if (optionalLibraries == null) {
|
ArrayList<String> libs = new ArrayList<String>();
|
||||||
values = new String[0];
|
|
||||||
} else {
|
if (platformLibraries != null) {
|
||||||
values = new String[optionalLibraries.length];
|
for (String name : platformLibraries) {
|
||||||
for (int i = 0; i < optionalLibraries.length; i++) {
|
libs.add(name);
|
||||||
values[i] = optionalLibraries[i].getName();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setValues("(uses-library,android:name)", values);
|
|
||||||
|
if (optionalLibraries != null) {
|
||||||
|
for (int i = 0; i < optionalLibraries.length; i++) {
|
||||||
|
libs.add(optionalLibraries[i].getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setValues("(uses-library,android:name)", libs.toArray(new String[libs.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -267,6 +267,7 @@ public final class AndroidTargetParser {
|
|||||||
broadcast_actions.toArray(new String[broadcast_actions.size()]),
|
broadcast_actions.toArray(new String[broadcast_actions.size()]),
|
||||||
service_actions.toArray(new String[service_actions.size()]),
|
service_actions.toArray(new String[service_actions.size()]),
|
||||||
categories.toArray(new String[categories.size()]),
|
categories.toArray(new String[categories.size()]),
|
||||||
|
mAndroidTarget.getPlatformLibraries(),
|
||||||
mAndroidTarget.getOptionalLibraries(),
|
mAndroidTarget.getOptionalLibraries(),
|
||||||
resources,
|
resources,
|
||||||
layoutBridge);
|
layoutBridge);
|
||||||
|
|||||||
@@ -192,6 +192,15 @@ final class AddOnTarget implements IAndroidTarget {
|
|||||||
return mLibraries;
|
return mLibraries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of libraries of the underlying platform.
|
||||||
|
*
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public String[] getPlatformLibraries() {
|
||||||
|
return mBasePlatform.getPlatformLibraries();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCompatibleBaseFor(IAndroidTarget target) {
|
public boolean isCompatibleBaseFor(IAndroidTarget target) {
|
||||||
// basic test
|
// basic test
|
||||||
if (target == this) {
|
if (target == this) {
|
||||||
|
|||||||
@@ -149,7 +149,14 @@ public interface IAndroidTarget extends Comparable<IAndroidTarget> {
|
|||||||
* @return an array of optional libraries or <code>null</code> if there is none.
|
* @return an array of optional libraries or <code>null</code> if there is none.
|
||||||
*/
|
*/
|
||||||
IOptionalLibrary[] getOptionalLibraries();
|
IOptionalLibrary[] getOptionalLibraries();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the list of libraries available for a given platform.
|
||||||
|
*
|
||||||
|
* @return an array of libraries provided by the platform or <code>null</code> if there is none.
|
||||||
|
*/
|
||||||
|
String[] getPlatformLibraries();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the given target is compatible with the receiver.
|
* Returns whether the given target is compatible with the receiver.
|
||||||
* <p/>A target is considered compatible if applications developed for the receiver can run on
|
* <p/>A target is considered compatible if applications developed for the receiver can run on
|
||||||
|
|||||||
@@ -149,15 +149,25 @@ final class PlatformTarget implements IAndroidTarget {
|
|||||||
return "HVGA";
|
return "HVGA";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Always returns null, as a standard platforms have no optional libraries.
|
* Always returns null, as a standard platform ha no optional libraries.
|
||||||
*
|
*
|
||||||
* (non-Javadoc)
|
* {@inheritDoc}
|
||||||
* @see com.android.sdklib.IAndroidTarget#getOptionalLibraries()
|
* @see com.android.sdklib.IAndroidTarget#getOptionalLibraries()
|
||||||
*/
|
*/
|
||||||
public IOptionalLibrary[] getOptionalLibraries() {
|
public IOptionalLibrary[] getOptionalLibraries() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Currently always return a fixed list with "android.test.runner" in it.
|
||||||
|
* <p/>
|
||||||
|
* TODO change the fixed library list to be build-dependent later.
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public String[] getPlatformLibraries() {
|
||||||
|
return new String[] { SdkConstants.ANDROID_TEST_RUNNER_LIB };
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCompatibleBaseFor(IAndroidTarget target) {
|
public boolean isCompatibleBaseFor(IAndroidTarget target) {
|
||||||
// basic test
|
// basic test
|
||||||
|
|||||||
@@ -167,6 +167,9 @@ public final class SdkConstants {
|
|||||||
/** Namespace for the resource XML, i.e. "http://schemas.android.com/apk/res/android" */
|
/** Namespace for the resource XML, i.e. "http://schemas.android.com/apk/res/android" */
|
||||||
public final static String NS_RESOURCES = "http://schemas.android.com/apk/res/android";
|
public final static String NS_RESOURCES = "http://schemas.android.com/apk/res/android";
|
||||||
|
|
||||||
|
/** The name of the uses-library that provides "android.test.runner" */
|
||||||
|
public final static String ANDROID_TEST_RUNNER_LIB = "android.test.runner";
|
||||||
|
|
||||||
/* Folder path relative to the SDK root */
|
/* Folder path relative to the SDK root */
|
||||||
/** Path of the documentation directory relative to the sdk folder.
|
/** Path of the documentation directory relative to the sdk folder.
|
||||||
* This is an OS path, ending with a separator. */
|
* This is an OS path, ending with a separator. */
|
||||||
|
|||||||
Reference in New Issue
Block a user