android icon indicating copy to clipboard operation
android copied to clipboard

Add WearDns for handling DNS resolution on Wear devices

Open yschimke opened this issue 10 months ago • 5 comments

Summary

This commit introduces a new WearDns class to handle DNS resolution on Wear OS devices. It attempts to use the system DNS and falls back to mobile DNS if there's an issue.

The implementation includes:

  • mobile_network_helper: Constant for the mobile DNS capability.
  • /dnsLookup: Constant for the mobile DNS request.

Any other notes

I'm experimenting to address https://github.com/home-assistant/android/issues/1866

If this isn't working, then next option to explore is requiring Wifi. See https://google.github.io/horologist/network-awareness/

yschimke avatar Mar 30 '25 15:03 yschimke

Open Questions

  • [ ] Should this be a user preference
  • [ ] Can we detect specific cases to retry (BT active, lan/local hostname)

yschimke avatar Mar 31 '25 08:03 yschimke

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks :+1:

Learn more about our pull request process.

home-assistant[bot] avatar Mar 31 '25 10:03 home-assistant[bot]

Would you mind adding some Unit test? I've added recently all the necessary tools to add them.

TimoPtr avatar Mar 31 '25 10:03 TimoPtr

Would you mind adding some Unit test? I've added recently all the necessary tools to add them.

@TimoPtr testing is hard with the DataLayer. In either instrumentation (need paired devices), or unit test (robolectric with custom shadows?).

I'll refactor to have some API we control for the DataLayer parts and test the rest of the structure.

I'm assuming unit tests based on this being recently added https://github.com/home-assistant/android/blob/master/common/src/test/kotlin/io/homeassistant/companion/android/common/data/websocket/impl/entities/ConversationResponseTest.kt

And put them under wear/src/test/kotlin

yschimke avatar Apr 01 '25 06:04 yschimke

Would you mind adding some Unit test? I've added recently all the necessary tools to add them.

@TimoPtr testing is hard with the DataLayer. In either instrumentation (need paired devices), or unit test (robolectric with custom shadows?).

I'll refactor to have some API we control for the DataLayer parts and test the rest of the structure.

I'm assuming unit tests based on this being recently added https://github.com/home-assistant/android/blob/master/common/src/test/kotlin/io/homeassistant/companion/android/common/data/websocket/impl/entities/ConversationResponseTest.kt

And put them under wear/src/test/kotlin

Yes unit test, unit test with robolectric and instrumentation test have been setup recently. For now it only contains very simple tests, I used them to work on the CI that run everything now. Lemme know if you need anything for writing the tests. I can help since it's still WIP.

TimoPtr avatar Apr 01 '25 08:04 TimoPtr

@yschimke do you plan to continue this PR?

TimoPtr avatar Aug 26 '25 11:08 TimoPtr

Yep - apologies, slipped my mind. I'll try to update in the next 2 weeks.

yschimke avatar Aug 26 '25 11:08 yschimke

I'll add unit tests next. Also still need to test again on device after latest changes.

yschimke avatar Sep 02 '25 08:09 yschimke

@TimoPtr I forgot about your suggestion of no setting, and added one. Should I remove?

yschimke avatar Sep 02 '25 08:09 yschimke

@TimoPtr I forgot about your suggestion of no setting, and added one. Should I remove?

I'm fine with the settings on the watch. You'll need to add a screenshot in the PR description and also a link to the companion app documentation that adds a mention to this option in the troubleshooting section I would say.

TimoPtr avatar Sep 02 '25 08:09 TimoPtr

The setting doesn't work as you can't get to it before selecting a server. Removing.

yschimke avatar Sep 03 '25 06:09 yschimke

I'll follow up with unit tests tomorrow

yschimke avatar Sep 03 '25 06:09 yschimke

Spent too much time on what I thought would be a quick fix. If I find some time later, I'll pick it up and continue.

Thanks for the reviews so far.

yschimke avatar Sep 16 '25 16:09 yschimke

Spent too much time on what I thought would be a quick fix. If I find some time later, I'll pick it up and continue.

Thanks for the reviews so far.

You're very close to the finish line. If you are fine with it I can apply my last comments and merge it 👍🏻

TimoPtr avatar Sep 17 '25 07:09 TimoPtr

@TimoPtr go for it. Appreciated.

yschimke avatar Sep 17 '25 07:09 yschimke

@yschimke would you mind have a quick look to my changes?

TimoPtr avatar Sep 17 '25 16:09 TimoPtr

LGTM, thanks.

I'd suggest living with testing dnsRequest instead of onRequest because it keeps the tests much simpler.

yschimke avatar Sep 17 '25 16:09 yschimke

LGTM, thanks.

I'd suggest living with testing dnsRequest instead of onRequest because it keeps the tests much simpler.

Indeed, I didn't see during the review that it was a task from Google. I just tested the else branch

TimoPtr avatar Sep 17 '25 16:09 TimoPtr

So after this merge should we reach out to users impacted by #1866 and see if this helps?

dshokouhi avatar Sep 17 '25 16:09 dshokouhi

Thanks for the help landing this. it was working for me testing locally, but the real test will be on real networks. So any user feedback sooner can confirm or identify any follow up.

yschimke avatar Sep 18 '25 08:09 yschimke