private void scanPlatforms(File collectionDir, Collection<LocalPkgInfo> outCollection) { for (File platformDir : mFileOp.listFiles(collectionDir)) { if (!shouldVisitDir(PkgType.PKG_PLATFORM, platformDir)) { continue; } Properties props = parseProperties(new File(platformDir, SdkConstants.FN_SOURCE_PROP)); MajorRevision rev = PackageParserUtils.getPropertyMajor(props, PkgProps.PKG_REVISION); if (rev == null) { continue; // skip, no revision } FullRevision minToolsRev = PackageParserUtils.getPropertyFull(props, PkgProps.MIN_TOOLS_REV); if (minToolsRev == null) { minToolsRev = FullRevision.NOT_SPECIFIED; } try { AndroidVersion vers = new AndroidVersion(props); LocalPlatformPkgInfo pkgInfo = new LocalPlatformPkgInfo(this, platformDir, props, vers, rev, minToolsRev); outCollection.add(pkgInfo); } catch (AndroidVersionException e) { continue; // skip invalid or missing android version. } } }
private void scanAddons(File collectionDir, Collection<LocalPkgInfo> outCollection) { for (File addonDir : mFileOp.listFiles(collectionDir)) { if (!shouldVisitDir(PkgType.PKG_ADDON, addonDir)) { continue; } Properties props = parseProperties(new File(addonDir, SdkConstants.FN_SOURCE_PROP)); MajorRevision rev = PackageParserUtils.getPropertyMajor(props, PkgProps.PKG_REVISION); if (rev == null) { continue; // skip, no revision } try { AndroidVersion vers = new AndroidVersion(props); // Starting with addon-4.xsd, we have vendor-id and name-id available // in the add-on source properties so we'll use that directly. String nameId = props.getProperty(PkgProps.ADDON_NAME_ID); String nameDisp = props.getProperty(PkgProps.ADDON_NAME_DISPLAY); String vendorId = props.getProperty(PkgProps.ADDON_VENDOR_ID); String vendorDisp = props.getProperty(PkgProps.ADDON_VENDOR_DISPLAY); if (nameId == null) { // Support earlier add-ons that only had a name display attribute nameDisp = props.getProperty(PkgProps.ADDON_NAME, "Unknown"); nameId = LocalAddonPkgInfo.sanitizeDisplayToNameId(nameDisp); } if (nameId != null && nameDisp == null) { nameDisp = LocalExtraPkgInfo.getPrettyName(null, nameId); } if (vendorId != null && vendorDisp == null) { vendorDisp = LocalExtraPkgInfo.getPrettyName(null, nameId); } if (vendorId == null) { // Support earlier add-ons that only had a vendor display attribute vendorDisp = props.getProperty(PkgProps.ADDON_VENDOR, "Unknown"); vendorId = LocalAddonPkgInfo.sanitizeDisplayToNameId(vendorDisp); } LocalAddonPkgInfo pkgInfo = new LocalAddonPkgInfo( this, addonDir, props, vers, rev, new IdDisplay(vendorId, vendorDisp), new IdDisplay(nameId, nameDisp)); outCollection.add(pkgInfo); } catch (AndroidVersionException e) { continue; // skip invalid or missing android version. } } }
private void scanSources(File collectionDir, Collection<LocalPkgInfo> outCollection) { // The build-tool root folder contains a list of per-revision folders. for (File platformDir : mFileOp.listFiles(collectionDir)) { if (!shouldVisitDir(PkgType.PKG_SOURCE, platformDir)) { continue; } Properties props = parseProperties(new File(platformDir, SdkConstants.FN_SOURCE_PROP)); MajorRevision rev = PackageParserUtils.getPropertyMajor(props, PkgProps.PKG_REVISION); if (rev == null) { continue; // skip, no revision } try { AndroidVersion vers = new AndroidVersion(props); LocalSourcePkgInfo pkgInfo = new LocalSourcePkgInfo(this, platformDir, props, vers, rev); outCollection.add(pkgInfo); } catch (AndroidVersionException e) { continue; // skip invalid or missing android version. } } }
/** Try to find a docs package at the given location. Returns null if not found. */ private LocalDocPkgInfo scanDoc(File docFolder) { // Can we find some properties? Properties props = parseProperties(new File(docFolder, SdkConstants.FN_SOURCE_PROP)); MajorRevision rev = PackageParserUtils.getPropertyMajor(props, PkgProps.PKG_REVISION); if (rev == null) { return null; } try { AndroidVersion vers = new AndroidVersion(props); LocalDocPkgInfo info = new LocalDocPkgInfo(this, docFolder, props, vers, rev); // To start with, a doc folder should have an "index.html" to be acceptable. // We don't actually check the content of the file. if (!mFileOp.isFile(new File(docFolder, "index.html"))) { info.appendLoadError("Missing index.html"); } return info; } catch (AndroidVersionException e) { return null; // skip invalid or missing android version. } }
private void scanSysImages( File collectionDir, Collection<LocalPkgInfo> outCollection, boolean scanAddons) { List<File> propFiles = Lists.newArrayList(); PkgType type = scanAddons ? PkgType.PKG_ADDON_SYS_IMAGE : PkgType.PKG_SYS_IMAGE; // Create a list of folders that contains a source.properties file matching these patterns: // sys-img/target/tag/abi // sys-img/target/abis // sys-img/add-on-target/abi // sys-img/target/add-on/abi for (File platformDir : mFileOp.listFiles(collectionDir)) { if (!shouldVisitDir(type, platformDir)) { continue; } for (File dir1 : mFileOp.listFiles(platformDir)) { // dir1 might be either a tag or an abi folder. if (!shouldVisitDir(type, dir1)) { continue; } File prop1 = new File(dir1, SdkConstants.FN_SOURCE_PROP); if (mFileOp.isFile(prop1)) { // dir1 was a legacy abi folder. if (!propFiles.contains(prop1)) { propFiles.add(prop1); } } else { File[] dir1Files = mFileOp.listFiles(dir1); for (File dir2 : dir1Files) { // dir2 should be an abi folder in a tag folder. if (!shouldVisitDir(type, dir2)) { continue; } File prop2 = new File(dir2, SdkConstants.FN_SOURCE_PROP); if (mFileOp.isFile(prop2)) { if (!propFiles.contains(prop2)) { propFiles.add(prop2); } } } } } } for (File propFile : propFiles) { Properties props = parseProperties(propFile); MajorRevision rev = PackageParserUtils.getPropertyMajor(props, PkgProps.PKG_REVISION); if (rev == null) { continue; // skip, no revision } try { AndroidVersion vers = new AndroidVersion(props); IdDisplay tag = LocalSysImgPkgInfo.extractTagFromProps(props); String vendorId = props.getProperty(PkgProps.ADDON_VENDOR_ID, null); File abiDir = propFile.getParentFile(); if (vendorId == null && !scanAddons) { LocalSysImgPkgInfo pkgInfo = new LocalSysImgPkgInfo(this, abiDir, props, vers, tag, abiDir.getName(), rev); outCollection.add(pkgInfo); } else if (vendorId != null && scanAddons) { String vendorDisp = props.getProperty(PkgProps.ADDON_VENDOR_DISPLAY, vendorId); IdDisplay vendor = new IdDisplay(vendorId, vendorDisp); LocalAddonSysImgPkgInfo pkgInfo = new LocalAddonSysImgPkgInfo( this, abiDir, props, vers, vendor, tag, abiDir.getName(), rev); outCollection.add(pkgInfo); } } catch (AndroidVersionException e) { continue; // skip invalid or missing android version. } } }