From e5ad90c37bc433ff3fb2058430bc64b67334dd6d Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 3 Nov 2021 16:44:22 +0000 Subject: [PATCH] Dedup logic for selecting system modules Previously, the selection of system modules was duplicated, once for source and once for prebuilts. This change dedups that by switching the source code to use the same mechanism as the prebuilts which will ensure consistent behavior in future. Bug: 204189791 Test: m nothing Change-Id: Ia1729017ae332181c95f7b205dab87fb47d43fb8 --- java/sdk.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/java/sdk.go b/java/sdk.go index 697deb1ec..e6bf220b4 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -141,11 +141,13 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) } } - toModule := func(systemModules string, module string, aidl android.Path) sdkDep { + toModule := func(module string, aidl android.Path) sdkDep { + // Select the kind of system modules needed for the sdk version. + systemModulesKind := systemModuleKind(sdkVersion.Kind, android.FutureApiLevel) return sdkDep{ useModule: true, bootclasspath: []string{module, config.DefaultLambdaStubsLibrary}, - systemModules: systemModules, + systemModules: fmt.Sprintf("core-%s-stubs-system-modules", systemModulesKind), java9Classpath: []string{module}, frameworkResModule: "framework-res", aidl: android.OptionalPathForPath(aidl), @@ -186,11 +188,11 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) noFrameworksLibs: true, } case android.SdkPublic: - return toModule("core-public-stubs-system-modules", "android_stubs_current", sdkFrameworkAidlPath(ctx)) + return toModule("android_stubs_current", sdkFrameworkAidlPath(ctx)) case android.SdkSystem: - return toModule("core-public-stubs-system-modules", "android_system_stubs_current", sdkFrameworkAidlPath(ctx)) + return toModule("android_system_stubs_current", sdkFrameworkAidlPath(ctx)) case android.SdkTest: - return toModule("core-public-stubs-system-modules", "android_test_stubs_current", sdkFrameworkAidlPath(ctx)) + return toModule("android_test_stubs_current", sdkFrameworkAidlPath(ctx)) case android.SdkCore: return sdkDep{ useModule: true, @@ -200,10 +202,10 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) } case android.SdkModule: // TODO(146757305): provide .apk and .aidl that have more APIs for modules - return toModule("core-module-lib-stubs-system-modules", "android_module_lib_stubs_current", nonUpdatableFrameworkAidlPath(ctx)) + return toModule("android_module_lib_stubs_current", nonUpdatableFrameworkAidlPath(ctx)) case android.SdkSystemServer: // TODO(146757305): provide .apk and .aidl that have more APIs for modules - return toModule("core-module-lib-stubs-system-modules", "android_system_server_stubs_current", sdkFrameworkAidlPath(ctx)) + return toModule("android_system_server_stubs_current", sdkFrameworkAidlPath(ctx)) default: panic(fmt.Errorf("invalid sdk %q", sdkVersion.Raw)) }