Search in sources :

Example 11 with LocalPackage

use of com.android.repository.api.LocalPackage in project android by JetBrains.

the class SdkBuildToolsTooLowErrorHandler method getQuickFixHyperlinks.

@NotNull
public List<NotificationHyperlink> getQuickFixHyperlinks(@NotNull String minimumVersion, @NotNull Project project, @Nullable Module module) {
    List<NotificationHyperlink> hyperlinks = new ArrayList<>();
    boolean buildToolInstalled = false;
    AndroidSdkHandler sdkHandler = null;
    AndroidSdkData androidSdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
    if (androidSdkData != null) {
        sdkHandler = androidSdkData.getSdkHandler();
    }
    if (sdkHandler != null) {
        ProgressIndicator progress = new StudioLoggerProgressIndicator(SdkBuildToolsTooLowErrorHandler.class);
        RepositoryPackages packages = sdkHandler.getSdkManager(progress).getPackages();
        LocalPackage buildTool = packages.getLocalPackages().get(getBuildToolsPath(parseRevision(minimumVersion)));
        buildToolInstalled = buildTool != null;
    }
    if (module != null) {
        VirtualFile buildFile = getGradleBuildFile(module);
        AndroidPluginInfo androidPluginInfo = AndroidPluginInfo.find(project);
        if (!buildToolInstalled) {
            if (androidPluginInfo != null && androidPluginInfo.isExperimental()) {
                hyperlinks.add(new InstallBuildToolsHyperlink(minimumVersion, null));
            } else {
                hyperlinks.add(new InstallBuildToolsHyperlink(minimumVersion, buildFile));
            }
        } else if (buildFile != null && androidPluginInfo != null && !androidPluginInfo.isExperimental()) {
            hyperlinks.add(new FixBuildToolsVersionHyperlink(buildFile, minimumVersion));
        }
        if (buildFile != null) {
            hyperlinks.add(new OpenFileHyperlink(buildFile.getPath()));
        }
    }
    return hyperlinks;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalPackage(com.android.repository.api.LocalPackage) FixBuildToolsVersionHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.FixBuildToolsVersionHyperlink) ArrayList(java.util.ArrayList) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) InstallBuildToolsHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.InstallBuildToolsHyperlink) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) AndroidPluginInfo(com.android.tools.idea.gradle.plugin.AndroidPluginInfo) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) OpenFileHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.OpenFileHyperlink) NotificationHyperlink(com.android.tools.idea.gradle.project.sync.hyperlink.NotificationHyperlink) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with LocalPackage

use of com.android.repository.api.LocalPackage in project android by JetBrains.

the class PatchInstallerFactoryTest method cantHandleLinuxUninstallWithPatcher.

@Test
public void cantHandleLinuxUninstallWithPatcher() {
    LocalPackage p = new FakeLocalPackage("foo");
    myRepositoryPackages.setLocalPkgInfos(ImmutableList.of(p, PATCHER_4));
    assertFalse(myInstallerFactory.canHandlePackage(p, myRepoManager, myFileOp));
}
Also used : FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) LocalPackage(com.android.repository.api.LocalPackage) FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) Test(org.junit.Test)

Example 13 with LocalPackage

use of com.android.repository.api.LocalPackage in project android by JetBrains.

the class SdkMergerTest method getSdkFingerprint.

private String getSdkFingerprint(File sdk) {
    StringBuilder s = new StringBuilder();
    RepoManager sdkManager = AndroidSdkHandler.getInstance(sdk).getSdkManager(new StudioLoggerProgressIndicator(getClass()));
    for (LocalPackage p : Sets.newTreeSet(sdkManager.getPackages().getLocalPackages().values())) {
        s.append(p.getPath());
        s.append(',');
        s.append(p.getVersion());
        s.append('\n');
    }
    return s.toString();
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) LocalPackage(com.android.repository.api.LocalPackage) RepoManager(com.android.repository.api.RepoManager)

Example 14 with LocalPackage

use of com.android.repository.api.LocalPackage in project android by JetBrains.

