Pregunta

When using AlarmManager, Android device can wake up from sleeping at some time.

How does Android schedule the wakeup at lower level?

I tried using rtcwake, but it fails with rtcwake: /dev/rtc0 not enabled for wakeup events (if I force rtcwake to proceed and make necessary ioctls I still don't see the device being woken up on time)

Which syscalls does Android use to set up an alarm and how to do them from console myself?

¿Fue útil?

Solución

Android uses /dev/alarm device to setup alarms that can wakeup the system from suspend state. From JNI it can access this device using ioctl. See frameworks/base/services/jni/com_android_server_AlarmManagerService.cpp file. Android has exclusive access to this device and from what I understand the interface is available only from Java using AlarmManager service. If you need to setup these alarms at java level you can get access to this service using getSystemservice(ALARM_SERVICE), from native it is little tricky, I am also currently having the same issue. I need alarms in a native process and I am using sockets to communicate with java service to schedule alarms. This may not be the answer you are looking for but I would like to share my experience with this.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top