summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kiran Ramachandra <kiranmr@google.com> 2024-01-25 17:38:18 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2024-01-25 17:38:18 +0000
commitd3611d09319b16f52036f5160d8fa44b3995ac03 (patch)
treef76cbc6d5f967fa57417827832441f8e3584a9eb
parentbf65d1ae40ff9b53bac4cc188c2d724c8a11d1f1 (diff)
parent63d122cf0e18ff6d8e77b7bcc8f0f3f8d4e4a018 (diff)
RESTRICT AUTOMERGE Added limitations for attributions to handle invalid cases am: 63d122cf0e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/25705787 Change-Id: I1ef63874bb0bcd29ef01bb9445e8f8d2b8409bf2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--services/core/java/com/android/server/appop/AppOpsService.java38
-rw-r--r--services/core/java/com/android/server/pm/pkg/component/ParsedAttributionImpl.java2
2 files changed, 39 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java
index 3b30c8f34087..1bde4e22428f 100644
--- a/services/core/java/com/android/server/appop/AppOpsService.java
+++ b/services/core/java/com/android/server/appop/AppOpsService.java
@@ -3460,6 +3460,10 @@ public class AppOpsService extends IAppOpsService.Stub {
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
packageName);
}
+ if (proxyAttributionTag != null
+ && !isAttributionTagDefined(packageName, proxyPackageName, proxyAttributionTag)) {
+ proxyAttributionTag = null;
+ }
synchronized (this) {
final Ops ops = getOpsLocked(uid, packageName, attributionTag,
@@ -3974,6 +3978,10 @@ public class AppOpsService extends IAppOpsService.Stub {
return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
packageName);
}
+ if (proxyAttributionTag != null
+ && !isAttributionTagDefined(packageName, proxyPackageName, proxyAttributionTag)) {
+ proxyAttributionTag = null;
+ }
boolean isRestricted = false;
int startType = START_TYPE_FAILED;
@@ -4715,6 +4723,36 @@ public class AppOpsService extends IAppOpsService.Stub {
}
/**
+ * Checks to see if the attribution tag is defined in either package or proxyPackage.
+ * This method is intended for ProxyAttributionTag validation and returns false
+ * if it does not exist in either one of them.
+ *
+ * @param packageName Name of the package
+ * @param proxyPackageName Name of the proxy package
+ * @param attributionTag attribution tag to be checked
+ *
+ * @return boolean specifying if attribution tag is valid or not
+ */
+ private boolean isAttributionTagDefined(@Nullable String packageName,
+ @Nullable String proxyPackageName,
+ @Nullable String attributionTag) {
+ if (packageName == null) {
+ return false;
+ } else if (attributionTag == null) {
+ return true;
+ }
+ PackageManagerInternal pmInt = LocalServices.getService(PackageManagerInternal.class);
+ if (proxyPackageName != null) {
+ AndroidPackage proxyPkg = pmInt.getPackage(proxyPackageName);
+ if (proxyPkg != null && isAttributionInPackage(proxyPkg, attributionTag)) {
+ return true;
+ }
+ }
+ AndroidPackage pkg = pmInt.getPackage(packageName);
+ return isAttributionInPackage(pkg, attributionTag);
+ }
+
+ /**
* Get (and potentially create) ops.
*
* @param uid The uid the package belongs to
diff --git a/services/core/java/com/android/server/pm/pkg/component/ParsedAttributionImpl.java b/services/core/java/com/android/server/pm/pkg/component/ParsedAttributionImpl.java
index b59f511afa57..0917eb6ee43f 100644
--- a/services/core/java/com/android/server/pm/pkg/component/ParsedAttributionImpl.java
+++ b/services/core/java/com/android/server/pm/pkg/component/ParsedAttributionImpl.java
@@ -38,7 +38,7 @@ import java.util.List;
public class ParsedAttributionImpl implements ParsedAttribution, Parcelable {
/** Maximum amount of attributions per package */
- static final int MAX_NUM_ATTRIBUTIONS = 10000;
+ static final int MAX_NUM_ATTRIBUTIONS = 1000;
/** Tag of the attribution */
private @NonNull String tag;