java_sdk_library: Simplify SdkLibrary.sdkJars
The expression !sdkVersion.specified() is equivalent to the following:
!sdkVersion.valid() || sdkVersion.kind == sdkPrivate
That means that the else if clause "sdkVersion.kind == sdkPrivate" will
never be reached so it was removed.
There is also no need to check sdkVersion.valid() as that will already
have been checked, and an error reported, before this code has been
called. Therefore that has been removed.
Bug: 148080325
Test: m nothing
Change-Id: Ib7c544b48dfb53bad3e15f9f73f71bd05cff9b49
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 2bdfe0d..8231278 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -1296,14 +1296,15 @@
func (module *SdkLibrary) sdkJars(ctx android.BaseModuleContext, sdkVersion sdkSpec, headerJars bool) android.Paths {
// Check any special cases for java_sdk_library.
- if !sdkVersion.specified() {
+ //
+ // Only allow access to the implementation library in the following condition:
+ // * No sdk_version specified on the referencing module.
+ if sdkVersion.kind == sdkPrivate {
if headerJars {
return module.HeaderJars()
} else {
return module.ImplementationJars()
}
- } else if sdkVersion.kind == sdkPrivate {
- return module.HeaderJars()
}
return module.selectHeaderJarsForSdkVersion(ctx, sdkVersion)