From 0c2e08312cdb9f9c568e4894912d0d3031cb6557 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 28 Apr 2021 00:39:52 +0100 Subject: [PATCH] Extract IsModuleInVersionedSdk Bug: 177892522 Test: m nothing Change-Id: I348d380a0d29abdd6a84420be52cc1b674f2a7ab --- android/sdk.go | 10 ++++++++++ java/bootclasspath_fragment.go | 4 ++-- java/platform_compat_config.go | 6 ++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/android/sdk.go b/android/sdk.go index 5521f4a31..6fc1910d0 100644 --- a/android/sdk.go +++ b/android/sdk.go @@ -171,6 +171,16 @@ func InitSdkAwareModule(m SdkAware) { m.AddProperties(&base.properties) } +// IsModuleInVersionedSdk returns true if the module is an versioned sdk. +func IsModuleInVersionedSdk(module Module) bool { + if s, ok := module.(SdkAware); ok { + if !s.ContainingSdk().Unversioned() { + return true + } + } + return false +} + // Provide support for generating the build rules which will build the snapshot. type SnapshotBuilder interface { // Copy src to the dest (which is a snapshot relative path) and add the dest diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index ef2cdae27..5c1c5f0c9 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -150,7 +150,7 @@ func bootclasspathFragmentInitContentsFromImage(ctx android.EarlyModuleContext, imageName := proptools.String(m.properties.Image_name) if imageName == "art" { // TODO(b/177892522): Prebuilts (versioned or not) should not use the image_name property. - if m.MemberName() != "" { + if android.IsModuleInVersionedSdk(m) { // The module is a versioned prebuilt so ignore it. This is done for a couple of reasons: // 1. There is no way to use this at the moment so ignoring it is safe. // 2. Attempting to initialize the contents property from the configuration will end up having @@ -205,7 +205,7 @@ func (b *BootclasspathFragmentModule) bootclasspathImageNameContentsConsistencyC imageName := proptools.String(b.properties.Image_name) if imageName == "art" { // TODO(b/177892522): Prebuilts (versioned or not) should not use the image_name property. - if b.MemberName() != "" { + if android.IsModuleInVersionedSdk(b) { // The module is a versioned prebuilt so ignore it. This is done for a couple of reasons: // 1. There is no way to use this at the moment so ignoring it is safe. // 2. Attempting to initialize the contents property from the configuration will end up having diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index edfa146f9..712c2a203 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -226,10 +226,8 @@ type platformCompatConfigSingleton struct { func isModulePreferredByCompatConfig(module android.Module) bool { // A versioned prebuilt_platform_compat_config, i.e. foo-platform-compat-config@current should be // ignored. - if s, ok := module.(android.SdkAware); ok { - if !s.ContainingSdk().Unversioned() { - return false - } + if android.IsModuleInVersionedSdk(module) { + return false } return android.IsModulePreferred(module)