1

Is there a way to acquire wake lock in Android native service in Android automotive, I need to hold the device from not going to suspend to Ram mode until my service done with certain tasks.

I tried to check if there are any ndk APIs available to acquire wake lock or something similar but no luck.

1 Answers1

1

I haven't personally needed to acquire a wakelock in native code, and I'm uncertain if NDK directly supports it. However, you can achieve wakelock functionality using the following files:

/sys/power/wake_lock
/sys/power/wake_unlock

In adb shell environment, you can hold and release wakelocks like this:

# echo "your_wakelock" > /sys/power/wake_lock
# echo "your_wakelock" > /sys/power/wake_unlock

If you need to use this functionality in native code, you may use the fstream library to manage both files.