Don't merge apex variations with different UsePlatformApis
Merging apex variations with different UsePlatformApis results in
the presence of an extra apex with UsePlatformApis false changing
the behavior of an existing apex -> module dependency with
UsePlatformApis true, which can't be supported with incremental
analysis. Don't merge apex variations with different UsePlatformApis
values, and add a _p suffix to the UsePlatformApis variation so they
can coexist.
Test: Test_mergeApexVariations
Bug: 372543712
Change-Id: I0e857a646a0449f87e4de6e6306ec921bc46fac1
diff --git a/android/apex.go b/android/apex.go
index 08c82eb..c2f73a9 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -105,6 +105,9 @@
// thus wouldn't be merged.
func (i ApexInfo) mergedName() string {
name := "apex" + strconv.Itoa(i.MinSdkVersion.FinalOrFutureInt())
+ if i.UsePlatformApis {
+ name += "_p"
+ }
return name
}
diff --git a/android/apex_test.go b/android/apex_test.go
index 78597b2..acc195d 100644
--- a/android/apex_test.go
+++ b/android/apex_test.go
@@ -193,7 +193,7 @@
},
},
{
- name: "merge different UsePlatformApis but don't allow using platform api",
+ name: "don't merge different UsePlatformApis",
in: []ApexInfo{
{
ApexVariationName: "foo",
@@ -213,13 +213,20 @@
{
ApexVariationName: "apex10000",
MinSdkVersion: FutureApiLevel,
- InApexVariants: []string{"foo", "bar"},
+ InApexVariants: []string{"foo"},
+ ForPrebuiltApex: NotForPrebuiltApex,
+ },
+ {
+ ApexVariationName: "apex10000_p",
+ MinSdkVersion: FutureApiLevel,
+ UsePlatformApis: true,
+ InApexVariants: []string{"bar"},
ForPrebuiltApex: NotForPrebuiltApex,
},
},
wantAliases: [][2]string{
{"foo", "apex10000"},
- {"bar", "apex10000"},
+ {"bar", "apex10000_p"},
},
},
{
@@ -242,7 +249,7 @@
},
wantMerged: []ApexInfo{
{
- ApexVariationName: "apex10000",
+ ApexVariationName: "apex10000_p",
MinSdkVersion: FutureApiLevel,
UsePlatformApis: true,
InApexVariants: []string{"foo", "bar"},
@@ -250,8 +257,8 @@
},
},
wantAliases: [][2]string{
- {"foo", "apex10000"},
- {"bar", "apex10000"},
+ {"foo", "apex10000_p"},
+ {"bar", "apex10000_p"},
},
},
}