Check supported kernel version in V and 25Q2+

V requires 4.19+ and 25Q2+ requires 5.4+

(while 25Q4 will presumably further bump to 5.10+)

On aosp/main we currently have:
  ro.build.version.sdk=35
    - which is returned by android_get_device_api_level()
  ro.build.version.codename=Baklava
    - which is looked at by IsAtLeastPreReleaseCodename/GetCodename

This is because we're already past the aosp/main automerge into 25Q1 cutoff.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I909d63406151fbafc15fa248133b9d1a5dc37bdb
This commit is contained in:
Maciej Żenczykowski 2025-01-13 12:18:47 -08:00
commit 1758f413a2

View file

@ -70,6 +70,13 @@ static Status checkProgramAccessible(const char* programPath) {
return netdutils::status::ok;
}
// Checks if the device is running on release version of Android 25Q2 or newer.
static bool isAtLeast25Q2() {
return android_get_device_api_level() >= 36 ||
(android_get_device_api_level() == 35 &&
modules::sdklevel::detail::IsAtLeastPreReleaseCodename("Baklava"));
}
static Status initPrograms(const char* cg2_path) {
if (!cg2_path) return Status("cg2_path is NULL");
@ -91,6 +98,16 @@ static Status initPrograms(const char* cg2_path) {
return Status("U+ platform with cg2_path != /sys/fs/cgroup is unsupported");
}
// V bumps the kernel requirement up to 4.19
if (modules::sdklevel::IsAtLeastV() && !bpf::isAtLeastKernelVersion(4, 19, 0)) {
return Status("V+ platform with kernel version < 4.19.0 is unsupported");
}
// 25Q2 bumps the kernel requirement up to 5.4
if (isAtLeast25Q2() && !bpf::isAtLeastKernelVersion(5, 4, 0)) {
return Status("25Q2+ platform with kernel version < 5.4.0 is unsupported");
}
unique_fd cg_fd(open(cg2_path, O_DIRECTORY | O_RDONLY | O_CLOEXEC));
if (!cg_fd.ok()) {
const int err = errno;