From 5c65211ec0dd1c7c876603637bce8ca4314cfd07 Mon Sep 17 00:00:00 2001 From: John Wu Date: Thu, 19 Aug 2021 16:05:34 -0700 Subject: [PATCH] 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 . Bug: 196261070 Test: build + flash + TH Change-Id: I12d2bc0997d1291991b1289a7b0dda0d954f2bd2 --- core/api/current.txt | 1 + .../android/content/pm/parsing/ParsingPackageUtils.java | 5 +++++ core/res/res/values/attrs_manifest.xml | 7 +++++++ core/res/res/values/public.xml | 1 + 4 files changed, 14 insertions(+) diff --git a/core/api/current.txt b/core/api/current.txt index 5f31e0be99654..95c784bd519c0 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -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 diff --git a/core/java/android/content/pm/parsing/ParsingPackageUtils.java b/core/java/android/content/pm/parsing/ParsingPackageUtils.java index 809a544039f9c..80befcdf02de5 100644 --- a/core/java/android/content/pm/parsing/ParsingPackageUtils.java +++ b/core/java/android/content/pm/parsing/ParsingPackageUtils.java @@ -996,6 +996,11 @@ public class ParsingPackageUtils { private static ParseResult 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); diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml index 73dfab683d486..cbf35f4a080d9 100644 --- a/core/res/res/values/attrs_manifest.xml +++ b/core/res/res/values/attrs_manifest.xml @@ -395,6 +395,12 @@ this attribute unnecessary. --> + + +