Introduce the sharedUserMaxSdkVersion attribute

We need a mechanism to allow developers to opt-out of
shared UID without removing the android:sharedUserId
attribute to maintain compatibility with older Android
versions.

The developer can set the highest API level at which the
sharedUserId attribute will be recognized, analogous to
using maxSdkVersion in <uses-permission>.

Bug: 196261070
Test: build + flash + TH
Change-Id: I12d2bc0997d1291991b1289a7b0dda0d954f2bd2
This commit is contained in:
John Wu
2021-08-19 16:05:34 -07:00
parent bbca23fee6
commit 5c65211ec0
4 changed files with 14 additions and 0 deletions

View File

@@ -1291,6 +1291,7 @@ package android {
field public static final int shareInterpolator = 16843195; // 0x10101bb
field @Deprecated public static final int sharedUserId = 16842763; // 0x101000b
field @Deprecated public static final int sharedUserLabel = 16843361; // 0x1010261
field public static final int sharedUserMaxSdkVersion;
field public static final int shell = 16844180; // 0x1010594
field public static final int shortcutDisabledMessage = 16844075; // 0x101052b
field public static final int shortcutId = 16844072; // 0x1010528

View File

@@ -996,6 +996,11 @@ public class ParsingPackageUtils {
private static ParseResult<ParsingPackage> parseSharedUser(ParseInput input,
ParsingPackage pkg, TypedArray sa) {
int maxSdkVersion = anInteger(0, R.styleable.AndroidManifest_sharedUserMaxSdkVersion, sa);
if ((maxSdkVersion != 0) && maxSdkVersion < Build.VERSION.RESOURCES_SDK_INT) {
return input.success(pkg);
}
String str = nonConfigString(0, R.styleable.AndroidManifest_sharedUserId, sa);
if (TextUtils.isEmpty(str)) {
return input.success(pkg);

View File

@@ -395,6 +395,12 @@
this attribute unnecessary. -->
<attr name="sharedUserLabel" format="reference" />
<!-- The maximum device SDK version for which the application will remain in the user ID
defined in sharedUserId. Used when the application wants to migrate out of using shared
user ID, but has to maintain backwards compatibility with the API level specified
and before. -->
<attr name="sharedUserMaxSdkVersion" format="integer" />
<!-- Internal version code. This is the number used to determine whether
one version is more recent than another: it has no other meaning than
that higher numbers are more recent. You could use this number to
@@ -1650,6 +1656,7 @@
<attr name="revisionCode" />
<attr name="sharedUserId" />
<attr name="sharedUserLabel" />
<attr name="sharedUserMaxSdkVersion" />
<attr name="installLocation" />
<attr name="isolatedSplits" />
<attr name="isFeatureSplit" />

View File

@@ -3295,6 +3295,7 @@
<eat-comment />
<staging-public-group type="attr" first-id="0x01df0000">
<public name="sharedUserMaxSdkVersion" />
</staging-public-group>
<staging-public-group type="id" first-id="0x01de0000">