From ea4c692875c8338f9970f7a4a7b383eae3400b7a Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Thu, 2 Mar 2023 04:41:35 +0000 Subject: [PATCH] Prework for migrating min_sdk_version from (kind+level) to (level) Currently, the following lib will be included in the sdk snapshot even though it is compiling against private apis ``` java_sdk_library { name: "foo", //sdk_version defaults to "", i.e. SdkSpecPrivate } ``` This is because min_sdk_version of `foo` inherits the api level of SdkSpecPrivate (i.e. FutureApiLevel). As part of the migration of min_sdk_version to ApiLevel, the api level of SdkSpecPrivate will be different than FutureApiLevel. In the above example, assuming the version of the sdk_snapshot is FutureApiLevel, `foo` will be included only if it explicitly sets a min_sdk_version <= FutureApiLevel. Update an existing unit test to set this value explicitly. Bug: 208456999 Test: go test ./sdk (top of CL stack) Change-Id: Iddd497df7da8c829325d902fbf70731dd8c6855d --- sdk/bootclasspath_fragment_sdk_test.go | 1 + sdk/update.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go index efb97be37..0d6496dd3 100644 --- a/sdk/bootclasspath_fragment_sdk_test.go +++ b/sdk/bootclasspath_fragment_sdk_test.go @@ -839,6 +839,7 @@ func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) { compile_dex: true, public: {enabled: true}, permitted_packages: ["mysdklibrary"], + min_sdk_version: "current", } java_sdk_library { diff --git a/sdk/update.go b/sdk/update.go index 0820d62b8..bed7f5254 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -319,7 +319,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext, sdkVariants []*sdk) { targetBuildRelease := s.targetBuildRelease(ctx) targetApiLevel, err := android.ApiLevelFromUser(ctx, targetBuildRelease.name) if err != nil { - targetApiLevel = android.FutureApiLevel + targetApiLevel = android.InvalidApiLevel } // Aggregate all the sdkMemberVariantDep instances from all the sdk variants.