use of com.android.sdklib.AndroidVersion in project kotlin by JetBrains.
the class Project method getResourceFolders.
/**
* Returns the resource folders.
*
* @return a list of files pointing to the resource folders, which might be empty if the project
* does not provide any resources.
*/
@NonNull
public List<File> getResourceFolders() {
if (mResourceFolders == null) {
List<File> folders = mClient.getResourceFolders(this);
if (folders.size() == 1 && isAospFrameworksRelatedProject(mDir)) {
// No manifest file for this project: just init the manifest values here
mManifestMinSdk = mManifestTargetSdk = new AndroidVersion(HIGHEST_KNOWN_API, null);
File folder = new File(folders.get(0), RES_FOLDER);
if (!folder.exists()) {
folders = Collections.emptyList();
}
}
mResourceFolders = folders;
}
return mResourceFolders;
}
use of com.android.sdklib.AndroidVersion in project kotlin by JetBrains.
the class Project method findCurrentAospVersion.
/** In an AOSP build environment, identify the currently built image version, if available */
private static AndroidVersion findCurrentAospVersion() {
if (sCurrentVersion == null) {
File versionMk = new File(getAospTop(), //$NON-NLS-1$
"build/core/version_defaults.mk".replace('/', File.separatorChar));
if (!versionMk.exists()) {
sCurrentVersion = AndroidVersion.DEFAULT;
return sCurrentVersion;
}
int sdkVersion = LOWEST_ACTIVE_API;
try {
Pattern p = Pattern.compile("PLATFORM_SDK_VERSION\\s*:=\\s*(.*)");
List<String> lines = Files.readLines(versionMk, Charsets.UTF_8);
for (String line : lines) {
line = line.trim();
Matcher matcher = p.matcher(line);
if (matcher.matches()) {
String version = matcher.group(1);
try {
sdkVersion = Integer.parseInt(version);
} catch (NumberFormatException nfe) {
// pass
}
break;
}
}
} catch (IOException io) {
// pass
}
sCurrentVersion = new AndroidVersion(sdkVersion, null);
}
return sCurrentVersion;
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class MakeBeforeRunTaskProviderTest method previewDeviceArguments.
@Test
public void previewDeviceArguments() {
when(myDevice.getVersion()).thenReturn(new AndroidVersion(23, "N"));
when(myDevice.getDensity()).thenReturn(640);
when(myDevice.getAbis()).thenReturn(ImmutableList.of(Abi.ARMEABI));
List<String> arguments = MakeBeforeRunTaskProvider.getDeviceSpecificArguments(Collections.singletonList(myDevice));
assertTrue(arguments.contains("-Pandroid.injected.build.api=24"));
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class AndroidVersionsInfoTest method setUp.
@Before
public void setUp() throws Exception {
initMocks(this);
Mockito.when(myMockAndroidVersionsInfo.getHighestInstalledVersion()).thenReturn(new AndroidVersion(HIGHEST_VERSION, null));
}
use of com.android.sdklib.AndroidVersion in project android by JetBrains.
the class LaunchCompatibilityTest method testMinSdk.
public void testMinSdk() {
final MockPlatformTarget projectTarget = new MockPlatformTarget(14, 0);
final EnumSet<IDevice.HardwareFeature> requiredFeatures = EnumSet.noneOf(IDevice.HardwareFeature.class);
// cannot run if the API level of device is < API level required by minSdk
LaunchCompatibility compatibility = LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, null), projectTarget, requiredFeatures, null, createMockDevice(7, null));
assertEquals(new LaunchCompatibility(ThreeState.NO, "minSdk(API 8) > deviceSdk(API 7)"), compatibility);
// can run if the API level of device is >= API level required by minSdk
compatibility = LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, null), projectTarget, requiredFeatures, null, createMockDevice(8, null));
assertEquals(new LaunchCompatibility(ThreeState.YES, null), compatibility);
// cannot run if minSdk uses a code name that is not matched by the device
compatibility = LaunchCompatibility.canRunOnDevice(new AndroidVersion(8, "P"), projectTarget, requiredFeatures, null, createMockDevice(9, null));
assertEquals(new LaunchCompatibility(ThreeState.NO, "minSdk(API 8, P preview) != deviceSdk(API 9)"), compatibility);
}
Aggregations