Revert "Create two sentinel api levels"
Revert submission 2457063 Reason for revert: Broken udc-dev Reverted changes: /q/submissionid:2457063 Change-Id: Ide8e1b23d5a575c57be44ebd801846dc5caf2e83
This commit is contained in:
@@ -55,9 +55,6 @@ type ApiLevel struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this ApiLevel) FinalInt() int {
|
func (this ApiLevel) FinalInt() int {
|
||||||
if this.IsInvalid() {
|
|
||||||
panic(fmt.Errorf("%v is not a recognized api_level\n", this))
|
|
||||||
}
|
|
||||||
if this.IsPreview() {
|
if this.IsPreview() {
|
||||||
panic("Requested a final int from a non-final ApiLevel")
|
panic("Requested a final int from a non-final ApiLevel")
|
||||||
} else {
|
} else {
|
||||||
@@ -66,9 +63,6 @@ func (this ApiLevel) FinalInt() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this ApiLevel) FinalOrFutureInt() int {
|
func (this ApiLevel) FinalOrFutureInt() int {
|
||||||
if this.IsInvalid() {
|
|
||||||
panic(fmt.Errorf("%v is not a recognized api_level\n", this))
|
|
||||||
}
|
|
||||||
if this.IsPreview() {
|
if this.IsPreview() {
|
||||||
return FutureApiLevelInt
|
return FutureApiLevelInt
|
||||||
} else {
|
} else {
|
||||||
@@ -82,9 +76,6 @@ func (this ApiLevel) FinalOrFutureInt() int {
|
|||||||
// - preview codenames -> preview base (9000) + index
|
// - preview codenames -> preview base (9000) + index
|
||||||
// - otherwise -> cast to int
|
// - otherwise -> cast to int
|
||||||
func (this ApiLevel) FinalOrPreviewInt() int {
|
func (this ApiLevel) FinalOrPreviewInt() int {
|
||||||
if this.IsInvalid() {
|
|
||||||
panic(fmt.Errorf("%v is not a recognized api_level\n", this))
|
|
||||||
}
|
|
||||||
if this.IsCurrent() {
|
if this.IsCurrent() {
|
||||||
return this.number
|
return this.number
|
||||||
}
|
}
|
||||||
@@ -106,11 +97,6 @@ func (this ApiLevel) IsPreview() bool {
|
|||||||
return this.isPreview
|
return this.isPreview
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the raw api level string is invalid
|
|
||||||
func (this ApiLevel) IsInvalid() bool {
|
|
||||||
return this.EqualTo(InvalidApiLevel)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if this is the unfinalized "current" API level. This means
|
// Returns true if this is the unfinalized "current" API level. This means
|
||||||
// different things across Java and native. Java APIs do not use explicit
|
// different things across Java and native. Java APIs do not use explicit
|
||||||
// codenames, so all non-final codenames are grouped into "current". For native
|
// codenames, so all non-final codenames are grouped into "current". For native
|
||||||
@@ -127,12 +113,6 @@ func (this ApiLevel) IsNone() bool {
|
|||||||
return this.number == -1
|
return this.number == -1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if an app is compiling against private apis.
|
|
||||||
// e.g. if sdk_version = "" in Android.bp, then the ApiLevel of that "sdk" is at PrivateApiLevel.
|
|
||||||
func (this ApiLevel) IsPrivate() bool {
|
|
||||||
return this.number == PrivateApiLevel.number
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns -1 if the current API level is less than the argument, 0 if they
|
// Returns -1 if the current API level is less than the argument, 0 if they
|
||||||
// are equal, and 1 if it is greater than the argument.
|
// are equal, and 1 if it is greater than the argument.
|
||||||
func (this ApiLevel) CompareTo(other ApiLevel) int {
|
func (this ApiLevel) CompareTo(other ApiLevel) int {
|
||||||
@@ -186,19 +166,6 @@ var NoneApiLevel = ApiLevel{
|
|||||||
isPreview: true,
|
isPreview: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sentinel ApiLevel to validate that an apiLevel is either an int or a recognized codename.
|
|
||||||
var InvalidApiLevel = NewInvalidApiLevel("invalid")
|
|
||||||
|
|
||||||
// Returns an apiLevel object at the same level as InvalidApiLevel.
|
|
||||||
// The object contains the raw string provied in bp file, and can be used for error handling.
|
|
||||||
func NewInvalidApiLevel(raw string) ApiLevel {
|
|
||||||
return ApiLevel{
|
|
||||||
value: raw,
|
|
||||||
number: -2, // One less than NoneApiLevel
|
|
||||||
isPreview: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The first version that introduced 64-bit ABIs.
|
// The first version that introduced 64-bit ABIs.
|
||||||
var FirstLp64Version = uncheckedFinalApiLevel(21)
|
var FirstLp64Version = uncheckedFinalApiLevel(21)
|
||||||
|
|
||||||
|
@@ -52,15 +52,6 @@ var StringDefault = proptools.StringDefault
|
|||||||
// FutureApiLevelInt is a placeholder constant for unreleased API levels.
|
// FutureApiLevelInt is a placeholder constant for unreleased API levels.
|
||||||
const FutureApiLevelInt = 10000
|
const FutureApiLevelInt = 10000
|
||||||
|
|
||||||
// PrivateApiLevel represents the api level of SdkSpecPrivate (sdk_version: "")
|
|
||||||
// This api_level exists to differentiate user-provided "" from "current" sdk_version
|
|
||||||
// The differentiation is necessary to enable different validation rules for these two possible values.
|
|
||||||
var PrivateApiLevel = ApiLevel{
|
|
||||||
value: "current", // The value is current since aidl expects `current` as the default (TestAidlFlagsWithMinSdkVersion)
|
|
||||||
number: FutureApiLevelInt + 1, // This is used to differentiate it from FutureApiLevel
|
|
||||||
isPreview: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
// FutureApiLevel represents unreleased API levels.
|
// FutureApiLevel represents unreleased API levels.
|
||||||
var FutureApiLevel = ApiLevel{
|
var FutureApiLevel = ApiLevel{
|
||||||
value: "current",
|
value: "current",
|
||||||
|
@@ -238,7 +238,7 @@ func (s SdkSpec) EffectiveVersionString(ctx EarlyModuleContext) (string, error)
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
SdkSpecNone = SdkSpec{SdkNone, NoneApiLevel, "(no version)"}
|
SdkSpecNone = SdkSpec{SdkNone, NoneApiLevel, "(no version)"}
|
||||||
SdkSpecPrivate = SdkSpec{SdkPrivate, PrivateApiLevel, ""}
|
SdkSpecPrivate = SdkSpec{SdkPrivate, FutureApiLevel, ""}
|
||||||
SdkSpecCorePlatform = SdkSpec{SdkCorePlatform, FutureApiLevel, "core_platform"}
|
SdkSpecCorePlatform = SdkSpec{SdkCorePlatform, FutureApiLevel, "core_platform"}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ func SdkSpecFromWithConfig(config Config, str string) SdkSpec {
|
|||||||
|
|
||||||
var kindString string
|
var kindString string
|
||||||
if sep == 0 {
|
if sep == 0 {
|
||||||
return SdkSpec{SdkInvalid, NewInvalidApiLevel(str), str}
|
return SdkSpec{SdkInvalid, NoneApiLevel, str}
|
||||||
} else if sep == -1 {
|
} else if sep == -1 {
|
||||||
kindString = ""
|
kindString = ""
|
||||||
} else {
|
} else {
|
||||||
@@ -289,7 +289,7 @@ func SdkSpecFromWithConfig(config Config, str string) SdkSpec {
|
|||||||
|
|
||||||
apiLevel, err := ApiLevelFromUserWithConfig(config, versionString)
|
apiLevel, err := ApiLevelFromUserWithConfig(config, versionString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return SdkSpec{SdkInvalid, NewInvalidApiLevel(versionString), str}
|
return SdkSpec{SdkInvalid, apiLevel, str}
|
||||||
}
|
}
|
||||||
return SdkSpec{kind, apiLevel, str}
|
return SdkSpec{kind, apiLevel, str}
|
||||||
}
|
}
|
||||||
|
@@ -37,11 +37,11 @@ func TestSdkSpecFrom(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: "_",
|
input: "_",
|
||||||
expected: "invalid__",
|
expected: "invalid_(no version)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: "_31",
|
input: "_31",
|
||||||
expected: "invalid__31",
|
expected: "invalid_(no version)",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
input: "system_R",
|
input: "system_R",
|
||||||
|
Reference in New Issue
Block a user