Class AbstractPackageOperation
- java.lang.Object
-
- com.android.repository.impl.installer.AbstractPackageOperation
-
- All Implemented Interfaces:
PackageOperation
- Direct Known Subclasses:
AbstractInstaller,AbstractUninstaller
public abstract class AbstractPackageOperation extends java.lang.Object implements PackageOperation
Frameworks for concreteInstallers andUninstallers that manages creation of temp directories, writing package metadata and install status, and resuming in-progress installs.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.android.repository.api.PackageOperation
PackageOperation.InstallStatus, PackageOperation.StatusChangeListener, PackageOperation.StatusChangeListenerException
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDOWNLOAD_INTERMEDIATES_DIR_FNName of the directory used as the base for download intermediates which some package operations may use to customize their downloader settings.static java.lang.StringMETADATA_FILENAME_PREFIXThe filename prefix used to store SDK manager metadata.static java.lang.StringREPO_TEMP_DIR_FNName of the directory used as the base for temporary files and located within the repo root.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractPackageOperation(RepoManager repoManager)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcleanup(ProgressIndicator progress)booleancomplete(ProgressIndicator progress)Finds the prepared files using the installer metadata, and callsdoComplete(Path, ProgressIndicator).protected abstract booleandoComplete(java.nio.file.Path installTemp, ProgressIndicator progress)Subclasses should implement this to do any install/uninstall completion actions required.protected abstract booleandoPrepare(java.nio.file.Path installTempPath, ProgressIndicator progress)Subclasses should override this to prepare a package for (un)installation, including downloading, unzipping, etc.PackageOperationgetFallbackOperation()If this operation fails, it might be possible to try the install a different way.PackageOperation.InstallStatusgetInstallStatus()Gets the currentPackageOperation.InstallStatusof this installer.RepoManagergetRepoManager()Gets theRepoManagerfor which we're installing/uninstalling a package.booleanprepare(ProgressIndicator progress)Writes information used to restore the operation state if needed, then callsdoPrepare(Path, ProgressIndicator)voidregisterStateChangeListener(PackageOperation.StatusChangeListener listener)Registers a listener that will be called when thePackageOperation.InstallStatusof this installer changes.voidsetFallbackOperation(PackageOperation mFallbackOperation)Sets the operation used to retry if this operation fails.protected booleanupdateStatus(PackageOperation.InstallStatus status, ProgressIndicator progress)Sets our status tostatusand notifies our listeners.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.android.repository.api.PackageOperation
getLocation, getName, getPackage
-
-
-
-
Field Detail
-
METADATA_FILENAME_PREFIX
public static final java.lang.String METADATA_FILENAME_PREFIX
The filename prefix used to store SDK manager metadata. Directories starting with this prefix should not be scanned for packages.- See Also:
- Constant Field Values
-
REPO_TEMP_DIR_FN
public static final java.lang.String REPO_TEMP_DIR_FN
Name of the directory used as the base for temporary files and located within the repo root. We intentionally do not use system temp for downloads due to potentially large download size that wouldn't always fit into a system-managed temp directory, but should fit into the SDK directory (since this is where the uncompressed package will be installed anyway).- See Also:
- Constant Field Values
-
DOWNLOAD_INTERMEDIATES_DIR_FN
public static final java.lang.String DOWNLOAD_INTERMEDIATES_DIR_FN
Name of the directory used as the base for download intermediates which some package operations may use to customize their downloader settings.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractPackageOperation
protected AbstractPackageOperation(@NonNull RepoManager repoManager)
-
-
Method Detail
-
doPrepare
protected abstract boolean doPrepare(@NonNull java.nio.file.Path installTempPath, @NonNull ProgressIndicator progress)Subclasses should override this to prepare a package for (un)installation, including downloading, unzipping, etc. as needed. No modification to the actual SDK should happen during this time.- Parameters:
installTempPath- The dir that should be used for any intermediate processing.progress- For logging and progress display
-
doComplete
protected abstract boolean doComplete(@Nullable java.nio.file.Path installTemp, @NonNull ProgressIndicator progress)Subclasses should implement this to do any install/uninstall completion actions required.- Parameters:
installTemp- The temporary dir in which we prepared the (un)install. May benullif for example the installer removed the installer properties file, but should not be normally.progress- For logging and progress indication.- Returns:
trueif the operation succeeded,falseotherwise.- See Also:
complete(ProgressIndicator)
-
complete
public final boolean complete(@NonNull ProgressIndicator progress)Finds the prepared files using the installer metadata, and callsdoComplete(Path, ProgressIndicator).- Specified by:
completein interfacePackageOperation- Parameters:
progress- AProgressIndicator, to show install progress and facilitate logging.- Returns:
trueif the install was successful,falseotherwise.
-
cleanup
protected void cleanup(@NonNull ProgressIndicator progress)
-
prepare
public final boolean prepare(@NonNull ProgressIndicator progress)Writes information used to restore the operation state if needed, then callsdoPrepare(Path, ProgressIndicator)- Specified by:
preparein interfacePackageOperation- Parameters:
progress- AProgressIndicator, to show progress and facilitate logging.- Returns:
trueif the operation succeeded,falseotherwise.
-
getRepoManager
@NonNull public RepoManager getRepoManager()
Description copied from interface:PackageOperationGets theRepoManagerfor which we're installing/uninstalling a package.- Specified by:
getRepoManagerin interfacePackageOperation
-
registerStateChangeListener
public final void registerStateChangeListener(@NonNull PackageOperation.StatusChangeListener listener)Registers a listener that will be called when thePackageOperation.InstallStatusof this installer changes.- Specified by:
registerStateChangeListenerin interfacePackageOperation
-
getInstallStatus
@NonNull public final PackageOperation.InstallStatus getInstallStatus()
Gets the currentPackageOperation.InstallStatusof this installer.- Specified by:
getInstallStatusin interfacePackageOperation
-
updateStatus
protected final boolean updateStatus(@NonNull PackageOperation.InstallStatus status, @NonNull ProgressIndicator progress)Sets our status tostatusand notifies our listeners. If any listener throws an exception we will stop processing listeners and update our status toInstallStatus.FAILED(calling the listeners again with that status update).
-
getFallbackOperation
@Nullable public PackageOperation getFallbackOperation()
Description copied from interface:PackageOperationIf this operation fails, it might be possible to try the install a different way. Specifically, if we have afallback factory, this could be an operation created by that factory.- Specified by:
getFallbackOperationin interfacePackageOperation
-
setFallbackOperation
public void setFallbackOperation(@Nullable PackageOperation mFallbackOperation)Description copied from interface:PackageOperationSets the operation used to retry if this operation fails.- Specified by:
setFallbackOperationin interfacePackageOperation- See Also:
PackageOperation.getFallbackOperation()
-
-