From dbcc29647ac87d6c3ea4ae183d23291d890c8f9d Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 15 Jul 2021 13:35:26 +0100 Subject: [PATCH] Build updatable-bcp-packages.txt from prebuilts in sdk snapshot Previously, the java_import and java_sdk_library_import modules did not make their permitted_packages available to the rule that generates the updatable-bcp-packages.txt file. This change corrects that. Bug: 193095050 Test: m nothing - Added unit tests, which all failed and then fixed the tests. Merged-In: If0706e4551a331b48d383123088e63924dded48b Change-Id: If0706e4551a331b48d383123088e63924dded48b (cherry picked from commit 630b11e9d4d63e5fabaa20adf5d1b1c81ede6681) --- apex/platform_bootclasspath_test.go | 1 + java/java.go | 6 ++++++ java/sdk_library.go | 6 ++++++ sdk/bootclasspath_fragment_sdk_test.go | 6 ++++++ 4 files changed, 19 insertions(+) diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go index bd4a9d599..bc354790f 100644 --- a/apex/platform_bootclasspath_test.go +++ b/apex/platform_bootclasspath_test.go @@ -398,6 +398,7 @@ func TestPlatformBootclasspath_AlwaysUsePrebuiltSdks(t *testing.T) { name: "foo", prefer: false, shared_library: false, + permitted_packages: ["foo"], public: { jars: ["sdk_library/public/foo-stubs.jar"], stub_srcs: ["sdk_library/public/foo_stub_sources"], diff --git a/java/java.go b/java/java.go index 727cef5ee..bbed42def 100644 --- a/java/java.go +++ b/java/java.go @@ -1192,6 +1192,12 @@ type Import struct { minSdkVersion android.SdkSpec } +var _ PermittedPackagesForUpdatableBootJars = (*Import)(nil) + +func (j *Import) PermittedPackagesForUpdatableBootJars() []string { + return j.properties.Permitted_packages +} + func (j *Import) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec { return android.SdkSpecFrom(ctx, String(j.properties.Sdk_version)) } diff --git a/java/sdk_library.go b/java/sdk_library.go index c0e566283..8c664383d 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1991,6 +1991,12 @@ func sdkLibraryImportFactory() android.Module { return module } +var _ PermittedPackagesForUpdatableBootJars = (*SdkLibraryImport)(nil) + +func (module *SdkLibraryImport) PermittedPackagesForUpdatableBootJars() []string { + return module.properties.Permitted_packages +} + func (module *SdkLibraryImport) Prebuilt() *android.Prebuilt { return &module.prebuilt } diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go index c30324a85..412e80682 100644 --- a/sdk/bootclasspath_fragment_sdk_test.go +++ b/sdk/bootclasspath_fragment_sdk_test.go @@ -532,6 +532,12 @@ sdk_snapshot { out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv snapshot/hiddenapi/index.csv `, rule) + + // Make sure that the permitted packages from the prebuilts end up in the + // updatable-bcp-packages.txt file. + rule = module.Output("updatable-bcp-packages.txt") + expectedContents := `'mybootlib\nmyothersdklibrary\n'` + android.AssertStringEquals(t, "updatable-bcp-packages.txt", expectedContents, rule.Args["content"]) }), snapshotTestPreparer(checkSnapshotWithSourcePreferred, preparerForSnapshot), snapshotTestPreparer(checkSnapshotPreferredWithSource, preparerForSnapshot),