From 57007c76018b49799fa86cc64ae4faffdb500b91 Mon Sep 17 00:00:00 2001 From: satayev Date: Mon, 31 Jan 2022 20:30:12 +0000 Subject: [PATCH] Introduce Build.VERSION.KNOWN_CODENAMES. See go/mainline-sdk-codenames-issue. Known values are to be used to distinguish multiple pre-release codenames, and to allow in development artifacts to be installable on released versions of the platform for testing going forward. This does not change pre-T behaviour at large however. Cherry-pick aosp change into sc-mainline-prod to allow utility code to compile. Given that all modules compile from source this should be safe short-term, before we switch away from sc-mainline-prod. Bug: 211747008 Test: presubmit Change-Id: I0c8df8e767ea61b27bb53da53fb6c9b2c842dbbc Merged-In: I0c8df8e767ea61b27bb53da53fb6c9b2c842dbbc --- core/api/system-current.txt | 1 + core/java/android/os/Build.java | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 2d73aa67ed1a2..c148836fd6e14 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -8126,6 +8126,7 @@ package android.os { } public static class Build.VERSION { + field @NonNull public static final java.util.Set KNOWN_CODENAMES; field @NonNull public static final String PREVIEW_SDK_FINGERPRINT; } diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 6bf394dc347b5..77e7df240b76c 100755 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -31,6 +31,7 @@ import android.sysprop.DeviceProperties; import android.sysprop.SocProperties; import android.sysprop.TelephonyProperties; import android.text.TextUtils; +import android.util.ArraySet; import android.util.Slog; import android.view.View; @@ -39,6 +40,7 @@ import dalvik.system.VMRuntime; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; /** @@ -396,6 +398,17 @@ public class Build { */ public static final String CODENAME = getString("ro.build.version.codename"); + /** + * All known codenames starting from {@link VERSION_CODES.Q}. + * + *

This includes in development codenames as well. + * + * @hide + */ + @SystemApi + @NonNull public static final Set KNOWN_CODENAMES = + new ArraySet<>(new String[]{"Q", "R", "S", "Sv2", "Tiramisu"}); + private static final String[] ALL_CODENAMES = getStringList("ro.build.version.all_codenames", ",");