patches/frameworks/base/0001-PackageParser-support-glob-matching-for-properties.patch
2021-10-20 20:51:07 -04:00

37 lines
1.5 KiB
Diff

From 70f7d35dda51036f04d31d507e4c30ee0a033ec5 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/2] 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 bbb0b8e30938..45ebe8e1aaaf 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2500,8 +2500,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.33.1