Enable FULL_TREBLE on hikey/hikey960

This is basically the current state of the rest of the
FULL_TREBLE enablement bits for both hikey/hikey960

This patch also requires kernels that are rebuilt to include the
DTS fstab changes seen here:
https://git.linaro.org/people/john.stultz/android-dev.git/log/?h=dev/treble

Credit for this patch goes to Vishal Bhoj <vishal.bhoj@linaro.org>
who basically was the original author and magician
who got things working.

I've only refactored and split up his changes to help
with the submissions.

Change-Id: Iab0f5fc93bdfd1b86c98aa1d54974fde33514063
Signed-off-by: John Stultz <john.stultz@linaro.org>
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index ef4544e..cf4976e 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -16,6 +16,10 @@
 # BT configs
 BOARD_HAVE_BLUETOOTH := true
 
+# enable Treble
+PRODUCT_FULL_TREBLE_OVERRIDE := true
+BOARD_VNDK_VERSION := current
+
 # generic wifi
 WPA_SUPPLICANT_VERSION := VER_0_8_X
 BOARD_WPA_SUPPLICANT_DRIVER := NL80211
diff --git a/device-common.mk b/device-common.mk
index 1b362bf..bad41b0 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -47,6 +47,8 @@
     android.hardware.broadcastradio@1.0-impl \
     android.hardware.soundtrigger@2.0-impl
 
+PRODUCT_PACKAGES += vndk_package
+
 PRODUCT_PACKAGES += \
     android.hardware.drm@1.0-impl \
 
diff --git a/hikey/BoardConfig.mk b/hikey/BoardConfig.mk
index f984c26..c76ad35 100644
--- a/hikey/BoardConfig.mk
+++ b/hikey/BoardConfig.mk
@@ -12,6 +12,9 @@
 BOARD_KERNEL_CMDLINE := console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/vendor/firmware efi=noruntime
 endif
 
+#Enable dtb fstab for treble
+BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab
+
 ifneq ($(TARGET_SENSOR_MEZZANINE),)
 BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_$(TARGET_SENSOR_MEZZANINE)
 endif
diff --git a/hikey/device-hikey.mk b/hikey/device-hikey.mk
index 4063c81..5e15cd5 100644
--- a/hikey/device-hikey.mk
+++ b/hikey/device-hikey.mk
@@ -16,12 +16,12 @@
 
 PRODUCT_COPY_FILES +=   $(TARGET_PREBUILT_KERNEL):kernel \
                         $(TARGET_PREBUILT_DTB):hi6220-hikey.dtb \
-			$(LOCAL_PATH)/$(TARGET_FSTAB):root/fstab.hikey \
-			device/linaro/hikey/init.common.rc:root/init.hikey.rc \
-			device/linaro/hikey/init.hikey.power.rc:root/init.hikey.power.rc \
-			device/linaro/hikey/init.common.usb.rc:root/init.hikey.usb.rc \
-			device/linaro/hikey/ueventd.common.rc:root/ueventd.hikey.rc \
-			device/linaro/hikey/common.kl:system/usr/keylayout/hikey.kl
+			$(LOCAL_PATH)/$(TARGET_FSTAB):$(TARGET_COPY_OUT_VENDOR)/etc/init/fstab.hikey \
+			device/linaro/hikey/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey.rc \
+			device/linaro/hikey/init.hikey.power.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey.power.rc \
+			device/linaro/hikey/init.common.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey.usb.rc \
+			device/linaro/hikey/ueventd.common.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc \
+			device/linaro/hikey/common.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/hikey.kl
 
 # Copy BT firmware
 PRODUCT_COPY_FILES += \
diff --git a/hikey/fstab.hikey b/hikey/fstab.hikey
index e70b2c6..a1ccdac 100644
--- a/hikey/fstab.hikey
+++ b/hikey/fstab.hikey
@@ -3,8 +3,6 @@
 # The filesystem that contains the filesystem checker binary (typically /system) cannot
 # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
 
-/dev/block/platform/soc/f723d000.dwmmc0/by-name/system      /system             ext4      ro                                                           wait,verify
-/dev/block/platform/soc/f723d000.dwmmc0/by-name/vendor      /vendor             ext4      ro                                                           wait,verify
 /dev/block/platform/soc/f723d000.dwmmc0/by-name/cache       /cache              ext4      discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait
 /dev/block/platform/soc/f723d000.dwmmc0/by-name/userdata    /data               f2fs      discard,noatime,nosuid,nodev                                 wait,check,fileencryption=software,quota
 /dev/block/platform/soc/f723d000.dwmmc0/by-name/userdata    /data               ext4      discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait,formattable
diff --git a/hikey/fstab.hikey-3.18 b/hikey/fstab.hikey-3.18
index 6e184c5..05f427f 100644
--- a/hikey/fstab.hikey-3.18
+++ b/hikey/fstab.hikey-3.18
@@ -3,9 +3,9 @@
 # The filesystem that contains the filesystem checker binary (typically /system) cannot
 # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
 
