From ebdd6ec40cf67365d1c05eaaee13afe477bec511 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Mon, 3 Feb 2020 12:58:59 +0800 Subject: [PATCH] Fallback to getprop to get SDK_INT Close #2274, close #2279 --- native/jni/core/daemon.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/native/jni/core/daemon.cpp b/native/jni/core/daemon.cpp index c772b3a8a..9897f0b71 100644 --- a/native/jni/core/daemon.cpp +++ b/native/jni/core/daemon.cpp @@ -138,6 +138,14 @@ static void main_daemon() { } return true; }); + if (SDK_INT < 0) { + // In case some devices do not store this info in build.prop, fallback to getprop + auto sdk = getprop("ro.build.version.sdk"); + if (!sdk.empty()) { + LOGI("* Device API level: %s\n", sdk.data()); + SDK_INT = parse_int(sdk); + } + } // Load config status parse_prop_file(MAGISKTMP "/config", [](auto key, auto val) -> bool {