IncrementalInstallSession
public
class
IncrementalInstallSession
extends Object
| java.lang.Object | |
| ↳ | com.android.incfs.install.IncrementalInstallSession |
Used to create a n incremental package installation session in which the blocks of the installed APKs are streamed to the device when they need to be read.
Incremental installation uses the Incremental Filesystem (IncFs) to allow installation to complete before the entire APK has been streamed to the device. This class can be used to start an incremental installation, control which blocks of the APK are allowed to be streamed to the device, and wait until APK installation has completed and/or until all blocks have been streamed to the device.
The connection to the device stays opened until the session is closed, the install fails, the device connection times-out, or an exception occurs while processing block requests from the device.
An example use of this class is:
{@code try (IncrementalInstallSession session = new IncrementalInstallSession.Builder()
.addApk(mTestApk0, mTestSignature0)
.build()) {
// Start the session on a separate thread.
session.start(Executors.newCachedThreadPool(), mockDevice.getFactory());
// Wait a maximum of 45 seconds for the install to finish.
session.waitForInstallCompleted(45, TimeUnit.SECONDS);
}Summary
Nested classes | |
|---|---|
class |
IncrementalInstallSession.Builder
|
Public methods | |
|---|---|
void
|
close()
Cancels communication with the device. |
IncrementalInstallSession
|
start(Executor executor, IDeviceConnection.Factory conFactory)
Starts the streaming install session. |
void
|
waitForAnyCompletion(long timeout, TimeUnit units)
Blocks the current thread until either APK data has been streamed to the device or the installation is finished. |
void
|
waitForInstallCompleted(long timeout, TimeUnit units)
Blocks the current thread until all APKs have been successfully installed. |
void
|
waitForServingCompleted(long timeout, TimeUnit units)
Blocks the current thread until all APK data has been streamed to the device. |
Public methods
close
public void close ()
Cancels communication with the device.
start
public IncrementalInstallSession start (Executor executor, IDeviceConnection.Factory conFactory)
Starts the streaming install session.
| Parameters | |
|---|---|
executor |
Executor: the executor on which to start handling block requests from the device |
conFactory |
IDeviceConnection.Factory: the device connection factory |
| Returns | |
|---|---|
IncrementalInstallSession |
|
| Throws | |
|---|---|
|
if an error occurs while communicating with the device |
waitForAnyCompletion
public void waitForAnyCompletion (long timeout,
TimeUnit units)Blocks the current thread until either APK data has been streamed to the device or the installation is finished.
| Parameters | |
|---|---|
timeout |
long: the maximum amount of time to wait. A value of 0 will cause this method to
wait indefinitely. |
units |
TimeUnit: units for non-zero timeout |
| Throws | |
|---|---|
|
if wait times out, an APK fails to be installed, or an exception occurs while handling block requests. |
waitForInstallCompleted
public void waitForInstallCompleted (long timeout,
TimeUnit units)Blocks the current thread until all APKs have been successfully installed. Data serving may finish before or after the install succeeds.
| Parameters | |
|---|---|
timeout |
long: the maximum amount of time to wait for the installs to finish. A value of 0
will cause this method to wait indefinitely. |
units |
TimeUnit: units for non-zero timeout |
| Throws | |
|---|---|
|
if wait times out, an APK fails to be installed, or an exception occurs while handling block requests. |
waitForServingCompleted
public void waitForServingCompleted (long timeout,
TimeUnit units)Blocks the current thread until all APK data has been streamed to the device. Installation may finishes before or after serving is completed.
| Parameters | |
|---|---|
timeout |
long: the maximum amount of time to wait for serving to finish. A value of 0 will
cause this method to wait indefinitely. |
units |
TimeUnit: units for non-zero timeout |
| Throws | |
|---|---|
|
if wait times out, an APK fails to be streamed, or an exception occurs while handling block requests. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-12-04 UTC.