diff options
Diffstat (limited to 'tests/resolv_test_utils.cpp')
| -rw-r--r-- | tests/resolv_test_utils.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/resolv_test_utils.cpp b/tests/resolv_test_utils.cpp index 4b09b213..a1a9e4e6 100644 --- a/tests/resolv_test_utils.cpp +++ b/tests/resolv_test_utils.cpp @@ -21,6 +21,7 @@ #include <android-base/chrono_utils.h> #include <android-base/logging.h> +#include <firewall.h> using android::netdutils::ScopedAddrinfo; @@ -230,6 +231,18 @@ void RemoveMdnsRoute() { EXPECT_EQ(0, ForkAndRun(args_v6)); } +void AllowNetworkInBackground(int uid, bool allow) { + if (android::modules::sdklevel::IsAtLeastV()) { + // Background networking is always allowed on earlier versions. + Firewall* firewall = Firewall::getInstance(); + if (allow) { + firewall->addRule(uid, BACKGROUND_MATCH); + } else { + firewall->removeRule(uid, BACKGROUND_MATCH); + } + } +} + bool is64bitAbi() { return android::base::GetProperty("ro.product.cpu.abi", "").find("64") != std::string::npos; } |
