Bind-mount individual flattened APEXes

There are a few directories for builtin APEXes: /system/apex,
/system_ext/apex, /product/apex, /vendor/apex.

For devices with ro.apex.updatable=false, init should bind-mount
"flattened" apexes from all of above.

Instead of making mount point for "com.android.art" at buildtime, init
process creates it before mounting.

Bug: 144732372
Test: OVERRIDE_TARGET_FLATTEN_APEX=true m && device boot
Change-Id: I64f0d6bdd1d297ccc0679fb6319103d5bfbfc620
diff --git a/Android.mk b/Android.mk
index 4e21ec8..a3bdb9e 100644
--- a/Android.mk
+++ b/Android.mk
@@ -380,13 +380,6 @@
 # Note that installation of the symlink is triggered by the apex_manifest.pb
 # file which is the file that is guaranteed to be created regardless of the
 # value of TARGET_FLATTEN_APEX.
-#
-# b/132413565: Also, when TARGET_FLATTEN_APEX is true, an empty directory
-# /system/apex/com.android.art is created. After the entire
-# /system/apex is mounted on /apex, the flattened ART APEX
-# (either com.android.art.debug or *.release) is mounted on the empty
-# directory so that the APEX is accessible via the canonical path
-# /apex/com.android.art
 ifeq ($(TARGET_FLATTEN_APEX),true)
 art_apex_manifest_file := $(PRODUCT_OUT)/system/apex/$(TARGET_ART_APEX)/apex_manifest.pb
 else
@@ -399,9 +392,6 @@
 $(art_apex_symlink_timestamp):
 	$(hide) mkdir -p $(dir $(PRIVATE_LINK_NAME))
 	$(hide) ln -sf $(TARGET_ART_APEX) $(PRIVATE_LINK_NAME)
-ifeq ($(TARGET_FLATTEN_APEX),true)
-	$(hide) mkdir -p $(TARGET_OUT)/apex/com.android.art
-endif
 	$(hide) touch $@
 
 art_apex_manifest_file :=
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 5aff4cf..fe613b2 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -102,6 +102,9 @@
 $(call add-clean-step, find $(OUT_DIR) -name "*.oat" -o -name "*.odex" -o -name "*.art" -o -name '*.vdex' | xargs rm -f)
 $(call add-clean-step, find $(OUT_DIR) -name "*.oat" -o -name "*.odex" -o -name "*.art" -o -name '*.vdex' | xargs rm -f)
 
+# Remove empty dir for art APEX because it will be created on demand while mounting release|debug
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/apex/com.android.art)
+
 # ************************************************
 # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
 # ************************************************