Merge "init.hikey.usb.rc: fix to bring down tethering interface"
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 3ddabef..3dfc149 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -30,7 +30,11 @@
 BOARD_HOSTAPD_DRIVER := NL80211
 CONFIG_DRIVER_NL80211 := y
 
-BOARD_KERNEL_CMDLINE := console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime androidboot.selinux=permissive
+ifeq ($(TARGET_KERNEL_USE_4_1), true)
+BOARD_KERNEL_CMDLINE := console=ttyAMA3,115200 androidboot.console=ttyAMA3 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
+else
+BOARD_KERNEL_CMDLINE := console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
+endif
 
 TARGET_NO_BOOTLOADER := true
 TARGET_NO_KERNEL := false
diff --git a/bootloader/EFI/BOOT/grub.cfg b/bootloader/EFI/BOOT/grub.cfg
index 093f1be..95c7dcc 100644
--- a/bootloader/EFI/BOOT/grub.cfg
+++ b/bootloader/EFI/BOOT/grub.cfg
@@ -3,35 +3,35 @@
 menuentry 'AOSP' {
     search.fs_label boot root
     set root=($root)
-    linux /Image console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime androidboot.selinux=permissive
+    linux /Image console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
     initrd /ramdisk.img
     devicetree /hi6220-hikey.dtb
 }
 menuentry 'AOSP-DEBUG' {
     search.fs_label boot root
     set root=($root)
-    linux /Image earlycon=pl011,0xf7113000 no_console_suspend=1 console=ttyFIQ0 androidboot.console=ttyFIQ0 sysrq_always_enabled androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime androidboot.selinux=permissive
+    linux /Image earlycon=pl011,0xf7113000 no_console_suspend=1 console=ttyFIQ0 androidboot.console=ttyFIQ0 sysrq_always_enabled androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
     initrd /ramdisk.img
     devicetree /hi6220-hikey.dtb
 }
 menuentry 'AOSP-CONSOLE' {
     search.fs_label boot root
     set root=($root)
-    linux /Image console=ttyAMA3,115200 androidboot.console=ttyAMA3 fiq_debugger.disable=Y androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime androidboot.selinux=permissive
+    linux /Image console=ttyAMA3,115200 androidboot.console=ttyAMA3 fiq_debugger.disable=Y androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime
     initrd /ramdisk.img
     devicetree /hi6220-hikey.dtb
 }
 menuentry 'AOSP@720P' {
     search.fs_label boot root
     set root=($root)
-    linux /Image console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime video=HDMI-A-1:1280x720@60 androidboot.selinux=permissive
+    linux /Image console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime video=HDMI-A-1:1280x720@60
     initrd /ramdisk.img
     devicetree /hi6220-hikey.dtb
 }
 menuentry 'AOSP@SVGA' {
     search.fs_label boot root
     set root=($root)
-    linux /Image console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime video=HDMI-A-1:800x600@60 androidboot.selinux=permissive
+    linux /Image console=ttyFIQ0 androidboot.console=ttyFIQ0 androidboot.hardware=hikey firmware_class.path=/system/etc/firmware efi=noruntime video=HDMI-A-1:800x600@60
     initrd /ramdisk.img
     devicetree /hi6220-hikey.dtb
 }
diff --git a/bt-wifi-firmware-util/wl18xx-fw-4.bin b/bt-wifi-firmware-util/wl18xx-fw-4.bin
index 252ea2d..5e65dbc 100755
--- a/bt-wifi-firmware-util/wl18xx-fw-4.bin
+++ b/bt-wifi-firmware-util/wl18xx-fw-4.bin
Binary files differ
diff --git a/init.hikey.rc b/init.hikey.rc
index 5c49333..bf16d91 100644
--- a/init.hikey.rc
+++ b/init.hikey.rc
@@ -48,10 +48,6 @@
 # Set supported opengles version
     setprop ro.opengles.version 196608
 
-# change permissions for process groups
-# https://bugs.launchpad.net/bugs/1037611
-    chmod 0660 /dev/cpuctl
-
     # update cpuset now that processors are up
     # Foreground should contain all cores
     write /dev/cpuset/foreground/cpus 0-7
diff --git a/installer/flash-all.sh b/installer/flash-all.sh
index c4049e2..2c3365c 100755
--- a/installer/flash-all.sh
+++ b/installer/flash-all.sh
@@ -5,51 +5,66 @@
     exit
 fi
 
-if [ ! -e $1 ]
+if [ ! -e "${1}" ]
   then
-    echo "device: $1 does not exist"
+    echo "device: ${1} does not exist"
     exit
 fi
