use of com.android.sdklib.AndroidVersion in project kotlin by JetBrains.
the class PermissionRequirement method appliesTo.
/**
* Returns false if this permission does not apply given the specified minimum and
* target sdk versions
*
* @param minSdkVersion the minimum SDK version
* @param targetSdkVersion the target SDK version
* @return true if this permission requirement applies for the given versions
*/
/**
* Returns false if this permission does not apply given the specified minimum and target
* sdk versions
*
* @param available the permission holder which also knows the min and target versions
* @return true if this permission requirement applies for the given versions
*/
protected boolean appliesTo(@NonNull PermissionHolder available) {
if (firstApi == 0) {
// initialized?
// initialized, not specified
firstApi = -1;
// Not initialized
String range = getAnnotationStringValue(annotation, "apis");
if (range != null) {
// Currently only support the syntax "a..b" where a and b are inclusive end points
// and where "a" and "b" are optional
int index = range.indexOf("..");
if (index != -1) {
try {
if (index > 0) {
firstApi = Integer.parseInt(range.substring(0, index));
} else {
firstApi = 1;
}
if (index + 2 < range.length()) {
lastApi = Integer.parseInt(range.substring(index + 2));
} else {
lastApi = Integer.MAX_VALUE;
}
} catch (NumberFormatException ignore) {
}
}
}
}
if (firstApi != -1) {
AndroidVersion minSdkVersion = available.getMinSdkVersion();
if (minSdkVersion.getFeatureLevel() > lastApi) {
return false;
}
AndroidVersion targetSdkVersion = available.getTargetSdkVersion();
if (targetSdkVersion.getFeatureLevel() < firstApi) {
return false;
}
}
return true;
}
use of com.android.sdklib.AndroidVersion in project kotlin by JetBrains.
the class ApiDetector method getMinSdk.
protected int getMinSdk(Context context) {
if (mMinApi == -1) {
AndroidVersion minSdkVersion = context.getMainProject().getMinSdkVersion();
mMinApi = minSdkVersion.getFeatureLevel();
}
return mMinApi;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class AndroidSdksTest method createTargetWithApiLevel.
@NotNull
private static IAndroidTarget createTargetWithApiLevel(int apiLevel) {
AndroidVersion version = new AndroidVersion(apiLevel, null);
IAndroidTarget target = mock(IAndroidTarget.class);
when(target.getVersion()).thenReturn(version);
return target;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class SdkComponentSource method getStatuses.
@NotNull
@Override
public Collection<? extends Pair<String, String>> getStatuses() {
Revision toolsRevision = null;
LocalPackage toolsPackage = getRepoManager().getPackages().getLocalPackages().get(SdkConstants.FD_TOOLS);
if (toolsPackage != null) {
toolsRevision = toolsPackage.getVersion();
}
Revision platformRevision = null;
AndroidVersion platformVersion = null;
for (LocalPackage info : getRepoManager().getPackages().getLocalPackagesForPrefix(SdkConstants.FD_PLATFORMS)) {
if (info.getTypeDetails() instanceof DetailsTypes.PlatformDetailsType) {
DetailsTypes.PlatformDetailsType details = (DetailsTypes.PlatformDetailsType) info.getTypeDetails();
AndroidVersion testVersion = new AndroidVersion(details.getApiLevel(), details.getCodename());
if (platformVersion == null || platformVersion.compareTo(testVersion) < 0) {
platformRevision = info.getVersion();
platformVersion = testVersion;
}
}
}
List<Pair<String, String>> result = Lists.newArrayList();
if (toolsRevision != null) {
result.add(Pair.create("Android SDK Tools:", toolsRevision.toString()));
}
if (platformVersion != null) {
result.add(Pair.create("Android Platform Version:", String.format("%1$s revision %2$s", platformVersion.getCodename() != null ? platformVersion.getCodename() : SdkVersionInfo.getAndroidName(platformVersion.getApiLevel()), platformRevision)));
}
return result;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class ApiLevelColumnInfo method valueOf.
@Nullable
@Override
public String valueOf(UpdaterTreeNode node) {
AndroidVersion version;
if (node instanceof DetailsTreeNode) {
DetailsTypes.ApiDetailsType details = (DetailsTypes.ApiDetailsType) ((DetailsTreeNode) node).getPackage().getTypeDetails();
version = new AndroidVersion(details.getApiLevel(), details.getCodename());
} else if (node instanceof SummaryTreeNode) {
version = ((SummaryTreeNode) node).getVersion();
} else {
return "";
}
if (version != null) {
return version.getApiString();
} else {
return "Unknown";
}
}
Aggregations