Loading android/allowlists/allowlists.go +4 −0 Original line number Diff line number Diff line Loading @@ -710,6 +710,10 @@ var ( // for building com.android.neuralnetworks "libimapper_stablec", "libimapper_providerutils", // min_sdk_version in android_app "CtsShimUpgrade", "fake-framework", } Bp2buildModuleTypeAlwaysConvertList = []string{ Loading bp2build/android_app_conversion_test.go +47 −0 Original line number Diff line number Diff line Loading @@ -344,3 +344,50 @@ android_app { }), }}) } func TestAndroidAppMinSdkProvided(t *testing.T) { runAndroidAppTestCase(t, Bp2buildTestCase{ Description: "Android app with value for min_sdk_version", ModuleTypeUnderTest: "android_app", ModuleTypeUnderTestFactory: java.AndroidAppFactory, Filesystem: map[string]string{}, Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + ` android_app { name: "foo", sdk_version: "current", min_sdk_version: "24", } `, ExpectedBazelTargets: []string{ MakeBazelTarget("android_binary", "foo", AttrNameToString{ "manifest": `"AndroidManifest.xml"`, "resource_files": `[]`, "manifest_values": `{ "minSdkVersion": "24", }`, }), }}) } func TestAndroidAppMinSdkDefaultToSdkVersion(t *testing.T) { runAndroidAppTestCase(t, Bp2buildTestCase{ Description: "Android app with value for sdk_version", ModuleTypeUnderTest: "android_app", ModuleTypeUnderTestFactory: java.AndroidAppFactory, Filesystem: map[string]string{}, Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + ` android_app { name: "foo", sdk_version: "30", } `, ExpectedBazelTargets: []string{ MakeBazelTarget("android_binary", "foo", AttrNameToString{ "manifest": `"AndroidManifest.xml"`, "resource_files": `[]`, "manifest_values": `{ "minSdkVersion": "30", }`, }), }}) } java/app.go +16 −0 Original line number Diff line number Diff line Loading @@ -1495,6 +1495,10 @@ func androidAppCertificateBp2Build(ctx android.TopDownMutatorContext, module *An ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs) } type manifestValueAttribute struct { MinSdkVersion *string } type bazelAndroidAppAttributes struct { *javaCommonAttributes *bazelAapt Loading @@ -1502,6 +1506,7 @@ type bazelAndroidAppAttributes struct { Custom_package *string Certificate bazel.LabelAttribute Certificate_name bazel.StringAttribute Manifest_values *manifestValueAttribute } // ConvertWithBp2build is used to convert android_app to Bazel. Loading @@ -1516,11 +1521,22 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) { certificate, certificateName := android.BazelStringOrLabelFromProp(ctx, a.overridableAppProperties.Certificate) manifestValues := &manifestValueAttribute{} // MinSdkVersion(ctx) calls SdkVersion(ctx) if no value for min_sdk_version is set minSdkSpec := a.MinSdkVersion(ctx) if !minSdkSpec.ApiLevel.IsPreview() && minSdkSpec.Valid() { minSdkStr, err := minSdkSpec.EffectiveVersionString(ctx) if err == nil { manifestValues.MinSdkVersion = &minSdkStr } } appAttrs := &bazelAndroidAppAttributes{ // TODO(b/209576404): handle package name override by product variable PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES Custom_package: a.overridableAppProperties.Package_name, Certificate: certificate, Certificate_name: certificateName, Manifest_values: manifestValues, } props := bazel.BazelTargetModuleProperties{ Loading Loading
android/allowlists/allowlists.go +4 −0 Original line number Diff line number Diff line Loading @@ -710,6 +710,10 @@ var ( // for building com.android.neuralnetworks "libimapper_stablec", "libimapper_providerutils", // min_sdk_version in android_app "CtsShimUpgrade", "fake-framework", } Bp2buildModuleTypeAlwaysConvertList = []string{ Loading
bp2build/android_app_conversion_test.go +47 −0 Original line number Diff line number Diff line Loading @@ -344,3 +344,50 @@ android_app { }), }}) } func TestAndroidAppMinSdkProvided(t *testing.T) { runAndroidAppTestCase(t, Bp2buildTestCase{ Description: "Android app with value for min_sdk_version", ModuleTypeUnderTest: "android_app", ModuleTypeUnderTestFactory: java.AndroidAppFactory, Filesystem: map[string]string{}, Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + ` android_app { name: "foo", sdk_version: "current", min_sdk_version: "24", } `, ExpectedBazelTargets: []string{ MakeBazelTarget("android_binary", "foo", AttrNameToString{ "manifest": `"AndroidManifest.xml"`, "resource_files": `[]`, "manifest_values": `{ "minSdkVersion": "24", }`, }), }}) } func TestAndroidAppMinSdkDefaultToSdkVersion(t *testing.T) { runAndroidAppTestCase(t, Bp2buildTestCase{ Description: "Android app with value for sdk_version", ModuleTypeUnderTest: "android_app", ModuleTypeUnderTestFactory: java.AndroidAppFactory, Filesystem: map[string]string{}, Blueprint: simpleModuleDoNotConvertBp2build("filegroup", "foocert") + ` android_app { name: "foo", sdk_version: "30", } `, ExpectedBazelTargets: []string{ MakeBazelTarget("android_binary", "foo", AttrNameToString{ "manifest": `"AndroidManifest.xml"`, "resource_files": `[]`, "manifest_values": `{ "minSdkVersion": "30", }`, }), }}) }
java/app.go +16 −0 Original line number Diff line number Diff line Loading @@ -1495,6 +1495,10 @@ func androidAppCertificateBp2Build(ctx android.TopDownMutatorContext, module *An ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs) } type manifestValueAttribute struct { MinSdkVersion *string } type bazelAndroidAppAttributes struct { *javaCommonAttributes *bazelAapt Loading @@ -1502,6 +1506,7 @@ type bazelAndroidAppAttributes struct { Custom_package *string Certificate bazel.LabelAttribute Certificate_name bazel.StringAttribute Manifest_values *manifestValueAttribute } // ConvertWithBp2build is used to convert android_app to Bazel. Loading @@ -1516,11 +1521,22 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) { certificate, certificateName := android.BazelStringOrLabelFromProp(ctx, a.overridableAppProperties.Certificate) manifestValues := &manifestValueAttribute{} // MinSdkVersion(ctx) calls SdkVersion(ctx) if no value for min_sdk_version is set minSdkSpec := a.MinSdkVersion(ctx) if !minSdkSpec.ApiLevel.IsPreview() && minSdkSpec.Valid() { minSdkStr, err := minSdkSpec.EffectiveVersionString(ctx) if err == nil { manifestValues.MinSdkVersion = &minSdkStr } } appAttrs := &bazelAndroidAppAttributes{ // TODO(b/209576404): handle package name override by product variable PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES Custom_package: a.overridableAppProperties.Package_name, Certificate: certificate, Certificate_name: certificateName, Manifest_values: manifestValues, } props := bazel.BazelTargetModuleProperties{ Loading