android icon indicating copy to clipboard operation
android copied to clipboard

Sensor for Private DNS function on Android

Open SamJongenelen opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe.

When i forget to re enable private DNS function in Android, i'd like homeassistant to know, so I can send a notification.

Describe the solution you'd like

Expose, if possible, an optional sensor to HA having as value the state of the private DNS function on my android device. (on/off/private)

Describe alternatives you've considered, if any

NA Additional context

SamJongenelen avatar Mar 07 '22 22:03 SamJongenelen

I think this is possible using 'getPrivateDnsServerName' api 28+

SamJongenelen avatar Mar 07 '22 22:03 SamJongenelen

For our app its usually best if we can find a method that works all the way down to API level 21 (if possible). Taking a brief look we may be able to leverage

https://developer.android.com/reference/android/net/NetworkCapabilities#TRANSPORT_VPN

This post may give a clue to the implementation :) https://stackoverflow.com/a/55609059 Looks like may be API minimum 23 if we go this route

the API listed in the comment above could probably be used as an attribute for the sensor as I would imagine TRANSPORT_VPN will always be there whether or not its a private VPN?

dshokouhi avatar Mar 07 '22 23:03 dshokouhi

Looking into this sensor to expose the transport type being used, hopefully it will work for your use case

dshokouhi avatar Mar 08 '22 00:03 dshokouhi

Disregard my comments, for some reason I confused DNS for VPN 🤦

dshokouhi avatar Mar 08 '22 00:03 dshokouhi