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
Merged-In: I0e19971033d6254bfbb6555f0e68fd5e529569c6
(cherry picked from commit 579668b122d88b9c810238412ab003192bf15d2b)
diff --git a/core/binary.mk b/core/binary.mk
index 954df1f..61cd5cf 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -1587,6 +1587,9 @@
     $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \
       NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib))
 
+$(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
@@ -1783,11 +1786,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
 ###########################################################