Package com.android.repository.util
Class InstallerUtil
- java.lang.Object
-
- com.android.repository.util.InstallerUtil
-
public class InstallerUtil extends java.lang.ObjectUtility methods forPackageOperationimplementations.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringINSTALLER_DIR_FNstatic java.lang.StringPENDING_PACKAGE_XML_FNThe name of the package metadata file for a package in the process of being installed.
-
Constructor Summary
Constructors Constructor Description InstallerUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancheckValidPath(java.nio.file.Path path, RepoManager manager, ProgressIndicator progress)Checks to see whetherpathis a valid install path.static java.util.List<RemotePackage>computeRequiredPackages(java.util.Collection<RemotePackage> requests, RepositoryPackages packages, ProgressIndicator logger)Compute the complete list of packages that need to be installed to meet the dependencies of the given list (including the requested packages themselves, if they are not already installed).static RepositoryreadPendingPackageXml(java.nio.file.Path containingDir, RepoManager manager, ProgressIndicator progress)static java.net.URLresolveCompleteArchiveUrl(RemotePackage p, ProgressIndicator progress)Returns a URL corresponding toArchive.getComplete()of the givenRemotePackage.static java.net.URLresolveUrl(java.lang.String urlStr, RemotePackage p, ProgressIndicator progress)static voidunzip(java.nio.file.Path in, java.nio.file.Path out, long expectedSize, ProgressIndicator progress)Unzips the given zipped input stream into the given directory.static voidwritePackageXml(RemotePackage p, java.nio.file.Path packageRoot, RepoManager manager, ProgressIndicator progress)Writes out the XML for aLocalPackageImplcorresponding to the givenRemotePackageto apackage.xmlfile inpackageRoot.static voidwritePendingPackageXml(RepoPackage p, java.nio.file.Path packageRoot, RepoManager manager, ProgressIndicator progress)static voidwriteRepoXml(RepoManager manager, Repository repo, java.nio.file.Path packageXml, CommonFactory factory, ProgressIndicator progress)
-
-
-
Field Detail
-
PENDING_PACKAGE_XML_FN
public static final java.lang.String PENDING_PACKAGE_XML_FN
The name of the package metadata file for a package in the process of being installed.- See Also:
- Constant Field Values
-
INSTALLER_DIR_FN
public static final java.lang.String INSTALLER_DIR_FN
- See Also:
- Constant Field Values
-
-
Method Detail
-
unzip
public static void unzip(@NonNull java.nio.file.Path in, @NonNull java.nio.file.Path out, long expectedSize, @NonNull ProgressIndicator progress) throws java.io.IOExceptionUnzips the given zipped input stream into the given directory.- Parameters:
in- The (zipped) input stream.out- The directory into which to expand the files. Must exist.expectedSize- Compressed size of the stream.progress- Currently only used for logging.- Throws:
java.io.IOException- If we're unable to read or write.
-
writePendingPackageXml
public static void writePendingPackageXml(@NonNull RepoPackage p, @NonNull java.nio.file.Path packageRoot, @NonNull RepoManager manager, @NonNull ProgressIndicator progress) throws java.io.IOException- Throws:
java.io.IOException
-
readPendingPackageXml
@Nullable public static Repository readPendingPackageXml(@NonNull java.nio.file.Path containingDir, @NonNull RepoManager manager, @NonNull ProgressIndicator progress) throws java.io.IOException
- Throws:
java.io.IOException
-
writePackageXml
public static void writePackageXml(@NonNull RemotePackage p, @NonNull java.nio.file.Path packageRoot, @NonNull RepoManager manager, @NonNull ProgressIndicator progress) throws java.io.IOExceptionWrites out the XML for aLocalPackageImplcorresponding to the givenRemotePackageto apackage.xmlfile inpackageRoot.- Parameters:
p- The package to convert to a local package and write out.packageRoot- The location to write to. Must exist and be a directory.manager- ARepoManagerinstance.progress- Currently only used for logging.- Throws:
java.io.IOException- If we fail to write the output file.
-
writeRepoXml
public static void writeRepoXml(@NonNull RepoManager manager, @NonNull Repository repo, @NonNull java.nio.file.Path packageXml, @NonNull CommonFactory factory, @NonNull ProgressIndicator progress) throws java.io.IOException- Throws:
java.io.IOException
-
resolveCompleteArchiveUrl
@Nullable public static java.net.URL resolveCompleteArchiveUrl(@NonNull RemotePackage p, @NonNull ProgressIndicator progress)Returns a URL corresponding toArchive.getComplete()of the givenRemotePackage. If the url in the package is a relative url, resolves it by using the prefix of the url in theRepositorySourceof the package.- Returns:
- The resolved
URL, ornullif the given archive location is not parsable in its original or resolved form.
-
resolveUrl
@Nullable public static java.net.URL resolveUrl(@NonNull java.lang.String urlStr, @NonNull RemotePackage p, @NonNull ProgressIndicator progress)
-
computeRequiredPackages
@Nullable public static java.util.List<RemotePackage> computeRequiredPackages(@NonNull java.util.Collection<RemotePackage> requests, @NonNull RepositoryPackages packages, @NonNull ProgressIndicator logger)
Compute the complete list of packages that need to be installed to meet the dependencies of the given list (including the requested packages themselves, if they are not already installed). Returnsnullif we were unable to compute a complete list of dependencies due to not being able to find required packages of the specified version. Packages are returned in install order (that is, if we request A which depends on B, the result will be [B, A]). If a dependency cycle is encountered the order of the returned results at or below the cycle is undefined. For example if we have A -> [B, C], B -> D, and D -> B then the returned list will be either [B, D, C, A] or [D, B, C, A]. Note that we assume installed packages already have their dependencies met.
-
checkValidPath
public static boolean checkValidPath(@NonNull java.nio.file.Path path, @NonNull RepoManager manager, @NonNull ProgressIndicator progress)Checks to see whetherpathis a valid install path. Specifically, checks whether there are any existing packages installed in parents or children ofpath. Returnstrueif the path is valid. Otherwise returnsfalseand logs a warning.
-
-