-/dev/block/platform/f723d000.dwmmc0/by-name/system      /system             ext4      ro                                                           wait
-/dev/block/platform/f723d000.dwmmc0/by-name/system      /system             squashfs  ro                                                           wait
-/dev/block/platform/f723d000.dwmmc0/by-name/vendor      /vendor             ext4      ro                                                           wait
+#/dev/block/platform/f723d000.dwmmc0/by-name/system      /system             ext4      ro                                                           wait
+#/dev/block/platform/f723d000.dwmmc0/by-name/system      /system             squashfs  ro                                                           wait
+#/dev/block/platform/f723d000.dwmmc0/by-name/vendor      /vendor             ext4      ro                                                           wait
 /dev/block/platform/f723d000.dwmmc0/by-name/cache       /cache              ext4      discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait
 /dev/block/platform/f723d000.dwmmc0/by-name/userdata    /data               f2fs      discard,noatime,nosuid,nodev                                 wait,check,fileencryption=software,quota
 /dev/block/platform/f723d000.dwmmc0/by-name/userdata    /data               ext4      discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait,formattable
diff --git a/hikey960/BoardConfig.mk b/hikey960/BoardConfig.mk
index 122fc67..1ba08db 100644
--- a/hikey960/BoardConfig.mk
+++ b/hikey960/BoardConfig.mk
@@ -10,6 +10,10 @@
 
 BOARD_KERNEL_CMDLINE := androidboot.hardware=hikey960 console=ttyFIQ0 androidboot.console=ttyFIQ0
 BOARD_KERNEL_CMDLINE += firmware_class.path=/vendor/firmware loglevel=15 efi=noruntime
+
+#Enable dtb fstab for treble
+BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_enable_android_fstab
+
 ifneq ($(TARGET_SENSOR_MEZZANINE),)
 BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_$(TARGET_SENSOR_MEZZANINE)
 endif
diff --git a/hikey960/device-hikey960.mk b/hikey960/device-hikey960.mk
index ad2f9d7..20001d4 100644
--- a/hikey960/device-hikey960.mk
+++ b/hikey960/device-hikey960.mk
@@ -17,14 +17,14 @@
 PRODUCT_COPY_FILES +=	$(TARGET_PREBUILT_KERNEL):kernel \
 			$(TARGET_PREBUILT_DTB):hi3660-hikey960.dtb
 
-PRODUCT_COPY_FILES +=	$(LOCAL_PATH)/fstab.hikey960:root/fstab.hikey960 \
-			device/linaro/hikey/init.common.rc:root/init.hikey960.rc \
-			device/linaro/hikey/init.hikey960.power.rc:root/init.hikey960.power.rc \
-			device/linaro/hikey/init.common.usb.rc:root/init.hikey960.usb.rc \
-			device/linaro/hikey/ueventd.common.rc:root/ueventd.hikey960.rc \
-			device/linaro/hikey/common.kl:system/usr/keylayout/hikey960.kl \
-			frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:system/etc/permissions/android.hardware.vulkan.level.xml \
-			frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:system/etc/permissions/android.hardware.vulkan.version.xml
+PRODUCT_COPY_FILES +=	$(LOCAL_PATH)/fstab.hikey960:$(TARGET_COPY_OUT_VENDOR)/etc/init/fstab.hikey960 \
+			device/linaro/hikey/init.common.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey960.rc \
+			device/linaro/hikey/init.hikey960.power.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey960.power.rc \
+			device/linaro/hikey/init.common.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/init.hikey960.usb.rc \
+			device/linaro/hikey/ueventd.common.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc \
+			device/linaro/hikey/common.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/hikey960.kl \
+			frameworks/native/data/etc/android.hardware.vulkan.level-1.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \
+			frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml
 
 # Copy BT firmware
 PRODUCT_COPY_FILES += \
diff --git a/hikey960/fstab.hikey960 b/hikey960/fstab.hikey960
index 4657187..9f18390 100644
--- a/hikey960/fstab.hikey960
+++ b/hikey960/fstab.hikey960
@@ -4,8 +4,6 @@
 # specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
 
 #/dev/block/platform/soc/ff3b0000.ufs/by-name/system_a    /system    ext4    ro                                                                   wait
-/dev/block/sdd10    /system    ext4    ro                                                                   wait
-/dev/block/sdd11    /vendor    ext4    ro                                                                   wait
 #/dev/block/platform/soc/ff3b0000.ufs/by-name/cache       /cache     ext4    discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait
 /dev/block/sdd5     /cache     ext4    discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait
 #/dev/block/platform/soc/ff3b0000.ufs/by-name/userdata    /data      ext4    discard,noauto_da_alloc,data=ordered,user_xattr,barrier=1    wait
diff --git a/init.common.rc b/init.common.rc
index cfea2f5..63eaa9c 100644
--- a/init.common.rc
+++ b/init.common.rc
@@ -27,7 +27,7 @@
     start watchdogd
 
 on fs
-    mount_all /fstab.${ro.hardware}
+    mount_all /vendor/etc/init/fstab.${ro.hardware}
     setprop ro.crypto.fuse_sdcard false
 
 on post-fs