Merge "Add a way to override LOCAL_PRODUCT_MODULE."
diff --git a/core/base_rules.mk b/core/base_rules.mk
index 31e8bad..3a1f396 100644
--- a/core/base_rules.mk
+++ b/core/base_rules.mk
@@ -66,6 +66,12 @@
   my_host_cross :=
 endif
 
+ifeq (true, $(LOCAL_PRODUCT_MODULE))
+ifneq (,$(filter $(LOCAL_MODULE),$(PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION)))
+  LOCAL_PRODUCT_MODULE :=
+endif
+endif
+
 _path := $(LOCAL_MODULE_PATH) $(LOCAL_MODULE_PATH_32) $(LOCAL_MODULE_PATH_64)
 ifneq ($(filter $(TARGET_OUT_VENDOR)%,$(_path)),)
 LOCAL_VENDOR_MODULE := true
diff --git a/core/product.mk b/core/product.mk
index d446026..8c8246e 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -209,6 +209,7 @@
     PRODUCT_USE_DYNAMIC_PARTITION_SIZE \
     PRODUCT_BUILD_SUPER_PARTITION \
     PRODUCT_USE_FASTBOOTD \
+    PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION \
 
 define dump-product
 $(info ==== $(1) ====)\
diff --git a/core/product_config.mk b/core/product_config.mk
index b5f2896..c5d182a 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -534,3 +534,9 @@
     $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_USE_FASTBOOTD)),\
     $(PRODUCT_USE_LOGICAL_PARTITIONS))
 .KATI_READONLY := PRODUCT_USE_FASTBOOTD
+
+# List of modules that should be forcefully unmarked from being LOCAL_PRODUCT_MODULE, and hence
+# installed on /system directory by default.
+PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION := \
+    $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION))
+.KATI_READONLY := PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION