#!/bin/sh

# Wait for the property system to be up.
while [ ! -e /dev/socket/property_service ]; do sleep 0.1; done

# Enable WIFI
while [ ! -e /dev/wcnss_wlan ]; do sleep 0.2; done
echo 1 > /dev/wcnss_wlan

# 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
