From 9c0e18975c2689e2899b3c0f2af963817387c1ac Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 6 Apr 2021 03:56:39 -0700 Subject: [PATCH] Fallback to getprop when reading system props Close #4153 --- scripts/util_functions.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/util_functions.sh b/scripts/util_functions.sh index be3f84523..6eabf2009 100644 --- a/scripts/util_functions.sh +++ b/scripts/util_functions.sh @@ -33,6 +33,16 @@ grep_prop() { cat $FILES 2>/dev/null | dos2unix | sed -n "$REGEX" | head -n 1 } +grep_get_prop() { + local result=$(grep_prop $@) + if [ -z "$result" ]; then + # Fallback to getprop + getprop "$1" + else + echo $result + fi +} + getvar() { local VARNAME=$1 local VALUE @@ -508,10 +518,10 @@ remove_system_su() { } api_level_arch_detect() { - API=`grep_prop ro.build.version.sdk` - ABI=`grep_prop ro.product.cpu.abi | cut -c-3` - ABI2=`grep_prop ro.product.cpu.abi2 | cut -c-3` - ABILONG=`grep_prop ro.product.cpu.abi` + API=$(grep_get_prop ro.build.version.sdk) + ABI=$(grep_get_prop ro.product.cpu.abi | cut -c-3) + ABI2=$(grep_get_prop ro.product.cpu.abi2 | cut -c-3) + ABILONG=$(grep_get_prop ro.product.cpu.abi) ARCH=arm ARCH32=arm