Merge "Revert "Revert "Add min_sdk_version to java_import."""
This commit is contained in:
@@ -805,16 +805,29 @@ var minSdkVersionAllowlist = func(apiMap map[string]int) map[string]ApiLevel {
|
|||||||
}(map[string]int{
|
}(map[string]int{
|
||||||
"adbd": 30,
|
"adbd": 30,
|
||||||
"android.net.ipsec.ike": 30,
|
"android.net.ipsec.ike": 30,
|
||||||
|
"androidx.annotation_annotation-nodeps": 29,
|
||||||
|
"androidx.arch.core_core-common-nodeps": 29,
|
||||||
|
"androidx.collection_collection-nodeps": 29,
|
||||||
|
"androidx.collection_collection-ktx-nodeps": 30,
|
||||||
|
"androidx.concurrent_concurrent-futures-nodeps": 30,
|
||||||
|
"androidx.lifecycle_lifecycle-common-java8-nodeps": 30,
|
||||||
|
"androidx.lifecycle_lifecycle-common-nodeps": 29,
|
||||||
|
"androidx.room_room-common-nodeps": 30,
|
||||||
|
"androidx-constraintlayout_constraintlayout-solver-nodeps": 29,
|
||||||
"apache-commons-compress": 29,
|
"apache-commons-compress": 29,
|
||||||
"bouncycastle_ike_digests": 30,
|
"bouncycastle_ike_digests": 30,
|
||||||
"brotli-java": 29,
|
"brotli-java": 29,
|
||||||
"captiveportal-lib": 28,
|
"captiveportal-lib": 28,
|
||||||
|
"error_prone_annotations": 30,
|
||||||
"flatbuffer_headers": 30,
|
"flatbuffer_headers": 30,
|
||||||
"framework-permission": 30,
|
"framework-permission": 30,
|
||||||
"gemmlowp_headers": 30,
|
"gemmlowp_headers": 30,
|
||||||
|
"guava-listenablefuture-prebuilt-jar": 30,
|
||||||
"ike-internals": 30,
|
"ike-internals": 30,
|
||||||
"kotlinx-coroutines-android": 28,
|
"kotlinx-coroutines-android": 28,
|
||||||
|
"kotlinx-coroutines-android-nodeps": 30,
|
||||||
"kotlinx-coroutines-core": 28,
|
"kotlinx-coroutines-core": 28,
|
||||||
|
"kotlinx-coroutines-core-nodeps": 30,
|
||||||
"libadb_crypto": 30,
|
"libadb_crypto": 30,
|
||||||
"libadb_pairing_auth": 30,
|
"libadb_pairing_auth": 30,
|
||||||
"libadb_pairing_connection": 30,
|
"libadb_pairing_connection": 30,
|
||||||
|
@@ -1836,6 +1836,30 @@ func TestApexMinSdkVersion_ErrorIfIncompatibleVersion(t *testing.T) {
|
|||||||
min_sdk_version: "30",
|
min_sdk_version: "30",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
testApexError(t, `module "libfoo".*: should support min_sdk_version\(29\)`, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
java_libs: ["libfoo"],
|
||||||
|
min_sdk_version: "29",
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
java_import {
|
||||||
|
name: "libfoo",
|
||||||
|
jars: ["libfoo.jar"],
|
||||||
|
apex_available: [
|
||||||
|
"myapex",
|
||||||
|
],
|
||||||
|
min_sdk_version: "30",
|
||||||
|
}
|
||||||
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApexMinSdkVersion_Okay(t *testing.T) {
|
func TestApexMinSdkVersion_Okay(t *testing.T) {
|
||||||
@@ -1873,7 +1897,10 @@ func TestApexMinSdkVersion_Okay(t *testing.T) {
|
|||||||
name: "libbar",
|
name: "libbar",
|
||||||
sdk_version: "current",
|
sdk_version: "current",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
static_libs: ["libbar_dep"],
|
static_libs: [
|
||||||
|
"libbar_dep",
|
||||||
|
"libbar_import_dep",
|
||||||
|
],
|
||||||
apex_available: ["myapex"],
|
apex_available: ["myapex"],
|
||||||
min_sdk_version: "29",
|
min_sdk_version: "29",
|
||||||
}
|
}
|
||||||
@@ -1885,6 +1912,13 @@ func TestApexMinSdkVersion_Okay(t *testing.T) {
|
|||||||
apex_available: ["myapex"],
|
apex_available: ["myapex"],
|
||||||
min_sdk_version: "29",
|
min_sdk_version: "29",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
java_import {
|
||||||
|
name: "libbar_import_dep",
|
||||||
|
jars: ["libbar.jar"],
|
||||||
|
apex_available: ["myapex"],
|
||||||
|
min_sdk_version: "29",
|
||||||
|
}
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
java/java.go
24
java/java.go
@@ -1074,8 +1074,14 @@ func BinaryHostFactory() android.Module {
|
|||||||
type ImportProperties struct {
|
type ImportProperties struct {
|
||||||
Jars []string `android:"path,arch_variant"`
|
Jars []string `android:"path,arch_variant"`
|
||||||
|
|
||||||
|
// The version of the SDK that the source prebuilt file was built against. Defaults to the
|
||||||
|
// current version if not specified.
|
||||||
Sdk_version *string
|
Sdk_version *string
|
||||||
|
|
||||||
|
// The minimum version of the SDK that this module supports. Defaults to sdk_version if not
|
||||||
|
// specified.
|
||||||
|
Min_sdk_version *string
|
||||||
|
|
||||||
Installable *bool
|
Installable *bool
|
||||||
|
|
||||||
// List of shared java libs that this module has dependencies to
|
// List of shared java libs that this module has dependencies to
|
||||||
@@ -1139,6 +1145,9 @@ func (j *Import) systemModules() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *Import) minSdkVersion() sdkSpec {
|
func (j *Import) minSdkVersion() sdkSpec {
|
||||||
|
if j.properties.Min_sdk_version != nil {
|
||||||
|
return sdkSpecFrom(*j.properties.Min_sdk_version)
|
||||||
|
}
|
||||||
return j.sdkVersion()
|
return j.sdkVersion()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1350,7 +1359,20 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
|
|||||||
// Implements android.ApexModule
|
// Implements android.ApexModule
|
||||||
func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
|
||||||
sdkVersion android.ApiLevel) error {
|
sdkVersion android.ApiLevel) error {
|
||||||
// Do not check for prebuilts against the min_sdk_version of enclosing APEX
|
sdkSpec := j.minSdkVersion()
|
||||||
|
if !sdkSpec.specified() {
|
||||||
|
return fmt.Errorf("min_sdk_version is not specified")
|
||||||
|
}
|
||||||
|
if sdkSpec.kind == sdkCore {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ver, err := sdkSpec.effectiveVersion(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if ver.ApiLevel(ctx).GreaterThan(sdkVersion) {
|
||||||
|
return fmt.Errorf("newer SDK(%v)", ver)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user