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

Commit fc04788c authored by Song Chun Fan's avatar Song Chun Fan Committed by Android (Google) Code Review
Browse files

Merge "[pm] do not send UID_REMOVED broadcast if shared uid still exists" into main

parents fa283aee 209c5b8b
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -392,8 +392,7 @@ final class RemovePackageHelper {
            // Delete from mSettings
            final SparseBooleanArray changedUsers = new SparseBooleanArray();
            synchronized (mPm.mLock) {
                mPm.mSettings.removePackageLPw(packageName);
                outInfo.mIsAppIdRemoved = true;
                outInfo.mIsAppIdRemoved = mPm.mSettings.removePackageAndAppIdLPw(packageName);
                if (!mPm.mSettings.isDisabledSystemPackageLPr(packageName)) {
                    final SharedUserSetting sus = mPm.mSettings.getSharedUserSettingLPr(deletedPs);
                    // If we don't have a disabled system package to reinstall, the package is
+12 −7
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@ import android.util.proto.ProtoOutputStream;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.BackgroundThread;
import com.android.internal.pm.parsing.pkg.PackageImpl;
import com.android.internal.pm.pkg.component.ParsedComponent;
import com.android.internal.pm.pkg.component.ParsedIntentInfo;
import com.android.internal.pm.pkg.component.ParsedPermission;
@@ -1460,22 +1459,28 @@ public final class Settings implements Watchable, Snappable, ResilientAtomicFile
        return false;
    }

    int removePackageLPw(String name) {

    /**
     * Remove package from mPackages and its corresponding AppId.
     *
     * @return True if the AppId has been removed.
     * False if the app doesn't exist, or if the app has a shared UID and there are other apps that
     * still use the same shared UID even after the target app is removed.
     */
    boolean removePackageAndAppIdLPw(String name) {
        final PackageSetting p = mPackages.remove(name);
        if (p != null) {
            removeInstallerPackageStatus(name);
            SharedUserSetting sharedUserSetting = getSharedUserSettingLPr(p);
            if (sharedUserSetting != null) {
                sharedUserSetting.removePackage(p);
                if (checkAndPruneSharedUserLPw(sharedUserSetting, false)) {
                    return sharedUserSetting.mAppId;
                }
                return checkAndPruneSharedUserLPw(sharedUserSetting, false);
            } else {
                removeAppIdLPw(p.getAppId());
                return p.getAppId();
                return true;
            }
        }
        return -1;
        return false;
    }

    /**