#!/bin/sh

# We'll need to remove both services because someone might
# not know that the firmware doesn't need to be installed for Hybris
# to work. (these also contribute to the long boot times)
rc-update del adsp-audio default
rc-update del wcnss-wlan default

# On this device, seems that refreshing the framebuffer creates artifacts
# in test_hwcomposer, so this had to be disabled.
rc-update del msm-fb-refresher boot

# Append Android mounts to Linux fstab
cat /etc/fstab.android >> /etc/fstab

# Create Android mount points
mkdir -p /data
mkdir -p /system
mkdir -p /cache
mkdir -p /persist
mkdir -p /dsp
mkdir -p /firmware

# /vendor symlink (points to nowhere until /system is mounted)
ln -s /system/vendor /vendor

# Since Android audio HAL on this device doesn't like to be unloaded,
# we need to stop PA from exit too.
DEFAULT_PA=/etc/pulse/daemon.conf
L1="exit-idle-time = -1"

append_line() {
	FN=$1
	LINE=$2
	if ! grep -q "${LINE}" "${FN}"; then
		echo "Adding $LINE..."
		echo "${LINE}" >> "${FN}"
	else
		echo "Not adding ${LINE}"
	fi
}

if [ -f ${DEFAULT_PA} ]; then
	append_line "${DEFAULT_PA}" "${L1}"
fi
