#!/bin/sh

if [ ! -e /dev/ipa ]; then
    exit 0
fi
while ! mountpoint -q -- /android/vendor
do
    sleep 1
done

if [ -f /vendor/firmware/ipa_fws.mdt ]; then
    echo 1 > /dev/ipa
fi
# Enable fix audio mic service, if disabled, which should
# only happen on first boot or maybe after an OTA-update
if ! systemctl --global -q is-enabled check-audio-mic.service; then
  echo "device-hacks script: enable and start check-audio-mic.service";
  # needs system writable to apply symlink on enabling service
  mount -o rw,remount /
  systemctl --global enable check-audio-mic.service
  systemctl --global start check-audio-mic.service
  # remount read only!
mount -o ro,remount /
else
  echo "device-hacks script: check-audio-mic.service already enabled";
fi
# While the time_daemon binary has been overlayed by a non-executable, Android
# init will continue trying to restart that service. Stop the cycle by
# explicitly tell it to stop.
setprop ctl.stop time_daemon
# Set schedtune boost
echo 20 > /sys/fs/cgroup/schedtune/schedtune.boost
echo 1 > /sys/fs/cgroup/schedtune/schedtune.prefer_idle