hikey960: Move to real vendor partition

Bug: 75290651
Test: Manual

Change-Id: I21939c7b290775ae492acb02dea485dfebba130e
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/bt-wifi-firmware-util/Android.mk b/bt-wifi-firmware-util/Android.mk
deleted file mode 100644
index 7e41a35..0000000
--- a/bt-wifi-firmware-util/Android.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-TI_WILINK_FW_PATH := $(TARGET_OUT_ETC)/firmware/ti-connectivity
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := TIInit_11.8.32.bts
-ifneq ($(filter hikey960, $(TARGET_DEVICE)),)
-LOCAL_SRC_FILES := TIInit_11.8.32-pcm-960.bts
-else
-LOCAL_SRC_FILES := TIInit_11.8.32.bts
-endif
-LOCAL_MODULE_CLASS := FIRMWARE
-LOCAL_MODULE_PATH := $(TI_WILINK_FW_PATH)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_OWNER := ti
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := wl18xx-fw-4.bin
-LOCAL_SRC_FILES := wl18xx-fw-4.bin
-LOCAL_MODULE_CLASS := FIRMWARE
-LOCAL_MODULE_PATH := $(TI_WILINK_FW_PATH)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_OWNER := ti
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := wl18xx-conf.bin
-ifneq ($(filter hikey960, $(TARGET_DEVICE)),)
-LOCAL_SRC_FILES := wl18xx-conf-wl1837mod.bin
-else
-LOCAL_SRC_FILES := wl18xx-conf.bin
-endif
-LOCAL_MODULE_CLASS := FIRMWARE
-LOCAL_MODULE_PATH := $(TI_WILINK_FW_PATH)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_OWNER := ti
-include $(BUILD_PREBUILT)
diff --git a/device-common.mk b/device-common.mk
index a03a80d..cbd48ce 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -62,11 +62,6 @@
     android.hardware.memtrack@1.0-service \
     android.hardware.memtrack@1.0-impl
 
-PRODUCT_PACKAGES +=	TIInit_11.8.32.bts \
-			wl18xx-fw-4.bin \
-			wl18xx-conf.bin
-
-
 ifeq ($(HIKEY_USE_LEGACY_TI_BLUETOOTH), true)
 PRODUCT_PACKAGES += android.hardware.bluetooth@1.0-service.hikey uim
 else
diff --git a/hikey/device-hikey.mk b/hikey/device-hikey.mk
index 79c8d1b..3156453 100644
--- a/hikey/device-hikey.mk
+++ b/hikey/device-hikey.mk
@@ -23,6 +23,15 @@
 			device/linaro/hikey/ueventd.common.rc:root/ueventd.hikey.rc \
 			device/linaro/hikey/common.kl:system/usr/keylayout/hikey.kl
 
+# Copy BT firmware
+PRODUCT_COPY_FILES += \
+	device/linaro/hikey/bt-wifi-firmware-util/TIInit_11.8.32.bts:$(TARGET_OUT_ETC)/firmware/ti-connectivity/TIInit_11.8.32.bts
+
+# Copy wlan firmware
+PRODUCT_COPY_FILES += \
+	device/linaro/hikey/bt-wifi-firmware-util/wl18xx-fw-4.bin:$(TARGET_OUT_ETC)/firmware/ti-connectivity/wl18xx-fw-4.bin \
+	device/linaro/hikey/bt-wifi-firmware-util/wl18xx-conf.bin:$(TARGET_OUT_ETC)/firmware/ti-connectivity/wl18xx-conf.bin
+
 # Build HiKey HDMI audio HAL
 PRODUCT_PACKAGES += audio.primary.hikey
 
diff --git a/hikey960/BoardConfig.mk b/hikey960/BoardConfig.mk
index a249cab..122fc67 100644
--- a/hikey960/BoardConfig.mk
+++ b/hikey960/BoardConfig.mk
@@ -9,7 +9,7 @@
 TARGET_NO_DTIMAGE := false
 
 BOARD_KERNEL_CMDLINE := androidboot.hardware=hikey960 console=ttyFIQ0 androidboot.console=ttyFIQ0
-BOARD_KERNEL_CMDLINE += firmware_class.path=/system/etc/firmware loglevel=15 efi=noruntime
+BOARD_KERNEL_CMDLINE += firmware_class.path=/vendor/firmware loglevel=15 efi=noruntime
 ifneq ($(TARGET_SENSOR_MEZZANINE),)
 BOARD_KERNEL_CMDLINE += overlay_mgr.overlay_dt_entry=hardware_cfg_$(TARGET_SENSOR_MEZZANINE)
 endif
@@ -19,3 +19,10 @@
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 25769803776 # 24GB
 BOARD_CACHEIMAGE_PARTITION_SIZE := 8388608       # 8MB
 BOARD_FLASH_BLOCK_SIZE := 512
+
+# Vendor partition definitions
+TARGET_COPY_OUT_VENDOR := vendor
+BOARD_VENDORIMAGE_PARTITION_SIZE :=  822083584   # 784MB
+BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_VENDORIMAGE_JOURNAL_SIZE := 0
+BOARD_VENDORIMAGE_EXTFS_INODE_COUNT := 2048
diff --git a/hikey960/device-hikey960.mk b/hikey960/device-hikey960.mk
index 8bfc5b8..d901a5e 100644
--- a/hikey960/device-hikey960.mk
+++ b/hikey960/device-hikey960.mk
@@ -26,9 +26,18 @@
 			frameworks/native/data/etc/android.hardware.vulkan.level-0.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
 
+# Copy BT firmware
+PRODUCT_COPY_FILES += \
+	device/linaro/hikey/bt-wifi-firmware-util/TIInit_11.8.32-pcm-960.bts:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/TIInit_11.8.32.bts
+
+# Copy wlan firmware
+PRODUCT_COPY_FILES += \
+	device/linaro/hikey/bt-wifi-firmware-util/wl18xx-fw-4.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/wl18xx-fw-4.bin \
+	device/linaro/hikey/bt-wifi-firmware-util/wl18xx-conf-wl1837mod.bin:$(TARGET_COPY_OUT_VENDOR)/firmware/ti-connectivity/wl18xx-conf.bin
+
 # Copy hifi firmware
 PRODUCT_COPY_FILES += \
-	device/linaro/hikey/hifi/firmware/hifi-hikey960.img:system/etc/firmware/hifi/hifi.img
+	device/linaro/hikey/hifi/firmware/hifi-hikey960.img:$(TARGET_COPY_OUT_VENDOR)/firmware/hifi/hifi.img
 
 
 # Build HiKey960 HDMI audio HAL. Experimental only may not work. FIXME
diff --git a/hikey960/fstab.hikey960 b/hikey960/fstab.hikey960
index 152e089..a811839 100644
--- a/hikey960/fstab.hikey960
+++ b/hikey960/fstab.hikey960
@@ -5,6 +5,7 @@
 
 #/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/sepolicy/vendor_init.te b/sepolicy/vendor_init.te
new file mode 100644
index 0000000..733a112
--- /dev/null
+++ b/sepolicy/vendor_init.te
@@ -0,0 +1,4 @@
+allow vendor_init {
+  hostapd_socket
+  wifi_data_file
+}:dir { create search getattr open read setattr ioctl write add_name remove_name rmdir relabelfrom };