From 50ec605b916591a7c86c3e88f84ae03f1582e793 Mon Sep 17 00:00:00 2001 From: FriendlyNeighborhoodShane Date: Wed, 2 Feb 2022 20:14:27 +0530 Subject: [PATCH] npem: fix permissions not being granted I messed up with the last fix. While that solved the case where there were both 'granted=true' and 'granted=false' entries, it introduced a regression. It was written with the assumption that whenever a permission is not granted, there will be 'granted=false' entries. That assumption was not tested well at the time, and further testing has revealed that there are also many situations where there are no 'granted=' entries for permissions at all, not even 'false'. Since there is no defined spec for the output of dumpsys, we just do a pessimistic case-by-case parsing of its output. --- Full/system/bin/nanodroid-perm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Full/system/bin/nanodroid-perm b/Full/system/bin/nanodroid-perm index 47abcaa3..19be7065 100755 --- a/Full/system/bin/nanodroid-perm +++ b/Full/system/bin/nanodroid-perm @@ -38,7 +38,10 @@ check_package () { } check_permission () { - [[ $(dumpsys package ${1} | grep -Eo "^[ ]+${2}: granted=false") ]] && return 1 || return 0 + perm="$(dumpsys package ${1} | grep "^ *${2}: granted=")" + echo "$perm" | grep -q "granted=false" && return 1 + echo "$perm" | grep -q "granted=true" && return 0 + return 1 } grant_permission () {