Store vendor module owner info on the build server.

Bug: 7048854
Change-Id: I5f0653c71a77774978655f8b5570e170b4a9c4ec
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 2957cec..bd92b09 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -555,7 +555,7 @@
 ALL_MODULES.$(LOCAL_MODULE).BUILT := \
     $(ALL_MODULES.$(LOCAL_MODULE).BUILT) $(LOCAL_BUILT_MODULE)
 ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
-    $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE)
+    $(strip $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE))
 ALL_MODULES.$(LOCAL_MODULE).REQUIRED := \
     $(ALL_MODULES.$(LOCAL_MODULE).REQUIRED) $(LOCAL_REQUIRED_MODULES)
 ALL_MODULES.$(LOCAL_MODULE).EVENT_LOG_TAGS := \
@@ -566,7 +566,7 @@
     $(ALL_MODULES.$(LOCAL_MODULE).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
 ifdef LOCAL_MODULE_OWNER
 ALL_MODULES.$(LOCAL_MODULE).OWNER := \
-    $(strip $(ALL_MODULES.$(LOCAL_MODULE).OWNER) $(LOCAL_MODULE_OWNER))
+    $(sort $(ALL_MODULES.$(LOCAL_MODULE).OWNER) $(LOCAL_MODULE_OWNER))
 endif
 
 INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(LOCAL_MODULE)
diff --git a/core/tasks/vendor_module_check.mk b/core/tasks/vendor_module_check.mk
index 2b10d1d..8d4eb05 100644
--- a/core/tasks/vendor_module_check.mk
+++ b/core/tasks/vendor_module_check.mk
@@ -40,6 +40,7 @@
 _vendor_check_modules := $(sort $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES))
 $(call expand-required-modules,_vendor_check_modules,$(_vendor_check_modules))
 
+_vendor_module_owner_info :=
 # Restrict owners
 ifneq (,$(filter true owner all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)))
 
@@ -50,8 +51,9 @@
 _vendor_check_copy_files := $(filter vendor/%, $(PRODUCT_COPY_FILES))
 ifneq (,$(_vendor_check_copy_files))
 $(foreach c, $(_vendor_check_copy_files), \
-  $(if $(filter $(_vendor_owner_whitelist), $(call word-colon, 3, $(c))),,\
-    $(error Error: vendor PRODUCT_COPY_FILES file "$(c)" has unknown owner)))
+  $(if $(filter $(_vendor_owner_whitelist), $(call word-colon,3,$(c))),,\
+    $(error Error: vendor PRODUCT_COPY_FILES file "$(c)" has unknown owner))\
+  $(eval _vendor_module_owner_info += $(call word-colon,2,$(c)):$(call word-colon,3,$(c))))
 endif
 _vendor_check_copy_files :=
 
@@ -59,7 +61,9 @@
   $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\
     $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\
       $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \
-        "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))))
+        "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))\
+    $(if $(ALL_MODULES.$(m).INSTALLED),\
+      $(eval _vendor_module_owner_info += $(patsubst $(PRODUCT_OUT)/%,%,$(ALL_MODULES.$(m).INSTALLED)):$(ALL_MODULES.$(m).OWNER)))))
 
 endif
 
@@ -76,5 +80,23 @@
 
 endif
 
+_vendor_module_owner_info_txt := $(call intermediates-dir-for,PACKAGING,vendor_owner_info)/vendor_owner_info.txt
+$(_vendor_module_owner_info_txt): PRIVATE_INFO := $(_vendor_module_owner_info)
+$(_vendor_module_owner_info_txt):
+	@echo "Write vendor module owner info $@"
+	@mkdir -p $(dir $@) && rm -f $@
+ifdef _vendor_module_owner_info
+	@for w in $(PRIVATE_INFO); \
+	  do \
+	    echo $$w >> $@; \
+	done
+else
+	@echo "No vendor module owner info." > $@
+endif
+
+$(call dist-for-goals, droidcore, $(_vendor_module_owner_info_txt))
+
+_vendor_module_owner_info_txt :=
+_vendor_module_owner_info :=
 _vendor_check_modules :=
 endif