Merge "Fix test_sign_apex"
diff --git a/core/sysprop.mk b/core/sysprop.mk
index bb19dc5..1540736 100644
--- a/core/sysprop.mk
+++ b/core/sysprop.mk
@@ -71,6 +71,7 @@
 #       $(3) and (4) are affected
 # $(6): optional list of files to append at the end. The content of each file is emitted
 #       to the output
+# $(7): optional flag to skip common properties generation
 define build-properties
 ALL_DEFAULT_INSTALLED_MODULES += $(2)
 
@@ -96,7 +97,9 @@
 	$(hide) echo Building $$@
 	$(hide) mkdir -p $$(dir $$@)
 	$(hide) rm -f $$@ && touch $$@
+ifneq ($(strip $(7)), true)
 	$(hide) $$(call generate-common-build-props,$(call to-lower,$(strip $(1))),$$@)
+endif
 	$(hide) $(foreach file,$(strip $(3)),\
 	    if [ -f "$(file)" ]; then\
 	        echo "" >> $$@;\
@@ -309,6 +312,7 @@
     $(_prop_files_),\
     $(_prop_vars_),\
     $(_blacklist_names_),\
+    $(empty),\
     $(empty)))
 
 # -----------------------------------------------------------------
@@ -346,6 +350,7 @@
     $(_prop_files_),\
     $(_prop_vars_),\
     $(PRODUCT_VENDOR_PROPERTY_BLACKLIST),\
+    $(empty),\
     $(empty)))
 
 # -----------------------------------------------------------------
@@ -379,13 +384,28 @@
 _footers_ :=
 endif
 
+# Skip common /product properties generation if device released before R and
+# has no product partition. This is the first part of the check.
+ifeq ($(call math_lt,$(if $(PRODUCT_SHIPPING_API_LEVEL),$(PRODUCT_SHIPPING_API_LEVEL),30),30), true)
+  _skip_common_properties := true
+endif
+
+# The second part of the check - always generate common properties for the
+# devices with product partition regardless of shipping level.
+ifneq ($(BOARD_USES_PRODUCTIMAGE),)
+  _skip_common_properties :=
+endif
+
 $(eval $(call build-properties,\
     product,\
     $(INSTALLED_PRODUCT_BUILD_PROP_TARGET),\
     $(_prop_files_),\
     $(_prop_vars_),\
     $(empty),\
-    $(_footers_)))
+    $(_footers_),\
+    $(_skip_common_properties)))
+
+_skip_common_properties :=
 
 # ----------------------------------------------------------------
 # odm/etc/build.prop
@@ -407,6 +427,7 @@
     $(_prop_files),\
     $(_prop_vars_),\
     $(empty),\
+    $(empty),\
     $(empty)))
 
 # ----------------------------------------------------------------
@@ -420,6 +441,7 @@
     $(empty),\
     $(empty),\
     $(empty),\
+    $(empty),\
     $(empty)))
 
 # ----------------------------------------------------------------
@@ -433,6 +455,7 @@
     $(empty),\
     $(empty),\
     $(empty),\
+    $(empty),\
     $(empty)))
 
 # -----------------------------------------------------------------
@@ -453,6 +476,7 @@
     $(_prop_files_),\
     $(_prop_vars_),\
     $(empty),\
+    $(empty),\
     $(empty)))
 
 # ----------------------------------------------------------------
@@ -467,4 +491,5 @@
     $(empty),\
     $(empty),\
     $(empty),\
+    $(empty),\
     $(empty)))