Always specify version to use aidl_interface except it is unstable

As-is, the rule for versions of generated modules from aidl_interface is
implicit and messy. For example, the version that <aidl_interface>-cpp
stands for can be different depending on the context(it can be the
latest stable version n or unstable version). And the version
<aidl_interface>-unstable-* or <aidl_interface>-* refers to can be
changed in accordance with freezing the interface. And also, for native
modules, version name and generated library file name is sometimes
mismatched.

So, I make it more explicit. There are only two rules
1. If an interface is unstable, the generated module name is
<aidl_interface>-<backend>

2. If not, the generated module name is always
<aidl_interface>-V<version>-<backend> (the version for ToT version is
the latest version + 1)

And the library name(so, jar, and so on) is the same as the generated
module name.

In terms of implemenation, the logic around version is getting simpler.
And Java, C++, NDK module creation logic is moved to PreArchMutator
because the other aidl_interface's version infomation is unknown
in the LoadHook phase, so we cannot find proper imported library name
which includes the version

Note that AIDL still generates <aidl_interface>-<backend> and
<aidl_interface>-unstable-<backend> to prevent unexpected breakage in
downstream branch and apply the change gradually, but it will be done
before release.

Bug: 150578172
Bug: 178138244
Test: m nothing

Change-Id: I7d5ed804843360a4e5e94ce9bb391cee5904402f
Merged-In: I7d5ed804843360a4e5e94ce9bb391cee5904402f
(cherry picked from commit cbda12e517c0c39b82992b5584c5f130c87477a3)
diff --git a/build/aidl_api.go b/build/aidl_api.go
index 496e2a5..2a45d3b 100644
--- a/build/aidl_api.go
+++ b/build/aidl_api.go
@@ -82,18 +82,7 @@
 
 // `m <iface>-freeze-api` will freeze ToT as this version
 func (m *aidlApi) nextVersion() string {
-	if len(m.properties.Versions) == 0 {
-		return "1"
-	} else {
-		latestVersion := m.properties.Versions[len(m.properties.Versions)-1]
-
-		i, err := strconv.Atoi(latestVersion)
-		if err != nil {
-			panic(err)
-		}
-
-		return strconv.Itoa(i + 1)
-	}
+	return nextVersion(m.properties.Versions)
 }
 
 type apiDump struct {
@@ -370,7 +359,7 @@
 
 func addApiModule(mctx android.LoadHookContext, i *aidlInterface) string {
 	apiModule := i.ModuleBase.Name() + aidlApiSuffix
-	srcs, aidlRoot := i.srcsForVersion(mctx, i.currentVersion())
+	srcs, aidlRoot := i.srcsForVersion(mctx, i.nextVersion())
 	mctx.CreateModule(aidlApiFactory, &nameProperties{
 		Name: proptools.StringPtr(apiModule),
 	}, &aidlApiProperties{