Check for first api level before turn on eBPF

The api check will ensure the device is running 4.9 or above kernel and
is shipped originally with P release. Also add some test to make sure
eligible devices always have eBPF turned on.

Test: ./netd_integration_test
Bug: 79408692
Change-Id: Ief56a95aab892c92276a5b4ac74b03f9f32f5b54
diff --git a/tests/binder_test.cpp b/tests/binder_test.cpp
index a099620..f339ced 100644
--- a/tests/binder_test.cpp
+++ b/tests/binder_test.cpp
@@ -37,6 +37,7 @@
 #include <android-base/macros.h>
 #include <android-base/stringprintf.h>
 #include <android-base/strings.h>
+#include <bpf/BpfUtils.h>
 #include <cutils/multiuser.h>
 #include <gtest/gtest.h>
 #include <logwrap/logwrap.h>
@@ -61,6 +62,7 @@
 using namespace android::base;
 using namespace android::binder;
 using android::base::StartsWith;
+using android::bpf::hasBpfSupport;
 using android::net::INetd;
 using android::net::TunInterface;
 using android::net::UidRange;
@@ -68,6 +70,11 @@
 using android::netdutils::sSyscalls;
 using android::os::PersistableBundle;
 
+#define SKIP_IF_BPF_SUPPORTED         \
+    do {                              \
+        if (hasBpfSupport()) return;  \
+    } while (0);
+
 static const char* IP_RULE_V4 = "-4";
 static const char* IP_RULE_V6 = "-6";
 static const int TEST_NETID1 = 65501;
@@ -200,6 +207,8 @@
 }
 
 TEST_F(BinderTest, TestFirewallReplaceUidChain) {
+    SKIP_IF_BPF_SUPPORTED;
+
     std::string chainName = StringPrintf("netd_binder_test_%u", arc4random_uniform(10000));
     const int kNumUids = 500;
     std::vector<int32_t> noUids(0);