Merge "Make net-utils-device-common-bpf only available for module and tests"
diff --git a/staticlibs/Android.bp b/staticlibs/Android.bp
index 1d0f49b..2fc4142 100644
--- a/staticlibs/Android.bp
+++ b/staticlibs/Android.bp
@@ -259,24 +259,15 @@
],
lint: { strict_updatability_linting: true },
}
-filegroup {
- name: "net-utils-services-common-srcs",
+
+java_library {
+ name: "net-utils-services-common",
srcs: [
"device/android/net/NetworkFactory.java",
"device/android/net/NetworkFactoryImpl.java",
"device/android/net/NetworkFactoryLegacyImpl.java",
"device/android/net/NetworkFactoryShim.java",
],
- visibility: [
- "//frameworks/base/services/net",
- ],
-}
-
-java_library {
- name: "net-utils-services-common",
- srcs: [
- ":net-utils-services-common-srcs",
- ],
sdk_version: "module_current",
min_sdk_version: "30",
static_libs: [
@@ -291,6 +282,7 @@
"//apex_available:platform",
"com.android.bluetooth",
"com.android.tethering",
+ "com.android.wifi",
],
visibility: [
// TODO: remove after NetworkStatsService moves to the module.
diff --git a/staticlibs/native/bpf_headers/include/bpf/BpfUtils.h b/staticlibs/native/bpf_headers/include/bpf/BpfUtils.h
index 3f06896..4429164 100644
--- a/staticlibs/native/bpf_headers/include/bpf/BpfUtils.h
+++ b/staticlibs/native/bpf_headers/include/bpf/BpfUtils.h
@@ -97,17 +97,12 @@
static inline unsigned uncachedKernelVersion() {
struct utsname buf;
- int ret = uname(&buf);
- if (ret) return 0;
+ if (uname(&buf)) return 0;
- unsigned kver_major;
- unsigned kver_minor;
- unsigned kver_sub;
- char unused;
- ret = sscanf(buf.release, "%u.%u.%u%c", &kver_major, &kver_minor, &kver_sub, &unused);
- // Check the device kernel version
- if (ret < 3) return 0;
-
+ unsigned kver_major = 0;
+ unsigned kver_minor = 0;
+ unsigned kver_sub = 0;
+ (void)sscanf(buf.release, "%u.%u.%u", &kver_major, &kver_minor, &kver_sub);
return KVER(kver_major, kver_minor, kver_sub);
}
diff --git a/staticlibs/native/tcutils/kernelversion.h b/staticlibs/native/tcutils/kernelversion.h
index 492444a..9aab31d 100644
--- a/staticlibs/native/tcutils/kernelversion.h
+++ b/staticlibs/native/tcutils/kernelversion.h
@@ -34,20 +34,12 @@
static inline unsigned uncachedKernelVersion() {
struct utsname buf;
- int ret = uname(&buf);
- if (ret)
- return 0;
+ if (uname(&buf)) return 0;
- unsigned kver_major;
- unsigned kver_minor;
- unsigned kver_sub;
- char discard;
- ret = sscanf(buf.release, "%u.%u.%u%c", &kver_major, &kver_minor, &kver_sub,
- &discard);
- // Check the device kernel version
- if (ret < 3)
- return 0;
-
+ unsigned kver_major = 0;
+ unsigned kver_minor = 0;
+ unsigned kver_sub = 0;
+ (void)sscanf(buf.release, "%u.%u.%u", &kver_major, &kver_minor, &kver_sub);
return KVER(kver_major, kver_minor, kver_sub);
}