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

Commit f2812853 authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Allow any app to silently uninstall the orphan packages." into nyc-dev

parents 4569e951 8c57aeaa
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -866,8 +866,9 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
        if ((callingUid != Process.SHELL_UID) && (callingUid != Process.ROOT_UID)) {
            mAppOps.checkPackage(callingUid, callerPackageName);
            final String installerPackageName = mPm.getInstallerPackageName(packageName);
            allowSilentUninstall = installerPackageName != null
                    && installerPackageName.equals(callerPackageName);
            allowSilentUninstall = mPm.isOrphaned(packageName) ||
                    (installerPackageName != null
                            && installerPackageName.equals(callerPackageName));
        }

        // Check whether the caller is device owner, in which case we do it silently.
+7 −0
Original line number Diff line number Diff line
@@ -17525,6 +17525,13 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
        }
    }
    public boolean isOrphaned(String packageName) {
        // reader
        synchronized (mPackages) {
            return mSettings.isOrphaned(packageName);
        }
    }
    @Override
    public int getApplicationEnabledSetting(String packageName, int userId) {
        if (!sUserManager.exists(userId)) return COMPONENT_ENABLED_STATE_DISABLED;
+3 −0
Original line number Diff line number Diff line
@@ -125,6 +125,8 @@ abstract class PackageSettingBase extends SettingBase {

    /** Package name of the app that installed this package */
    String installerPackageName;
    /** Indicates if the package that installed this app has been uninstalled */
    boolean isOrphaned;
    /** UUID of {@link VolumeInfo} hosting this app */
    String volumeUuid;

@@ -182,6 +184,7 @@ abstract class PackageSettingBase extends SettingBase {
        origPackage = base.origPackage;

        installerPackageName = base.installerPackageName;
        isOrphaned = base.isOrphaned;
        volumeUuid = base.volumeUuid;

        keySetData = new PackageKeySetData(base.keySetData);
+15 −0
Original line number Diff line number Diff line
@@ -1117,6 +1117,7 @@ final class Settings {
            if (installerPackageName != null
                    && installerPackageName.equals(packageName)) {
                ps.setInstallerPackageName(null);
                ps.isOrphaned = true;
            }
        }
        mInstallerPackages.remove(packageName);
@@ -2647,6 +2648,9 @@ final class Settings {
        if (pkg.installerPackageName != null) {
            serializer.attribute(null, "installer", pkg.installerPackageName);
        }
        if (pkg.isOrphaned) {
            serializer.attribute(null, "isOrphaned", "true");
        }
        if (pkg.volumeUuid != null) {
            serializer.attribute(null, "volumeUuid", pkg.volumeUuid);
        }
@@ -3522,6 +3526,7 @@ final class Settings {
        String cpuAbiOverrideString = null;
        String systemStr = null;
        String installerPackageName = null;
        String isOrphaned = null;
        String volumeUuid = null;
        String uidError = null;
        int pkgFlags = 0;
@@ -3563,6 +3568,7 @@ final class Settings {
                }
            }
            installerPackageName = parser.getAttributeValue(null, "installer");
            isOrphaned = parser.getAttributeValue(null, "isOrphaned");
            volumeUuid = parser.getAttributeValue(null, "volumeUuid");

            systemStr = parser.getAttributeValue(null, "publicFlags");
@@ -3713,6 +3719,7 @@ final class Settings {
        if (packageSetting != null) {
            packageSetting.uidError = "true".equals(uidError);
            packageSetting.installerPackageName = installerPackageName;
            packageSetting.isOrphaned = "true".equals(isOrphaned);
            packageSetting.volumeUuid = volumeUuid;
            packageSetting.legacyNativeLibraryPathString = legacyNativeLibraryPathStr;
            packageSetting.primaryCpuAbiString = primaryCpuAbiString;
@@ -4115,6 +4122,14 @@ final class Settings {
        return pkg.installerPackageName;
    }

    boolean isOrphaned(String packageName) {
        final PackageSetting pkg = mPackages.get(packageName);
        if (pkg == null) {
            throw new IllegalArgumentException("Unknown package: " + packageName);
        }
        return pkg.isOrphaned;
    }

    int getApplicationEnabledSettingLPr(String packageName, int userId) {
        final PackageSetting pkg = mPackages.get(packageName);
        if (pkg == null) {