-DEVICE_PORT=${1}
+DEVICE_PORT="${1}"
 PTABLE=ptable-aosp-8g.img
 if [ $# -gt 1 ]
   then
-    if [ $2 == '4g' ]
+    if [ "${2}" == '4g' ]
       then
         PTABLE=ptable-aosp-4g.img
     fi
 fi
 
-INSTALLER_DIR="`dirname $0`"
-ANDROID_TOP=${INSTALLER_DIR}/../../../../
+INSTALLER_DIR="`dirname ${0}`"
+FIRMWARE_DIR="${INSTALLER_DIR}"
+
+# for cases that not run "lunch hikey-userdebu"
+if [ -z "${ANDROID_BUILD_TOP}" ]; then
+    ANDROID_BUILD_TOP=${INSTALLER_DIR}/../../../../
+    ANDROID_PRODUCT_OUT="${ANDROID_BUILD_TOP}/out/target/product/hikey"
+fi
+
+if [ -z "${DIST_DIR}" ]; then
+    DIST_DIR="${ANDROID_BUILD_TOP}"/out/dist
+fi
 
 #get out directory path
 while [ $# -ne 0 ]; do
-    case "$1" in
-        --out) OUT_IMGDIR=$2;shift;
+    case "${1}" in
+        --out) OUT_IMGDIR=${2};shift;;
+        --use-compiled-binaries) FIRMWARE_DIR="${DIST_DIR}";shift;;
     esac
     shift
 done
 
-if [ -z $OUT_IMGDIR ]; then
-    if [ ! -z $ANDROID_PRODUCT_OUT ]; then
-        OUT_IMGDIR=${ANDROID_PRODUCT_OUT}
-    else
-        OUT_IMGDIR="${ANDROID_TOP}/out/target/product/hikey"
+if [[ "${FIRMWARE_DIR}" == "${DIST_DIR}" && ! -e "${DIST_DIR}"/fip.bin && ! -e "${DIST_DIR}"/l-loader.bin ]]; then
+    echo "No binaries found at ${DIST_DIR}. Please build the bootloader first"
+    exit
+fi
+
+if [ -z "${OUT_IMGDIR}" ]; then
+    if [ ! -z "${ANDROID_PRODUCT_OUT}" ]; then
+        OUT_IMGDIR="${ANDROID_PRODUCT_OUT}"
     fi
 fi
 
-if [ ! -d $OUT_IMGDIR ]; then
+if [ ! -d "${OUT_IMGDIR}" ]; then
     echo "error in locating out directory, check if it exist"
     exit
 fi
-echo "android out dir:$OUT_IMGDIR"
 
-sudo python ${INSTALLER_DIR}/hisi-idt.py --img1=${INSTALLER_DIR}/l-loader.bin -d ${DEVICE_PORT}
-fastboot flash ptable ${INSTALLER_DIR}/${PTABLE}
-fastboot flash fastboot ${INSTALLER_DIR}/fip.bin
-fastboot flash nvme ${INSTALLER_DIR}/nvme.img
-fastboot flash boot ${OUT_IMGDIR}/boot.img
-fastboot flash system ${OUT_IMGDIR}/system.img
-fastboot flash cache ${OUT_IMGDIR}/cache.img
-fastboot flash userdata ${OUT_IMGDIR}/userdata.img
+echo "android out dir:${OUT_IMGDIR}"
+
+sudo python "${INSTALLER_DIR}"/hisi-idt.py --img1="${FIRMWARE_DIR}"/l-loader.bin -d "${DEVICE_PORT}"
+fastboot flash ptable "${INSTALLER_DIR}"/"${PTABLE}"
+fastboot flash fastboot "${FIRMWARE_DIR}"/fip.bin
+fastboot flash nvme "${INSTALLER_DIR}"/nvme.img
+fastboot flash boot "${OUT_IMGDIR}"/boot.img
+fastboot flash system "${OUT_IMGDIR}"/system.img
+fastboot flash cache "${OUT_IMGDIR}"/cache.img
+fastboot flash userdata "${OUT_IMGDIR}"/userdata.img
diff --git a/sepolicy/file.te b/sepolicy/file.te
deleted file mode 100644
index 45c5117..0000000
--- a/sepolicy/file.te
+++ /dev/null
@@ -1 +0,0 @@
-type configfs, fs_type;
diff --git a/sepolicy/genfs_contexts b/sepolicy/genfs_contexts
deleted file mode 100644
index 50c7cd7..0000000
--- a/sepolicy/genfs_contexts
+++ /dev/null
@@ -1 +0,0 @@
-genfscon configfs / u:object_r:configfs:s0
diff --git a/sepolicy/netd.te b/sepolicy/netd.te
new file mode 100644
index 0000000..86fe108
--- /dev/null
+++ b/sepolicy/netd.te
@@ -0,0 +1,2 @@
+# Triggers a sys_module denial, but kernel has CONFIG_MODULES=n.
+dontaudit netd self:capability sys_module;