Cleanup hardcoded references to android_*stubs_current

These hardcoded refs will need to be updated when we start using .txt
stub equivalent (single-tree/multi-tree). Instead of strewing this logic
all over the codebase, create a helper function that contains the
replacement logic. All other places should call this helper function
instead of calculating the name of .txt equivalent soong module by
itself.

(Will do a similar cleanup in build/make)

Test: no change in ninja file

Change-Id: I6bf999eb4aeaba6ac2a44b9016bae4ec8c79ce19
diff --git a/android/sdk_version.go b/android/sdk_version.go
index a7e03dc..cace88a 100644
--- a/android/sdk_version.go
+++ b/android/sdk_version.go
@@ -84,6 +84,40 @@
 	}
 }
 
+// JavaLibraryName returns the soong module containing the Java APIs of that API surface.
+func (k SdkKind) JavaLibraryName(c Config) string {
+	name := k.defaultJavaLibraryName()
+	return JavaLibraryNameFromText(c, name)
+}
+
+// JavaLibraryNameFromText returns the name of .txt equivalent of a java_library, but does
+// not check if either module exists.
+// TODO: Return .txt (single-tree or multi-tree equivalents) based on config
+func JavaLibraryNameFromText(c Config, name string) string {
+	// This returns the default for now.
+	// TODO: Implement this
+	return name
+}
+
+func (k SdkKind) defaultJavaLibraryName() string {
+	switch k {
+	case SdkPublic:
+		return "android_stubs_current"
+	case SdkSystem:
+		return "android_system_stubs_current"
+	case SdkTest:
+		return "android_test_stubs_current"
+	case SdkCore:
+		return "core.current.stubs"
+	case SdkModule:
+		return "android_module_lib_stubs_current"
+	case SdkSystemServer:
+		return "android_system_server_stubs_current"
+	default:
+		panic(fmt.Errorf("APIs of API surface %v cannot be provided by a single Soong module\n", k))
+	}
+}
+
 // SdkSpec represents the kind and the version of an SDK for a module to build against
 type SdkSpec struct {
 	Kind     SdkKind