Browsing around forums and sites I found out the following answers to my doubts.
I'm not completely satisfied but it helped understand more.
Every device's power management depends on some suspend
/resume
policies that are implemented in the firmware controlling that particular device.
This is very device dependent: how and when each device turns off (suspends itself) and wakes up (resumes) depends on the HW specifications, you have to read the datasheets to understand which particular registries must be manipulated to suspend/resume it.
You can control this stuff via software in the drivers of the devices, inside of the kernel's source code, by accessing some funcions in the form <something>_suspend
and <something>_resume
.
E.g. From the source code of the kernel of the emulator "goldfish":
in file drivers/video/goldfishfb.c
(the driver responsible for the frame buffer)
#ifdef CONFIG_ANDROID_POWER
static void goldfish_fb_early_suspend(android_early_suspend_t *h)
{
struct goldfish_fb *fb = container_of(h, struct goldfish_fb, early_suspend);
writel(1, fb->reg_base + FB_SET_BLANK);
}
static void goldfish_fb_late_resume(android_early_suspend_t *h)
{
struct goldfish_fb *fb = container_of(h, struct goldfish_fb, early_suspend);
writel(0, fb->reg_base + FB_SET_BLANK);
}
#endif
So the early_suspend
writes a 1 in the register FB_SET_BLANK
to turn off the screen, or a 0 to turn it back on.
So it seems to me that a process in the application execution environment needs to access and corrupt the devices drivers to manipulate maliciously power management of a device.