From 7b95d99077562dd2f367fd89bfe8132e4f8e4659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Thu, 13 Jun 2024 18:18:11 -0700 Subject: [PATCH] NetBpfLoad: on aosp/main bump version from U QPR3 to V MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit aosp/main is currently still sdk 34/U, and netbpfload runs as root (like on U QPR3 and V) which makes us treat it as U QPR3. This change will make us treat it as 35/V. This will also potentially result in us already seeing sdk 36 in places (goog/main?), but this won't currently hurt (because we don't distinguish anything >=35). And indeed it likely won't ever hurt us, as too high a version on dev branches (goog/main?) is unlikely to be a practical problem. Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: I318df93e5b3a06af2ee2c6ab1cb40d8a8dffa212 --- netbpfload/NetBpfLoad.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/netbpfload/NetBpfLoad.cpp b/netbpfload/NetBpfLoad.cpp index e9f8e7c972..b9976e0297 100644 --- a/netbpfload/NetBpfLoad.cpp +++ b/netbpfload/NetBpfLoad.cpp @@ -255,7 +255,9 @@ static bool isTV() { static int doLoad(char** argv, char * const envp[]) { const bool runningAsRoot = !getuid(); // true iff U QPR3 or V+ - const int device_api_level = android_get_device_api_level(); + const bool unreleased = (base::GetProperty("ro.build.version.codename", "") != "REL"); + + const int device_api_level = android_get_device_api_level() + (int)unreleased; const bool isAtLeastT = (device_api_level >= __ANDROID_API_T__); const bool isAtLeastU = (device_api_level >= __ANDROID_API_U__); const bool isAtLeastV = (device_api_level >= __ANDROID_API_V__); @@ -272,8 +274,9 @@ static int doLoad(char** argv, char * const envp[]) { if (runningAsRoot) ++bpfloader_ver; // [45] BPFLOADER_MAINLINE_U_QPR3_VERSION if (isAtLeastV) ++bpfloader_ver; // [46] BPFLOADER_MAINLINE_V_VERSION - ALOGI("NetBpfLoad v0.%u (%s) api:%d kver:%07x (%s) uid:%d rc:%d%d", - bpfloader_ver, argv[0], device_api_level, kernelVersion(), describeArch(), getuid(), + ALOGI("NetBpfLoad v0.%u (%s) api:%d/%d kver:%07x (%s) uid:%d rc:%d%d", + bpfloader_ver, argv[0], android_get_device_api_level(), device_api_level, + kernelVersion(), describeArch(), getuid(), has_platform_bpfloader_rc, has_platform_netbpfload_rc); if (!has_platform_bpfloader_rc && !has_platform_netbpfload_rc) {