Added in API level 33

ApiVersion

public abstract class ApiVersion
extends Object

java.lang.Object
   ↳ android.car.ApiVersion<T extends android.car.ApiVersion<?>>


Abstraction of Android APIs.

This class is used to represent a pair of major / minor API versions: the "major" version represents a "traditional" Android SDK release, while the "minor" is used to indicate incremental releases for that major.

This class is needed because the standard Android SDK API versioning only supports major releases, but Car APIs can now (starting on Android 13) be updated on minor releases as well.

Summary

Public methods

final int getMajorVersion()

Gets the major version of the API represented by this object.

final int getMinorVersion()

Gets the minor version change of API for the same getMajorVersion().

final boolean isAtLeast(T requiredVersion)

Checks if this API version meets the required version.

Inherited methods

Public methods

getMajorVersion

Added in API level 33
public final int getMajorVersion ()

Gets the major version of the API represented by this object.

Returns
int

getMinorVersion

Added in API level 33
public final int getMinorVersion ()

Gets the minor version change of API for the same getMajorVersion().

It will reset to 0 whenever getMajorVersion() is updated and will increase by 1 if car builtin or other car platform part is changed with the same getMajorVersion().

Client should check this version to use APIs which were added in a minor-only version update.

Returns
int

isAtLeast

Added in API level 33
public final boolean isAtLeast (T requiredVersion)

Checks if this API version meets the required version.

Parameters
requiredVersion T: required major and minor version number

Returns
boolean true if the major version is newer than the requiredVersion's major or if the major version is the same as requiredVersion's major with the minor version the same or newer than requiredVersion's minor

Throws
IllegalArgumentException if requiredVersion is not an instance of the same class as this object