diff options
| author | 2024-10-13 14:48:04 +0000 | |
|---|---|---|
| committer | 2024-10-13 14:48:04 +0000 | |
| commit | ffda9a50c92dea3fa7f0435e2b3d1c5313a6fb30 (patch) | |
| tree | 0968c5c3af3478c95d04dd573f45b45a8b6b14a2 | |
| parent | 31782750629f6b91e248a0ab4a953145a16d2aca (diff) | |
| parent | 2f3e1cc54dfdd0e21eb89758051d98fc5b0e0a2a (diff) | |
Merge "Add methods to deconstruct SDK_INT_FULL" into main
| -rw-r--r-- | core/api/current.txt | 2 | ||||
| -rw-r--r-- | core/java/android/os/Build.java | 31 |
2 files changed, 33 insertions, 0 deletions
diff --git a/core/api/current.txt b/core/api/current.txt index ebc534f6e391..75c9d7108b08 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -32782,6 +32782,8 @@ package android.os { public class Build { ctor public Build(); method @NonNull public static java.util.List<android.os.Build.Partition> getFingerprintedPartitions(); + method @FlaggedApi("android.sdk.major_minor_versioning_scheme") public static int getMajorSdkVersion(int); + method @FlaggedApi("android.sdk.major_minor_versioning_scheme") public static int getMinorSdkVersion(int); method public static String getRadioVersion(); method @RequiresPermission("android.permission.READ_PRIVILEGED_PHONE_STATE") public static String getSerial(); field public static final String BOARD; diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java index 479aa98f80de..d3ba73ed1421 100644 --- a/core/java/android/os/Build.java +++ b/core/java/android/os/Build.java @@ -18,6 +18,7 @@ package android.os; import android.Manifest; import android.annotation.FlaggedApi; +import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; @@ -43,6 +44,8 @@ import com.android.internal.ravenwood.RavenwoodEnvironment; import dalvik.system.VMRuntime; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -1273,6 +1276,12 @@ public class Build { public static final int VANILLA_ICE_CREAM = 35; } + /** @hide */ + @IntDef(value = { + }) + @Retention(RetentionPolicy.SOURCE) + public @interface SdkIntFull {} + /** * Enumeration of the currently known SDK major and minor version codes. * The numbers increase for every release, and are guaranteed to be ordered @@ -1293,6 +1302,28 @@ public class Build { } /** + * Obtain the major version encoded in a VERSION_CODES_FULL value. + * This value is guaranteed to be non-negative. + * + * @return The major version encoded in a VERSION_CODES_FULL value + */ + @FlaggedApi(Flags.FLAG_MAJOR_MINOR_VERSIONING_SCHEME) + public static int getMajorSdkVersion(@SdkIntFull int sdkIntFull) { + return sdkIntFull / VERSION_CODES_FULL.SDK_INT_MULTIPLIER; + } + + /** + * Obtain the minor version encoded in a VERSION_CODES_FULL value. + * This value is guaranteed to be non-negative. + * + * @return The minor version encoded in a VERSION_CODES_FULL value + */ + @FlaggedApi(Flags.FLAG_MAJOR_MINOR_VERSIONING_SCHEME) + public static int getMinorSdkVersion(@SdkIntFull int sdkIntFull) { + return sdkIntFull % VERSION_CODES_FULL.SDK_INT_MULTIPLIER; + } + + /** * The vendor API for 2024 Q2 * * <p>For Android 14-QPR3 and later, the vendor API level is completely decoupled from the SDK |