Add option to override defaultManifestVersion for app.

Add an option to override defaultManifestVersion using environment
variable. With this environment variable, the mainline developer will be able to locally customize the app version to higher version and install it to target devices. This is also helpful as a workaround to adjust app/apex version for coverage build (e.g. 3520 to 3500) and allow the installation of app/apex from mainline release branch (e.g. 3508) onto it. This functionality already existed for apex, so we are extending to the app.

Test: 347735412
Bug: 350986287
Bug: 347735412
Test: OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION=990090000 m
Test: adb shell pm list packages --show-versioncode
Change-Id: I58259fe781ca121ba4067f308f1744d80c1c2d48
This commit is contained in:
Alyssa Ketpreechasawat
2024-07-04 10:45:04 +00:00
parent 2f9af23734
commit ee8b44e72a
2 changed files with 89 additions and 1 deletions

View File

@@ -519,6 +519,49 @@ func TestUpdatableApps_ErrorIfDepMinSdkVersionIsHigher(t *testing.T) {
testJavaError(t, `"libjni" .*: links "libbar" built against newer API version "current"`, bp)
}
func TestUpdatableApps_ApplyDefaultUpdatableModuleVersion(t *testing.T) {
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
android_app {
name: "com.android.foo",
srcs: ["a.java"],
sdk_version: "current",
min_sdk_version: "31",
updatable: true,
}
`)
foo := result.ModuleForTests("com.android.foo", "android_common").Rule("manifestFixer")
android.AssertStringDoesContain(t,
"com.android.foo: expected manifest fixer to set override-placeholder-version to android.DefaultUpdatableModuleVersion",
foo.BuildParams.Args["args"],
fmt.Sprintf("--override-placeholder-version %s", android.DefaultUpdatableModuleVersion),
)
}
func TestUpdatableApps_ApplyOverrideApexManifestDefaultVersion(t *testing.T) {
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureMergeEnv(map[string]string{
"OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION": "1234",
}),
).RunTestWithBp(t, `
android_app {
name: "com.android.foo",
srcs: ["a.java"],
sdk_version: "current",
min_sdk_version: "31",
updatable: true,
}
`)
foo := result.ModuleForTests("com.android.foo", "android_common").Rule("manifestFixer")
android.AssertStringDoesContain(t,
"com.android.foo: expected manifest fixer to set override-placeholder-version to 1234",
foo.BuildParams.Args["args"],
"--override-placeholder-version 1234",
)
}
func TestResourceDirs(t *testing.T) {
testCases := []struct {
name string
@@ -4479,3 +4522,44 @@ func TestAppMinSdkVersionOverride(t *testing.T) {
)
}
func TestNotApplyDefaultUpdatableModuleVersion(t *testing.T) {
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
android_app {
name: "com.android.foo",
srcs: ["a.java"],
sdk_version: "current",
min_sdk_version: "31",
}
`)
foo := result.ModuleForTests("com.android.foo", "android_common").Rule("manifestFixer")
android.AssertStringDoesNotContain(t,
"com.android.foo: expected manifest fixer to not set override-placeholder-version",
foo.BuildParams.Args["args"],
"--override-placeholder-version",
)
}
func TestNotApplyOverrideApexManifestDefaultVersion(t *testing.T) {
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureMergeEnv(map[string]string{
"OVERRIDE_APEX_MANIFEST_DEFAULT_VERSION": "1234",
}),
).RunTestWithBp(t, `
android_app {
name: "com.android.foo",
srcs: ["a.java"],
sdk_version: "current",
min_sdk_version: "31",
}
`)
foo := result.ModuleForTests("com.android.foo", "android_common").Rule("manifestFixer")
android.AssertStringDoesNotContain(t,
"com.android.foo: expected manifest fixer to not set override-placeholder-version",
foo.BuildParams.Args["args"],
"--override-placeholder-version",
)
}