Use regex for winscope filters

Bug: 265666404
Test: run winscope and test the filters
Change-Id: I7db71e880a196203e5c7592704fa777781d20d28
This commit is contained in:
Nataniel Borges
2023-02-02 11:01:48 +00:00
parent 929a4d412c
commit 8992b465f5
2 changed files with 3 additions and 17 deletions

View File

@@ -53,25 +53,11 @@ class TreeUtils {
}
static makeNodeFilter(filterString: string): FilterType {
const filterStrings = filterString.split(',');
const positive: any[] = [];
const negative: any[] = [];
filterStrings.forEach((f) => {
f = f.trim();
if (f.startsWith('!')) {
const regex = new RegExp(f.substring(1), 'i');
negative.push((s: any) => !regex.test(s));
} else {
const regex = new RegExp(f, 'i');
positive.push((s: any) => regex.test(s));
}
});
const filter = (item: TreeNode | undefined | null) => {
if (item) {
const apply = (f: any) => f(`${item.name}`);
const regex = new RegExp(filterString, 'i');
return (
(positive.length === 0 || positive.some(apply)) &&
(negative.length === 0 || negative.every(apply))
(filterString.length === 0 || regex.test(`${item.name}`))
);
}
return false;

View File

@@ -129,7 +129,7 @@ class ImeUtils {
return undefined;
}
const isTaskLayer = TreeUtils.makeNodeFilter('Task, ImePlaceholder');
const isTaskLayer = TreeUtils.makeNodeFilter('Task|ImePlaceholder');
const taskLayer = TreeUtils.findAncestorNode(imeLayer, isTaskLayer) as Layer;
if (!taskLayer) {
return undefined;