Is there any reason a programmatic or command-line shutdown (or reboot) process in Android 7.1 might randomly result in a hard freeze-up, requiring a long (~8 second) press of the power button to force the shutdown? It doesn't happen every time, but seems to randomly happen infrequently, but frequently enough to be a problem.
Background Info...
I'm developing a "kiosk" style tablet, which runs 24/7. It's rooted and I have full control over it. It also has a customization from the supplier to automatically turn on when power is connected.
To keep things fresh and responsive, I want to issue a nightly reboot command. The reboot command was originally just a call to /system/bin/reboot -p
via my own app "watchdog" kind of service that always runs in the background. (Yes, I know the -p causes the tablet to turn-OFF, but then our custom auto-boot will turn it back on immediately, if power is connected, resulting in a reboot situation... doing a pure reboot without the -p causes more problems)
Anyway, I've since moved on to experiment with all of the following commands to cause a shutdown/reboot, and none really fix the problem.
/system/bin/setprop sys.powerctl shutdown
/system/bin/svc power shutdown
/system/bin/am start -a android.intent.action.ACTION_REQUEST_SHUTDOWN
/system/bin/busybox poweroff -f
/system/bin/busybox poweroff -d 10 -f
One more bit of info... I made an app to shutdown/reboot the device every five minutes. I've been running it on about a dozen devices, and have about 4 or 5 failures every 24 hours.