Add file with updatable BCP packages to /system/etc/

Make `permitted_packages` mandatory for updatable boot class
path jars. Collect the permitted_packages from those jars to
a file installed as /system/etc/updatable_bcp_packages.txt .

(cherry picked from commit 205e6c2a15)

Test: aosp_taimen-userdebug boots.
Test: adb shell cat /system/etc/updatable-bcp-packages
Test: Manual, remove permitted_packages from framework-tethering,
      build fails.
Bug: 151314205
Merged-In: I21def97ace9081e707910d449943c683189f16cf
Change-Id: I68486f0d8d3368636e1a5324321bd0106fbe241a
This commit is contained in:
Vladimir Marko 2020-04-01 13:52:27 +01:00
parent 163bda65fd
commit b92ae27ca0
1 changed files with 57 additions and 0 deletions

View File

@ -16,6 +16,7 @@ package java
import (
"path/filepath"
"sort"
"strings"
"android/soong/android"
@ -277,6 +278,7 @@ func buildBootImage(ctx android.SingletonContext, image *bootImageConfig) *bootI
profile := bootImageProfileRule(ctx, image, missingDeps)
bootFrameworkProfileRule(ctx, image, missingDeps)
updatableBcpPackagesRule(ctx, image, missingDeps)
var allFiles android.Paths
for _, variant := range image.variants {
@ -541,6 +543,61 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConf
var bootFrameworkProfileRuleKey = android.NewOnceKey("bootFrameworkProfileRule")
func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConfig, missingDeps []string) android.WritablePath {
if ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
return nil
}
return ctx.Config().Once(updatableBcpPackagesRuleKey, func() interface{} {
global := dexpreopt.GetGlobalConfig(ctx)
updatableModules := dexpreopt.GetJarsFromApexJarPairs(global.UpdatableBootJars)
// Collect `permitted_packages` for updatable boot jars.
var updatablePackages []string
ctx.VisitAllModules(func(module android.Module) {
if j, ok := module.(*Library); ok {
name := ctx.ModuleName(module)
if i := android.IndexList(name, updatableModules); i != -1 {
pp := j.properties.Permitted_packages
if len(pp) > 0 {
updatablePackages = append(updatablePackages, pp...)
} else {
ctx.Errorf("Missing permitted_packages for %s", name)
}
// Do not match the same library repeatedly.
updatableModules = append(updatableModules[:i], updatableModules[i+1:]...)
}
}
})
// Sort updatable packages to ensure deterministic ordering.
sort.Strings(updatablePackages)
updatableBcpPackagesName := "updatable-bcp-packages.txt"
updatableBcpPackages := image.dir.Join(ctx, updatableBcpPackagesName)
ctx.Build(pctx, android.BuildParams{
Rule: android.WriteFile,
Output: updatableBcpPackages,
Args: map[string]string{
// WriteFile automatically adds the last end-of-line.
"content": strings.Join(updatablePackages, "\\n"),
},
})
rule := android.NewRuleBuilder()
rule.MissingDeps(missingDeps)
rule.Install(updatableBcpPackages, "/system/etc/"+updatableBcpPackagesName)
// TODO: Rename `profileInstalls` to `extraInstalls`?
// Maybe even move the field out of the bootImageConfig into some higher level type?
image.profileInstalls = append(image.profileInstalls, rule.Installs()...)
return updatableBcpPackages
}).(android.WritablePath)
}
var updatableBcpPackagesRuleKey = android.NewOnceKey("updatableBcpPackagesRule")
func dumpOatRules(ctx android.SingletonContext, image *bootImageConfig) {
var allPhonies android.Paths
for _, image := range image.variants {