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

Commit 9e6b95e5 authored by JW Wang's avatar JW Wang
Browse files

Protect mIncrementalFileStorages with mLock (2/n)

Bug: 159663586
Test: atest StagedInstallTest AtomicInstallTest
Change-Id: I130736e0758032e93bc60294b9b22a4931609684
parent 94899bde
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -402,7 +402,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {

    private boolean mDataLoaderFinished = false;

    // TODO(b/159663586): should be protected by mLock
    @GuardedBy("mLock")
    private IncrementalFileStorages mIncrementalFileStorages;

    private static final FileFilter sAddedApkFilter = new FileFilter() {
@@ -3133,11 +3133,11 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
            for (FileBridge bridge : mBridges) {
                bridge.forceClose();
            }
        }
            if (mIncrementalFileStorages != null) {
                mIncrementalFileStorages.cleanUp();
                mIncrementalFileStorages = null;
            }
        }
        // For staged sessions, we don't delete the directory where the packages have been copied,
        // since these packages are supposed to be read on reboot.
        // Those dirs are deleted when the staged session has reached a final state.
@@ -3173,10 +3173,12 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
    }

    private void cleanStageDir() {
        synchronized (mLock) {
            if (mIncrementalFileStorages != null) {
                mIncrementalFileStorages.cleanUp();
                mIncrementalFileStorages = null;
            }
        }
        try {
            mPm.mInstaller.rmPackageDir(stageDir.getAbsolutePath());
        } catch (InstallerException ignored) {