com.android.sdklib.AndroidTargetHash Java Examples
The following examples show how to use
com.android.sdklib.AndroidTargetHash.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PkgDesc.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
/** * Creates a new platform package descriptor. * * @param version The android version of the platform package. * @param revision The revision of the extra package. * @param minToolsRev An optional {@code min-tools-rev}. * Use {@link FullRevision#NOT_SPECIFIED} to indicate * there is no requirement. * @return A {@link PkgDesc} describing this platform package. */ @NonNull public static Builder newPlatform(@NonNull AndroidVersion version, @NonNull MajorRevision revision, @NonNull FullRevision minToolsRev) { Builder p = new Builder(PkgType.PKG_PLATFORM); p.mAndroidVersion = version; p.mMajorRevision = revision; p.mMinToolsRev = minToolsRev; p.mCustomPath = new IGetPath() { @Override public String getPath(PkgDesc thisPkgDesc) { /** The "path" of a Platform is its Target Hash. */ return AndroidTargetHash.getPlatformHashString(thisPkgDesc.getAndroidVersion()); } }; return p; }
Example #2
Source File: PkgDesc.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Creates a new platform package descriptor. * * @param version The android version of the platform package. * @param revision The revision of the extra package. * @param minToolsRev An optional {@code min-tools-rev}. * Use {@link FullRevision#NOT_SPECIFIED} to indicate * there is no requirement. * @return A {@link PkgDesc} describing this platform package. */ @NonNull public static Builder newPlatform(@NonNull AndroidVersion version, @NonNull MajorRevision revision, @NonNull FullRevision minToolsRev) { Builder p = new Builder(PkgType.PKG_PLATFORM); p.mAndroidVersion = version; p.mMajorRevision = revision; p.mMinToolsRev = minToolsRev; p.mCustomPath = new IGetPath() { @Override public String getPath(PkgDesc thisPkgDesc) { /** The "path" of a Platform is its Target Hash. */ return AndroidTargetHash.getPlatformHashString(thisPkgDesc.getAndroidVersion()); } }; return p; }
Example #3
Source File: LocalSdk.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Returns a target from a hash that was generated by {@link IAndroidTarget#hashString()}. * * @param hash the {@link IAndroidTarget} hash string. * @return The matching {@link IAndroidTarget} or null. */ @Nullable public IAndroidTarget getTargetFromHashString(@Nullable String hash) { if (hash != null) { IAndroidTarget[] targets = getTargets(); for (IAndroidTarget target : targets) { if (target != null && hash.equals(AndroidTargetHash.getTargetHashString(target))) { return target; } } } return null; }
Example #4
Source File: PkgDescAddon.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Add-on descriptor. * The following attributes are mandatory: */ PkgDescAddon(@NonNull PkgType type, @Nullable License license, @Nullable String listDisplay, @Nullable String descriptionShort, @Nullable String descriptionUrl, boolean isObsolete, @NonNull MajorRevision majorRevision, @NonNull AndroidVersion androidVersion, @NonNull IdDisplay addonVendor, @NonNull IdDisplay addonName) { super(type, license, listDisplay, descriptionShort, descriptionUrl, isObsolete, null, //fullRevision majorRevision, androidVersion, AndroidTargetHash.getAddonHashString(addonVendor.getDisplay(), addonName.getDisplay(), androidVersion), null, //tag addonVendor, null, //minToolsRev null, //minPlatformToolsRev null, //customIsUpdateFor null); //customPath mAddonName = addonName; }
Example #5
Source File: PkgDescAddon.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Add-on descriptor. * The following attributes are mandatory: */ PkgDescAddon(@NonNull PkgType type, @Nullable License license, @Nullable String listDisplay, @Nullable String descriptionShort, @Nullable String descriptionUrl, boolean isObsolete, @NonNull MajorRevision majorRevision, @NonNull AndroidVersion androidVersion, @NonNull IdDisplay addonVendor, @NonNull IdDisplay addonName) { super(type, license, listDisplay, descriptionShort, descriptionUrl, isObsolete, null, //fullRevision majorRevision, androidVersion, AndroidTargetHash.getAddonHashString(addonVendor.getDisplay(), addonName.getDisplay(), androidVersion), null, //tag addonVendor, null, //minToolsRev null, //minPlatformToolsRev null, //customIsUpdateFor null); //customPath mAddonName = addonName; }
Example #6
Source File: AbstractCompilesUtil.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Determines the java language level to use and sets it on the given task and * {@link CompileOptions}. The latter is to propagate the information to Studio. */ public static void configureLanguageLevel( AbstractCompile compileTask, final CompileOptions compileOptions, String compileSdkVersion) { final AndroidVersion hash = AndroidTargetHash.getVersionFromHash(compileSdkVersion); Integer compileSdkLevel = (hash == null ? null : hash.getApiLevel()); JavaVersion javaVersionToUse; if (compileSdkLevel == null || (0 <= compileSdkLevel && compileSdkLevel <= 20)) { javaVersionToUse = JavaVersion.VERSION_1_6; } else { javaVersionToUse = JavaVersion.VERSION_1_7; } JavaVersion jdkVersion = JavaVersion.toVersion(System.getProperty("java.specification.version")); if (jdkVersion.compareTo(javaVersionToUse) < 0) { compileTask.getLogger().warn( "Default language level for compileSdkVersion '{}' is " + "{}, but the JDK used is {}, so the JDK language level will be used.", compileSdkVersion, javaVersionToUse, jdkVersion); javaVersionToUse = jdkVersion; } compileOptions.setDefaultJavaVersion(javaVersionToUse); compileTask.setSourceCompatibility(compileOptions.getSourceCompatibility().toString()); compileTask.setTargetCompatibility(compileOptions.getTargetCompatibility().toString()); }
Example #7
Source File: LintGradleProject.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public int getBuildSdk() { String compileTarget = mProject.getCompileTarget(); AndroidVersion version = AndroidTargetHash.getPlatformVersion(compileTarget); if (version != null) { return version.getApiLevel(); } return super.getBuildSdk(); }
Example #8
Source File: LocalSdk.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Returns a target from a hash that was generated by {@link IAndroidTarget#hashString()}. * * @param hash the {@link IAndroidTarget} hash string. * @return The matching {@link IAndroidTarget} or null. */ @Nullable public IAndroidTarget getTargetFromHashString(@Nullable String hash) { if (hash != null) { IAndroidTarget[] targets = getTargets(true); for (IAndroidTarget target : targets) { if (target != null && hash.equals(AndroidTargetHash.getTargetHashString(target))) { return target; } } } return null; }
Example #9
Source File: TemplateMetadata.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
/** * Computes a suitable build api string, e.g. for API level 18 the build API * string is "18". */ @NotNull public static String getBuildApiString(@NotNull AndroidVersion version) { return version.isPreview() ? AndroidTargetHash.getPlatformHashString(version) : version.getApiString(); }
Example #10
Source File: MissingTarget.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public String hashString() { return AndroidTargetHash.getTargetHashString(this); }
Example #11
Source File: PlatformTarget.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public String hashString() { return AndroidTargetHash.getPlatformHashString(mVersion); }
Example #12
Source File: AddOnTarget.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public String hashString() { return String.format(AndroidTargetHash.ADD_ON_FORMAT, mVendor, mName, mBasePlatform.getVersion().getApiString()); }
Example #13
Source File: PkgDesc.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public File getCanonicalInstallFolder(@NonNull File sdkLocation) { File f = FileOp.append(sdkLocation, mType.getFolderName()); /* folder patterns: tools, platform-tools, doc => FOLDER build-tools, add-on => FOLDER/IID platform, sample, source => FOLDER/android-API platform sys-img => FOLDER/android-API/TAG/ABI add-on sys-img => FOLDER/addon-NAME.id-VENDOR.id-API/ABI extra => FOLDER/VENDOR.id/PATH */ switch (mType) { case PKG_TOOLS: case PKG_PLATFORM_TOOLS: case PKG_DOC: // no-op, top-folder is all what is needed here break; case PKG_BUILD_TOOLS: case PKG_ADDON: f = FileOp.append(f, getInstallId()); break; case PKG_PLATFORM: case PKG_SAMPLE: case PKG_SOURCE: f = FileOp.append(f, AndroidTargetHash.PLATFORM_HASH_PREFIX + sanitize( getAndroidVersion().getApiString())); break; case PKG_SYS_IMAGE: f = FileOp.append(f, AndroidTargetHash.PLATFORM_HASH_PREFIX + sanitize( getAndroidVersion().getApiString()), sanitize(SystemImage.DEFAULT_TAG.equals(getTag()) ? "android" : getTag().getId()), sanitize(getPath())); // path==abi break; case PKG_ADDON_SYS_IMAGE: String name = "addon-" + (SystemImage.DEFAULT_TAG.equals(getTag()) ? "android" : getTag().getId()) + '-' + getVendor().getId() + '-' + getAndroidVersion().getApiString(); f = FileOp.append(f, sanitize(name), sanitize(getPath())); // path==abi break; case PKG_EXTRA: f = FileOp.append(f, sanitize(getVendor().getId()), sanitize(getPath())); break; default: throw new IllegalArgumentException( "CanonicalFolder not defined for type " + mType.toString()); } return f; }
Example #14
Source File: PkgDesc.java From javaide with GNU General Public License v3.0 | 4 votes |
@Override public String getBaseInstallId() { StringBuilder sb = new StringBuilder(); /* iid patterns: tools, platform-tools => FOLDER build-tools => FOLDER-REV doc, sample, source => ENUM-API extra => ENUM-VENDOR.id-PATH platform => android-API add-on => addon-NAME.id-VENDOR.id-API platform sys-img => sys-img-ABI-TAG|android-API add-on sys-img => sys-img-ABI-addon-NAME.id-VENDOR.id-API */ switch (mType) { case PKG_TOOLS: case PKG_PLATFORM_TOOLS: sb.append(mType.getFolderName()); break; case PKG_BUILD_TOOLS: sb.append(mType.getFolderName()).append('-'); // Add version number without the preview revision number. This is to make preview // packages be updatable to the next revision. int[] version = getPreciseRevision().toIntArray(false); for (int i = 0; i < version.length; i++) { sb.append(version[i]); if (i != version.length - 1) { sb.append('.'); } } break; case PKG_DOC: sb.append("doc"); break; case PKG_SAMPLE: case PKG_SOURCE: sb.append(mType.toString().toLowerCase(Locale.US).replace("pkg_", "")); sb.append('-').append(getAndroidVersion().getApiString()); break; case PKG_EXTRA: sb.append("extra-") .append(getVendor().getId()) .append('-') .append(getPath()); break; case PKG_PLATFORM: sb.append(AndroidTargetHash.PLATFORM_HASH_PREFIX) .append(getAndroidVersion().getApiString()); break; case PKG_ADDON: sb.append("addon-") .append(((IPkgDescAddon)this).getName().getId()) .append('-') .append(getVendor().getId()) .append('-') .append(getAndroidVersion().getApiString()); break; case PKG_SYS_IMAGE: sb.append("sys-img-") .append(getPath()) // path==ABI for sys-img .append('-') .append(SystemImage.DEFAULT_TAG.equals(getTag()) ? "android" : getTag().getId()) .append('-') .append(getAndroidVersion().getApiString()); break; case PKG_ADDON_SYS_IMAGE: sb.append("sys-img-") .append(getPath()) // path==ABI for sys-img .append("-addon-") .append(SystemImage.DEFAULT_TAG.equals(getTag()) ? "android" : getTag().getId()) .append('-') .append(getVendor().getId()) .append('-') .append(getAndroidVersion().getApiString()); break; default: throw new IllegalArgumentException("IID not defined for type " + mType.toString()); } return sanitize(sb.toString()); }
Example #15
Source File: AwbAndroidJavaCompile.java From atlas with Apache License 2.0 | 4 votes |
private boolean isPostN() { final AndroidVersion hash = AndroidTargetHash.getVersionFromHash(compileSdkVersion); return hash != null && hash.getApiLevel() >= 24; }
Example #16
Source File: PlatformTarget.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
@Override public String hashString() { return AndroidTargetHash.getPlatformHashString(mVersion); }
Example #17
Source File: AddOnTarget.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
@Override public String hashString() { return String.format(AndroidTargetHash.ADD_ON_FORMAT, mVendor, mName, mBasePlatform.getVersion().getApiString()); }
Example #18
Source File: PkgDesc.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
@Override public File getCanonicalInstallFolder(@NonNull File sdkLocation) { File f = FileOp.append(sdkLocation, mType.getFolderName()); /* folder patterns: tools, platform-tools, doc => FOLDER build-tools, add-on => FOLDER/IID platform, sample, source => FOLDER/android-API platform sys-img => FOLDER/android-API/TAG/ABI add-on sys-img => FOLDER/addon-NAME.id-VENDOR.id-API/ABI extra => FOLDER/VENDOR.id/PATH */ switch (mType) { case PKG_TOOLS: case PKG_PLATFORM_TOOLS: case PKG_DOC: // no-op, top-folder is all what is needed here break; case PKG_BUILD_TOOLS: case PKG_ADDON: f = FileOp.append(f, getInstallId()); break; case PKG_PLATFORM: case PKG_SAMPLE: case PKG_SOURCE: f = FileOp.append(f, AndroidTargetHash.PLATFORM_HASH_PREFIX + sanitize(getAndroidVersion().getApiString())); break; case PKG_SYS_IMAGE: f = FileOp.append(f, AndroidTargetHash.PLATFORM_HASH_PREFIX + sanitize(getAndroidVersion().getApiString()), sanitize(SystemImage.DEFAULT_TAG.equals(getTag()) ? "android" : getTag().getId()), sanitize(getPath())); // path==abi break; case PKG_ADDON_SYS_IMAGE: String name = "addon-" + (SystemImage.DEFAULT_TAG.equals(getTag()) ? "android" : getTag().getId()) + '-' + getVendor().getId() + '-' + getAndroidVersion().getApiString(); f = FileOp.append(f, sanitize(name), sanitize(getPath())); // path==abi break; case PKG_EXTRA: f = FileOp.append(f, sanitize(getVendor().getId()), sanitize(getPath())); break; default: throw new IllegalArgumentException("CanonicalFolder not defined for type " + mType.toString()); } return f; }
Example #19
Source File: PkgDesc.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
@Override public String getInstallId() { StringBuilder sb = new StringBuilder(); /* iid patterns: tools, platform-tools => FOLDER / FOLDER-preview build-tools => FOLDER-REV doc, sample, source => ENUM-API extra => ENUM-VENDOR.id-PATH platform => android-API add-on => addon-NAME.id-VENDOR.id-API platform sys-img => sys-img-ABI-TAG|android-API add-on sys-img => sys-img-ABI-addon-NAME.id-VENDOR.id-API */ switch (mType) { case PKG_TOOLS: case PKG_PLATFORM_TOOLS: sb.append(mType.getFolderName()); if (getFullRevision().isPreview()) { sb.append("-preview"); } break; case PKG_BUILD_TOOLS: sb.append(mType.getFolderName()); sb.append('-').append(getFullRevision().toString()); break; case PKG_DOC: case PKG_SAMPLE: case PKG_SOURCE: sb.append(mType.toString().toLowerCase(Locale.US).replace("pkg_", "")); sb.append('-').append(getAndroidVersion().getApiString()); break; case PKG_EXTRA: sb.append("extra-") .append(getVendor().getId()) .append('-') .append(getPath()); break; case PKG_PLATFORM: sb.append(AndroidTargetHash.PLATFORM_HASH_PREFIX).append(getAndroidVersion().getApiString()); break; case PKG_ADDON: sb.append("addon-") .append(((IPkgDescAddon) this).getName().getId()) .append('-') .append(getVendor().getId()) .append('-') .append(getAndroidVersion().getApiString()); break; case PKG_SYS_IMAGE: sb.append("sys-img-") .append(getPath()) // path==ABI for sys-img .append('-') .append(SystemImage.DEFAULT_TAG.equals(getTag()) ? "android" : getTag().getId()) .append('-') .append(getAndroidVersion().getApiString()); break; case PKG_ADDON_SYS_IMAGE: sb.append("sys-img-") .append(getPath()) // path==ABI for sys-img .append("-addon-") .append(SystemImage.DEFAULT_TAG.equals(getTag()) ? "android" : getTag().getId()) .append('-') .append(getVendor().getId()) .append('-') .append(getAndroidVersion().getApiString()); break; default: throw new IllegalArgumentException("IID not defined for type " + mType.toString()); } return sanitize(sb.toString()); }
Example #20
Source File: PlatformPackage.java From java-n-IDE-for-Android with Apache License 2.0 | 2 votes |
/** * Returns a string identifier to install this package from the command line. * For platforms, we use "android-N" where N is the API or the preview codename. * <p/> * {@inheritDoc} */ @Override public String installId() { return AndroidTargetHash.getPlatformHashString(mVersion); }
Example #21
Source File: PlatformPackage.java From javaide with GNU General Public License v3.0 | 2 votes |
/** * Returns a string identifier to install this package from the command line. * For platforms, we use "android-N" where N is the API or the preview codename. * <p/> * {@inheritDoc} */ @Override public String installId() { return AndroidTargetHash.getPlatformHashString(mVersion); }