• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/vendor/bin/sh
2
3# Init starts this script in the factory, to trigger shutdown after
4# setupwizard has started, and USB is removed.
5
6# wait for system to settle down after sys.boot_complete
7sleep 5
8
9# Wait for USB to be removed, debounce it three times in case it's enumerating still.
10disconnect_count=0
11while [ disconnect_count -le 3 ]; do
12    type=`cat /sys/class/power_supply/usb/typec_mode`
13    if [ "x$type" == "xNothing attached" ]; then
14        (( disconnect_count++ ))
15        echo disconnect count is $disconnect_count
16    else
17        # Restart the debounce count
18        disconnect_count=0
19    fi
20    sleep 1
21done
22
23# Shutdown
24setprop sys.powerctl reboot,packout
25