Strengthen dependencies on LOCAL_REQUIRED_MODULES

Bug: 6418863
This change expands the PRODUCT_PACKAGES with the required modules.
Before this change, since the required modules are not in the
PRODUCT_PACKAGES, they are not directly depended on by the image files.
If the dependent is not to be included in the image but the required
modules are to be included, the dependency of the image on the required
modules gets lost!
That would lead to build race condition.

Change-Id: Idbd504fd415b488c397e67ab487a22bff4fa188e
diff --git a/core/main.mk b/core/main.mk
index c22c967..fa56b83 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -546,13 +546,9 @@
   # The base list of modules to build for this product is specified
   # by the appropriate product definition file, which was included
   # by product_config.make.
-  user_PACKAGES := $(call module-installed-files, \
-                       $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES))
-  ifeq (0,1)
-    $(info user packages for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
-    $(foreach p,$(user_PACKAGES),$(info :   $(p)))
-    $(error done)
-  endif
+  user_PACKAGES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)
+  $(call expand-required-modules,user_PACKAGES,$(user_PACKAGES))
+  user_PACKAGES := $(call module-installed-files, $(user_PACKAGES))
 else
   # We're not doing a full build, and are probably only including
   # a subset of the module makefiles.  Don't try to build any modules