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

Commit d378c630 authored by Jackal Guo's avatar Jackal Guo
Browse files

Add new manifest attr allowUpdateOwnership (4/n)

Setting this new attr to false indicates to the platform that this
package wants to opt-out of the update ownership enforcement. This
overrides the installers' use of setRequestUpdateOwnership.

Bug: 244413073
Test: atest PackageManagerServiceUnitTests:AndroidPackageTest
Test: atest CtsPackageInstallTestCases:UpdateOwnershipEnforcementTest
Change-Id: I4b3e851b87a25583a7c43b40a7fad07ad46c3761
parent 688b46e3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -385,6 +385,7 @@ package android {
    field public static final int allowTaskReparenting = 16843268; // 0x1010204
    field public static final int allowUndo = 16843999; // 0x10104df
    field public static final int allowUntrustedActivityEmbedding = 16844393; // 0x1010669
    field public static final int allowUpdateOwnership;
    field public static final int alpha = 16843551; // 0x101031f
    field public static final int alphabeticModifiers = 16844110; // 0x101054e
    field public static final int alphabeticShortcut = 16843235; // 0x10101e3
+9 −0
Original line number Diff line number Diff line
@@ -1783,6 +1783,14 @@
    -->
    <attr name="attributionTags" format="string" />

    <!-- Default value <code>true</code> allows an installer to enable update
         ownership enforcement for this package via {@link
         android.content.pm.PackageInstaller.SessionParams#setRequestUpdateOwnership}
         during initial installation. This overrides the installer's use of {@link
         android.content.pm.PackageInstaller.SessionParams#setRequestUpdateOwnership}.
    -->
    <attr name="allowUpdateOwnership" format="boolean" />

    <!-- The <code>manifest</code> tag is the root of an
         <code>AndroidManifest.xml</code> file,
         describing the contents of an Android package (.apk) file.  One
@@ -1820,6 +1828,7 @@
        <attr name="isSplitRequired" />
        <attr name="requiredSplitTypes" />
        <attr name="splitTypes" />
        <attr name="allowUpdateOwnership" />
    </declare-styleable>

    <!-- The <code>application</code> tag describes application-level components
+1 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@
    <public name="allowSharedIsolatedProcess" />
    <public name="keyboardLocale" />
    <public name="keyboardLayoutType" />
    <public name="allowUpdateOwnership" />
  </staging-public-group>

  <staging-public-group type="id" first-id="0x01cd0000">
+4 −0
Original line number Diff line number Diff line
@@ -333,6 +333,10 @@ final class InstallPackageHelper {
            if (updateOwnerFromSysconfig != null) {
                // For system app, we always use the update owner from sysconfig if presented.
                installSource = installSource.setUpdateOwnerPackageName(updateOwnerFromSysconfig);
            } else if (!parsedPackage.isAllowUpdateOwnership()) {
                // If the app wants to opt-out of the update ownership enforcement via manifest,
                // it overrides the installer's use of #setRequestUpdateOwnership.
                installSource = installSource.setUpdateOwnerPackageName(null);
            } else if (!isApex) {
                final boolean isUpdate = oldPkgSetting != null;
                final String oldUpdateOwner =
+11 −0
Original line number Diff line number Diff line
@@ -1809,6 +1809,11 @@ public class PackageImpl implements ParsedPackage, AndroidPackageInternal,
        return getBoolean(Booleans.VISIBLE_TO_INSTANT_APPS);
    }

    @Override
    public boolean isAllowUpdateOwnership() {
        return getBoolean2(Booleans2.ALLOW_UPDATE_OWNERSHIP);
    }

    @Override
    public boolean isVmSafeMode() {
        return getBoolean(Booleans.VM_SAFE_MODE);
@@ -2512,6 +2517,11 @@ public class PackageImpl implements ParsedPackage, AndroidPackageInternal,
        return this;
    }

    @Override
    public PackageImpl setAllowUpdateOwnership(boolean value) {
        return setBoolean2(Booleans2.ALLOW_UPDATE_OWNERSHIP, value);
    }

    @Override
    public PackageImpl sortActivities() {
        Collections.sort(this.activities, ORDER_COMPARATOR);
@@ -3726,5 +3736,6 @@ public class PackageImpl implements ParsedPackage, AndroidPackageInternal,

        private static final long STUB = 1L;
        private static final long APEX = 1L << 1;
        private static final long ALLOW_UPDATE_OWNERSHIP = 1L << 2;
    }
}
Loading