on early-init
#    loglevel 8
    symlink /sdcard /storage/sdcard0
    symlink /profile /.profile
    chmod 0555 /profile
    mkdir /var/run 0755 root root
    mkdir /var/run/media 0755 media root
    mkdir /var/run/system 0755 system root
    mkdir /dev/gce 0750
    chown system system /dev/gce

    mount debugfs debugfs /sys/kernel/debug
    chmod 0755 /sys/kernel/debug
    setprop service.adb.tcp.port 5555
    setprop ro.sf.lcd_density ${ro.boot.lcd_density}

on init
    chown system root /dev/input_events
    chmod 0660 /dev/input_events
    restorecon /dev/input_events
    chown radio root /dev/ril
    chmod 0660 /dev/ril
    restorecon /dev/ril
    chown audioserver root /dev/audio_data
    chmod 0660 /dev/audio_data
    restorecon /dev/audio_data
    chown system root /dev/screen
    chmod 0660 /dev/screen
    restorecon /dev/screen


on fs
    mount_all /vendor/etc/fstab.${ro.hardware}
    wait /vendor/etc/selinux/nonplat_mac_permissions.xml
    restorecon_recursive /vendor

    # works around framework netiface enumeration issue
    start rename_eth0

    # TODO(ender): Find better way to talk to serial port.
    chmod 622 /dev/kmsg

    # for GCE camera HAL
    mkdir /var/media 0770 audio media

    chmod 0664 /sys/kernel/debug/ieee80211/phy1/hwsim/group
    chmod 0664 /sys/kernel/debug/ieee80211/phy1/hwsim/ps
    chmod 0664 /sys/kernel/debug/ieee80211/phy0/rc/fixed_rate_idx
    chmod 0664 /sys/kernel/debug/ieee80211/phy0/hwsim/group
    chmod 0664 /sys/kernel/debug/ieee80211/phy0/hwsim/ps
    chmod 0664 /sys/kernel/debug/ieee80211/phy1/rc/fixed_rate_idx

    chmod 0755 /system/bin/dhcpcd_wlan0


on post-fs-data
    start vsoc_guest_region_e2e_test
    mkdir /data/dalvik-cache 0771 root root
    mkdir /data/dalvik-cache/x86 0771 root system
    mkdir /data/misc/dhcp-6.8.2 0755 dhcp root
    start gce_fs_monitor
    start vport_trigger


on early-boot
    start vsoc_input_service


on boot
    chmod 0660 /dev/cpuctl
    mkdir /data/vendor/wifi 0770 wifi wifi
    mkdir /data/vendor/wifi/wpa 0770 wifi wifi
    mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi
    start socket_forward_proxy

    # TODO(ender): Re-enable these
    # Compass.
    stop akmd


service rename_eth0 /vendor/bin/rename_netiface eth0 rmnet0
    oneshot


service vsoc_guest_region_e2e_test /vendor/bin/vsoc_guest_region_e2e_test
    user root
    group shell
    oneshot


service vsoc_input_service /vendor/bin/vsoc_input_service
    oneshot


service socket_forward_proxy /vendor/bin/socket_forward_proxy


service vport_trigger /vendor/bin/vport_trigger
    oneshot


on property:sys.cf.ser.cf-logcat=*
    symlink ${sys.cf.ser.cf-logcat} /dev/cf-logcat
    enable seriallogging


on property:sys.cf.ser.cf-gadget-usb-v1=*
    symlink ${sys.cf.ser.cf-gadget-usb-v1} /dev/cf-gadget-usb-v1
    enable usbforward


service seriallogging /system/bin/logcat -b all -v threadtime -f /dev/cf-logcat *:V
    class main
    user root
    disabled


service wpa_supplicant /vendor/bin/hw/wpa_supplicant -g@android:wpa_wlan0
    interface android.hardware.wifi.supplicant@1.0::ISupplicant default
    interface android.hardware.wifi.supplicant@1.1::ISupplicant default
    socket wpa_wlan0 dgram 660 wifi wifi
    group system wifi inet
    disabled
    oneshot


service gce_fs_monitor /vendor/bin/gce_fs_monitor
    class late_start
    disabled
    oneshot


service usbforward /vendor/bin/usbforward /dev/cf-gadget-usb-v1
    class late_start
    user root
    disabled


service wifi_relay /vendor/bin/wifi_relay
    class late_start
    user root


service bugreport /system/bin/dumpstate -d -p -B -z -o /sdcard/bugreport
    class main
    disabled
    oneshot
    keycodes 30 48