• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Wear OS battery optimization

Hello,


I'm developping a tracking application that runs on Wear OS watches. I have some troubles when the watch goes to sleep. As soon as the watch goes to Deep Idle mode, all sensors acquisition stops. For that I'll need to whitelist the app using:

Code:
                                Intent intent = new Intent();
                                intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
                                intent.setData(Uri.parse("package:" + packageName));
                                context.startActivity(intent);

This piece of code works well on mobile version but nothing happen on Wear OS version. I realized that Wear OS as no UI to set the battery optimization mode which should be the cause of the fact that nothing happens when trying to change the optimization.

I also used a wake lock to keep the CPU partially awake with:


Code:
                PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);

               wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MY-WAKELOCK");

But even with that the watch goes to deep sleep after about 15min ?

The last solution I see is to force the screen on or at least dimmed but it will drain the battery very fast.

Is there another solution to keep sensors working ? How can I whitelist my app on a Wear OS device as no UI seems available ? As anyone already encountered this issue?
 
Last edited:

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones