Merge "Fix writing soong.variables ." am: 828b1e99ec am: 85787f8720 am: 8f35b4df58
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1641405
Change-Id: I1ef94c752459994c75248d9525fab6eadad87c40
diff --git a/android/variable.go b/android/variable.go
index 08fa12c..3f7e1cc 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -130,6 +130,7 @@
Arc struct {
Cflags []string `android:"arch_variant"`
Exclude_srcs []string `android:"arch_variant"`
+ Header_libs []string `android:"arch_variant"`
Include_dirs []string `android:"arch_variant"`
Shared_libs []string `android:"arch_variant"`
Static_libs []string `android:"arch_variant"`
diff --git a/apex/apex.go b/apex/apex.go
index 3db20f4..9fd9ca0 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2687,7 +2687,6 @@
"libstagefright_amrwbdec",
"libstagefright_amrwbenc",
"libstagefright_bufferpool@2.0.1",
- "libstagefright_bufferqueue_helper",
"libstagefright_enc_common",
"libstagefright_flacdec",
"libstagefright_foundation",
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go
index 4890ba4..f587c90 100644
--- a/apex/apex_singleton.go
+++ b/apex/apex_singleton.go
@@ -17,9 +17,9 @@
package apex
import (
- "android/soong/android"
-
"github.com/google/blueprint"
+
+ "android/soong/android"
)
func init() {
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 3280cd8..460e559 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -21,7 +21,6 @@
"android/soong/android"
"android/soong/java"
-
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -437,9 +436,6 @@
// list of commands to create symlinks for backward compatibility.
// these commands will be attached as LOCAL_POST_INSTALL_CMD
compatSymlinks []string
-
- hostRequired []string
- postInstallCommands []string
}
type ApexSetProperties struct {
@@ -578,43 +574,21 @@
for _, overridden := range a.properties.Overrides {
a.compatSymlinks = append(a.compatSymlinks, makeCompatSymlinks(overridden, ctx)...)
}
-
- if ctx.Config().InstallExtraFlattenedApexes() {
- // flattened apex should be in /system_ext/apex
- flattenedApexDir := android.PathForModuleInstall(&systemExtContext{ctx}, "apex", a.BaseModuleName())
- a.postInstallCommands = append(a.postInstallCommands,
- fmt.Sprintf("$(HOST_OUT_EXECUTABLES)/deapexer --debugfs_path $(HOST_OUT_EXECUTABLES)/debugfs extract %s %s",
- a.outputApex.String(),
- flattenedApexDir.ToMakePath().String(),
- ))
- a.hostRequired = []string{"deapexer", "debugfs"}
- }
-}
-
-type systemExtContext struct {
- android.ModuleContext
-}
-
-func (*systemExtContext) SystemExtSpecific() bool {
- return true
}
func (a *ApexSet) AndroidMkEntries() []android.AndroidMkEntries {
return []android.AndroidMkEntries{android.AndroidMkEntries{
- Class: "ETC",
- OutputFile: android.OptionalPathForPath(a.outputApex),
- Include: "$(BUILD_PREBUILT)",
- Host_required: a.hostRequired,
+ Class: "ETC",
+ OutputFile: android.OptionalPathForPath(a.outputApex),
+ Include: "$(BUILD_PREBUILT)",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_PATH", a.installDir.ToMakePath().String())
entries.SetString("LOCAL_MODULE_STEM", a.installFilename)
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !a.installable())
entries.AddStrings("LOCAL_OVERRIDES_MODULES", a.properties.Overrides...)
- postInstallCommands := append([]string{}, a.postInstallCommands...)
- postInstallCommands = append(postInstallCommands, a.compatSymlinks...)
- if len(postInstallCommands) > 0 {
- entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(postInstallCommands, " && "))
+ if len(a.compatSymlinks) > 0 {
+ entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(a.compatSymlinks, " && "))
}
},
},
diff --git a/cc/config/vndk.go b/cc/config/vndk.go
index 425e349..d58c7a5 100644
--- a/cc/config/vndk.go
+++ b/cc/config/vndk.go
@@ -24,6 +24,9 @@
"android.hardware.authsecret-V1-ndk_platform",
"android.hardware.automotive.occupant_awareness-ndk_platform",
"android.hardware.automotive.occupant_awareness-V1-ndk_platform",
+ "android.hardware.gnss-unstable-ndk_platform",
+ "android.hardware.gnss-ndk_platform",
+ "android.hardware.gnss-V1-ndk_platform",
"android.hardware.health.storage-V1-ndk_platform",
"android.hardware.health.storage-ndk_platform",
"android.hardware.health.storage-unstable-ndk_platform",
@@ -40,10 +43,10 @@
"android.hardware.oemlock-unstable-ndk_platform",
"android.hardware.power-V1-ndk_platform",
"android.hardware.power-ndk_platform",
- "android.hardware.rebootescrow-V1-ndk_platform",
"android.hardware.power.stats-V1-ndk_platform",
"android.hardware.power.stats-ndk_platform",
"android.hardware.power.stats-unstable-ndk_platform",
+ "android.hardware.rebootescrow-V1-ndk_platform",
"android.hardware.rebootescrow-ndk_platform",
"android.hardware.security.keymint-V1-ndk_platform",
"android.hardware.security.keymint-ndk_platform",
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index 4999bc7..fdb00bd 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -261,17 +261,21 @@
} else if module.EnforceUsesLibraries {
// Generate command that saves target SDK version in a shell variable.
- manifestOrApk := module.ManifestPath
- if manifestOrApk == nil {
- // No manifest to extract targetSdkVersion from, hope that dexjar is an APK.
- manifestOrApk = module.DexPath
+ if module.ManifestPath != nil {
+ rule.Command().Text(`target_sdk_version="$(`).
+ Tool(globalSoong.ManifestCheck).
+ Flag("--extract-target-sdk-version").
+ Input(module.ManifestPath).
+ Text(`)"`)
+ } else {
+ // No manifest to extract targetSdkVersion from, hope that DexJar is an APK
+ rule.Command().Text(`target_sdk_version="$(`).
+ Tool(globalSoong.Aapt).
+ Flag("dump badging").
+ Input(module.DexPath).
+ Text(`| grep "targetSdkVersion" | sed -n "s/targetSdkVersion:'\(.*\)'/\1/p"`).
+ Text(`)"`)
}
- rule.Command().Text(`target_sdk_version="$(`).
- Tool(globalSoong.ManifestCheck).
- Flag("--extract-target-sdk-version").
- Input(manifestOrApk).
- FlagWithInput("--aapt ", ctx.Config().HostToolPath(ctx, "aapt")).
- Text(`)"`)
// Generate command that saves host and target class loader context in shell variables.
clc, paths := ComputeClassLoaderContext(module.ClassLoaderContexts)
diff --git a/java/app.go b/java/app.go
index 7c09350..59f823e 100755
--- a/java/app.go
+++ b/java/app.go
@@ -913,6 +913,8 @@
&module.appProperties,
&module.overridableAppProperties)
+ module.usesLibrary.enforce = true
+
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
android.InitOverridableModule(module, &module.appProperties.Overrides)
@@ -1183,6 +1185,9 @@
// with knowledge of their shared libraries.
type usesLibrary struct {
usesLibraryProperties UsesLibraryProperties
+
+ // Whether to enforce verify_uses_library check.
+ enforce bool
}
func (u *usesLibrary) addLib(lib string, optional bool) {
@@ -1267,7 +1272,7 @@
func (u *usesLibrary) enforceUsesLibraries() bool {
defaultEnforceUsesLibs := len(u.usesLibraryProperties.Uses_libs) > 0 ||
len(u.usesLibraryProperties.Optional_uses_libs) > 0
- return BoolDefault(u.usesLibraryProperties.Enforce_uses_libs, defaultEnforceUsesLibs)
+ return BoolDefault(u.usesLibraryProperties.Enforce_uses_libs, u.enforce || defaultEnforceUsesLibs)
}
// Freeze the value of `enforce_uses_libs` based on the current values of `uses_libs` and `optional_uses_libs`.
@@ -1276,13 +1281,10 @@
u.usesLibraryProperties.Enforce_uses_libs = &enforce
}
-// verifyUsesLibraries checks the <uses-library> tags in the manifest against the ones specified
-// in the `uses_libs`/`optional_uses_libs` properties. The input can be either an XML manifest, or
-// an APK with the manifest embedded in it (manifest_check will know which one it is by the file
-// extension: APKs are supposed to end with '.apk').
-func (u *usesLibrary) verifyUsesLibraries(ctx android.ModuleContext, inputFile android.Path,
- outputFile android.WritablePath) android.Path {
-
+// verifyUsesLibrariesManifest checks the <uses-library> tags in an AndroidManifest.xml against the ones specified
+// in the uses_libs and optional_uses_libs properties. It returns the path to a copy of the manifest.
+func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, manifest android.Path) android.Path {
+ outputFile := android.PathForModuleOut(ctx, "manifest_check", "AndroidManifest.xml")
statusFile := dexpreopt.UsesLibrariesStatusFile(ctx)
// Disable verify_uses_libraries check if dexpreopt is globally disabled. Without dexpreopt the
@@ -1290,19 +1292,15 @@
// non-linux build platforms where dexpreopt is generally disabled (the check may fail due to
// various unrelated reasons, such as a failure to get manifest from an APK).
if dexpreopt.GetGlobalConfig(ctx).DisablePreopt {
- return inputFile
+ return manifest
}
rule := android.NewRuleBuilder(pctx, ctx)
cmd := rule.Command().BuiltTool("manifest_check").
Flag("--enforce-uses-libraries").
- Input(inputFile).
+ Input(manifest).
FlagWithOutput("--enforce-uses-libraries-status ", statusFile).
- FlagWithInput("--aapt ", ctx.Config().HostToolPath(ctx, "aapt"))
-
- if outputFile != nil {
- cmd.FlagWithOutput("-o ", outputFile)
- }
+ FlagWithOutput("-o ", outputFile)
if dexpreopt.GetGlobalConfig(ctx).RelaxUsesLibraryCheck {
cmd.Flag("--enforce-uses-libraries-relax")
@@ -1317,20 +1315,35 @@
}
rule.Build("verify_uses_libraries", "verify <uses-library>")
+
return outputFile
}
-// verifyUsesLibrariesManifest checks the <uses-library> tags in an AndroidManifest.xml against
-// the build system and returns the path to a copy of the manifest.
-func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, manifest android.Path) android.Path {
- outputFile := android.PathForModuleOut(ctx, "manifest_check", "AndroidManifest.xml")
- return u.verifyUsesLibraries(ctx, manifest, outputFile)
-}
-
-// verifyUsesLibrariesAPK checks the <uses-library> tags in the manifest of an APK against the build
-// system and returns the path to a copy of the APK.
+// verifyUsesLibrariesAPK checks the <uses-library> tags in the manifest of an APK against the ones specified
+// in the uses_libs and optional_uses_libs properties. It returns the path to a copy of the APK.
func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk android.Path) android.Path {
- u.verifyUsesLibraries(ctx, apk, nil) // for APKs manifest_check does not write output file
outputFile := android.PathForModuleOut(ctx, "verify_uses_libraries", apk.Base())
+ statusFile := dexpreopt.UsesLibrariesStatusFile(ctx)
+
+ // Disable verify_uses_libraries check if dexpreopt is globally disabled. Without dexpreopt the
+ // check is not necessary, and although it is good to have, it is difficult to maintain on
+ // non-linux build platforms where dexpreopt is generally disabled (the check may fail due to
+ // various unrelated reasons, such as a failure to get manifest from an APK).
+ if dexpreopt.GetGlobalConfig(ctx).DisablePreopt {
+ return apk
+ }
+
+ rule := android.NewRuleBuilder(pctx, ctx)
+ aapt := ctx.Config().HostToolPath(ctx, "aapt")
+ rule.Command().
+ Textf("aapt_binary=%s", aapt.String()).Implicit(aapt).
+ Textf(`uses_library_names="%s"`, strings.Join(u.usesLibraryProperties.Uses_libs, " ")).
+ Textf(`optional_uses_library_names="%s"`, strings.Join(u.usesLibraryProperties.Optional_uses_libs, " ")).
+ Textf(`relax_check="%t"`, dexpreopt.GetGlobalConfig(ctx).RelaxUsesLibraryCheck).
+ Tool(android.PathForSource(ctx, "build/make/core/verify_uses_libraries.sh")).Input(apk).Output(statusFile)
+ rule.Command().Text("cp -f").Input(apk).Output(outputFile)
+
+ rule.Build("verify_uses_libraries", "verify <uses-library>")
+
return outputFile
}
diff --git a/java/app_import.go b/java/app_import.go
index 16a3cb9..d4da64d 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -462,6 +462,8 @@
android.InitDefaultableModule(module)
android.InitSingleSourcePrebuiltModule(module, &module.properties, "Apk")
+ module.usesLibrary.enforce = true
+
return module
}
diff --git a/java/app_import_test.go b/java/app_import_test.go
index 4994c98..cae41d0 100644
--- a/java/app_import_test.go
+++ b/java/app_import_test.go
@@ -222,31 +222,31 @@
name: "no preferred",
aaptPreferredConfig: nil,
aaptPrebuiltDPI: []string{},
- expected: "prebuilts/apk/app.apk",
+ expected: "verify_uses_libraries/apk/app.apk",
},
{
name: "AAPTPreferredConfig matches",
aaptPreferredConfig: proptools.StringPtr("xhdpi"),
aaptPrebuiltDPI: []string{"xxhdpi", "ldpi"},
- expected: "prebuilts/apk/app_xhdpi.apk",
+ expected: "verify_uses_libraries/apk/app_xhdpi.apk",
},
{
name: "AAPTPrebuiltDPI matches",
aaptPreferredConfig: proptools.StringPtr("mdpi"),
aaptPrebuiltDPI: []string{"xxhdpi", "xhdpi"},
- expected: "prebuilts/apk/app_xxhdpi.apk",
+ expected: "verify_uses_libraries/apk/app_xxhdpi.apk",
},
{
name: "non-first AAPTPrebuiltDPI matches",
aaptPreferredConfig: proptools.StringPtr("mdpi"),
aaptPrebuiltDPI: []string{"ldpi", "xhdpi"},
- expected: "prebuilts/apk/app_xhdpi.apk",
+ expected: "verify_uses_libraries/apk/app_xhdpi.apk",
},
{
name: "no matches",
aaptPreferredConfig: proptools.StringPtr("mdpi"),
aaptPrebuiltDPI: []string{"ldpi", "xxxhdpi"},
- expected: "prebuilts/apk/app.apk",
+ expected: "verify_uses_libraries/apk/app.apk",
},
}
@@ -265,7 +265,7 @@
if len(matches) != 2 {
t.Errorf("failed to extract the src apk path from %q", jniRuleCommand)
}
- if test.expected != matches[1] {
+ if strings.HasSuffix(matches[1], test.expected) {
t.Errorf("wrong src apk, expected: %q got: %q", test.expected, matches[1])
}
}
@@ -341,7 +341,7 @@
},
}
`,
- expected: "prebuilts/apk/app_arm64.apk",
+ expected: "verify_uses_libraries/apk/app_arm64.apk",
},
{
name: "no matching arch",
@@ -360,7 +360,7 @@
},
}
`,
- expected: "prebuilts/apk/app.apk",
+ expected: "verify_uses_libraries/apk/app.apk",
},
{
name: "no matching arch without default",
@@ -398,7 +398,7 @@
if len(matches) != 2 {
t.Errorf("failed to extract the src apk path from %q", jniRuleCommand)
}
- if test.expected != matches[1] {
+ if strings.HasSuffix(matches[1], test.expected) {
t.Errorf("wrong src apk, expected: %q got: %q", test.expected, matches[1])
}
}
diff --git a/java/app_test.go b/java/app_test.go
index c189ee5..3b37473 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -2400,13 +2400,13 @@
// Test that all libraries are verified for an APK (library order matters).
verifyApkCmd := prebuilt.Rule("verify_uses_libraries").RuleParams.Command
- verifyApkArgs := `--uses-library foo ` +
- `--uses-library com.non.sdk.lib ` +
- `--uses-library android.test.runner ` +
- `--optional-uses-library bar ` +
- `--optional-uses-library baz `
- if !strings.Contains(verifyApkCmd, verifyApkArgs) {
- t.Errorf("wanted %q in %q", verifyApkArgs, verifyApkCmd)
+ verifyApkReqLibs := `uses_library_names="foo com.non.sdk.lib android.test.runner"`
+ verifyApkOptLibs := `optional_uses_library_names="bar baz"`
+ if !strings.Contains(verifyApkCmd, verifyApkReqLibs) {
+ t.Errorf("wanted %q in %q", verifyApkReqLibs, verifyApkCmd)
+ }
+ if !strings.Contains(verifyApkCmd, verifyApkOptLibs) {
+ t.Errorf("wanted %q in %q", verifyApkOptLibs, verifyApkCmd)
}
// Test that all present libraries are preopted, including implicit SDK dependencies, possibly stubs
diff --git a/java/legacy_core_platform_api_usage.go b/java/legacy_core_platform_api_usage.go
index 8c401a7..628a100 100644
--- a/java/legacy_core_platform_api_usage.go
+++ b/java/legacy_core_platform_api_usage.go
@@ -20,6 +20,8 @@
)
var legacyCorePlatformApiModules = []string{
+ "AAECarSystemUI",
+ "AAECarSystemUI-tests",
"ArcSettings",
"ahat-test-dump",
"android.car",
@@ -30,28 +32,33 @@
"api-stubs-docs",
"art_cts_jvmti_test_library",
"art-gtest-jars-MyClassNatives",
+ "BackupEncryption",
"BackupFrameworksServicesRoboTests",
"backuplib",
"BandwidthEnforcementTest",
"BlockedNumberProvider",
"BluetoothInstrumentationTests",
+ "BluetoothMidiLib",
"BluetoothMidiService",
- "CarDeveloperOptions",
+ "BTTestApp",
+ "CallEnhancement",
+ "CapCtrlInterface",
"CarService",
"CarServiceTest",
- "car-apps-common",
"car-service-test-lib",
"car-service-test-static-lib",
"CertInstaller",
+ "com.qti.location.sdk",
"com.qti.media.secureprocessor",
"ConnectivityManagerTest",
"ContactsProvider",
"CorePerfTests",
"core-tests-support",
+ "cronet_impl_common_java",
+ "cronet_impl_native_java",
+ "cronet_impl_platform_java",
"CtsAppExitTestCases",
"CtsContentTestCases",
- "CtsIkeTestCases",
- "CtsAppExitTestCases",
"CtsLibcoreWycheproofBCTestCases",
"CtsMediaTestCases",
"CtsNetTestCases",
@@ -64,8 +71,10 @@
"DeviceInfo",
"DiagnosticTools",
"DisplayCutoutEmulationEmu01Overlay",
+ "DocumentsUIGoogleTests",
"DocumentsUIPerfTests",
"DocumentsUITests",
+ "DocumentsUIUnitTests",
"DownloadProvider",
"DownloadProviderTests",
"DownloadProviderUi",
@@ -75,10 +84,12 @@
"ethernet-service",
"EthernetServiceTests",
"ExternalStorageProvider",
- "ExtServices",
- "ExtServices-core",
- "framework-all",
+ "face-V1-0-javalib",
+ "FloralClocks",
+ "framework-jobscheduler",
"framework-minus-apex",
+ "framework-minus-apex-intdefs",
+ "FrameworkOverlayG6QU3",
"FrameworksCoreTests",
"FrameworksIkeTests",
"FrameworksNetCommonTests",
@@ -87,29 +98,50 @@
"FrameworksServicesTests",
"FrameworksMockingServicesTests",
"FrameworksUtilTests",
- "FrameworksWifiTests",
+ "GtsIncrementalInstallTestCases",
+ "GtsIncrementalInstallTriggerApp",
+ "GtsInstallerV2TestCases",
+ "HelloOslo",
"hid",
"hidl_test_java_java",
"hwbinder",
- "ims",
+ "imssettings",
+ "izat.lib.glue",
"KeyChain",
- "ksoap2",
+ "LocalSettingsLib",
"LocalTransport",
"lockagent",
"mediaframeworktest",
- "MediaProvider",
+ "mediatek-ims-base",
"MmsService",
- "MtpDocumentsProvider",
+ "ModemTestMode",
+ "MtkCapCtrl",
+ "MtpService",
"MultiDisplayProvider",
+ "my.tests.snapdragonsdktest",
+ "NetworkSetting",
"NetworkStackIntegrationTestsLib",
"NetworkStackNextIntegrationTests",
"NetworkStackNextTests",
"NetworkStackTests",
"NetworkStackTestsLib",
- "NfcNci",
+ "online-gcm-ref-docs",
+ "online-gts-docs",
+ "PerformanceMode",
"platform_library-docs",
+ "PowerStatsService",
"PrintSpooler",
+ "pxp-monitor",
+ "QColor",
+ "qcom.fmradio",
+ "QDCMMobileApp",
+ "Qmmi",
+ "QPerformance",
+ "remotesimlockmanagerlibrary",
"RollbackTest",
+ "sam",
+ "saminterfacelibrary",
+ "sammanagerlibrary",
"service-blobstore",
"service-connectivity-pre-jarjar",
"service-jobscheduler",
@@ -123,21 +155,50 @@
"services.usb",
"Settings-core",
"SettingsGoogle",
+ "SettingsGoogleOverlayCoral",
+ "SettingsGoogleOverlayFlame",
"SettingsLib",
+ "SettingsOverlayG020A",
+ "SettingsOverlayG020B",
+ "SettingsOverlayG020C",
+ "SettingsOverlayG020D",
+ "SettingsOverlayG020E",
+ "SettingsOverlayG020E_VN",
+ "SettingsOverlayG020F",
+ "SettingsOverlayG020F_VN",
+ "SettingsOverlayG020G",
+ "SettingsOverlayG020G_VN",
+ "SettingsOverlayG020H",
+ "SettingsOverlayG020H_VN",
+ "SettingsOverlayG020I",
+ "SettingsOverlayG020I_VN",
+ "SettingsOverlayG020J",
+ "SettingsOverlayG020M",
+ "SettingsOverlayG020N",
+ "SettingsOverlayG020P",
+ "SettingsOverlayG020Q",
+ "SettingsOverlayG025H",
+ "SettingsOverlayG025J",
+ "SettingsOverlayG025M",
+ "SettingsOverlayG025N",
+ "SettingsOverlayG5NZ6",
"SettingsProvider",
"SettingsProviderTest",
"SettingsRoboTests",
"Shell",
"ShellTests",
+ "SimContact",
+ "SimContacts",
+ "SimSettings",
"sl4a.Common",
"StatementService",
"SystemUI-core",
"SystemUISharedLib",
"SystemUI-tests",
+ "tcmiface",
"Telecom",
"TelecomUnitTests",
"telephony-common",
- "TelephonyProvider",
"TelephonyProviderTests",
"TeleService",
"testables",
@@ -147,12 +208,16 @@
"time_zone_distro_installer-tests",
"time_zone_distro-tests",
"time_zone_updater",
+ "TMobilePlanProvider",
"TvProvider",
"uiautomator-stubs-docs",
+ "uimgbamanagerlibrary",
"UsbHostExternalManagementTestApp",
"UserDictionaryProvider",
+ "UxPerformance",
"WallpaperBackup",
- "wifi-service",
+ "WallpaperBackupAgentTests",
+ "WfdCommon",
}
var legacyCorePlatformApiLookup = make(map[string]struct{})
diff --git a/java/robolectric.go b/java/robolectric.go
index 00f233e..9fe1f0e 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -405,10 +405,8 @@
}
runtimeFromSourceJar := android.OutputFileForModule(ctx, runtimeFromSourceModule, "")
- // TODO(murj) Update this to ctx.Config().PlatformSdkCodename() once the platform
- // classes like android.os.Build are updated to S.
runtimeName := fmt.Sprintf("android-all-%s-robolectric-r0.jar",
- "R")
+ ctx.Config().PlatformSdkCodename())
installedRuntime := ctx.InstallFile(androidAllDir, runtimeName, runtimeFromSourceJar)
r.runtimes = append(r.runtimes, installedRuntime)
}
diff --git a/scripts/manifest_check.py b/scripts/manifest_check.py
index 973a675..0eb1b76 100755
--- a/scripts/manifest_check.py
+++ b/scripts/manifest_check.py
@@ -19,8 +19,6 @@
from __future__ import print_function
import argparse
-import re
-import subprocess
import sys
from xml.dom import minidom
@@ -61,75 +59,25 @@
dest='extract_target_sdk_version',
action='store_true',
help='print the targetSdkVersion from the manifest')
- parser.add_argument('--aapt',
- dest='aapt',
- help='path to aapt executable')
parser.add_argument('--output', '-o', dest='output', help='output AndroidManifest.xml file')
parser.add_argument('input', help='input AndroidManifest.xml file')
return parser.parse_args()
-def enforce_uses_libraries(manifest, required, optional, relax, is_apk = False):
- """Verify that the <uses-library> tags in the manifest match those provided
- by the build system.
+def enforce_uses_libraries(doc, uses_libraries, optional_uses_libraries, relax):
+ """Verify that the <uses-library> tags in the manifest match those provided by the build system.
Args:
- manifest: manifest (either parsed XML or aapt dump of APK)
- required: required libs known to the build system
- optional: optional libs known to the build system
- relax: if true, suppress error on mismatch and just write it to file
- is_apk: if the manifest comes from an APK or an XML file
+ doc: The XML document.
+ uses_libraries: The names of <uses-library> tags known to the build system
+ optional_uses_libraries: The names of <uses-library> tags with required:fals
+ known to the build system
+ Raises:
+ RuntimeError: Invalid manifest
+ ManifestMismatchError: Manifest does not match
"""
- if is_apk:
- manifest_required, manifest_optional = extract_uses_libs_apk(manifest)
- else:
- manifest_required, manifest_optional = extract_uses_libs_xml(manifest)
- if required is None:
- required = []
-
- if optional is None:
- optional = []
-
- err = []
- if manifest_required != required:
- err.append('Expected required <uses-library> tags "%s", got "%s"' %
- (', '.join(required), ', '.join(manifest_required)))
-
- if manifest_optional != optional:
- err.append('Expected optional <uses-library> tags "%s", got "%s"' %
- (', '.join(optional), ', '.join(manifest_optional)))
-
- if err:
- errmsg = '\n'.join(err)
- if not relax:
- raise ManifestMismatchError(errmsg)
- return errmsg
-
- return None
-
-
-def extract_uses_libs_apk(badging):
- """Extract <uses-library> tags from the manifest of an APK."""
-
- pattern = re.compile("^uses-library(-not-required)?:'(.*)'$", re.MULTILINE)
-
- required = []
- optional = []
- for match in re.finditer(pattern, badging):
- libname = match.group(2)
- if match.group(1) == None:
- required.append(libname)
- else:
- optional.append(libname)
-
- return first_unique_elements(required), first_unique_elements(optional)
-
-
-def extract_uses_libs_xml(xml):
- """Extract <uses-library> tags from the manifest."""
-
- manifest = parse_manifest(xml)
+ manifest = parse_manifest(doc)
elems = get_children_with_tag(manifest, 'application')
application = elems[0] if len(elems) == 1 else None
if len(elems) > 1:
@@ -139,12 +87,58 @@
raise ManifestMismatchError('no <application> tag found')
return
+ return verify_uses_library(application, uses_libraries, optional_uses_libraries, relax)
+
+
+def verify_uses_library(application, uses_libraries, optional_uses_libraries, relax):
+ """Verify that the uses-library values known to the build system match the manifest.
+
+ Args:
+ application: the <application> tag in the manifest.
+ uses_libraries: the names of expected <uses-library> tags.
+ optional_uses_libraries: the names of expected <uses-library> tags with required="false".
+ Raises:
+ ManifestMismatchError: Manifest does not match
+ """
+
+ if uses_libraries is None:
+ uses_libraries = []
+
+ if optional_uses_libraries is None:
+ optional_uses_libraries = []
+
+ manifest_uses_libraries, manifest_optional_uses_libraries = parse_uses_library(application)
+
+ err = []
+ if manifest_uses_libraries != uses_libraries:
+ err.append('Expected required <uses-library> tags "%s", got "%s"' %
+ (', '.join(uses_libraries), ', '.join(manifest_uses_libraries)))
+
+ if manifest_optional_uses_libraries != optional_uses_libraries:
+ err.append('Expected optional <uses-library> tags "%s", got "%s"' %
+ (', '.join(optional_uses_libraries), ', '.join(manifest_optional_uses_libraries)))
+
+ if err:
+ errmsg = '\n'.join(err)
+ if not relax:
+ raise ManifestMismatchError(errmsg)
+ return errmsg
+
+ return None
+
+def parse_uses_library(application):
+ """Extract uses-library tags from the manifest.
+
+ Args:
+ application: the <application> tag in the manifest.
+ """
+
libs = get_children_with_tag(application, 'uses-library')
- required = [uses_library_name(x) for x in libs if uses_library_required(x)]
- optional = [uses_library_name(x) for x in libs if not uses_library_required(x)]
+ uses_libraries = [uses_library_name(x) for x in libs if uses_library_required(x)]
+ optional_uses_libraries = [uses_library_name(x) for x in libs if not uses_library_required(x)]
- return first_unique_elements(required), first_unique_elements(optional)
+ return first_unique_elements(uses_libraries), first_unique_elements(optional_uses_libraries)
def first_unique_elements(l):
@@ -173,34 +167,16 @@
return (required.value == 'true') if required is not None else True
-def extract_target_sdk_version(manifest, is_apk = False):
+def extract_target_sdk_version(doc):
"""Returns the targetSdkVersion from the manifest.
Args:
- manifest: manifest (either parsed XML or aapt dump of APK)
- is_apk: if the manifest comes from an APK or an XML file
+ doc: The XML document.
+ Raises:
+ RuntimeError: invalid manifest
"""
- if is_apk:
- return extract_target_sdk_version_apk(manifest)
- else:
- return extract_target_sdk_version_xml(manifest)
-
-def extract_target_sdk_version_apk(badging):
- """Extract targetSdkVersion tags from the manifest of an APK."""
-
- pattern = re.compile("^targetSdkVersion?:'(.*)'$", re.MULTILINE)
-
- for match in re.finditer(pattern, badging):
- return match.group(1)
-
- raise RuntimeError('cannot find targetSdkVersion in the manifest')
-
-
-def extract_target_sdk_version_xml(xml):
- """Extract targetSdkVersion tags from the manifest."""
-
- manifest = parse_manifest(xml)
+ manifest = parse_manifest(doc)
# Get or insert the uses-sdk element
uses_sdk = get_children_with_tag(manifest, 'uses-sdk')
@@ -227,22 +203,14 @@
try:
args = parse_args()
- # The input can be either an XML manifest or an APK, they are parsed and
- # processed in different ways.
- is_apk = args.input.endswith('.apk')
- if is_apk:
- aapt = args.aapt if args.aapt != None else "aapt"
- manifest = subprocess.check_output([aapt, "dump", "badging", args.input])
- else:
- manifest = minidom.parse(args.input)
+ doc = minidom.parse(args.input)
if args.enforce_uses_libraries:
# Check if the <uses-library> lists in the build system agree with those
# in the manifest. Raise an exception on mismatch, unless the script was
# passed a special parameter to suppress exceptions.
- errmsg = enforce_uses_libraries(manifest, args.uses_libraries,
- args.optional_uses_libraries, args.enforce_uses_libraries_relax,
- is_apk)
+ errmsg = enforce_uses_libraries(doc, args.uses_libraries,
+ args.optional_uses_libraries, args.enforce_uses_libraries_relax)
# Create a status file that is empty on success, or contains an error
# message on failure. When exceptions are suppressed, dexpreopt command
@@ -253,16 +221,11 @@
f.write("%s\n" % errmsg)
if args.extract_target_sdk_version:
- print(extract_target_sdk_version(manifest, is_apk))
+ print(extract_target_sdk_version(doc))
if args.output:
- # XML output is supposed to be written only when this script is invoked
- # with XML input manifest, not with an APK.
- if is_apk:
- raise RuntimeError('cannot save APK manifest as XML')
-
with open(args.output, 'wb') as f:
- write_xml(f, manifest)
+ write_xml(f, doc)
# pylint: disable=broad-except
except Exception as err:
diff --git a/scripts/manifest_check_test.py b/scripts/manifest_check_test.py
index 635ba9d..56c2d9e 100755
--- a/scripts/manifest_check_test.py
+++ b/scripts/manifest_check_test.py
@@ -25,38 +25,28 @@
sys.dont_write_bytecode = True
-def uses_library_xml(name, attr=''):
+def uses_library(name, attr=''):
return '<uses-library android:name="%s"%s />' % (name, attr)
-def required_xml(value):
+def required(value):
return ' android:required="%s"' % ('true' if value else 'false')
-def uses_library_apk(name, sfx=''):
- return "uses-library%s:'%s'" % (sfx, name)
-
-
-def required_apk(value):
- return '' if value else '-not-required'
-
-
class EnforceUsesLibrariesTest(unittest.TestCase):
"""Unit tests for add_extract_native_libs function."""
- def run_test(self, xml, apk, uses_libraries=[], optional_uses_libraries=[]):
- doc = minidom.parseString(xml)
+ def run_test(self, input_manifest, uses_libraries=None, optional_uses_libraries=None):
+ doc = minidom.parseString(input_manifest)
try:
relax = False
manifest_check.enforce_uses_libraries(doc, uses_libraries,
- optional_uses_libraries, relax, is_apk=False)
- manifest_check.enforce_uses_libraries(apk, uses_libraries,
- optional_uses_libraries, relax, is_apk=True)
+ optional_uses_libraries, relax)
return True
except manifest_check.ManifestMismatchError:
return False
- xml_tmpl = (
+ manifest_tmpl = (
'<?xml version="1.0" encoding="utf-8"?>\n'
'<manifest xmlns:android="http://schemas.android.com/apk/res/android">\n'
' <application>\n'
@@ -64,155 +54,115 @@
' </application>\n'
'</manifest>\n')
- apk_tmpl = (
- "package: name='com.google.android.something' versionCode='100'\n"
- "sdkVersion:'29'\n"
- "targetSdkVersion:'29'\n"
- "uses-permission: name='android.permission.ACCESS_NETWORK_STATE'\n"
- "%s\n"
- "densities: '160' '240' '320' '480' '640' '65534")
-
def test_uses_library(self):
- xml = self.xml_tmpl % (uses_library_xml('foo'))
- apk = self.apk_tmpl % (uses_library_apk('foo'))
- matches = self.run_test(xml, apk, uses_libraries=['foo'])
+ manifest_input = self.manifest_tmpl % (uses_library('foo'))
+ matches = self.run_test(manifest_input, uses_libraries=['foo'])
self.assertTrue(matches)
def test_uses_library_required(self):
- xml = self.xml_tmpl % (uses_library_xml('foo', required_xml(True)))
- apk = self.apk_tmpl % (uses_library_apk('foo', required_apk(True)))
- matches = self.run_test(xml, apk, uses_libraries=['foo'])
+ manifest_input = self.manifest_tmpl % (uses_library('foo', required(True)))
+ matches = self.run_test(manifest_input, uses_libraries=['foo'])
self.assertTrue(matches)
def test_optional_uses_library(self):
- xml = self.xml_tmpl % (uses_library_xml('foo', required_xml(False)))
- apk = self.apk_tmpl % (uses_library_apk('foo', required_apk(False)))
- matches = self.run_test(xml, apk, optional_uses_libraries=['foo'])
+ manifest_input = self.manifest_tmpl % (uses_library('foo', required(False)))
+ matches = self.run_test(manifest_input, optional_uses_libraries=['foo'])
self.assertTrue(matches)
def test_expected_uses_library(self):
- xml = self.xml_tmpl % (uses_library_xml('foo', required_xml(False)))
- apk = self.apk_tmpl % (uses_library_apk('foo', required_apk(False)))
- matches = self.run_test(xml, apk, uses_libraries=['foo'])
+ manifest_input = self.manifest_tmpl % (uses_library('foo', required(False)))
+ matches = self.run_test(manifest_input, uses_libraries=['foo'])
self.assertFalse(matches)
def test_expected_optional_uses_library(self):
- xml = self.xml_tmpl % (uses_library_xml('foo'))
- apk = self.apk_tmpl % (uses_library_apk('foo'))
- matches = self.run_test(xml, apk, optional_uses_libraries=['foo'])
+ manifest_input = self.manifest_tmpl % (uses_library('foo'))
+ matches = self.run_test(manifest_input, optional_uses_libraries=['foo'])
self.assertFalse(matches)
def test_missing_uses_library(self):
- xml = self.xml_tmpl % ('')
- apk = self.apk_tmpl % ('')
- matches = self.run_test(xml, apk, uses_libraries=['foo'])
+ manifest_input = self.manifest_tmpl % ('')
+ matches = self.run_test(manifest_input, uses_libraries=['foo'])
self.assertFalse(matches)
def test_missing_optional_uses_library(self):
- xml = self.xml_tmpl % ('')
- apk = self.apk_tmpl % ('')
- matches = self.run_test(xml, apk, optional_uses_libraries=['foo'])
+ manifest_input = self.manifest_tmpl % ('')
+ matches = self.run_test(manifest_input, optional_uses_libraries=['foo'])
self.assertFalse(matches)
def test_extra_uses_library(self):
- xml = self.xml_tmpl % (uses_library_xml('foo'))
- apk = self.apk_tmpl % (uses_library_xml('foo'))
- matches = self.run_test(xml, apk)
+ manifest_input = self.manifest_tmpl % (uses_library('foo'))
+ matches = self.run_test(manifest_input)
self.assertFalse(matches)
def test_extra_optional_uses_library(self):
- xml = self.xml_tmpl % (uses_library_xml('foo', required_xml(False)))
- apk = self.apk_tmpl % (uses_library_apk('foo', required_apk(False)))
- matches = self.run_test(xml, apk)
+ manifest_input = self.manifest_tmpl % (uses_library('foo', required(False)))
+ matches = self.run_test(manifest_input)
self.assertFalse(matches)
def test_multiple_uses_library(self):
- xml = self.xml_tmpl % ('\n'.join([uses_library_xml('foo'),
- uses_library_xml('bar')]))
- apk = self.apk_tmpl % ('\n'.join([uses_library_apk('foo'),
- uses_library_apk('bar')]))
- matches = self.run_test(xml, apk, uses_libraries=['foo', 'bar'])
+ manifest_input = self.manifest_tmpl % ('\n'.join([uses_library('foo'),
+ uses_library('bar')]))
+ matches = self.run_test(manifest_input, uses_libraries=['foo', 'bar'])
self.assertTrue(matches)
def test_multiple_optional_uses_library(self):
- xml = self.xml_tmpl % ('\n'.join([uses_library_xml('foo', required_xml(False)),
- uses_library_xml('bar', required_xml(False))]))
- apk = self.apk_tmpl % ('\n'.join([uses_library_apk('foo', required_apk(False)),
- uses_library_apk('bar', required_apk(False))]))
- matches = self.run_test(xml, apk, optional_uses_libraries=['foo', 'bar'])
+ manifest_input = self.manifest_tmpl % ('\n'.join([uses_library('foo', required(False)),
+ uses_library('bar', required(False))]))
+ matches = self.run_test(manifest_input, optional_uses_libraries=['foo', 'bar'])
self.assertTrue(matches)
def test_order_uses_library(self):
- xml = self.xml_tmpl % ('\n'.join([uses_library_xml('foo'),
- uses_library_xml('bar')]))
- apk = self.apk_tmpl % ('\n'.join([uses_library_apk('foo'),
- uses_library_apk('bar')]))
- matches = self.run_test(xml, apk, uses_libraries=['bar', 'foo'])
+ manifest_input = self.manifest_tmpl % ('\n'.join([uses_library('foo'),
+ uses_library('bar')]))
+ matches = self.run_test(manifest_input, uses_libraries=['bar', 'foo'])
self.assertFalse(matches)
def test_order_optional_uses_library(self):
- xml = self.xml_tmpl % ('\n'.join([uses_library_xml('foo', required_xml(False)),
- uses_library_xml('bar', required_xml(False))]))
- apk = self.apk_tmpl % ('\n'.join([uses_library_apk('foo', required_apk(False)),
- uses_library_apk('bar', required_apk(False))]))
- matches = self.run_test(xml, apk, optional_uses_libraries=['bar', 'foo'])
+ manifest_input = self.manifest_tmpl % ('\n'.join([uses_library('foo', required(False)),
+ uses_library('bar', required(False))]))
+ matches = self.run_test(manifest_input, optional_uses_libraries=['bar', 'foo'])
self.assertFalse(matches)
def test_duplicate_uses_library(self):
- xml = self.xml_tmpl % ('\n'.join([uses_library_xml('foo'),
- uses_library_xml('foo')]))
- apk = self.apk_tmpl % ('\n'.join([uses_library_apk('foo'),
- uses_library_apk('foo')]))
- matches = self.run_test(xml, apk, uses_libraries=['foo'])
+ manifest_input = self.manifest_tmpl % ('\n'.join([uses_library('foo'),
+ uses_library('foo')]))
+ matches = self.run_test(manifest_input, uses_libraries=['foo'])
self.assertTrue(matches)
def test_duplicate_optional_uses_library(self):
- xml = self.xml_tmpl % ('\n'.join([uses_library_xml('foo', required_xml(False)),
- uses_library_xml('foo', required_xml(False))]))
- apk = self.apk_tmpl % ('\n'.join([uses_library_apk('foo', required_apk(False)),
- uses_library_apk('foo', required_apk(False))]))
- matches = self.run_test(xml, apk, optional_uses_libraries=['foo'])
+ manifest_input = self.manifest_tmpl % ('\n'.join([uses_library('foo', required(False)),
+ uses_library('foo', required(False))]))
+ matches = self.run_test(manifest_input, optional_uses_libraries=['foo'])
self.assertTrue(matches)
def test_mixed(self):
- xml = self.xml_tmpl % ('\n'.join([uses_library_xml('foo'),
- uses_library_xml('bar', required_xml(False))]))
- apk = self.apk_tmpl % ('\n'.join([uses_library_apk('foo'),
- uses_library_apk('bar', required_apk(False))]))
- matches = self.run_test(xml, apk, uses_libraries=['foo'],
+ manifest_input = self.manifest_tmpl % ('\n'.join([uses_library('foo'),
+ uses_library('bar', required(False))]))
+ matches = self.run_test(manifest_input, uses_libraries=['foo'],
optional_uses_libraries=['bar'])
self.assertTrue(matches)
class ExtractTargetSdkVersionTest(unittest.TestCase):
- def run_test(self, xml, apk, version):
- doc = minidom.parseString(xml)
- v = manifest_check.extract_target_sdk_version(doc, is_apk=False)
- self.assertEqual(v, version)
- v = manifest_check.extract_target_sdk_version(apk, is_apk=True)
- self.assertEqual(v, version)
-
- xml_tmpl = (
+ def test_target_sdk_version(self):
+ manifest = (
'<?xml version="1.0" encoding="utf-8"?>\n'
'<manifest xmlns:android="http://schemas.android.com/apk/res/android">\n'
- ' <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="%s" />\n'
+ ' <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="29" />\n'
'</manifest>\n')
+ doc = minidom.parseString(manifest)
+ target_sdk_version = manifest_check.extract_target_sdk_version(doc)
+ self.assertEqual(target_sdk_version, '29')
- apk_tmpl = (
- "package: name='com.google.android.something' versionCode='100'\n"
- "sdkVersion:'28'\n"
- "targetSdkVersion:'%s'\n"
- "uses-permission: name='android.permission.ACCESS_NETWORK_STATE'\n")
-
- def test_targert_sdk_version_28(self):
- xml = self.xml_tmpl % "28"
- apk = self.apk_tmpl % "28"
- self.run_test(xml, apk, "28")
-
- def test_targert_sdk_version_29(self):
- xml = self.xml_tmpl % "29"
- apk = self.apk_tmpl % "29"
- self.run_test(xml, apk, "29")
+ def test_min_sdk_version(self):
+ manifest = (
+ '<?xml version="1.0" encoding="utf-8"?>\n'
+ '<manifest xmlns:android="http://schemas.android.com/apk/res/android">\n'
+ ' <uses-sdk android:minSdkVersion="28" />\n'
+ '</manifest>\n')
+ doc = minidom.parseString(manifest)
+ target_sdk_version = manifest_check.extract_target_sdk_version(doc)
+ self.assertEqual(target_sdk_version, '28')
if __name__ == '__main__':
unittest.main(verbosity=2)