Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac00c1ba authored by Songchun Fan's avatar Songchun Fan Committed by Automerger Merge Worker
Browse files

Merge "Revert "Revert "[pm/incremental] start monitoring progress on storage...

Merge "Revert "Revert "[pm/incremental] start monitoring progress on storage creation""" into sc-dev am: 1f535786

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13585238

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6e31b4b03cdd2f748f4ec442e1410ea06ead7d03
parents 8be991d0 1f535786
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -36,6 +36,7 @@ import android.annotation.Nullable;
import android.content.Context;
import android.content.Context;
import android.content.pm.DataLoaderParams;
import android.content.pm.DataLoaderParams;
import android.content.pm.IDataLoaderStatusListener;
import android.content.pm.IDataLoaderStatusListener;
import android.content.pm.IPackageLoadingProgressCallback;
import android.content.pm.InstallationFileParcel;
import android.content.pm.InstallationFileParcel;


import java.io.File;
import java.io.File;
@@ -71,7 +72,8 @@ public final class IncrementalFileStorages {
            @Nullable StorageHealthCheckParams healthCheckParams,
            @Nullable StorageHealthCheckParams healthCheckParams,
            @Nullable IStorageHealthListener healthListener,
            @Nullable IStorageHealthListener healthListener,
            @NonNull List<InstallationFileParcel> addedFiles,
            @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
        // 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);
@@ -95,6 +97,11 @@ public final class IncrementalFileStorages {
                throw new IOException("Unknown file location: " + file.location);
                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,
        result.startLoading(dataLoaderParams, statusListener, healthCheckParams, healthListener,
                perUidReadTimeouts);
                perUidReadTimeouts);


@@ -205,6 +212,7 @@ public final class IncrementalFileStorages {


        try {
        try {
            mDefaultStorage.unBind(mStageDir.getAbsolutePath());
            mDefaultStorage.unBind(mStageDir.getAbsolutePath());
            mDefaultStorage.unregisterLoadingProgressListener();
        } catch (IOException ignored) {
        } catch (IOException ignored) {
        }
        }
        mDefaultStorage = null;
        mDefaultStorage = null;
+12 −1
Original line number Original line Diff line number Diff line
@@ -70,6 +70,7 @@ import android.content.pm.IDataLoaderStatusListener;
import android.content.pm.IPackageInstallObserver2;
import android.content.pm.IPackageInstallObserver2;
import android.content.pm.IPackageInstallerSession;
import android.content.pm.IPackageInstallerSession;
import android.content.pm.IPackageInstallerSessionFileSystemConnector;
import android.content.pm.IPackageInstallerSessionFileSystemConnector;
import android.content.pm.IPackageLoadingProgressCallback;
import android.content.pm.InstallationFile;
import android.content.pm.InstallationFile;
import android.content.pm.InstallationFileParcel;
import android.content.pm.InstallationFileParcel;
import android.content.pm.PackageInfo;
import android.content.pm.PackageInfo;
@@ -321,6 +322,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    private float mProgress = 0;
    private float mProgress = 0;
    @GuardedBy("mLock")
    @GuardedBy("mLock")
    private float mReportedProgress = -1;
    private float mReportedProgress = -1;
    @GuardedBy("mLock")
    private float mIncrementalProgress = 0;


    /** State of the session. */
    /** State of the session. */
    @GuardedBy("mLock")
    @GuardedBy("mLock")
@@ -3770,7 +3773,15 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {


                mIncrementalFileStorages = IncrementalFileStorages.initialize(mContext, stageDir,
                mIncrementalFileStorages = IncrementalFileStorages.initialize(mContext, stageDir,
                        inheritedDir, params, statusListener, healthCheckParams, healthListener,
                        inheritedDir, params, statusListener, healthCheckParams, healthListener,
                        addedFiles, perUidReadTimeouts);
                        addedFiles, perUidReadTimeouts,
                        new IPackageLoadingProgressCallback.Stub() {
                            @Override
                            public void onPackageLoadingProgressChanged(float progress) {
                                synchronized (mLock) {
                                    mIncrementalProgress = progress;
                                }
                            }
                        });
                return false;
                return false;
            } catch (IOException e) {
            } catch (IOException e) {
                throw new PackageManagerException(INSTALL_FAILED_MEDIA_UNAVAILABLE, e.getMessage(),
                throw new PackageManagerException(INSTALL_FAILED_MEDIA_UNAVAILABLE, e.getMessage(),