In fact without removing battery it's not possible to shut down a device completely in order to avoid the loss that could possibly occur due to short circuit caused by water.
Let's have a brief look at what shut down means and what are possible options to achieve this.
HOW SHUTDOWN WORKS?
Android is based on Linux kernel which is the very first executable of operating system which is run during boot process. Kernel initializes necessary hardware and prepares a basic environment before executing init
, the very first userspace process we can see. It's init
which then starts and takes care of all services and processes. On shutdown, reverse of this happens.
INIT
When you tap Power Off
from Power Menu, or when you issue reboot -p
command from terminal app or adb
, it sets Android property sys.powerctl
to shutdown
(with an optional reason for shutdown) which tells init
it's time to save any unsaved work to persistent storage, stop all services and processes gracefully (or brutally), sync filesystem caches, un-mount filesystems and then hand over charge to kernel by making syscall reboot (ref). Kernel then makes sure all userspace processes are stopped including init
, forcibly unmounts any stubborn filesystems and ultimately powers down hardware devices including CPUs and RAM.
Android's init
supports two modes: shutdown
and reboot
. Linux init
has some more shutdown options including halt
and poweroff
. See this answer for more details.
KERNEL
Most of the time during shut down is taken by init
. In order to save time you can bypass init
and ask kernel directly for a poweroff by making syscall:
reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, LINUX_REBOOT_CMD_POWER_OFF)
That's what busybox poweroff -f
command or the magic SysRq key O
(equivalent to Alt-SysRq-O on a PC) would do (ref). Both should be preceded by sync
to avoid damaging filesystems. From commandline we can do:
~# echo 1 >/proc/sys/kernel/sysrq
~# echo s >/proc/sysrq-trigger
~# echo o >/proc/sysrq-trigger
This is the fastest way to shutdown OS on rooted device.
HARD REBOOT
But how to power down the device if even the kernel becomes non-responsive? Hardware can usually take care of this i.e. if you keep power button pressed for a fixed time interval. There's some hard-coded value (mostly 10 seconds) inside Power Management Unit (PMIC). No process will be stopped, no filesystem would be unmounted, no goodbye would be conveyed, just the power will be cut to CPU, RAM and other relevant hardware resources. Most SoCs (which have PMIC embedded inside) implement this as reboot, not shut down.
So to summarize the above lines, there are two ways to shutdown device: through init
or calling kernel directly. Both can be achieved through simple shell commands or can be mapped to some hardware key or special key combination. But water can make any hardware key useless, so this method can't be a universal solution.
POWER BUTTON
But the point is, your device isn't fully powered off whichever path you have chosen. During boot process there are things which are powered up before the OS loads (and possibly be powered up even when there is no OS on device). There must be a circuitry in PMIC (e.g. a microcontroller in low-power mode and may be some software stack too) which is always powered up so than it can listen to your request for switching on the device when you press power button for a few seconds, or even when you connect a charger to device in powered-off state.
COMMUNICATION PROCESSOR
Also the baseband processor (BP) - which runs modem and is responsible for all communication through mobile networks e.g. call, SMS and internet - is totally isolated from Application Processor (the one we call CPU) and is not governed by Android kernel; it runs an independent RTOS. And as they say, government agencies may use it to track you even when you think your device is powered off. So it means it may possibly be (partially or fully or periodically) running when Android isn't running.
If nothing else, at least battery terminals are always live, connected to some part of motherboard which may get short when got wet. So if your device isn't water resistant and the battery doesn't have some short-circuit protection built-in, you can never be dead sure your device won't get damaged when water poured on it.