diff options
| author | Tom Natan <tomnatan@google.com> | 2021-07-08 10:30:08 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-07-08 10:30:08 +0000 |
| commit | 7cefb4c54741733800af8b81da0e78475162f52c (patch) | |
| tree | f345f421f4485f84a8a6ebde27017907faf740fa /core/java | |
| parent | 862be93ec20843da3a0dd55b7796db7b7cfe6069 (diff) | |
| parent | 28a6e9f9735d30bd07a05d7783fc9a3315f17edf (diff) | |
Merge "Add support for always_constrain_display_apis flag" into sc-dev am: 28a6e9f973
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15216092
Change-Id: Icfe7b9f2e19805a935fbe9677e313b33128d9e37
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/content/pm/ActivityInfo.java | 3 | ||||
| -rw-r--r-- | core/java/android/content/pm/ConstrainDisplayApisConfig.java | 32 |
2 files changed, 33 insertions, 2 deletions
diff --git a/core/java/android/content/pm/ActivityInfo.java b/core/java/android/content/pm/ActivityInfo.java index 60ab83aa2264..95c5612aeee4 100644 --- a/core/java/android/content/pm/ActivityInfo.java +++ b/core/java/android/content/pm/ActivityInfo.java @@ -1363,7 +1363,8 @@ public class ActivityInfo extends ComponentInfo implements Parcelable { public boolean alwaysSandboxDisplayApis() { return CompatChanges.isChangeEnabled(ALWAYS_SANDBOX_DISPLAY_APIS, applicationInfo.packageName, - UserHandle.getUserHandleForUid(applicationInfo.uid)); + UserHandle.getUserHandleForUid(applicationInfo.uid)) + || ConstrainDisplayApisConfig.alwaysConstrainDisplayApis(applicationInfo); } /** @hide */ diff --git a/core/java/android/content/pm/ConstrainDisplayApisConfig.java b/core/java/android/content/pm/ConstrainDisplayApisConfig.java index 1337347cdaf0..11ba3d4ba9a2 100644 --- a/core/java/android/content/pm/ConstrainDisplayApisConfig.java +++ b/core/java/android/content/pm/ConstrainDisplayApisConfig.java @@ -47,6 +47,14 @@ public final class ConstrainDisplayApisConfig { "never_constrain_display_apis_all_packages"; /** + * A string flag whose value holds a comma separated list of package entries in the format + * '<package-name>:<min-version-code>?:<max-version-code>?' for which Display APIs should + * always be constrained. + */ + private static final String FLAG_ALWAYS_CONSTRAIN_DISPLAY_APIS = + "always_constrain_display_apis"; + + /** * Returns true if either the flag 'never_constrain_display_apis_all_packages' is true or the * flag 'never_constrain_display_apis' contains a package entry that matches the given {@code * applicationInfo}. @@ -58,8 +66,30 @@ public final class ConstrainDisplayApisConfig { FLAG_NEVER_CONSTRAIN_DISPLAY_APIS_ALL_PACKAGES, /* defaultValue= */ false)) { return true; } + + return flagHasMatchingPackageEntry(FLAG_NEVER_CONSTRAIN_DISPLAY_APIS, applicationInfo); + } + + /** + * Returns true if the flag 'always_constrain_display_apis' contains a package entry that + * matches the given {@code applicationInfo}. + * + * @param applicationInfo Information about the application/package. + */ + public static boolean alwaysConstrainDisplayApis(ApplicationInfo applicationInfo) { + return flagHasMatchingPackageEntry(FLAG_ALWAYS_CONSTRAIN_DISPLAY_APIS, applicationInfo); + } + + /** + * Returns true if the flag with the given {@code flagName} contains a package entry that + * matches the given {@code applicationInfo}. + * + * @param applicationInfo Information about the application/package. + */ + private static boolean flagHasMatchingPackageEntry(String flagName, + ApplicationInfo applicationInfo) { String configStr = DeviceConfig.getString(NAMESPACE_CONSTRAIN_DISPLAY_APIS, - FLAG_NEVER_CONSTRAIN_DISPLAY_APIS, /* defaultValue= */ ""); + flagName, /* defaultValue= */ ""); // String#split returns a non-empty array given an empty string. if (configStr.isEmpty()) { |
