0

I am trying to program a bedside clock like the Moto 360's showing the time during the night while charging. Therefore I have set up an "Always-On-App" with alarm manager according to https://developer.android.com/training/wearables/apps/always-on.html#BackwardCompatibility which works basically as intended (Android 7.1.1 Wearable Activity on a "Diesel On Full Guard").
However after several minutes lying still on the desk, the watch is leaving ambient mode (my preferred mode during night time) and switching its screen off.

I've already tried using a wake lock according to Android Wear: measuring sensors and preventing ambient mode / sleep but with no success. The processor may still be working, but the screen goes black after a while (very bothersome to debug as you always have to wait and can't reproduce on the emulator, which never switches off).

So how can I prevent the watch from leaving ambient mode onto the direction "off", or at least detect that state and switch it back on?

tomseitz
  • 503
  • 2
  • 4
  • 14

1 Answers1

0

Your watch probably has ro.ambient.plugged_timeout_min set to some positive value (see the reddit post here). It's meant for protecting the OLED screen from burn in. If you run adb shell dumpsys alarm you can see a wake alarm for com.google.android.wearable.ambient with the action com.google.android.wearable.action.STOP_AMBIENT_DREAM that will turn the screen off/doze device after the timeout mentioned above.

My best guess is that to prevent it from going to ambient you'd need to either

  • Stop it from going into ambient entirely, i.e holding a SCREEN_DIM_WAKELOCK or similar, and using an entirely black background.
  • Periodically wake the screen up so that the timeout resets. This is probably suboptimal if it's meant as a night clock though.
z153
  • 156
  • 5
  • I am quite sure, you are right with the timeout. I tried `SCREEN_DIM_WAKELOCK`, WindowManager `FLAG_KEEP_SCREEN_ON` , AlarmManager along with WakefulBroadcastReceiver and startWakefulService(), deactivating ambient mode, even sending a toast every minute; all with no help. Running out of ideas meanwhile... – tomseitz Oct 28 '17 at 16:27