Adding relative_install_path field to android_app_import
Test: Ran go test ./java from build/soong Bug: 149873762 Change-Id: I4abc1fb9e2386c7319b446b84aebaabacc882fd6
This commit is contained in:
@@ -99,6 +99,9 @@ type AndroidAppImportProperties struct {
|
|||||||
// If set, create package-export.apk, which other packages can
|
// If set, create package-export.apk, which other packages can
|
||||||
// use to get PRODUCT-agnostic resource data like IDs and type definitions.
|
// use to get PRODUCT-agnostic resource data like IDs and type definitions.
|
||||||
Export_package_resources *bool
|
Export_package_resources *bool
|
||||||
|
|
||||||
|
// Optional. Install to a subdirectory of the default install path for the module
|
||||||
|
Relative_install_path *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *AndroidAppImport) IsInstallable() bool {
|
func (a *AndroidAppImport) IsInstallable() bool {
|
||||||
@@ -263,20 +266,25 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext
|
|||||||
jnisUncompressed := android.PathForModuleOut(ctx, "jnis-uncompressed", ctx.ModuleName()+".apk")
|
jnisUncompressed := android.PathForModuleOut(ctx, "jnis-uncompressed", ctx.ModuleName()+".apk")
|
||||||
a.uncompressEmbeddedJniLibs(ctx, srcApk, jnisUncompressed.OutputPath)
|
a.uncompressEmbeddedJniLibs(ctx, srcApk, jnisUncompressed.OutputPath)
|
||||||
|
|
||||||
var installDir android.InstallPath
|
var pathFragments []string
|
||||||
|
relInstallPath := String(a.properties.Relative_install_path)
|
||||||
|
|
||||||
if a.isPrebuiltFrameworkRes() {
|
if a.isPrebuiltFrameworkRes() {
|
||||||
// framework-res.apk is installed as system/framework/framework-res.apk
|
// framework-res.apk is installed as system/framework/framework-res.apk
|
||||||
installDir = android.PathForModuleInstall(ctx, "framework")
|
if relInstallPath != "" {
|
||||||
|
ctx.PropertyErrorf("relative_install_path", "Relative_install_path cannot be set for framework-res")
|
||||||
|
}
|
||||||
|
pathFragments = []string{"framework"}
|
||||||
a.preprocessed = true
|
a.preprocessed = true
|
||||||
} else if Bool(a.properties.Privileged) {
|
} else if Bool(a.properties.Privileged) {
|
||||||
installDir = android.PathForModuleInstall(ctx, "priv-app", a.BaseModuleName())
|
pathFragments = []string{"priv-app", relInstallPath, a.BaseModuleName()}
|
||||||
} else if ctx.InstallInTestcases() {
|
} else if ctx.InstallInTestcases() {
|
||||||
installDir = android.PathForModuleInstall(ctx, a.BaseModuleName(), ctx.DeviceConfig().DeviceArch())
|
pathFragments = []string{relInstallPath, a.BaseModuleName(), ctx.DeviceConfig().DeviceArch()}
|
||||||
} else {
|
} else {
|
||||||
installDir = android.PathForModuleInstall(ctx, "app", a.BaseModuleName())
|
pathFragments = []string{"app", relInstallPath, a.BaseModuleName()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
installDir := android.PathForModuleInstall(ctx, pathFragments...)
|
||||||
a.dexpreopter.isApp = true
|
a.dexpreopter.isApp = true
|
||||||
a.dexpreopter.installPath = installDir.Join(ctx, a.BaseModuleName()+".apk")
|
a.dexpreopter.installPath = installDir.Join(ctx, a.BaseModuleName()+".apk")
|
||||||
a.dexpreopter.isPresignedPrebuilt = Bool(a.properties.Presigned)
|
a.dexpreopter.isPresignedPrebuilt = Bool(a.properties.Presigned)
|
||||||
|
@@ -493,6 +493,69 @@ func TestAndroidAppImport_frameworkRes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAndroidAppImport_relativeInstallPath(t *testing.T) {
|
||||||
|
bp := `
|
||||||
|
android_app_import {
|
||||||
|
name: "no_relative_install_path",
|
||||||
|
apk: "prebuilts/apk/app.apk",
|
||||||
|
presigned: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
android_app_import {
|
||||||
|
name: "relative_install_path",
|
||||||
|
apk: "prebuilts/apk/app.apk",
|
||||||
|
presigned: true,
|
||||||
|
relative_install_path: "my/path",
|
||||||
|
}
|
||||||
|
|
||||||
|
android_app_import {
|
||||||
|
name: "framework-res",
|
||||||
|
apk: "prebuilts/apk/app.apk",
|
||||||
|
presigned: true,
|
||||||
|
prefer: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
android_app_import {
|
||||||
|
name: "privileged_relative_install_path",
|
||||||
|
apk: "prebuilts/apk/app.apk",
|
||||||
|
presigned: true,
|
||||||
|
privileged: true,
|
||||||
|
relative_install_path: "my/path"
|
||||||
|
}
|
||||||
|
`
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
expectedInstallPath string
|
||||||
|
errorMessage string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "no_relative_install_path",
|
||||||
|
expectedInstallPath: "out/soong/target/product/test_device/system/app/no_relative_install_path/no_relative_install_path.apk",
|
||||||
|
errorMessage: "Install path is not correct when relative_install_path is missing",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "relative_install_path",
|
||||||
|
expectedInstallPath: "out/soong/target/product/test_device/system/app/my/path/relative_install_path/relative_install_path.apk",
|
||||||
|
errorMessage: "Install path is not correct for app when relative_install_path is present",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "prebuilt_framework-res",
|
||||||
|
expectedInstallPath: "out/soong/target/product/test_device/system/framework/framework-res.apk",
|
||||||
|
errorMessage: "Install path is not correct for framework-res",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "privileged_relative_install_path",
|
||||||
|
expectedInstallPath: "out/soong/target/product/test_device/system/priv-app/my/path/privileged_relative_install_path/privileged_relative_install_path.apk",
|
||||||
|
errorMessage: "Install path is not correct for privileged app when relative_install_path is present",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
ctx, _ := testJava(t, bp)
|
||||||
|
mod := ctx.ModuleForTests(testCase.name, "android_common").Module().(*AndroidAppImport)
|
||||||
|
android.AssertPathRelativeToTopEquals(t, testCase.errorMessage, testCase.expectedInstallPath, mod.installPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestAndroidTestImport(t *testing.T) {
|
func TestAndroidTestImport(t *testing.T) {
|
||||||
ctx, _ := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
android_test_import {
|
android_test_import {
|
||||||
|
Reference in New Issue
Block a user