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

37 lines
1.5 KiB
Diff

From b2a523bde06164be9431c4e5f51d3acd2b459bd5 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/4] 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 c15b3e0b80c3..05bb843c0c4d 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2545,8 +2545,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.39.2