import /init.recovery.${ro.hardware}.rc

on early-init
    start ueventd

on init
    export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
    export ANDROID_ROOT /system
    export ANDROID_DATA /data
    export EXTERNAL_STORAGE /sdcard

    mkdir /sdcard
    mkdir /sdcard1
    mkdir /system
    mkdir /data
    mkdir /cache
    mkdir /preload
    mkdir /custom
    mkdir /efs
    mkdir /tmp
    mkdir /firmware 0771 system system

    chown root shell /tmp
    chmod 0775 /tmp

# for lkmauth
    mount vfat /dev/block/mmcblk0p1 /firmware ro

# ko files for exfat
    insmod /system/lib/modules/exfat_core.ko
    insmod /system/lib/modules/exfat_fs.ko

on boot

    ifup lo
    hostname localhost
    domainname localdomain

    class_start default

service ueventd /sbin/ueventd
    critical

service recovery /sbin/recovery

service adbd /sbin/adbd recovery
    enabled 

service vold /system/bin/vold
    socket vold stream 0660 root mount
    ioprio be 2
    socket dir_enc_report stream 0660 root mount

service prepare-mobicore /system/bin/mobicore-presetup.sh
    class core
    user root
    group root
    oneshot

service run-mobicore /system/bin/sh /system/bin/mobicore-startup.sh
    class core
    user root
    group root
    oneshot

service prepare-ssdaemon /system/bin/sh /system/bin/ss-presetup.sh
    class core
    user root
    group root
    oneshot

service secure_storage /system/bin/secure_storage_daemon
    class core
    user root
    group root
    disabled
    oneshot

on property:ro.securestorage.ready=true
    start secure_storage

# Always start adbd on userdebug and eng builds
on property:ro.debuggable=1
    setprop adb.recovery 1

on property:adb.recovery=1
    write /sys/class/android_usb/android0/enable 0
    write /sys/class/android_usb/android0/idVendor 04e8
    write /sys/class/android_usb/android0/idProduct 6860
    write /sys/class/android_usb/android0/functions adb
    write /sys/class/android_usb/android0/enable 1
    write /sys/class/android_usb/android0/iManufacturer $ro.product.manufacturer
    write /sys/class/android_usb/android0/iProduct $ro.product.model
    write /sys/class/android_usb/android0/iSerial $ro.serialno
    start adbd
    start vold
    start prepare-mobicore
    start run-mobicore
    start prepare-ssdaemon


# Restart adbd so it can run as root
on property:service.adb.root=1
    write /sys/class/android_usb/android0/enable 0
    restart adbd
    write /sys/class/android_usb/android0/enable 1
    
