getBpfSupportLevel - check ro.product.kernel_has_ebpf first
This allows a launched on Android O device but now running
a 4.9-P+ kernel to declare itself as ebpf capable.
This will eliminate a whole class of waivers.
Test: atest
Bug: 151753987
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4c860991abc252919283d6c17a5ff70915d14dd7
diff --git a/libbpf_android/BpfUtils.cpp b/libbpf_android/BpfUtils.cpp
index cf10449..2b96f95 100644
--- a/libbpf_android/BpfUtils.cpp
+++ b/libbpf_android/BpfUtils.cpp
@@ -39,7 +39,6 @@
#include <log/log.h>
#include <processgroup/processgroup.h>
-using android::base::GetUintProperty;
using android::base::unique_fd;
// The buffer size for the buffer that records program loading logs, needs to be large enough for
@@ -138,10 +137,14 @@
if (kver >= KVER(4, 19, 0)) return BpfLevel::EXTENDED_4_19;
if (kver >= KVER(4, 14, 0)) return BpfLevel::EXTENDED_4_14;
- uint64_t api_level = GetUintProperty<uint64_t>("ro.product.first_api_level", 0);
+ // Override for devices launched with O but now on a 4.9-P+ kernel.
+ bool has_ebpf = base::GetBoolProperty("ro.product.kernel_has_ebpf", false);
+ if (has_ebpf) return BpfLevel::BASIC_4_9;
+
+ uint64_t api_level = base::GetUintProperty<uint64_t>("ro.product.first_api_level", 0);
if (api_level == 0) {
ALOGE("Cannot determine initial API level of the device");
- api_level = GetUintProperty<uint64_t>("ro.build.version.sdk", 0);
+ api_level = base::GetUintProperty<uint64_t>("ro.build.version.sdk", 0);
}
// Check if the device is shipped originally with android P.