Merge "Support privleged app in APEX"
am: d091c6a67a
Change-Id: Ic2982b4a4224ca8a15769071cebc66b0986a67a3
diff --git a/apex/apex.go b/apex/apex.go
index e14d82d..c9b989a 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -972,7 +972,11 @@
}
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()
return
}
diff --git a/apex/apex_test.go b/apex/apex_test.go
index d1cd969..7a51bb6 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -2232,6 +2232,7 @@
key: "myapex.key",
apps: [
"AppFoo",
+ "AppFooPriv",
],
}
@@ -2247,6 +2248,14 @@
sdk_version: "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")
@@ -2254,6 +2263,7 @@
copyCmds := apexRule.Args["copy_commands"]
ensureContains(t, copyCmds, "image.apex/app/AppFoo/AppFoo.apk")
+ ensureContains(t, copyCmds, "image.apex/priv-app/AppFooPriv/AppFooPriv.apk")
}
diff --git a/java/androidmk.go b/java/androidmk.go
index 955f22b..7927acf 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -317,7 +317,7 @@
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.AddStrings("LOCAL_OVERRIDES_PACKAGES", app.getOverriddenPackages()...)
@@ -630,7 +630,7 @@
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(entries *android.AndroidMkEntries) {
- entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(a.properties.Privileged))
+ entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", a.Privileged())
if a.certificate != nil {
entries.SetPath("LOCAL_CERTIFICATE", a.certificate.Pem)
} else {
diff --git a/java/app.go b/java/app.go
index 6b640f1..3dbcbf4 100644
--- a/java/app.go
+++ b/java/app.go
@@ -228,7 +228,7 @@
// Uncompress dex in APKs of privileged apps (even for unbundled builds, they may
// be preinstalled as prebuilts).
- if ctx.Config().UncompressPrivAppDex() && Bool(a.appProperties.Privileged) {
+ if ctx.Config().UncompressPrivAppDex() && a.Privileged() {
return true
}
@@ -316,7 +316,7 @@
if ctx.ModuleName() == "framework-res" {
// framework-res.apk is installed as system/framework/framework-res.apk
installDir = "framework"
- } else if Bool(a.appProperties.Privileged) {
+ } else if a.Privileged() {
installDir = filepath.Join("priv-app", a.installApkName)
} else {
installDir = filepath.Join("app", a.installApkName)
@@ -442,7 +442,7 @@
if ctx.ModuleName() == "framework-res" {
// framework-res.apk is installed as system/framework/framework-res.apk
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)
} else if ctx.InstallInTestcases() {
a.installDir = android.PathForModuleInstall(ctx, a.installApkName)
@@ -555,6 +555,10 @@
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.
func AndroidAppFactory() android.Module {
module := &AndroidApp{}
@@ -872,7 +876,7 @@
}
// Uncompress dex in APKs of privileged apps
- if ctx.Config().UncompressPrivAppDex() && Bool(a.properties.Privileged) {
+ if ctx.Config().UncompressPrivAppDex() && a.Privileged() {
return true
}
@@ -1003,6 +1007,10 @@
a.AddProperties(a.archVariants)
}
+func (a *AndroidAppImport) Privileged() bool {
+ return Bool(a.properties.Privileged)
+}
+
func createVariantGroupType(variants []string, variantGroupName string) reflect.Type {
props := reflect.TypeOf((*AndroidAppImportProperties)(nil))