Revert "Revert "[pm/incremental] start monitoring progress on storage creation""
This reverts commit 5f47bc6ba1.
Reason for revert: We still need part of this CL that starts monitoring progress on storage creation. This helps detect the kernel selinux issue where the security context of a file was assigned wrongly.
BUG: 180514262
Test: builds
Change-Id: I33fca8f9be27f3f2dfab089feaf3c241ae7d5d49
This commit is contained in:
@@ -36,6 +36,7 @@ import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
import android.content.pm.DataLoaderParams;
|
||||
import android.content.pm.IDataLoaderStatusListener;
|
||||
import android.content.pm.IPackageLoadingProgressCallback;
|
||||
import android.content.pm.InstallationFileParcel;
|
||||
|
||||
import java.io.File;
|
||||
@@ -71,7 +72,8 @@ public final class IncrementalFileStorages {
|
||||
@Nullable StorageHealthCheckParams healthCheckParams,
|
||||
@Nullable IStorageHealthListener healthListener,
|
||||
@NonNull List<InstallationFileParcel> addedFiles,
|
||||
@NonNull PerUidReadTimeouts[] perUidReadTimeouts) throws IOException {
|
||||
@NonNull PerUidReadTimeouts[] perUidReadTimeouts,
|
||||
IPackageLoadingProgressCallback progressCallback) throws IOException {
|
||||
// TODO(b/136132412): validity check if session should not be incremental
|
||||
IncrementalManager incrementalManager = (IncrementalManager) context.getSystemService(
|
||||
Context.INCREMENTAL_SERVICE);
|
||||
@@ -95,6 +97,11 @@ public final class IncrementalFileStorages {
|
||||
throw new IOException("Unknown file location: " + file.location);
|
||||
}
|
||||
}
|
||||
// Register progress loading callback after files have been added
|
||||
if (progressCallback != null) {
|
||||
incrementalManager.registerLoadingProgressCallback(stageDir.getAbsolutePath(),
|
||||
progressCallback);
|
||||
}
|
||||
result.startLoading(dataLoaderParams, statusListener, healthCheckParams, healthListener,
|
||||
perUidReadTimeouts);
|
||||
|
||||
@@ -205,6 +212,7 @@ public final class IncrementalFileStorages {
|
||||
|
||||
try {
|
||||
mDefaultStorage.unBind(mStageDir.getAbsolutePath());
|
||||
mDefaultStorage.unregisterLoadingProgressListener();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
mDefaultStorage = null;
|
||||
|
||||
@@ -70,6 +70,7 @@ import android.content.pm.IDataLoaderStatusListener;
|
||||
import android.content.pm.IPackageInstallObserver2;
|
||||
import android.content.pm.IPackageInstallerSession;
|
||||
import android.content.pm.IPackageInstallerSessionFileSystemConnector;
|
||||
import android.content.pm.IPackageLoadingProgressCallback;
|
||||
import android.content.pm.InstallationFile;
|
||||
import android.content.pm.InstallationFileParcel;
|
||||
import android.content.pm.PackageInfo;
|
||||
@@ -321,6 +322,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
private float mProgress = 0;
|
||||
@GuardedBy("mLock")
|
||||
private float mReportedProgress = -1;
|
||||
@GuardedBy("mLock")
|
||||
private float mIncrementalProgress = 0;
|
||||
|
||||
/** State of the session. */
|
||||
@GuardedBy("mLock")
|
||||
@@ -3770,7 +3773,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
||||
|
||||
mIncrementalFileStorages = IncrementalFileStorages.initialize(mContext, stageDir,
|
||||
inheritedDir, params, statusListener, healthCheckParams, healthListener,
|
||||
addedFiles, perUidReadTimeouts);
|
||||
addedFiles, perUidReadTimeouts,
|
||||
new IPackageLoadingProgressCallback.Stub() {
|
||||
@Override
|
||||
public void onPackageLoadingProgressChanged(float progress) {
|
||||
synchronized (mLock) {
|
||||
mIncrementalProgress = progress;
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
throw new PackageManagerException(INSTALL_FAILED_MEDIA_UNAVAILABLE, e.getMessage(),
|
||||
|
||||
Reference in New Issue
Block a user