Track more static dependencies for notice files

Track transitive static dependencies of native binaries, and
and direct and transitive static dependencies of java and app
modules.

Bug: 112331930
Test: m checkbuild
Change-Id: I0e19971033d6254bfbb6555f0e68fd5e529569c6
diff --git a/core/binary.mk b/core/binary.mk
index 73d420c..4a65c6e 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -1608,6 +1608,9 @@
 installed_static_library_notice_file_targets :=
 endif
 
+$(notice_target): | $(installed_static_library_notice_file_targets)
+$(LOCAL_INSTALLED_MODULE): | $(notice_target)
+
 # Default is -fno-rtti.
 ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
 LOCAL_RTTI_FLAG := -fno-rtti
@@ -1813,11 +1816,6 @@
     $(built_static_libraries) \
     $(built_whole_libraries)
 
-# Also depend on the notice files for any static libraries that
-# are linked into this module.  This will force them to be installed
-# when this module is.
-$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets)
-
 ###########################################################
 # Export includes
 ###########################################################