lineage_patches_unified/patches_treble/frameworks_base/0001-Re-implement-fnmatch-like-behaviour-for-RRO-java-sid.patch

65 lines
3.0 KiB
Diff

From 1891dacd48c4d502666fb4468582c088e4c0c097 Mon Sep 17 00:00:00 2001
From: Pierre-Hugues Husson <phh@phh.me>
Date: Sun, 25 Oct 2020 23:57:26 +0100
Subject: [PATCH 1/3] Re-implement fnmatch-like behaviour for RRO java-side
T: Also apply to FrameworkParsingPackageUtils (@PeterCxy)
Change-Id: Id38292a9a1453aa87b8401c1fdb390fa4e63c7d1
---
core/java/android/content/pm/PackageParser.java | 13 +++++++++++--
.../pm/parsing/FrameworkParsingPackageUtils.java | 13 +++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 995092117f4d..28efda00393d 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2544,8 +2544,17 @@ 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;
+ final String value = propValues[i];
+ if(value.startsWith("+")) {
+ final java.util.regex.Pattern regex = java.util.regex.Pattern.compile(value.substring(1, value.length()).replace("*", ".*"));
+ java.util.regex.Matcher matcher = regex.matcher(currValue);
+ if (!matcher.find()) {
+ return false;
+ }
+ } else {
+ if(!value.equals(currValue)) {
+ return false;
+ }
}
}
return true;
diff --git a/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java b/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java
index 3e1c5bb3d7ec..8182e9e0c771 100644
--- a/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java
+++ b/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java
@@ -215,8 +215,17 @@ public class FrameworkParsingPackageUtils {
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;
+ final String value = propValues[i];
+ if(value.startsWith("+")) {
+ final java.util.regex.Pattern regex = java.util.regex.Pattern.compile(value.substring(1, value.length()).replace("*", ".*"));
+ java.util.regex.Matcher matcher = regex.matcher(currValue);
+ if (!matcher.find()) {
+ return false;
+ }
+ } else {
+ if(!value.equals(currValue)) {
+ return false;
+ }
}
}
return true;
--
2.25.1