Don't make SplitPerApiLevel imply UseSdk

UseSdk was returning true when SplitPerApiLevel returned true,
which was causing the platform variant of SplitPerApiLevel
module to compile against the SDK.  Check SplitPerApiLevel
separately in the sdkMutator instead.

Test: m checkbuild
Change-Id: I0ae667d48a3b7b96709a6cad8e8ea9701659fc2a
diff --git a/cc/cc.go b/cc/cc.go
index caefea4..006a4a5 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -697,6 +697,9 @@
 }
 
 func (c *Module) SplitPerApiLevel() bool {
+	if !c.canUseSdk() {
+		return false
+	}
 	if linker, ok := c.linker.(*objectLinker); ok {
 		return linker.isCrt()
 	}
@@ -1026,7 +1029,7 @@
 
 func (c *Module) UseSdk() bool {
 	if c.canUseSdk() {
-		return String(c.Properties.Sdk_version) != "" || c.SplitPerApiLevel()
+		return String(c.Properties.Sdk_version) != ""
 	}
 	return false
 }
diff --git a/cc/linkable.go b/cc/linkable.go
index 6d8a4b7..a67cd4e 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -63,6 +63,8 @@
 	ToolchainLibrary() bool
 	NdkPrebuiltStl() bool
 	StubDecorator() bool
+
+	SplitPerApiLevel() bool
 }
 
 var (
diff --git a/cc/sdk.go b/cc/sdk.go
index b68baad..ec57f06 100644
--- a/cc/sdk.go
+++ b/cc/sdk.go
@@ -32,11 +32,11 @@
 	switch m := ctx.Module().(type) {
 	case LinkableInterface:
 		if m.AlwaysSdk() {
-			if !m.UseSdk() {
+			if !m.UseSdk() && !m.SplitPerApiLevel() {
 				ctx.ModuleErrorf("UseSdk() must return true when AlwaysSdk is set, did the factory forget to set Sdk_version?")
 			}
 			ctx.CreateVariations("sdk")
-		} else if m.UseSdk() {
+		} else if m.UseSdk() || m.SplitPerApiLevel() {
 			modules := ctx.CreateVariations("", "sdk")
 			modules[0].(*Module).Properties.Sdk_version = nil
 			modules[1].(*Module).Properties.IsSdkVariant = true