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

Commit 8763e6ba authored by Songchun Fan's avatar Songchun Fan
Browse files

[pm] do not call prepareAppDataAfterInstallLIF from inside mLock

Fix some lock ordering.

BUG: 219931252
Test: manual with uninstalling system app updates
Change-Id: Icf89e493b1c781b738e55c0d81afe1b1c4f5d7c3
parent 34435473
Loading
Loading
Loading
Loading
+25 −25
Original line number Original line Diff line number Diff line
@@ -2987,7 +2987,6 @@ final class InstallPackageHelper {
     * APK will be installed and the package will be disabled. To recover from this situation,
     * APK will be installed and the package will be disabled. To recover from this situation,
     * the user will need to go into system settings and re-enable the package.
     * the user will need to go into system settings and re-enable the package.
     */
     */
    @GuardedBy({"mPm.mLock", "mPm.mInstallLock"})
    boolean enableCompressedPackage(AndroidPackage stubPkg,
    boolean enableCompressedPackage(AndroidPackage stubPkg,
            @NonNull PackageSetting stubPkgSetting) {
            @NonNull PackageSetting stubPkgSetting) {
        final int parseFlags = mPm.getDefParseFlags() | ParsingPackageUtils.PARSE_CHATTY
        final int parseFlags = mPm.getDefParseFlags() | ParsingPackageUtils.PARSE_CHATTY
@@ -2997,8 +2996,8 @@ final class InstallPackageHelper {
            try (PackageFreezer freezer =
            try (PackageFreezer freezer =
                         mPm.freezePackage(stubPkg.getPackageName(), "setEnabledSetting")) {
                         mPm.freezePackage(stubPkg.getPackageName(), "setEnabledSetting")) {
                pkg = installStubPackageLI(stubPkg, parseFlags, 0 /*scanFlags*/);
                pkg = installStubPackageLI(stubPkg, parseFlags, 0 /*scanFlags*/);
                synchronized (mPm.mLock) {
                mAppDataHelper.prepareAppDataAfterInstallLIF(pkg);
                mAppDataHelper.prepareAppDataAfterInstallLIF(pkg);
                synchronized (mPm.mLock) {
                    try {
                    try {
                        mSharedLibraries.updateSharedLibrariesLPw(
                        mSharedLibraries.updateSharedLibrariesLPw(
                                pkg, stubPkgSetting, null, null,
                                pkg, stubPkgSetting, null, null,
@@ -3055,7 +3054,7 @@ final class InstallPackageHelper {
        return true;
        return true;
    }
    }


    @GuardedBy({"mPm.mLock", "mPm.mInstallLock"})
    @GuardedBy("mPm.mInstallLock")
    private AndroidPackage installStubPackageLI(AndroidPackage stubPkg,
    private AndroidPackage installStubPackageLI(AndroidPackage stubPkg,
            @ParsingPackageUtils.ParseFlags int parseFlags,
            @ParsingPackageUtils.ParseFlags int parseFlags,
            @PackageManagerService.ScanFlags int scanFlags)
            @PackageManagerService.ScanFlags int scanFlags)
@@ -3148,7 +3147,7 @@ final class InstallPackageHelper {
            mPm.mSettings.enableSystemPackageLPw(disabledPs.getPkg().getPackageName());
            mPm.mSettings.enableSystemPackageLPw(disabledPs.getPkg().getPackageName());
            // Remove any native libraries from the upgraded package.
            // Remove any native libraries from the upgraded package.
            PackageManagerServiceUtils.removeNativeBinariesLI(deletedPs);
            PackageManagerServiceUtils.removeNativeBinariesLI(deletedPs);

        }
        // Install the system package
        // Install the system package
        if (DEBUG_REMOVE) Slog.d(TAG, "Re-installing system package: " + disabledPs);
        if (DEBUG_REMOVE) Slog.d(TAG, "Re-installing system package: " + disabledPs);
        try {
        try {
@@ -3169,6 +3168,7 @@ final class InstallPackageHelper {
                // We've re-installed the stub; make sure it's disabled here. If package was
                // We've re-installed the stub; make sure it's disabled here. If package was
                // originally enabled, we'll install the compressed version of the application
                // originally enabled, we'll install the compressed version of the application
                // and re-enable it afterward.
                // and re-enable it afterward.
                synchronized (mPm.mLock) {
                    disableStubPackage(action, deletedPs, allUserHandles);
                    disableStubPackage(action, deletedPs, allUserHandles);
                }
                }
            }
            }
@@ -3196,7 +3196,7 @@ final class InstallPackageHelper {
    /**
    /**
     * Installs a package that's already on the system partition.
     * Installs a package that's already on the system partition.
     */
     */
    @GuardedBy({"mPm.mLock", "mPm.mInstallLock"})
    @GuardedBy("mPm.mInstallLock")
    private void installPackageFromSystemLIF(@NonNull String codePathString,
    private void installPackageFromSystemLIF(@NonNull String codePathString,
            @NonNull int[] allUserHandles, @Nullable int[] origUserHandles,
            @NonNull int[] allUserHandles, @Nullable int[] origUserHandles,
            boolean writeSettings, int previousAppId)
            boolean writeSettings, int previousAppId)