Use "packout" reboot reason for the firstboot shutdown

Use "packout" to trigger serial number / IMEI displayed in bootloader
for in-boxing process.

Also debounce the USB for a few seconds to avoid false shutdowns.

Bug: 112744852
Change-Id: I8ec4b31bcbf4e22f154cd15221bcde0f05394dce
diff --git a/init.firstboot.sh b/init.firstboot.sh
index 05a1b85..c66811c 100755
--- a/init.firstboot.sh
+++ b/init.firstboot.sh
@@ -6,13 +6,19 @@
 # wait for system to settle down after sys.boot_complete
 sleep 5
 
-# Wait for USB to be removed.
-type=`cat /sys/class/power_supply/usb/typec_mode`
-while [ "x$type" != "xNothing attached" ]; do
-    echo Wait for \"$type\" == \"Nothing attached\"
-    sleep 1;
+# Wait for USB to be removed, debounce it three times in case it's enumerating still.
+disconnect_count=0
+while [ disconnect_count -le 3 ]; do
     type=`cat /sys/class/power_supply/usb/typec_mode`
-done;
+    if [ "x$type" == "xNothing attached" ]; then
+        (( disconnect_count++ ))
+        echo disconnect count is $disconnect_count
+    else
+        # Restart the debounce count
+        disconnect_count=0
+    fi
+    sleep 1
+done
 
 # Shutdown
-setprop sys.powerctl shutdown
+setprop sys.powerctl reboot,packout