use of com.android.repository.api.RemotePackage in project android by JetBrains.
the class InstallNdkHyperlink method execute.
@Override
protected void execute(@NotNull Project project) {
File path = getNdkPath(project);
if (path != null) {
// Try to install SDK in local.properties.
SelectNdkDialog dialog = new SelectNdkDialog(path.getPath(), false, true);
dialog.setModal(true);
if (dialog.showAndGet() && setNdkPath(project, dialog.getAndroidNdkPath())) {
// Saving NDK path is successful.
GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
}
return;
}
// There is no path. Try installing from SDK.
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
StudioLoggerProgressIndicator progressIndicator = new StudioLoggerProgressIndicator(getClass());
RepoManager sdkManager = sdkHandler.getSdkManager(progressIndicator);
StudioProgressRunner progressRunner = new StudioProgressRunner(false, /* backgroundable */
false, /* cancellable */
"Loading Remote SDK", true, /* in UI thread */
project);
RepoManager.RepoLoadedCallback onComplete = packages -> {
Map<String, RemotePackage> remotePackages = packages.getRemotePackages();
RemotePackage ndkPackage = remotePackages.get(FD_NDK);
if (ndkPackage != null) {
ModelWizardDialog dialog = createDialogForPaths(project, ImmutableList.of(ndkPackage.getPath()));
if (dialog != null && dialog.showAndGet()) {
GradleSyncInvoker.getInstance().requestProjectSyncAndSourceGeneration(project, null);
}
return;
}
notifyNdkPackageNotFound(project);
};
Runnable onError = () -> notifyNdkPackageNotFound(project);
sdkManager.load(DEFAULT_EXPIRATION_PERIOD_MS, null, ImmutableList.of(onComplete), ImmutableList.of(onError), progressRunner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
use of com.android.repository.api.RemotePackage in project android by JetBrains.
the class SmwOldApiDirectInstall method startSdkInstallUsingNonSwtOldApi.
private void startSdkInstallUsingNonSwtOldApi() {
// Get the SDK instance.
final AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
if (sdkHandler.getLocation() == null) {
myErrorLabel.setText("Error: can't get SDK instance.");
myErrorLabel.setIcon(AllIcons.General.BalloonError);
return;
}
File androidSdkPath = IdeSdks.getInstance().getAndroidSdkPath();
if (androidSdkPath != null && androidSdkPath.exists() && !androidSdkPath.canWrite()) {
myErrorLabel.setText(String.format("SDK folder is read-only: '%1$s'", androidSdkPath.getPath()));
myErrorLabel.setIcon(AllIcons.General.BalloonError);
return;
}
myLabelSdkPath.setText(sdkHandler.getLocation().getPath());
final CustomLogger logger = new CustomLogger();
final com.android.repository.api.ProgressIndicator repoProgress = new StudioLoggerProgressIndicator(getClass());
RepoManager.RepoLoadedCallback onComplete = packages -> UIUtil.invokeLaterIfNeeded(() -> {
List<String> requestedChanges = myState.get(INSTALL_REQUESTS_KEY);
if (requestedChanges == null) {
assert false : "Shouldn't be in installer with no requests";
myInstallFinished = true;
invokeUpdate(null);
return;
}
Map<String, RemotePackage> remotes = packages.getRemotePackages();
List<RemotePackage> requestedPackages = Lists.newArrayList();
boolean notFound = false;
for (String path : requestedChanges) {
RemotePackage remotePackage = remotes.get(path);
if (remotePackage != null) {
requestedPackages.add(remotePackage);
} else {
notFound = true;
}
}
if (requestedPackages.isEmpty()) {
myInstallFinished = true;
invokeUpdate(null);
} else {
requestedPackages = InstallerUtil.computeRequiredPackages(requestedPackages, packages, repoProgress);
if (requestedPackages == null) {
notFound = true;
} else {
InstallTask task = new InstallTask(sdkHandler, requestedPackages, logger);
BackgroundableProcessIndicator indicator = new BackgroundableProcessIndicator(task);
logger.setIndicator(indicator);
ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, indicator);
}
}
if (notFound) {
myErrorLabel.setText("Problem: Some required packages could not be installed. Check internet connection.");
myErrorLabel.setIcon(AllIcons.General.BalloonError);
}
});
StudioProgressRunner runner = new StudioProgressRunner(false, false, "Updating SDK", false, null);
sdkHandler.getSdkManager(repoProgress).load(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, null, ImmutableList.of(onComplete), null, runner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
use of com.android.repository.api.RemotePackage in project android by JetBrains.
the class RepositoryUrlManagerTest method testResolvedCoordinateRemoteSdk.
public void testResolvedCoordinateRemoteSdk() throws Exception {
RemotePackage pkg = new FakePackage.FakeRemotePackage("extras;m2repository;com;google;android;gms;play-services;4.5.0");
RepositoryPackages pkgs = new RepositoryPackages(ImmutableList.of(), ImmutableList.of(pkg));
RepoManager mgr = new FakeRepoManager(pkgs);
mySdkHandler = new AndroidSdkHandler(new File("/emptysdk"), ANDROID_HOME, myFileOp, mgr);
GradleCoordinate coordinate = GradleCoordinate.parseCoordinateString("com.google.android.gms:play-services:4.+");
assertNotNull(coordinate);
assertEquals("4.5.0", resolveDynamicCoordinateVersion(coordinate));
}
use of com.android.repository.api.RemotePackage in project android by JetBrains.
the class AndroidVirtualDeviceTest method testCreateDevice.
public void testCreateDevice() throws Exception {
MockFileOp fop = new MockFileOp();
recordPlatform23(fop);
recordGoogleApisAddon23(fop);
recordGoogleApisSysImg23(fop);
fop.recordExistingFile(new File(DeviceArtDescriptor.getBundledDescriptorsFolder(), "nexus_5x"));
AndroidSdkHandler sdkHandler = new AndroidSdkHandler(new File("/sdk"), new File("/android-home"), fop);
final AvdManagerConnection connection = new AvdManagerConnection(sdkHandler);
FakePackage.FakeRemotePackage remotePlatform = new FakePackage.FakeRemotePackage("platforms;android-23");
RepoFactory factory = AndroidSdkHandler.getRepositoryModule().createLatestFactory();
DetailsTypes.PlatformDetailsType platformDetailsType = factory.createPlatformDetailsType();
platformDetailsType.setApiLevel(23);
remotePlatform.setTypeDetails((TypeDetails) platformDetailsType);
Map<String, RemotePackage> remotes = Maps.newHashMap();
remotes.put("platforms;android-23", remotePlatform);
AndroidVirtualDevice avd = new AndroidVirtualDevice(new ScopedStateStore(ScopedStateStore.Scope.STEP, null, null), remotes, true, fop);
final AvdInfo avdInfo = avd.createAvd(connection, sdkHandler);
assertNotNull(avdInfo);
disposeOnTearDown(() -> connection.deleteAvd(avdInfo));
assertNotNull(avdInfo);
Map<String, String> properties = avdInfo.getProperties();
Map<String, String> referenceMap = getReferenceMap();
for (Map.Entry<String, String> entry : referenceMap.entrySet()) {
assertEquals(entry.getKey(), entry.getValue(), FileUtil.toSystemIndependentName(properties.get(entry.getKey())));
}
// AVD manager will set some extra properties that we don't care about and that may be system dependant.
// We do not care about those so we only ensure we have the ones we need.
File skin = new File(properties.get(AvdManager.AVD_INI_SKIN_PATH));
assertEquals("nexus_5x", skin.getName());
}
use of com.android.repository.api.RemotePackage in project android by JetBrains.
the class Platform method getLatestPlatform.
@Nullable
private static Platform getLatestPlatform(@NotNull ScopedStateStore store, @Nullable Map<String, RemotePackage> remotePackages, boolean installUpdates) {
RemotePackage latest = InstallComponentsPath.findLatestPlatform(remotePackages);
if (latest != null) {
AndroidVersion version = ((DetailsTypes.PlatformDetailsType) latest.getTypeDetails()).getAndroidVersion();
String versionName = SdkVersionInfo.getAndroidName(version.getFeatureLevel());
final String description = "Android platform libraries for targeting " + versionName + " platform";
return new Platform(store, versionName, description, version, !version.isPreview(), installUpdates);
}
return null;
}
Aggregations