patches/frameworks/base/0001-PackageParser-support-...

37 lines
1.5 KiB
Diff

From a26d483d257bdb33553f43719cdad0b392fc6ea4 Mon Sep 17 00:00:00 2001
From: Peter Cai <peter@typeblog.net>
Date: Tue, 12 Oct 2021 21:37:22 -0400
Subject: [PATCH 1/5] PackageParser: support glob matching for properties
Needed to make phh's vendor overlays work
---
core/java/android/content/pm/PackageParser.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 80058d31245c..0ea286c1591a 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2504,8 +2504,16 @@ public class PackageParser {
for (int i = 0; i < propNames.length; i++) {
// Check property value: make sure it is both set and equal to expected value
final String currValue = SystemProperties.get(propNames[i]);
- if (!TextUtils.equals(currValue, propValues[i])) {
- return false;
+ if (propValues[i].startsWith("+") && propValues[i].endsWith("*")) {
+ // Glob matching
+ int idx = TextUtils.indexOf(currValue, propValues[i].substring(1, propValues[i].length() - 1));
+ if (idx < 0) {
+ return false;
+ }
+ } else {
+ if (!TextUtils.equals(currValue, propValues[i])) {
+ return false;
+ }
}
}
return true;
--
2.36.1