the class PatchInstallerUtilTest method getDependantPatcher.

@Test
public void getDependantPatcher() throws Exception {
    LocalPackage target = new FakeLocalPackage("patcher;v2");
    List<LocalPackage> local = ImmutableList.of(new FakeLocalPackage("patcher;v1"), target, new FakeLocalPackage("patcher;v3"));
    FakeRemotePackage update = new FakeRemotePackage("p");
    List<RemotePackage> remote = ImmutableList.of(update, new FakeRemotePackage("patcher;v4"));
    update.setDependencies(ImmutableList.of(new FakeDependency(target.getPath())));
    RepositoryPackages packages = new RepositoryPackages(local, remote);
    FakeRepoManager mgr = new FakeRepoManager(new File("/sdk"), packages);
    LocalPackage patcher = PatchInstallerUtil.getDependantPatcher(update, mgr);
    assertEquals(target, patcher);
}
Also used : FakeRemotePackage(com.android.repository.testframework.FakePackage.FakeRemotePackage) FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) LocalPackage(com.android.repository.api.LocalPackage) FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeDependency(com.android.repository.testframework.FakeDependency) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) RemotePackage(com.android.repository.api.RemotePackage) FakeRemotePackage(com.android.repository.testframework.FakePackage.FakeRemotePackage) File(java.io.File) Test(org.junit.Test)

Example 15 with LocalPackage

use of com.android.repository.api.LocalPackage in project android by JetBrains.

the class PatchInstallerUtilTest method dependantPatcherNotInstalled.

@Test
public void dependantPatcherNotInstalled() throws Exception {
    FakeLocalPackage target = new FakeLocalPackage("patcher;v2");
    List<LocalPackage> local = ImmutableList.of(new FakeLocalPackage("patcher;v1"), new FakeLocalPackage("patcher;v3"));
    FakeRemotePackage update = new FakeRemotePackage("p");
    List<RemotePackage> remote = ImmutableList.of(update, new FakeRemotePackage("patcher;v4"));
    update.setDependencies(ImmutableList.of(new FakeDependency(target.getPath())));
    RepositoryPackages packages = new RepositoryPackages(local, remote);
    FakeRepoManager mgr = new FakeRepoManager(new File("/sdk"), packages);
    LocalPackage patcher = PatchInstallerUtil.getDependantPatcher(update, mgr);
    assertNull(patcher);
}
Also used : FakeRemotePackage(com.android.repository.testframework.FakePackage.FakeRemotePackage) FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) LocalPackage(com.android.repository.api.LocalPackage) FakeLocalPackage(com.android.repository.testframework.FakePackage.FakeLocalPackage) RepositoryPackages(com.android.repository.impl.meta.RepositoryPackages) FakeDependency(com.android.repository.testframework.FakeDependency) FakeRepoManager(com.android.repository.testframework.FakeRepoManager) RemotePackage(com.android.repository.api.RemotePackage) FakeRemotePackage(com.android.repository.testframework.FakePackage.FakeRemotePackage) File(java.io.File) Test(org.junit.Test)

Aggregations

LocalPackage (com.android.repository.api.LocalPackage)16 FakeLocalPackage (com.android.repository.testframework.FakePackage.FakeLocalPackage)7 Test (org.junit.Test)7 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)6 File (java.io.File)6 RepositoryPackages (com.android.repository.impl.meta.RepositoryPackages)5 Revision (com.android.repository.Revision)4 FakeRepoManager (com.android.repository.testframework.FakeRepoManager)4 ProgressIndicator (com.android.repository.api.ProgressIndicator)3 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)3 RemotePackage (com.android.repository.api.RemotePackage)2 FakeDependency (com.android.repository.testframework.FakeDependency)2 FakeRemotePackage (com.android.repository.testframework.FakePackage.FakeRemotePackage)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 VisibleForTesting (com.android.annotations.VisibleForTesting)1 RepoManager (com.android.repository.api.RepoManager)1 TypeDetails (com.android.repository.impl.meta.TypeDetails)1 AndroidVersion (com.android.sdklib.AndroidVersion)1