apex/apk: enforce min_sdk_version of all deps
Enforce min_sdk_version for every payload dependency of updatable APEX/APKs. android.CheckMinSdkVersion() calls ApexModule.ShouldSupportSdkVersion for every transitive dependency from APEX/APK modules to see if it meets the min_sdk_version requirements. The common implementation for apex/android_app is provided in android/apex.go. Bug: 145796956 Bug: 152655956 Bug: 153333044 Test: m nothing Change-Id: I4a947dc94026df7cebd552b6e8ccdb4cc1f67170
This commit is contained in:
28
java/java.go
28
java/java.go
@@ -1887,6 +1887,24 @@ func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
|
||||
return j.depIsInSameApex(ctx, dep)
|
||||
}
|
||||
|
||||
func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error {
|
||||
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 int(ver) > sdkVersion {
|
||||
return fmt.Errorf("newer SDK(%v)", ver)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (j *Module) Stem() string {
|
||||
return proptools.StringDefault(j.deviceProperties.Stem, j.Name())
|
||||
}
|
||||
@@ -2651,6 +2669,11 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
|
||||
return j.depIsInSameApex(ctx, dep)
|
||||
}
|
||||
|
||||
func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error {
|
||||
// Do not check for prebuilts against the min_sdk_version of enclosing APEX
|
||||
return nil
|
||||
}
|
||||
|
||||
// Add compile time check for interface implementation
|
||||
var _ android.IDEInfo = (*Import)(nil)
|
||||
var _ android.IDECustomizedModuleName = (*Import)(nil)
|
||||
@@ -2820,6 +2843,11 @@ func (j *DexImport) DexJarBuildPath() android.Path {
|
||||
return j.dexJarFile
|
||||
}
|
||||
|
||||
func (j *DexImport) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error {
|
||||
// we don't check prebuilt modules for sdk_version
|
||||
return nil
|
||||
}
|
||||
|
||||
// dex_import imports a `.jar` file containing classes.dex files.
|
||||
//
|
||||
// A dex_import module cannot be used as a dependency of a java_* or android_* module, it can only be installed
|
||||
|
Reference in New Issue
Block a user