hikey960: Add /metadata support (reusing cache partition) am: e8fe717c88 am: b754c17dea am: e97fb06202

Original change: https://android-review.googlesource.com/c/device/linaro/hikey/+/1584533

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib6579ebc9eba849f352e98a291699e04ed3e8548
diff --git a/hikey960/BoardConfig.mk b/hikey960/BoardConfig.mk
index 939723b..b3a059f 100644
--- a/hikey960/BoardConfig.mk
+++ b/hikey960/BoardConfig.mk
@@ -51,6 +51,7 @@
 BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE := ext4
 TARGET_COPY_OUT_PRODUCT := product
 BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_USES_METADATA_PARTITION := true
 
 #Dynamic Partition details
 TARGET_USE_DYNAMIC_PARTITIONS := true
@@ -59,6 +60,7 @@
 BOARD_SUPER_PARTITION_GROUPS := hikey960_dynamic_partitions
 BOARD_HIKEY960_DYNAMIC_PARTITIONS_PARTITION_LIST := system vendor system_ext product
 BOARD_HIKEY960_DYNAMIC_PARTITIONS_SIZE := 4915724288
+BOARD_SUPER_PARTITION_METADATA_DEVICE := super
 BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE := true
 
 TARGET_RECOVERY_FSTAB := device/linaro/hikey/hikey960/fstab.hikey960
diff --git a/hikey960/fstab.hikey960 b/hikey960/fstab.hikey960
index 53e1ae4..63326f6 100644
--- a/hikey960/fstab.hikey960
+++ b/hikey960/fstab.hikey960
@@ -8,6 +8,7 @@
 #/dev/block/platform/soc/ff3b0000.ufs/by-name/userdata    /data      ext4    discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait
 /dev/block/by-name/userdata    /data      f2fs    discard,noatime,nosuid,nodev                                 wait,check,fileencryption=software,quota
 /dev/block/by-name/userdata    /data      ext4    discard,noatime,nosuid,nodev,noauto_da_alloc,data=ordered,user_xattr,barrier=1,inlinecrypt    wait,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,quota
+/dev/block/by-name/cache	/metadata       ext4    noatime,nosuid,nodev,discard                                    wait,formattable
 /devices/platform/soc/ff37f000.dwmmc1/mmc_host/mmc*      auto       auto    defaults    voldmanaged=sdcard1:auto,encryptable=userdata
 /devices/platform/soc/ff200000.hisi_usb/ff100000.dwc3/xhci-hcd.*.auto/usb*               auto               auto      defaults  voldmanaged=usbdisk:auto,encryptable=userdata
 /devices/platform/soc/f4000000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/nvme/nvme*      auto       auto    defaults    voldmanaged=nvmedisk:auto,encryptable=userdata
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 6a1f8d3..1e71211 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -35,7 +35,7 @@
 /dev/block/platform/soc/f723d000\.dwmmc0/by-name/userdata u:object_r:userdata_block_device:s0
 
 # for HiKey960 Board
-/dev/block/platform/soc/ff3b0000\.ufs/by-name/cache u:object_r:cache_block_device:s0
+/dev/block/platform/soc/ff3b0000\.ufs/by-name/cache u:object_r:metadata_block_device:s0
 /dev/block/platform/soc/ff3b0000\.ufs/by-name/userdata u:object_r:userdata_block_device:s0