Install signed split apks.

This fixes a bug where unsigned split apks were installed instead of
their signed counterparts.

Fixes: 140795853
Test: app_test.go
Test: m Split && apksigner verify --print-certs
Change-Id: I12cdbcaff9932b6388f920d7e03301d687c3bfdb
This commit is contained in:
Jaewoong Jung
2019-11-07 14:14:38 -08:00
parent af60d490ff
commit 5a49881eea
3 changed files with 10 additions and 12 deletions

View File

@@ -332,10 +332,9 @@ func (app *AndroidApp) AndroidMkEntries() android.AndroidMkEntries {
if len(app.dexpreopter.builtInstalled) > 0 {
entries.SetString("LOCAL_SOONG_BUILT_INSTALLED", app.dexpreopter.builtInstalled)
}
for _, split := range app.aapt.splits {
install := app.onDeviceDir + "/" +
strings.TrimSuffix(app.installApkName, ".apk") + "_" + split.suffix + ".apk"
entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", split.path.String()+":"+install)
for _, extra := range app.extraOutputFiles {
install := app.onDeviceDir + "/" + extra.Base()
entries.AddStrings("LOCAL_SOONG_BUILT_INSTALLED", extra.String()+":"+install)
}
},
},

View File

@@ -479,14 +479,13 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
a.certificate = certificates[0]
// Build a final signed app package.
// TODO(jungjw): Consider changing this to installApkName.
packageFile := android.PathForModuleOut(ctx, ctx.ModuleName()+".apk")
packageFile := android.PathForModuleOut(ctx, a.installApkName+".apk")
CreateAndSignAppPackage(ctx, packageFile, a.exportPackage, jniJarFile, dexJarFile, certificates, apkDeps)
a.outputFile = packageFile
for _, split := range a.aapt.splits {
// Sign the split APKs
packageFile := android.PathForModuleOut(ctx, ctx.ModuleName()+"_"+split.suffix+".apk")
packageFile := android.PathForModuleOut(ctx, a.installApkName+"_"+split.suffix+".apk")
CreateAndSignAppPackage(ctx, packageFile, split.path, nil, nil, certificates, apkDeps)
a.extraOutputFiles = append(a.extraOutputFiles, packageFile)
}
@@ -497,9 +496,9 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
a.bundleFile = bundleFile
// Install the app package.
ctx.InstallFile(a.installDir, a.installApkName+".apk", a.outputFile)
for _, split := range a.aapt.splits {
ctx.InstallFile(a.installDir, a.installApkName+"_"+split.suffix+".apk", split.path)
ctx.InstallFile(a.installDir, a.outputFile.Base(), a.outputFile)
for _, extra := range a.extraOutputFiles {
ctx.InstallFile(a.installDir, extra.Base(), extra)
}
}

View File

@@ -876,7 +876,7 @@ func TestPackageNameOverride(t *testing.T) {
packageNameOverride: "foo:bar",
expected: []string{
// The package apk should be still be the original name for test dependencies.
buildDir + "/.intermediates/foo/android_common/foo.apk",
buildDir + "/.intermediates/foo/android_common/bar.apk",
buildDir + "/target/product/test_device/system/app/bar/bar.apk",
},
},
@@ -1016,7 +1016,7 @@ func TestOverrideAndroidApp(t *testing.T) {
}
// Check the certificate paths
signapk := variant.Output("foo.apk")
signapk := variant.Output(expected.moduleName + ".apk")
signFlag := signapk.Args["certificates"]
if expected.signFlag != signFlag {
t.Errorf("Incorrect signing flags, expected: %q, got: %q", expected.signFlag, signFlag)