Add option to fail when Android.mk files change PRODUCT_* variables.

It's turned off for now.

Change-Id: I0b5a3ce5fdc7693c8ebd870312f0c2e13fdb8b22
diff --git a/core/main.mk b/core/main.mk
index 325a0e5..35760d6 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -472,6 +472,13 @@
 
 endif	# !SDK_ONLY
 
+# Before we go and include all of the module makefiles, stash away
+# the PRODUCT_* values so you can't get to them.
+stash_product_vars:=#true
+ifeq ($(stash_product_vars),true)
+  $(call stash-product-vars, __STASHED, DO_NOT_USE_IN_ANDROID_MK_)
+endif
+
 ifneq ($(ONE_SHOT_MAKEFILE),)
 # We've probably been invoked by the "mm" shell function
 # with a subdirectory's makefile.
@@ -502,6 +509,11 @@
 include $(subdir_makefiles)
 endif # ONE_SHOT_MAKEFILE
 
+ifeq ($(stash_product_vars),true)
+  $(call assert-product-vars, __STASHED, DO_NOT_USE_IN_ANDROID_MK_)
+  $(call restore-product-vars, __STASHED)
+endif
+
 # -------------------------------------------------------------------
 # All module makefiles have been included at this point.
 # -------------------------------------------------------------------