#!/system/bin/sh
#
# load adbd during first boot if property is set

if [ -f /system/firstboot ]; then

    LOAD_ADBD=`getprop persist.service.adb.enable`
    USB_LINK=`cat /sys/class/power_supply/usb/online`

    if [ "$LOAD_ADBD $USB_LINK" = "1 1" ]; then

        echo charge_adb > /dev/usb_device_mode

        # set initial state for usb.apk
        echo usb_mode_charge_adb > /tmp/usbd_current_state
        chmod 666 /tmp/usbd_current_state

    fi

    busybox mount -o remount,rw /system
    rm -f /system/firstboot
    busybox mount -o remount,ro /system
fi

