#!/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

# 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
# cgroup v1 (20.04)
if [ -e /sys/fs/cgroup/schedtune/schedtune.boost ]; then
    echo 20 > /sys/fs/cgroup/schedtune/schedtune.boost
    echo 1 > /sys/fs/cgroup/schedtune/schedtune.prefer_idle
# cgroup v2 (24.04)
elif [ -e /sys/fs/cgroup/user.slice/schedtune.boost ]; then
    echo 20 > /sys/fs/cgroup/user.slice/schedtune.boost
    echo 1 > /sys/fs/cgroup/user.slice/schedtune.prefer_idle
fi

# binfmt_misc support
if ! mountpoint -q /proc/sys/fs/binfmt_misc; then
    mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
    systemctl restart systemd-binfmt.service
fi

# Silence Android init failing to find a QCOM service for cacert management
systemctl start dummy_cacert.service
