Search in sources :

Example 6 with LocalPackage

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

the class PatchInstallerFactoryTest method canHandleWindowsUninstallWithPatcher.

@Test
public void canHandleWindowsUninstallWithPatcher() {
    myFileOp.setIsWindows(true);
    LocalPackage p = new FakeLocalPackage("foo");
    myRepositoryPackages.setLocalPkgInfos(ImmutableList.of(p, PATCHER_4));
    assertTrue(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 7 with LocalPackage

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

the class AvdWizardUtils method emulatorSupportsWebp.

@VisibleForTesting
static boolean emulatorSupportsWebp(@NotNull AndroidSdkHandler sdkHandler) {
    ProgressIndicator log = new StudioLoggerProgressIndicator(AvdWizardUtils.class);
    LocalPackage sdkPackage = sdkHandler.getLocalPackage(FD_EMULATOR, log);
    if (sdkPackage == null) {
        sdkPackage = sdkHandler.getLocalPackage(FD_TOOLS, log);
    }
    if (sdkPackage != null) {
        Revision version = sdkPackage.getVersion();
        // >= 25.2.3?
        if (version.getMajor() > 25 || version.getMajor() == 25 && (version.getMinor() > 2 || version.getMinor() == 2 && version.getMicro() >= 3)) {
            return true;
        }
    }
    return false;
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) LocalPackage(com.android.repository.api.LocalPackage) Revision(com.android.repository.Revision) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) VisibleForTesting(com.android.annotations.VisibleForTesting)

Example 8 with LocalPackage

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

the class SdkMerger method compareSdks.

@NotNull
private static Collection<MergeablePackage> compareSdks(@NotNull File srcDir, @NotNull File destDir, @Nullable ProgressIndicator progress) {
    com.android.repository.api.ProgressIndicator repoProgress = getRepoProgress(progress);
    Collection<MergeablePackage> results = Lists.newArrayList();
    AndroidSdkHandler srcHandler = AndroidSdkHandler.getInstance(srcDir);
    AndroidSdkHandler destHandler = AndroidSdkHandler.getInstance(destDir);
    Map<String, ? extends LocalPackage> srcPackages = srcHandler.getSdkManager(repoProgress).getPackages().getLocalPackages();
    Map<String, ? extends LocalPackage> destPackages = destHandler.getSdkManager(repoProgress).getPackages().getLocalPackages();
    for (LocalPackage srcPkg : srcPackages.values()) {
        LocalPackage destPkg = destPackages.get(srcPkg.getPath());
        if (destPkg != null) {
            if (srcPkg.getVersion().compareTo(destPkg.getVersion()) > 0) {
                // Package exists in destination but is old; replace it.
                results.add(new MergeablePackage(srcPkg, destPkg, destDir));
            }
        } else {
            // Package doesn't exist in destination; copy it over.
            results.add(new MergeablePackage(srcPkg, null, destDir));
        }
    }
    return results;
}
Also used : LocalPackage(com.android.repository.api.LocalPackage) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with LocalPackage

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

the class IdeSdks method isJdk7Supported.

public boolean isJdk7Supported(@Nullable AndroidSdkData sdkData) {
    if (sdkData != null) {
        ProgressIndicator progress = new StudioLoggerProgressIndicator(Jdks.class);
        LocalPackage info = sdkData.getSdkHandler().getLocalPackage(SdkConstants.FD_PLATFORM_TOOLS, progress);
        if (info != null) {
            Revision revision = info.getVersion();
            if (revision.getMajor() >= 19) {
                JavaSdk jdk = JavaSdk.getInstance();
                Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(jdk);
                if (sdk != null) {
                    JavaSdkVersion version = jdk.getVersion(sdk);
                    if (version != null && version.isAtLeast(JavaSdkVersion.JDK_1_7)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) LocalPackage(com.android.repository.api.LocalPackage) Revision(com.android.repository.Revision) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) ProgressIndicator(com.android.repository.api.ProgressIndicator) SdkPaths.validateAndroidSdk(com.android.tools.idea.sdk.SdkPaths.validateAndroidSdk)

Example 10 with LocalPackage

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

the class InstantRunPositionManager method createSourcesByApiLevel.

private static Map<AndroidVersion, VirtualFile> createSourcesByApiLevel() {
    Collection<? extends LocalPackage> sourcePackages = getAllPlatformSourcePackages();
    Map<AndroidVersion, VirtualFile> sourcesByApi = Maps.newHashMap();
    for (LocalPackage sourcePackage : sourcePackages) {
        TypeDetails typeDetails = sourcePackage.getTypeDetails();
        if (!(typeDetails instanceof DetailsTypes.ApiDetailsType)) {
            Logger.getInstance(InstantRunPositionManager.class).warn("Unable to get type details for source package @ " + sourcePackage.getLocation().getPath());
            continue;
        }
        DetailsTypes.ApiDetailsType details = (DetailsTypes.ApiDetailsType) typeDetails;
        AndroidVersion version = details.getAndroidVersion();
        VirtualFile sourceFolder = VfsUtil.findFileByIoFile(sourcePackage.getLocation(), true);
        if (sourceFolder != null && sourceFolder.isValid()) {
            sourcesByApi.put(version, sourceFolder);
        }
    }
    return ImmutableMap.copyOf(sourcesByApi);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TypeDetails(com.android.repository.impl.meta.TypeDetails) LocalPackage(com.android.repository.api.LocalPackage) DetailsTypes(com.android.sdklib.repository.meta.DetailsTypes) AndroidVersion(com.android.sdklib.AndroidVersion)

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