use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class AndroidVersionsInfo method loadInstalledVersions.
/**
* Load the installed android versions from the installed SDK
*/
public void loadInstalledVersions() {
myInstalledVersions.clear();
IAndroidTarget highestInstalledTarget = null;
for (IAndroidTarget target : getCompilationTargets()) {
if (target.isPlatform() && target.getVersion().getFeatureLevel() >= SdkVersionInfo.LOWEST_COMPILE_SDK_VERSION && (highestInstalledTarget == null || target.getVersion().getFeatureLevel() > highestInstalledTarget.getVersion().getFeatureLevel() && !target.getVersion().isPreview())) {
highestInstalledTarget = target;
}
if (target.getVersion().isPreview() || !target.getAdditionalLibraries().isEmpty()) {
myInstalledVersions.add(target.getVersion());
}
}
myHighestInstalledApiTarget = highestInstalledTarget;
}
use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class AndroidPropertyFilesUpdater method updateProjectPropertiesIfNecessary.
@Nullable
private static Pair<VirtualFile, List<Runnable>> updateProjectPropertiesIfNecessary(@NotNull AndroidFacet facet) {
if (facet.isDisposed()) {
return null;
}
final Module module = facet.getModule();
final Pair<PropertiesFile, VirtualFile> pair = AndroidRootUtil.findPropertyFile(module, SdkConstants.FN_PROJECT_PROPERTIES);
if (pair == null) {
return null;
}
final PropertiesFile projectProperties = pair.getFirst();
final VirtualFile projectPropertiesVFile = pair.getSecond();
final Pair<Properties, VirtualFile> localProperties = AndroidRootUtil.readPropertyFile(module, SdkConstants.FN_LOCAL_PROPERTIES);
final List<Runnable> changes = new ArrayList<Runnable>();
final IAndroidTarget androidTarget = facet.getConfiguration().getAndroidTarget();
final String androidTargetHashString = androidTarget != null ? androidTarget.hashString() : null;
final VirtualFile[] dependencies = collectDependencies(module);
final String[] dependencyPaths = toSortedPaths(dependencies);
final List<Object> newState = Arrays.asList(androidTargetHashString, facet.getProjectType(), Arrays.asList(dependencyPaths), facet.getProperties().ENABLE_MANIFEST_MERGING, facet.getProperties().ENABLE_PRE_DEXING);
final List<Object> state = facet.getUserData(ANDROID_PROPERTIES_STATE_KEY);
if (state == null || !Comparing.equal(state, newState)) {
updateTargetProperty(facet, projectProperties, changes);
updateProjectTypeProperty(facet, projectProperties, changes);
updateManifestMergerProperty(facet, projectProperties, changes);
updateDependenciesInPropertyFile(projectProperties, localProperties, dependencies, changes);
facet.putUserData(ANDROID_PROPERTIES_STATE_KEY, newState);
}
return changes.size() > 0 ? Pair.create(projectPropertiesVFile, changes) : null;
}
use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class TargetApiConverter method getHighestKnownApi.
private static int getHighestKnownApi(@NotNull ConvertContext context) {
Module module = context.getModule();
if (module == null) {
return HIGHEST_KNOWN_API;
}
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet == null) {
return HIGHEST_KNOWN_API;
}
IAndroidTarget apiTarget = facet.getConfigurationManager().getHighestApiTarget();
if (apiTarget == null) {
return HIGHEST_KNOWN_API;
}
return Math.max(apiTarget.getVersion().getApiLevel(), HIGHEST_KNOWN_API);
}
use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class GradleSyncTest method sdkCreationForAddons.
// https://code.google.com/p/android/issues/detail?id=185313
@Test
public void sdkCreationForAddons() throws IOException {
guiTest.importSimpleApplication();
IdeFrameFixture ideFrame = guiTest.ideFrame();
Project project = ideFrame.getProject();
Module appModule = ideFrame.getModule("app");
GradleBuildFile buildFile = GradleBuildFile.get(appModule);
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
runWriteCommandAction(project, () -> buildFile.setValue(BuildFileKey.COMPILE_SDK_VERSION, "Google Inc.:Google APIs:24"));
}
});
ideFrame.requestProjectSync().waitForGradleProjectSyncToFinish();
Sdk sdk = ModuleRootManager.getInstance(appModule).getSdk();
AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdk);
SdkAdditionalData data = sdk.getSdkAdditionalData();
assertThat(data).isInstanceOf(AndroidSdkAdditionalData.class);
AndroidSdkAdditionalData androidSdkData = (AndroidSdkAdditionalData) data;
IAndroidTarget buildTarget = androidSdkData.getBuildTarget(sdkData);
// By checking that there are no additional libraries in the SDK, we are verifying that an additional SDK was not created for add-ons.
assertThat(buildTarget.getAdditionalLibraries()).hasSize(0);
}
use of com.android.sdklib.IAndroidTarget in project android by JetBrains.
the class Configuration method syncFolderConfig.
/**
* Updates the folder configuration such that it reflects changes in
* configuration state such as the device orientation, the UI mode, the
* rendering target, etc.
*/
protected void syncFolderConfig() {
Device device = getDevice();
if (device == null) {
return;
}
// get the device config from the device/state combos.
State deviceState = getDeviceState();
if (deviceState == null) {
deviceState = device.getDefaultState();
}
FolderConfiguration config = getFolderConfig(getModule(), deviceState, getLocale(), getTarget());
// replace the config with the one from the device
myFullConfig.set(config);
// sync the selected locale
Locale locale = getLocale();
myFullConfig.setLocaleQualifier(locale.qualifier);
if (myEditedConfig.getLayoutDirectionQualifier() != null) {
myFullConfig.setLayoutDirectionQualifier(myEditedConfig.getLayoutDirectionQualifier());
} else if (!locale.hasLanguage()) {
// Avoid getting the layout library if the locale doesn't have any language.
myFullConfig.setLayoutDirectionQualifier(new LayoutDirectionQualifier(LayoutDirection.LTR));
} else {
LayoutLibrary layoutLib = RenderService.getLayoutLibrary(getModule(), getTarget());
if (layoutLib != null) {
if (layoutLib.isRtl(locale.toLocaleId())) {
myFullConfig.setLayoutDirectionQualifier(new LayoutDirectionQualifier(LayoutDirection.RTL));
} else {
myFullConfig.setLayoutDirectionQualifier(new LayoutDirectionQualifier(LayoutDirection.LTR));
}
}
}
// Replace the UiMode with the selected one, if one is selected
UiMode uiMode = getUiMode();
myFullConfig.setUiModeQualifier(new UiModeQualifier(uiMode));
// Replace the NightMode with the selected one, if one is selected
NightMode nightMode = getNightMode();
myFullConfig.setNightModeQualifier(new NightModeQualifier(nightMode));
// replace the API level by the selection of the combo
IAndroidTarget target = getTarget();
if (target != null) {
int apiLevel = target.getVersion().getFeatureLevel();
myFullConfig.setVersionQualifier(new VersionQualifier(apiLevel));
}
myFolderConfigDirty = 0;
myProjectStateVersion = myManager.getStateVersion();
}
Aggregations