I have an AOSP 5.1 - build on my Allwinner A33 device.
When long-pressing the "Power-Button" the device starts the "shutdown"-procedure. It shows a dialog "Power off" along with a spinner (see screenshot). This is visible for ~ 3.5s - 4.5s, then the device is off.
However when I connect to adb and enter adb shell reboot -p
the device goes off immediately (-p
stands for "poweroff")
Android should not have a problem with an immediate shutdown request.
The device should not do this when the KeyEvent
KEYCODE_POWER
occurs. According to the Android docs, this should broadcast the Intent
with ACTION_SHUTDOWN
to inform apps, etc. that the device is powering off. https://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN
So you could tweak the AOSP but then it wouldn't conform to the docs.
For a more in-depth look, this blog post mentions the dialog confirmation process, ringer silencing, etc. that most users also expect to have happen when the power button is long-pressed:
http://kpbird.blogspot.com/2013/08/in-depth-android-shutdown-sequence.html