use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.
the class InstallTask method run.
@Override
public void run(@NotNull ProgressIndicator indicator) {
final List<RepoPackage> failures = Lists.newArrayList();
LinkedHashMap<RepoPackage, PackageOperation> operations = new LinkedHashMap<>();
for (UpdatablePackage install : myInstallRequests) {
operations.put(install.getRemote(), getOrCreateInstaller(install.getRemote(), indicator));
}
for (LocalPackage uninstall : myUninstallRequests) {
operations.put(uninstall, getOrCreateUninstaller(uninstall));
}
try {
while (!operations.isEmpty()) {
preparePackages(operations, failures);
if (myPrepareCompleteCallback != null) {
myPrepareCompleteCallback.run();
}
if (!myBackgrounded) {
completePackages(operations, failures);
} else {
// Otherwise show a notification that we're ready to complete.
showPrepareCompleteNotification(operations.keySet());
return;
}
}
} finally {
if (!failures.isEmpty()) {
myLogger.logInfo("Failed packages:");
for (RepoPackage p : failures) {
myLogger.logInfo(String.format("- %1$s (%2$s)", p.getDisplayName(), p.getPath()));
}
}
}
// Use a simple progress indicator here so we don't pick up the log messages from the reload.
StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(getClass());
myRepoManager.loadSynchronously(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, progress, null, mySettingsController);
if (myCompleteCallback != null) {
myCompleteCallback.apply(failures);
}
}
use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.
the class PatchInstallingRestarter method restartAndInstallIfNecessary.
/**
* Find any pending patches under the given sdk root that require studio to be restarted, and if there are any, restart and install them.
* If they have already been installed (as indicated by the patch itself being missing, and the revision mentioned in source.properties
* matching that in the pending XML, do the install complete actions (write package.xml and fire listeners) and clean up.
*/
public void restartAndInstallIfNecessary() {
File patchesDir = new File(mySdkHandler.getLocation(), PatchInstallerUtil.PATCHES_DIR_NAME);
StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(PatchInstallerFactory.class);
if (patchesDir.exists()) {
File[] subDirs = patchesDir.listFiles(file -> file.isDirectory() && file.getName().startsWith(PatchInstallerUtil.PATCH_DIR_PREFIX));
for (File patchDir : subDirs) {
processPatch(mySdkHandler.getLocation(), progress, patchDir);
}
}
}
use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.
the class AaptInvoker method getPathToAapt.
/**
* @return the path to aapt from the latest version of build tools that is installed, null if there are no build tools
*/
@Nullable
private static Path getPathToAapt() {
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
BuildToolInfo latestBuildTool = sdkHandler.getLatestBuildTool(new StudioLoggerProgressIndicator(AaptInvoker.class), true);
if (latestBuildTool == null) {
return null;
}
return latestBuildTool.getLocation().toPath().resolve(SdkConstants.FN_AAPT);
}
use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.
the class SdksCleanupStep method cleanUpSdk.
public void cleanUpSdk(@NotNull Module module, @NotNull Collection<Sdk> invalidAndroidSdks) {
AndroidFacet androidFacet = AndroidFacet.getInstance(module);
if (androidFacet == null || androidFacet.getAndroidModel() == null) {
return;
}
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null && !invalidAndroidSdks.contains(sdk) && (isMissingAndroidLibrary(sdk) || shouldRemoveAnnotationsJar(sdk))) {
// First try to recreate SDK; workaround for issue 78072
AndroidSdkAdditionalData additionalData = myAndroidSdks.getAndroidSdkAdditionalData(sdk);
AndroidSdkData sdkData = AndroidSdkData.getSdkData(sdk);
if (additionalData != null && sdkData != null) {
IAndroidTarget target = additionalData.getBuildTarget(sdkData);
if (target == null) {
AndroidSdkHandler sdkHandler = sdkData.getSdkHandler();
StudioLoggerProgressIndicator logger = new StudioLoggerProgressIndicator(getClass());
sdkHandler.getSdkManager(logger).loadSynchronously(0, logger, null, null);
target = sdkHandler.getAndroidTargetManager(logger).getTargetFromHashString(additionalData.getBuildTargetHashString(), logger);
}
if (target != null) {
SdkModificator sdkModificator = sdk.getSdkModificator();
sdkModificator.removeAllRoots();
for (OrderRoot orderRoot : myAndroidSdks.getLibraryRootsForTarget(target, sdk, true)) {
sdkModificator.addRoot(orderRoot.getFile(), orderRoot.getType());
}
attachJdkAnnotations(sdkModificator);
sdkModificator.commitChanges();
}
}
// above workaround deals with)
if (isMissingAndroidLibrary(sdk)) {
invalidAndroidSdks.add(sdk);
}
}
}
use of com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator in project android by JetBrains.
the class UpgradeConstraintLayoutFix method apply.
public static void apply(@Nullable Module module) {
if (module != null) {
StudioSdkUtil.reloadRemoteSdkWithModalProgress();
AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(AndroidLintMissingConstraintsInspection.class);
RepoPackage p = SdkMavenRepository.findLatestVersion(LATEST_KNOWN_VERSION, sdkHandler, progress);
if (p != null) {
GradleCoordinate gc = SdkMavenRepository.getCoordinateFromSdkPath(p.getPath());
if (gc != null) {
// should always be the case unless the version suffix is somehow wrong
// Update version dependency in the module. Note that this will trigger a sync too.
GradleDependencyManager manager = GradleDependencyManager.getInstance(module.getProject());
manager.updateLibrariesToVersion(module, Collections.singletonList(gc), null);
}
}
}
}
Aggregations