Support privleged app in APEX
privileged apps are installed to priv-app dir in APEX Test: m Change-Id: I8141e1c20e9486655606fa43b949783f11da09f4
This commit is contained in:
parent
d7d5e5a1ac
commit
f7487318ac
|
@ -975,7 +975,11 @@ func getCopyManifestForPrebuiltEtc(prebuilt *android.PrebuiltEtc) (fileToCopy an
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCopyManifestForAndroidApp(app *java.AndroidApp, pkgName string) (fileToCopy android.Path, dirInApex string) {
|
func getCopyManifestForAndroidApp(app *java.AndroidApp, pkgName string) (fileToCopy android.Path, dirInApex string) {
|
||||||
dirInApex = filepath.Join("app", pkgName)
|
appDir := "app"
|
||||||
|
if app.Privileged() {
|
||||||
|
appDir = "priv-app"
|
||||||
|
}
|
||||||
|
dirInApex = filepath.Join(appDir, pkgName)
|
||||||
fileToCopy = app.OutputFile()
|
fileToCopy = app.OutputFile()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -2404,6 +2404,7 @@ func TestApexWithApps(t *testing.T) {
|
||||||
key: "myapex.key",
|
key: "myapex.key",
|
||||||
apps: [
|
apps: [
|
||||||
"AppFoo",
|
"AppFoo",
|
||||||
|
"AppFooPriv",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2419,6 +2420,14 @@ func TestApexWithApps(t *testing.T) {
|
||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
android_app {
|
||||||
|
name: "AppFooPriv",
|
||||||
|
srcs: ["foo/bar/MyClass.java"],
|
||||||
|
sdk_version: "none",
|
||||||
|
system_modules: "none",
|
||||||
|
privileged: true,
|
||||||
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
module := ctx.ModuleForTests("myapex", "android_common_myapex")
|
module := ctx.ModuleForTests("myapex", "android_common_myapex")
|
||||||
|
@ -2426,6 +2435,7 @@ func TestApexWithApps(t *testing.T) {
|
||||||
copyCmds := apexRule.Args["copy_commands"]
|
copyCmds := apexRule.Args["copy_commands"]
|
||||||
|
|
||||||
ensureContains(t, copyCmds, "image.apex/app/AppFoo/AppFoo.apk")
|
ensureContains(t, copyCmds, "image.apex/app/AppFoo/AppFoo.apk")
|
||||||
|
ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv/AppFooPriv.apk")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,7 +317,7 @@ func (app *AndroidApp) AndroidMkEntries() android.AndroidMkEntries {
|
||||||
|
|
||||||
entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
|
entries.SetPath("LOCAL_FULL_MANIFEST_FILE", app.manifestPath)
|
||||||
|
|
||||||
entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(app.appProperties.Privileged))
|
entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", app.Privileged())
|
||||||
|
|
||||||
entries.SetPath("LOCAL_CERTIFICATE", app.certificate.Pem)
|
entries.SetPath("LOCAL_CERTIFICATE", app.certificate.Pem)
|
||||||
entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
|
entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
|
||||||
|
@ -630,7 +630,7 @@ func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
|
||||||
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
|
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
|
||||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||||
func(entries *android.AndroidMkEntries) {
|
func(entries *android.AndroidMkEntries) {
|
||||||
entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(a.properties.Privileged))
|
entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
|
||||||
if a.certificate != nil {
|
if a.certificate != nil {
|
||||||
entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem)
|
entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem)
|
||||||
} else {
|
} else {
|
||||||
|
|
16
java/app.go
16
java/app.go
|
@ -230,7 +230,7 @@ func (a *AndroidApp) shouldUncompressDex(ctx android.ModuleContext) bool {
|
||||||
|
|
||||||
// Uncompress dex in APKs of privileged apps (even for unbundled builds, they may
|
// Uncompress dex in APKs of privileged apps (even for unbundled builds, they may
|
||||||
// be preinstalled as prebuilts).
|
// be preinstalled as prebuilts).
|
||||||
if ctx.Config().UncompressPrivAppDex() && Bool(a.appProperties.Privileged) {
|
if ctx.Config().UncompressPrivAppDex() && a.Privileged() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ func (a *AndroidApp) dexBuildActions(ctx android.ModuleContext) android.Path {
|
||||||
if ctx.ModuleName() == "framework-res" {
|
if ctx.ModuleName() == "framework-res" {
|
||||||
// framework-res.apk is installed as system/framework/framework-res.apk
|
// framework-res.apk is installed as system/framework/framework-res.apk
|
||||||
installDir = "framework"
|
installDir = "framework"
|
||||||
} else if Bool(a.appProperties.Privileged) {
|
} else if a.Privileged() {
|
||||||
installDir = filepath.Join("priv-app", a.installApkName)
|
installDir = filepath.Join("priv-app", a.installApkName)
|
||||||
} else {
|
} else {
|
||||||
installDir = filepath.Join("app", a.installApkName)
|
installDir = filepath.Join("app", a.installApkName)
|
||||||
|
@ -444,7 +444,7 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
if ctx.ModuleName() == "framework-res" {
|
if ctx.ModuleName() == "framework-res" {
|
||||||
// framework-res.apk is installed as system/framework/framework-res.apk
|
// framework-res.apk is installed as system/framework/framework-res.apk
|
||||||
a.installDir = android.PathForModuleInstall(ctx, "framework")
|
a.installDir = android.PathForModuleInstall(ctx, "framework")
|
||||||
} else if Bool(a.appProperties.Privileged) {
|
} else if a.Privileged() {
|
||||||
a.installDir = android.PathForModuleInstall(ctx, "priv-app", a.installApkName)
|
a.installDir = android.PathForModuleInstall(ctx, "priv-app", a.installApkName)
|
||||||
} else if ctx.InstallInTestcases() {
|
} else if ctx.InstallInTestcases() {
|
||||||
a.installDir = android.PathForModuleInstall(ctx, a.installApkName)
|
a.installDir = android.PathForModuleInstall(ctx, a.installApkName)
|
||||||
|
@ -557,6 +557,10 @@ func (a *AndroidApp) OutputFiles(tag string) (android.Paths, error) {
|
||||||
return a.Library.OutputFiles(tag)
|
return a.Library.OutputFiles(tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AndroidApp) Privileged() bool {
|
||||||
|
return Bool(a.appProperties.Privileged)
|
||||||
|
}
|
||||||
|
|
||||||
// android_app compiles sources and Android resources into an Android application package `.apk` file.
|
// android_app compiles sources and Android resources into an Android application package `.apk` file.
|
||||||
func AndroidAppFactory() android.Module {
|
func AndroidAppFactory() android.Module {
|
||||||
module := &AndroidApp{}
|
module := &AndroidApp{}
|
||||||
|
@ -874,7 +878,7 @@ func (a *AndroidAppImport) shouldUncompressDex(ctx android.ModuleContext) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uncompress dex in APKs of privileged apps
|
// Uncompress dex in APKs of privileged apps
|
||||||
if ctx.Config().UncompressPrivAppDex() && Bool(a.properties.Privileged) {
|
if ctx.Config().UncompressPrivAppDex() && a.Privileged() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1005,6 +1009,10 @@ func (a *AndroidAppImport) populateAllVariantStructs() {
|
||||||
a.AddProperties(a.archVariants)
|
a.AddProperties(a.archVariants)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *AndroidAppImport) Privileged() bool {
|
||||||
|
return Bool(a.properties.Privileged)
|
||||||
|
}
|
||||||
|
|
||||||
func createVariantGroupType(variants []string, variantGroupName string) reflect.Type {
|
func createVariantGroupType(variants []string, variantGroupName string) reflect.Type {
|
||||||
props := reflect.TypeOf((*AndroidAppImportProperties)(nil))
|
props := reflect.TypeOf((*AndroidAppImportProperties)(nil))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue