Merge "[pm] smooth transition from install progress to incremental loading progress" into sc-dev
This commit is contained in:
@@ -59,7 +59,6 @@ public final class IncrementalFileStorages {
|
|||||||
/**
|
/**
|
||||||
* Set up files and directories used in an installation session. Only used by Incremental.
|
* Set up files and directories used in an installation session. Only used by Incremental.
|
||||||
* All the files will be created in defaultStorage.
|
* All the files will be created in defaultStorage.
|
||||||
* TODO(b/133435829): code clean up
|
|
||||||
*
|
*
|
||||||
* @throws IllegalStateException the session is not an Incremental installation session.
|
* @throws IllegalStateException the session is not an Incremental installation session.
|
||||||
* @throws IOException if fails to setup files or directories.
|
* @throws IOException if fails to setup files or directories.
|
||||||
@@ -73,12 +72,10 @@ public final class IncrementalFileStorages {
|
|||||||
@Nullable IStorageHealthListener healthListener,
|
@Nullable IStorageHealthListener healthListener,
|
||||||
@NonNull List<InstallationFileParcel> addedFiles,
|
@NonNull List<InstallationFileParcel> addedFiles,
|
||||||
@NonNull PerUidReadTimeouts[] perUidReadTimeouts,
|
@NonNull PerUidReadTimeouts[] perUidReadTimeouts,
|
||||||
IPackageLoadingProgressCallback progressCallback) throws IOException {
|
@Nullable IPackageLoadingProgressCallback progressCallback) throws IOException {
|
||||||
// TODO(b/136132412): validity check if session should not be incremental
|
|
||||||
IncrementalManager incrementalManager = (IncrementalManager) context.getSystemService(
|
IncrementalManager incrementalManager = (IncrementalManager) context.getSystemService(
|
||||||
Context.INCREMENTAL_SERVICE);
|
Context.INCREMENTAL_SERVICE);
|
||||||
if (incrementalManager == null) {
|
if (incrementalManager == null) {
|
||||||
// TODO(b/146080380): add incremental-specific error code
|
|
||||||
throw new IOException("Failed to obtain incrementalManager.");
|
throw new IOException("Failed to obtain incrementalManager.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +86,6 @@ public final class IncrementalFileStorages {
|
|||||||
try {
|
try {
|
||||||
result.addApkFile(file);
|
result.addApkFile(file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO(b/146080380): add incremental-specific error code
|
|
||||||
throw new IOException(
|
throw new IOException(
|
||||||
"Failed to add file to IncFS: " + file.name + ", reason: ", e);
|
"Failed to add file to IncFS: " + file.name + ", reason: ", e);
|
||||||
}
|
}
|
||||||
@@ -203,7 +199,6 @@ public final class IncrementalFileStorages {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the states and unbinds storage instances for an installation session.
|
* Resets the states and unbinds storage instances for an installation session.
|
||||||
* TODO(b/136132412): make sure unnecessary binds are removed but useful storages are kept
|
|
||||||
*/
|
*/
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
if (mDefaultStorage == null) {
|
if (mDefaultStorage == null) {
|
||||||
@@ -211,8 +206,8 @@ public final class IncrementalFileStorages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
mIncrementalManager.unregisterLoadingProgressCallbacks(mStageDir.getAbsolutePath());
|
||||||
mDefaultStorage.unBind(mStageDir.getAbsolutePath());
|
mDefaultStorage.unBind(mStageDir.getAbsolutePath());
|
||||||
mDefaultStorage.unregisterLoadingProgressListener();
|
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
}
|
}
|
||||||
mDefaultStorage = null;
|
mDefaultStorage = null;
|
||||||
|
|||||||
@@ -342,7 +342,6 @@ public final class IncrementalManager {
|
|||||||
storage.unregisterLoadingProgressListener();
|
storage.unregisterLoadingProgressListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(b/165841827): handle reboot and app update
|
|
||||||
public boolean registerCallback(@NonNull IncrementalStorage storage,
|
public boolean registerCallback(@NonNull IncrementalStorage storage,
|
||||||
@NonNull IPackageLoadingProgressCallback callback) {
|
@NonNull IPackageLoadingProgressCallback callback) {
|
||||||
final int storageId = storage.getId();
|
final int storageId = storage.getId();
|
||||||
@@ -364,30 +363,6 @@ public final class IncrementalManager {
|
|||||||
return storage.registerLoadingProgressListener(this);
|
return storage.registerLoadingProgressListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean unregisterCallback(@NonNull IncrementalStorage storage,
|
|
||||||
@NonNull IPackageLoadingProgressCallback callback) {
|
|
||||||
final int storageId = storage.getId();
|
|
||||||
final RemoteCallbackList<IPackageLoadingProgressCallback> callbacksForStorage;
|
|
||||||
synchronized (mCallbacks) {
|
|
||||||
callbacksForStorage = mCallbacks.get(storageId);
|
|
||||||
if (callbacksForStorage == null) {
|
|
||||||
// no callback has ever been registered on this storage
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!callbacksForStorage.unregister(callback)) {
|
|
||||||
// the callback was not registered
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (callbacksForStorage.getRegisteredCallbackCount() > 0) {
|
|
||||||
// other callbacks are still listening on this storage
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
mCallbacks.delete(storageId);
|
|
||||||
}
|
|
||||||
// stop listening for this storage
|
|
||||||
return storage.unregisterLoadingProgressListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStorageLoadingProgressChanged(int storageId, float progress) {
|
public void onStorageLoadingProgressChanged(int storageId, float progress) {
|
||||||
final RemoteCallbackList<IPackageLoadingProgressCallback> callbacksForStorage;
|
final RemoteCallbackList<IPackageLoadingProgressCallback> callbacksForStorage;
|
||||||
|
|||||||
@@ -1207,8 +1207,13 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
|||||||
|
|
||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private void computeProgressLocked(boolean forcePublish) {
|
private void computeProgressLocked(boolean forcePublish) {
|
||||||
mProgress = MathUtils.constrain(mClientProgress * 0.8f, 0f, 0.8f)
|
if (!mCommitted) {
|
||||||
+ MathUtils.constrain(mInternalProgress * 0.2f, 0f, 0.2f);
|
mProgress = MathUtils.constrain(mClientProgress * 0.8f, 0f, 0.8f)
|
||||||
|
+ MathUtils.constrain(mInternalProgress * 0.2f, 0f, 0.2f);
|
||||||
|
} else {
|
||||||
|
// For incremental installs, continue publishing the install progress during committing.
|
||||||
|
mProgress = mIncrementalProgress;
|
||||||
|
}
|
||||||
|
|
||||||
// Only publish when meaningful change
|
// Only publish when meaningful change
|
||||||
if (forcePublish || Math.abs(mProgress - mReportedProgress) >= 0.01) {
|
if (forcePublish || Math.abs(mProgress - mReportedProgress) >= 0.01) {
|
||||||
@@ -1944,9 +1949,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
|||||||
throw new PackageManagerException(INSTALL_FAILED_INTERNAL_ERROR,
|
throw new PackageManagerException(INSTALL_FAILED_INTERNAL_ERROR,
|
||||||
"Session destroyed");
|
"Session destroyed");
|
||||||
}
|
}
|
||||||
// Client staging is fully done at this point
|
if (!isIncrementalInstallation()) {
|
||||||
mClientProgress = 1f;
|
// For non-incremental installs, client staging is fully done at this point
|
||||||
computeProgressLocked(true);
|
mClientProgress = 1f;
|
||||||
|
computeProgressLocked(true);
|
||||||
|
}
|
||||||
|
|
||||||
// This ongoing commit should keep session active, even though client
|
// This ongoing commit should keep session active, even though client
|
||||||
// will probably close their end.
|
// will probably close their end.
|
||||||
@@ -3804,6 +3811,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
|||||||
public void onPackageLoadingProgressChanged(float progress) {
|
public void onPackageLoadingProgressChanged(float progress) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
mIncrementalProgress = progress;
|
mIncrementalProgress = progress;
|
||||||
|
computeProgressLocked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user