Add '-java-shallow' library.

Originally, we used to have '-java' and '-java-static' libraries.
However, when the build system was updated so that a static java
library could be used as either a shared library or a static library,
these two module types are combined into just '-java' (since people
could use this in both contexts).

However, this introduced another problem. Imagine this scenario with
interface IFoo inherits from IBar.

java lib A
    - statically includes IFoo (using '-java')
          (implicitly statically includes IBar)
    - shared links B
java lib B statically includes IBar (using '-java')

Because '-java' always has static libs, IBar gets duplicated twice.
This problem went unnoticed/unreported, but now that Android is
being more strict about hiddenapi and classes duplicated on the class
path, the build system has been erroring on this case.

With this change, now the following is possible:

java lib A statically includes IFoo (using '-java-shallow')
java lib B statically includes IBar (using either version)

Now IBar is no longer duplicated.

Bug: 127875362
Test: manual
Change-Id: Icc3ebf39fca4073cc24012351d6151bf8ea4642b
diff --git a/build/hidl_interface.go b/build/hidl_interface.go
index 0154a61..7892193 100644
--- a/build/hidl_interface.go
+++ b/build/hidl_interface.go
@@ -507,13 +507,12 @@
 			Inputs:     i.properties.Srcs,
 			Outputs:    []string{"srcs.srcjar"},
 		}, &i.inheritCommonProperties)
-		mctx.CreateModule(android.ModuleFactoryAdaptor(java.LibraryFactory), &javaProperties{
-			Name:              proptools.StringPtr(name.javaName()),
+
+		commonJavaProperties := javaProperties{
 			Defaults:          []string{"hidl-java-module-defaults"},
 			No_framework_libs: proptools.BoolPtr(true),
 			Installable:       proptools.BoolPtr(true),
 			Srcs:              []string{":" + name.javaSourcesName()},
-			Static_libs:       javaDependencies,
 
 			// This should ideally be system_current, but android.hidl.base-V1.0-java is used
 			// to build framework, which is used to build system_current.  Use core_current
@@ -521,7 +520,16 @@
 			// not depend on framework.
 			Sdk_version: proptools.StringPtr("core_current"),
 			Libs:        []string{"hwbinder.stubs"},
-		}, &i.inheritCommonProperties)
+		}
+
+		mctx.CreateModule(android.ModuleFactoryAdaptor(java.LibraryFactory), &javaProperties{
+			Name:        proptools.StringPtr(name.javaName()),
+			Static_libs: javaDependencies,
+		}, &i.inheritCommonProperties, &commonJavaProperties)
+		mctx.CreateModule(android.ModuleFactoryAdaptor(java.LibraryFactory), &javaProperties{
+			Name: proptools.StringPtr(name.javaSharedName()),
+			Libs: javaDependencies,
+		}, &i.inheritCommonProperties, &commonJavaProperties)
 	}
 
 	if shouldGenerateJavaConstants {