From 260bd316bf3b8722ddf3b9c11ca54b519466d189 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 28 Apr 2020 14:15:17 +0100 Subject: [PATCH 1/2] Fix definition of android_stubs_current in sdk tests This change fixes an issue with the definition of the android_stubs_current (and similar) modules in the sdk tests. They were incorrectly defined as java_sdk_library_import and not java_import. Test: m nothing Bug: 155164730 Change-Id: I4e9bfebdd2ff0a374e12284ccdf5ee5518968969 --- sdk/java_sdk_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go index c0ad35c3f..788d0166e 100644 --- a/sdk/java_sdk_test.go +++ b/sdk/java_sdk_test.go @@ -46,13 +46,13 @@ java_system_modules_import { java_import { name: "core.platform.api.stubs", } -java_sdk_library_import { +java_import { name: "android_stubs_current", } -java_sdk_library_import { +java_import { name: "android_system_stubs_current", } -java_sdk_library_import { +java_import { name: "android_test_stubs_current", } java_import { From 7b78b4d404328b5555ff720bb06d627e009d8db6 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Tue, 28 Apr 2020 14:08:32 +0100 Subject: [PATCH 2/2] java_sdk_library: Correct stubs source generation classpath The stubs source should be generated using the same classpath that is used to compile the implementation library, i.e. sdk_version, system_modules and libs/static_libs. Previously, the sdk_version used to generate the stubs was different. It provided access to a wider API surface than was necessary. This change fixes that. Test: m checkapi Bug: 155164730 Change-Id: I7bc54dc4ad12a7d6c7503111d1322ee35c56d713 --- java/sdk_library.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/java/sdk_library.go b/java/sdk_library.go index 6fa315082..9e3ad5bfa 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -498,17 +498,15 @@ func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiSc } }{} - sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) - // Use the platform API if standard libraries were requested, otherwise use - // no default libraries. - sdkVersion := "" - if !sdkDep.hasStandardLibs() { - sdkVersion = "none" - } + // The stubs source processing uses the same compile time classpath when extracting the + // API from the implementation library as it does when compiling it. i.e. the same + // * sdk version + // * system_modules + // * libs (static_libs/libs) props.Name = proptools.StringPtr(module.docsName(apiScope)) props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...) - props.Sdk_version = proptools.StringPtr(sdkVersion) + props.Sdk_version = module.Library.Module.deviceProperties.Sdk_version props.System_modules = module.Library.Module.deviceProperties.System_modules props.Installable = proptools.BoolPtr(false) // A droiddoc module has only one Libs property and doesn't distinguish between